From 88291c196a4bba84429a7dd72444af80cd3c337e Mon Sep 17 00:00:00 2001 From: Jakob Olsson Date: Wed, 17 Oct 2018 13:54:52 +0200 Subject: [PATCH] samba: prevent mulitple lines from being written to an option in smb.conf --- samba3/files/samba.init | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/samba3/files/samba.init b/samba3/files/samba.init index 887593e2b..2dd51cb5a 100755 --- a/samba3/files/samba.init +++ b/samba3/files/samba.init @@ -80,6 +80,12 @@ smb_header() { config_get description $1 description "Samba on ${hostname:-OpenWrt}" config_get charset $1 charset "UTF-8" + name=`echo -e "$name" | head -1` + workgroup=`echo -e "$workgroup" | head -1` + description=`echo -e "$description" | head -1` + interfaces=`echo -e "$interfaces" | head -1` + charset=`echo -e "$charset" | head -1` + mkdir -p /var/etc sed -e "s#|NAME|#$name#g" \ -e "s#|WORKGROUP|#$workgroup#g" \ @@ -138,13 +144,13 @@ smb_add_share() { path=$(readlink -f $path) [ "${path:0:4}" == "/mnt" ] || path="/mnt/" - echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf - [ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf - [ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf - [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf - [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf - [ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf - [ -n "$browseable" ] && echo -e "\tbrowseable = $browseable" >> /var/etc/smb.conf + echo -e "\n[$name]\n\tpath = ${path%%\\n*}" >> /var/etc/smb.conf + [ -n "$users" ] && echo -e "\tvalid users = $users" | head -1 >> /var/etc/smb.conf + [ -n "$read_only" ] && echo -e "\tread only = $read_only" | head -1 >> /var/etc/smb.conf + [ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" | head -1 >> /var/etc/smb.conf + [ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" | head -1 >> /var/etc/smb.conf + [ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" | head -1 >> /var/etc/smb.conf + [ -n "$browseable" ] && echo -e "\tbrowseable = $browseable" | head -1 >> /var/etc/smb.conf } start_service() {