Skip to content

Commit 4df3aeb

Browse files
authored
fix: Supply config to smbpasswd
1 parent 186d466 commit 4df3aeb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

samba.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ add_user() {
4848
# Check if the user is a samba user
4949
if pdbedit -s "$cfg" -L | grep -q "^$username:"; then
5050
# if the user is a samba user, change its password
51-
echo -e "$password\n$password" | smbpasswd -s "$username" || { echo "Failed to update Samba password for $username"; return 1; }
51+
echo -e "$password\n$password" | smbpasswd -c "$cfg" -s "$username" || { echo "Failed to update Samba password for $username"; return 1; }
5252
[[ "$username" != "samba" ]] && echo "Password for existing Samba user $username has been updated."
5353
else
5454
# if the user is not a samba user, create it and set a password
55-
echo -e "$password\n$password" | smbpasswd -a -s "$username" || { echo "Failed to add Samba user $username"; return 1; }
55+
echo -e "$password\n$password" | smbpasswd -a -c "$cfg" -s "$username" || { echo "Failed to add Samba user $username"; return 1; }
5656
[[ "$username" != "samba" ]] && echo "User $username has been added to Samba and password set."
5757
fi
5858
}

0 commit comments

Comments
 (0)