From ad9af475d3504d467e16c953fa5c78133e67304d Mon Sep 17 00:00:00 2001 From: Hugo Chinchilla Carbonell Date: Thu, 18 Jun 2015 14:05:52 +0200 Subject: [PATCH] Import users preserving UID pdbimport will ignore users where the system UID does not match the UID in the file, in order to prevent this error we can create the users with their original UIDs --- samba.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/samba.sh b/samba.sh index 729556a..7c45708 100755 --- a/samba.sh +++ b/samba.sh @@ -22,9 +22,11 @@ set -o nounset # Treat unset variables as an error # Arguments: # file) file to import # Return: user(s) added to container -import() { local name file="${2}" - for name in $(cat $file | cut -d: -f1); do - useradd "$name" -M +import() { local file="$1" + for line in $(cat $file | cut -d: -f1,2); do + local user=$(echo $line | cut -d: -f1) + local uid=$(echo $line | cut -d: -f2) + useradd "$user" -u "$uid" -M done pdbedit -i smbpasswd:$file }