samba: samba-config: call smbpasswd with valid smb.conf

Use fresh created tempfile as parameter. Allow smbpasswd logging to
journal to catch errors.
This commit is contained in:
mglae 2023-06-03 15:29:27 +02:00
parent 1bded02269
commit b3d8150bea

View File

@ -98,14 +98,15 @@ if [ ! -f /storage/.cache/services/samba.disabled ]; then
# processing continues, so if user chooses root as username, second line overrides the first # processing continues, so if user chooses root as username, second line overrides the first
# this is done always in case user uses passwords in userconf. # this is done always in case user uses passwords in userconf.
# many thanks to viljoviitanen for this # many thanks to viljoviitanen for this
printf "%s\n%s" "${SAMBA_PASSWORD}" "${SAMBA_PASSWORD}" | smbpasswd -s -a root >/dev/null 2>&1
printf 'nobody = root\nroot = "%s"\n' "${SAMBA_USERNAME}" > /run/samba/samba.map
sed -e 's|^.[ \t]*.public.=.*| public = no |' \ sed -e 's|^.[ \t]*.public.=.*| public = no |' \
-e 's|^.[ \t]*.username map.=.*||' \ -e 's|^.[ \t]*.username map.=.*||' \
-e 's|^.[ \t]*.security.=.*| security = user\n username map = /run/samba/samba.map|' \ -e 's|^.[ \t]*.security.=.*| security = user\n username map = /run/samba/samba.map|' \
-e 's|^.[ \t]*.map.to.guest.=.*| map to guest = Never|' \ -e 's|^.[ \t]*.map.to.guest.=.*| map to guest = Never|' \
-i ${SMB_TMP} -i ${SMB_TMP}
printf "%s\n%s" "${SAMBA_PASSWORD}" "${SAMBA_PASSWORD}" | smbpasswd -c ${SMB_TMP} -s -a root
printf 'nobody = root\nroot = "%s"\n' "${SAMBA_USERNAME}" > /run/samba/samba.map
else else
sed -e 's|^.[ \t]*.public.=.*| public = yes |' \ sed -e 's|^.[ \t]*.public.=.*| public = yes |' \
-e 's|^.[ \t]*.username map.=.*||' \ -e 's|^.[ \t]*.username map.=.*||' \