Samba won't start when an include statement in smb.conf has a variable substitution
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
samba (Ubuntu) |
Fix Released
|
Medium
|
Andreas Hasenack | ||
Trusty |
Fix Released
|
Undecided
|
Andreas Hasenack | ||
Xenial |
Fix Released
|
Undecided
|
Andreas Hasenack |
Bug Description
[Impact]
Samba in AD mode refuses to start when the smb.conf file contains an include line with a variable substitution like "include = /etc/samba/
This happens because the initscript calls "samba-tool testparm" to obtain a configuration parameter from smb.conf, and this testparm tool fails because it doesn't expand the %U macro and fails to read the literal filename.
Note that "samba-tool testparm" is different from just "testparm". The latter doesn't fail. We could just replace one with the other in the initscript, but later on in the process of provisioning an AD controller this error is encountered again, so it's best to fix it properly.
The patch is straight from an upstream commit, and that code is in place in the samba packages from bionic and cosmic already.
[Test Case]
* install samba:
sudo apt install samba
* create /etc/samba/smb.conf with this content:
[global]
netbios name = samba
log file = /var/log/
map to guest = Bad User
max log size = 1000
obey pam restrictions = Yes
pam password change = Yes
panic action = /usr/share/
passwd chat = *Enter\
passwd program = /usr/bin/passwd %u
server string = %h server (Samba, Ubuntu)
unix password sync = Yes
usershare allow guests = Yes
idmap config * : backend = tdb
include = /etc/samba/
* run the command that fails:
ubuntu@
lpcfg_load: refreshing parameters from /etc/samba/smb.conf
Can't find include file /etc/samba/
ERROR: Unable to load default file
ubuntu@
255
Note the debug level 2 message saying the include file couldn't be found.
* install the updated packages and run the same command again. This time it will work, exit with status 0, and show the main config file.
ubuntu@
lpcfg_load: refreshing parameters from /etc/samba/smb.conf
Tried to load /etc/samba/
# Global parameters
[global]
netbios name = SAMBA
server string = %h server (Samba, Ubuntu)
map to guest = Bad User
obey pam restrictions = Yes
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\
unix password sync = Yes
log level = 2
log file = /var/log/
max log size = 1000
usershare allow guests = Yes
panic action = /usr/share/
idmap config * : backend = tdb
include = /etc/samba/
ubuntu@
0
We can also see the new debugging message saying that the include file was ignored because of the variable substitution.
[Regression Potential]
If you happen to include a filename that has an actual "%" in its name, followed by a letter, and it doesn't exist, this patch will not flag that as an error and just ignore it, whereas before it would be flagged. Having such a filename is asking for trouble, though, because %<letter> is a variable and samba would try to expand it.
[Other Info]
The fix and test procedure is identical for trusty and xenial. It's the same samba version in both releases of ubuntu.
There is still a difference in behaviour between "testparm(1)" and "samba-tool testparm". This fix only affects "samba-tool testparm":
ubuntu@
Load smb config files from /etc/samba/smb.conf
Can't find include file /etc/samba/
(...)
Note the ending dot in the error above, that's where %U would come. testparm doesn't exit non-zero because of that, though.
[Original Description]
Samba refuses to start when the smb.conf file contains an include line with a variable substitution like "include = /etc/samba/
According to the man page for smb.conf, all but a few specific variable substitutions should work.
include (G)
This allows you to include one config file inside another. The file is included literally, as though typed in place.
It takes the standard substitutions, except %u, %P and %S.
The parameter include = registry has a special meaning: It does not include a file named registry from the current working directory, but
instead reads the global configuration options from the registry. See the section on registry-based configuration for details. Note that
this option automatically activates registry shares.
Default: include =
Example: include = /usr/local/
It is probably related to this bug in samba:
https:/
Description: Ubuntu 16.04 LTS
Release: 16.04
samba:
Installed: 2:4.3.9+
Candidate: 2:4.3.9+
Version table:
*** 2:4.3.9+
500 http://
500 http://
100 /var/lib/
2:
500 http://
Related branches
- Christian Ehrhardt (community): Approve
- Canonical Server: Pending requested
-
Diff: 95 lines (+73/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/bug_1583324_include_with_macro.patch (+65/-0)
debian/patches/series (+1/-0)
- Christian Ehrhardt (community): Approve
- Canonical Server: Pending requested
-
Diff: 95 lines (+73/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/bug_1583324_include_with_macro.patch (+65/-0)
debian/patches/series (+1/-0)
Changed in samba (Ubuntu): | |
status: | Incomplete → Triaged |
Changed in samba (Ubuntu): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
status: | Triaged → In Progress |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
tags: |
added: verification-done-xenial removed: verification-needed-xenial |
This seems to be working in 4.3.11 that is in xenial: samba-dynamic- include: ~# testparm -s smb.conf.
root@xenial-
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
WARNING: The "syslog" option is deprecated
Can't find include file /etc/samba/
Loaded services file OK.
WARNING: The 'netbios name' is too long (max. 15 chars).
Server role: ROLE_STANDALONE
# Global parameters snew\s* \spassword: * %n\n *Retype\ snew\s* \spassword: * %n\n *password\ supdated\ ssuccessfully* . samba/log. %m samba/panic- action %d smb.conf. samba-dynamic- include: ~# echo $?
[global]
server string = %h server (Samba, Ubuntu)
server role = standalone server
map to guest = Bad User
obey pam restrictions = Yes
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\
unix password sync = Yes
syslog = 0
log file = /var/log/
max log size = 1000
dns proxy = No
usershare allow guests = Yes
panic action = /usr/share/
idmap config * : backend = tdb
include = /etc/samba/
root@xenial-
0
Notice how it didn't expand %U, and the include file was /etc/samba/ smb.conf. (ending dot). Restart works: samba-dynamic- include: ~# systemctl restart smbd nmbd samba-dynamic- include: ~# systemctl status smbd nmbd sysv-generator( 8) /etc/init. d/smbd stop (code=exited, status=0/SUCCESS) /etc/init. d/smbd start (code=exited, status=0/SUCCESS) slice/smbd. service
root@xenial-
root@xenial-
● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
Active: active (running) since Tue 2018-07-17 19:12:51 UTC; 3s ago
Docs: man:systemd-
Process: 2983 ExecStop=
Process: 3012 ExecStart=
Tasks: 3
Memory: 7.1M
CPU: 127ms
CGroup: /system.
├─3023 /usr/sbin/smbd -D
├─3024 /usr/sbin/smbd -D
└─3026 /usr/sbin/smbd -D
Jul 17 19:12:51 xenial- samba-dynamic- include systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)... samba-dynamic- include smbd[3012]: * Starting SMB/CIFS daemon smbd samba-dynamic- include smbd[3012]: ...done. samba-dynamic- include systemd[1]: Started LSB: start Samba SMB/CIFS daemon (smbd).
Jul 17 19:12:51 xenial-
Jul 17 19:12:51 xenial-
Jul 17 19:12:51 xenial-
● nmbd.service - LSB: start Samba NetBIOS nameserver (nmbd) sysv-generator( 8) /etc/init. d/nmbd stop (code=exited, status=0/SUCCESS) /etc/init. d/nmbd start (code=exited, status=0/SUCCESS) slice/nmbd. service
Loaded: loaded (/etc/init.d/nmbd; bad; vendor preset: enabled)
Active: active (running) since Tue 2018-07-17 19:12:51 UTC; 3s ago
Docs: man:systemd-
Process: 2990 ExecStop=
Process: 2998 ExecStart=
Tasks: 1
Memory: 3.7M
CPU: 127ms
CGroup: /system.
└─3011 /usr/sbin/nmbd -D
Jul 17 19:12:51 xenial- samba-dynamic- include systemd[1]: Starting LSB: start Samba NetBIOS nameserver (nmbd)... samba-dynamic- include nmbd[2998]: * Starting NetBIOS name server nmbd samba-dynamic- include nmbd[2998]: ...done. samba-dynamic- include systemd[1]: Started LSB: start Samba NetBIOS nameserver (nmbd).
Jul 17 19:12:51 xenial-
Jul 17 19:12:51 xenial-
Jul 17 19:12:51 xenial-
Are you also seeing this behavior n...