So changes made to the smb.conf persist for what seem like about 1 day. Then they get overwritten.
As I often reboot/powerdown my pbo, it's not a big deal.
But I wanted to understand what was happening. So I looked into the configsamba file (of foxeye's mod fame) to see what goodness it did.
I think it's the key. I think it periodically is retriggered to write the smb.conf anew. (I don't understand under what circumstances configsamba is rerun).
Anyway, as I want the root to mount with out much funny business, I simply added the lines I wanted in the smb.conf files to the configsamba file- which then echoes my additions to the smb_user.conf and smb_anonymous.conf files.
But wait a minute, my slow brain eventually asked- why isn't the configsamba adding to the smb.conf file? However will my changes end up in the smb.file?
The key is in the
/tmp/package/script/samba-security anonymous
command at the end of the script.
Code:
/ # cat /tmp/package/script/samba-security
#!/bin/sh
#
# description: modify the samba security level
anonymous() {
cp -f /tmp/package/samba/lib/smb_anonymous.conf /tmp/package/samba/lib/smb.conf
RETVAL=$?
echo
return $RETVAL
}
user() {
echo -e "123\n123" >/usr/local/etc/dvdplayer/tmpfile_samba
/tmp/package/samba/sbin/smbpasswd -a admin -s</usr/local/etc/dvdplayer/tmpfile_samba >/dev/null 2>&1
rm -f /usr/local/etc/dvdplayer/tmpfile_samba
cp -f /tmp/package/samba/lib/smb_user.conf /tmp/package/samba/lib/smb.conf
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
anonymous)
anonymous
;;
user)
user
;;
*)
echo $"Usage: $0 {anonymous|user}"
exit 1
esac
exit $?
/ #
Following the script along, we find that the "samba-security" script has been invoked with the "anonymous" option, so the smb_anonymous.conf is then written over onto the /tmp/package/samba/lib/smb.conf file.
So here's the improved process and code:
On Firmware 4, you will have to free up some memory so you can make symbolic links and such- follow the instructions "
Custom Root Partition Size" or face the dreaded memory allocation error.
Then:
Code:
cd /usr/local/etc/
touch configsamba
chmod +x configsamba
Open up configsamba with vi, copy and paste the code below:
Code:
#!/bin/sh
#
# description: create the samba conf file
# if smb.conf already exist,nothing need to be done
#if [ -e /tmp/package/samba/lib/smb.conf ]
#then
# echo "smb conf already exist"
# exit 0
#fi
if [ -d /tmp/smb ]
then
echo ""
else
mkdir /tmp/smb
fi
cp /tmp/package/samba/conf/smb_anonymous_head.conf /tmp/package/samba/lib/smb_anonymous.conf
cp /tmp/package/samba/conf/smb_user_head.conf /tmp/package/samba/lib/smb_user.conf
str=$(ls /tmp/ramfs/volumes/)
cd /tmp/ramfs/volumes/
if [ $# -gt 0 ]
then
str=$(ls $1)
cd $1
fi
for i in $str
do
path=$(readlink -f $i)
echo $path
mountpoint=$(cat /proc/mounts|grep $path |cut -d" " -f 2)
carrier=$(cat /sys/class/net/eth0/carrier)
echo $carrier
if [ $# -gt 1 ]
then
mount -o remount,$2 $mountpoint
echo "remount $2"
else
if [ -f /sys/class/net/eth0/carrier ] && [ $(cat /sys/class/net/eth0/carrier) -eq 1 ]
then
echo "remount rw"
mount -o remount,rw $mountpoint
else
if [ -f /sys/class/net/wlan0/carrier ] && [ $(cat /sys/class/net/wlan0/carrier) -eq 1 ]
then
echo "remount rw"
mount -o remount,rw $mountpoint
else
echo "remount ro"
mount -o remount,ro $mountpoint
fi
fi
fi
# || [ -f /sys/class/net/wlan0/carrier ] && [$(cat /sys/class/net/wlan/carrier | echo) -eq '1' ];
sharename=$(echo $i | cut -d":" -f 1)
echo $sharename
echo "[$sharename]" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "path=$mountpoint" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "hide dot files=yes" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "hide files=/.*/lost+found/">>/tmp/package/samba/lib/smb_anonymous.conf
echo "guest ok=yes" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "writable=yes " >>/tmp/package/samba/lib/smb_anonymous.conf
echo "force create mode=0775 " >>/tmp/package/samba/lib/smb_anonymous.conf
echo "force directory mode=0775 " >>/tmp/package/samba/lib/smb_anonymous.conf
echo "[$sharename]" >>/tmp/package/samba/lib/smb_user.conf
echo "path=$mountpoint" >>/tmp/package/samba/lib/smb_user.conf
echo "hide dot files=yes" >>/tmp/package/samba/lib/smb_user.conf
echo "hide files=/.*/lost+found/">>/tmp/package/samba/lib/smb_user.conf
echo "guest ok=no" >>/tmp/package/samba/lib/smb_user.conf
echo "writable=yes " >>/tmp/package/samba/lib/smb_user.conf
echo "force create mode=0775 " >>/tmp/package/samba/lib/smb_user.conf
echo "force directory mode=0775 " >>/tmp/package/samba/lib/smb_user.conf
done
#Start show root partition edits
echo "[root]" >>/tmp/package/samba/lib/smb_user.conf
echo "path=./" >>/tmp/package/samba/lib/smb_user.conf
echo "hide dot files=no" >>/tmp/package/samba/lib/smb_user.conf
echo "hide files=/.*/lost+found/">>/tmp/package/samba/lib/smb_user.conf
echo "guest ok=yes" >>/tmp/package/samba/lib/smb_user.conf
echo "writable=yes " >>/tmp/package/samba/lib/smb_user.conf
echo "force create mode=0775 " >>/tmp/package/samba/lib/smb_user.conf
echo "force directory mode=0775 " >>/tmp/package/samba/lib/smb_user.conf
echo "[root]" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "path=./" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "hide dot files=no" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "hide files=/.*/lost+found/">>/tmp/package/samba/lib/smb_anonymous.conf
echo "guest ok=yes" >>/tmp/package/samba/lib/smb_anonymous.conf
echo "writable=yes " >>/tmp/package/samba/lib/smb_anonymous.conf
echo "force create mode=0775 " >>/tmp/package/samba/lib/smb_anonymous.conf
echo "force directory mode=0775 " >>/tmp/package/samba/lib/smb_anonymous.conf
#End show root partition edits
/tmp/package/script/samba-security anonymous
exit 0
Then:
Code:
mv /usr/local/bin/package/script/configsamba /usr/local/etc/configsamba_bak
ln -s /usr/local/etc/configsamba /usr/local/bin/package/script/
reboot and enjoy perpetual access to your pbo's root partition over the network.