Modify samba configuration permanently

161 views
Skip to first unread message

Paolo Conti

unread,
Nov 8, 2017, 8:06:37 PM11/8/17
to Alt-F
Hi,
I'm using a 320L with Alt-F 1.0 and my network is configured with 2 subnets, but samba keeps to reset to the default configuration upon reboots (allowing access only to one subnet).

The default value of
"hosts allow" in SWAT/Globals is "127., 192.168.1.0/255.255.255.0", I'm able to change it into "127., 192.168.1.0/255.255.0.0", so I can access to samba also from my other subnet (with IP 192.168.2.0/24), but if I reboot the NAS, my custom setting is gone.

The button "Set Default" in SWAT is not working.

How can I change the samba configuration permanently?

Let me know,
Thanks! :-)


João Cardoso

unread,
Nov 10, 2017, 1:31:17 PM11/10/17
to al...@googlegroups.com
You might have discovered a bug, but that needs more investigation and I'm currently away of my boxes until the next week.

Very early on the boot process (but after loading saved settings from flash memory) /etc/samba/smb.conf hosts allow directive is modified to allow access to the current network (in case the box was moved to another network). The automatic editing assumes that several networks exists separated by *spaces*, not commas, and only the first two are/should be changed.
So you should be able to set "hosts allow = 127. yournet1/yourmask1 yournet2/yourmask2" and yournet2/yourmask2 should be preserved. I can't verify now that it is working that way.
There are a couple of other places that might also change smb.conf, such as when a DHCP renew happens,  Setup->Host, Samba Configuration, SWAT and possibly others.

Changing the current behavior is not simple, and needs experimenting, but it might be that by creating and editing a user boot script solves the issue (until a DHCP renew happens?):

Go to Services->User->user Configure and fill-in under "Script to execute on power-up" the full path of a executable shell script that resides on the base of a filesystem, such as /mnt/sda2/mybootscript.sh or /mnt/md1/userboot.sh, whatever, then hit Edit and after the 'start)' line add

sed -i 's|hosts allow = .*|hosts allow = 127. yournetwork/yournetmask|' /etc/samba/smb.conf

changing yournetwork/yournetmask with your desired values, then save it. You can experiment if it is working by Stopping and Starting the user service and verifying that smb.conf is OK. A definitive test can only be made after a "save settings" and a reboot.

\Worked?

Paolo Conti

unread,
Nov 10, 2017, 2:32:17 PM11/10/17
to Alt-F
WOW! :-)

You are amazing!

I've just setup my "Host allow" without commas (so like this "127. 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0") and the directive is maintained upon reboots.

I've also tried to use a netmask more open, like 255.255.0.0, again without commas and so, only a network range after 127. but this setting is not maintained...

Anyway, using the directive with the double network for me is good enough :)

Thank you also for the hints about ways for changing Alt-F settings (they can become useful in the future).

Have a nice day!
Reply all
Reply to author
Forward
0 new messages