Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 573976 - net-fs/samba-4.2.8-9 - samba.service should only be installed when USE=addc is set
Summary: net-fs/samba-4.2.8-9 - samba.service should only be installed when USE=addc i...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's SAMBA Team
URL:
Whiteboard:
Keywords:
: 573524 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-06 07:52 UTC by Juergen Rose
Modified: 2020-02-09 14:46 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juergen Rose 2016-02-06 07:52:20 UTC
/usr/lib/systemd/system/samba.service fails to start samba:

root@lynx2:/usr/local/portage/app-editors(43)# systemctl status  samba
● samba.service - Samba AD server
   Loaded: loaded (/usr/lib64/systemd/system/samba.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2016-02-06 08:22:32 CET; 13min ago
  Process: 3351 ExecStart=/usr/sbin/samba --interactive (code=exited, status=203/EXEC)
 Main PID: 3351 (code=exited, status=203/EXEC)

Feb 06 08:22:32 lynx2 systemd[1]: Started Samba AD server.
Feb 06 08:22:32 lynx2 systemd[1]: samba.service: Main process exited, code=exited, status=203/EXEC
Feb 06 08:22:32 lynx2 systemd[1]: samba.service: Unit entered failed state.
Feb 06 08:22:32 lynx2 systemd[1]: samba.service: Failed with result 'exit-code'.
root@lynx2:/usr/local/portage/app-editors(44)# systemctl start  samba
root@lynx2:/usr/local/portage/app-editors(45)# echo $?
0
root@lynx2:/usr/local/portage/app-editors(46)# systemctl status  samba
● samba.service - Samba AD server
   Loaded: loaded (/usr/lib64/systemd/system/samba.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2016-02-06 08:35:49 CET; 14s ago
  Process: 3461 ExecStart=/usr/sbin/samba --interactive (code=exited, status=203/EXEC)
 Main PID: 3461 (code=exited, status=203/EXEC)

Feb 06 08:35:49 lynx2 systemd[1]: Started Samba AD server.
Feb 06 08:35:49 lynx2 systemd[1]: samba.service: Main process exited, code=exited, status=203/EXEC
Feb 06 08:35:49 lynx2 systemd[1]: samba.service: Unit entered failed state.
Feb 06 08:35:49 lynx2 systemd[1]: samba.service: Failed with result 'exit-code'.


Jan 31 19:29:09 lynx2 systemd[1]: Started Samba AD server.
Jan 31 19:29:09 lynx2 systemd[22714]: samba.service: Failed at step EXEC spawning /usr/sbin/samba: No such file or directory
Jan 31 19:29:09 lynx2 systemd[1]: samba.service: Main process exited, code=exited, status=203/EXEC
Jan 31 19:29:09 lynx2 systemd[1]: samba.service: Unit entered failed state.
Jan 31 19:29:09 lynx2 systemd[1]: samba.service: Failed with result 'exit-code'.
-- Reboot --
Feb 02 09:54:29 lynx2 systemd[1]: Started Samba AD server.
Feb 02 09:54:29 lynx2 systemd[1]: samba.service: Main process exited, code=exited, status=203/EXEC
Feb 02 09:54:29 lynx2 systemd[1]: samba.service: Unit entered failed state.
Feb 02 09:54:29 lynx2 systemd[1]: samba.service: Failed with result 'exit-code'.
Feb 06 08:22:32 lynx2 systemd[1]: Started Samba AD server.
Feb 06 08:22:32 lynx2 systemd[1]: samba.service: Main process exited, code=exited, status=203/EXEC
Feb 06 08:22:32 lynx2 systemd[1]: samba.service: Unit entered failed state.
Feb 06 08:22:32 lynx2 systemd[1]: samba.service: Failed with result 'exit-code'.
Feb 06 08:35:49 lynx2 systemd[1]: Started Samba AD server.
Feb 06 08:35:49 lynx2 systemd[1]: samba.service: Main process exited, code=exited, status=203/EXEC
Feb 06 08:35:49 lynx2 systemd[1]: samba.service: Unit entered failed state.
Feb 06 08:35:49 lynx2 systemd[1]: samba.service: Failed with result 'exit-code'.



root@lynx2:/usr/local/portage/app-editors(48)# cat  /etc/systemd/system/multi-user.target.wants/samba.service
[Unit]

Description=Samba AD server
After=network.target winbindd.service
Conflicts=nmbd.service smbd.service

[Service]
ExecStart=/usr/sbin/samba --interactive 

[Install]
WantedBy=multi-user.target

root@lynx2:/usr/local/portage/app-editors(49)# ll  /etc/systemd/system/multi-user.target.wants/samba.service
lrwxrwxrwx 1 root root 39 Jan 31 19:20 /etc/systemd/system/multi-user.target.wants/samba.service -> /usr/lib64/systemd/system/samba.service

root@lynx2:/usr/local/portage/app-editors(50)# qlist -v samba | grep sbin
/usr/sbin/winbindd
/usr/sbin/nmbd
/usr/sbin/smbd

root@lynx2:/usr/local/portage/app-editors(51)# qlist -v samba | grep samba.service
/usr/lib/systemd/system/samba.service

root@lynx2:/usr/local/portage/app-editors(52)# qlist -Iv samba
net-fs/samba-4.2.8

root@lynx2:/usr/local/portage/app-editors(53)# ll /usr/sbin/samba
/bin/ls: cannot access '/usr/sbin/samba': No such file or directory

I.e., samba-4.2.8 installs /etc/systemd/system/multi-user.target.wants/samba.service, which wants to start /usr/sbin/samba, which does not exist.
Comment 1 Jonathan Scruggs (RETIRED) gentoo-dev 2016-02-16 13:03:52 UTC
Same on my system.

A quick and dirty hack that one probably shouldn't do:
# cd /usr/sbin
# ln -s smbd samba
# systemctl restart samba

I did this so the official systemd unit was not modified in case that is the fix. Then the upgrade will be easier without collisions.
Comment 2 Juergen Rose 2016-03-27 07:09:00 UTC
The issue still happens, also with samba-4.2.9. I also created the link from /usr/sbin/smbd to /usr/sbin/samba. 
'systemctl status samba' does not show any errors, but it seems me, that there are no running samba server or NetBIOS name server processes.

root@impala:/usr/sbin(310)# systemctl status samba
● samba.service - Samba AD server
   Loaded: loaded (/usr/lib64/systemd/system/samba.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Mar 27 08:44:02 impala systemd[1]: Stopped Samba AD server.
Mar 27 08:44:02 impala systemd[1]: Started Samba AD server.
Mar 27 08:44:03 impala samba[23057]: smbd version 4.2.9 started.
Mar 27 08:44:03 impala samba[23057]: Copyright Andrew Tridgell and the Samba Team 1992-2014
Mar 27 08:49:03 impala systemd[1]: Stopping Samba AD server...
Mar 27 08:49:03 impala systemd[1]: Stopped Samba AD server.
Mar 27 08:49:17 impala systemd[1]: Stopped Samba AD server.
Mar 27 08:49:40 impala systemd[1]: Started Samba AD server.
Mar 27 08:49:40 impala samba[23311]: smbd version 4.2.9 started.
Mar 27 08:49:40 impala samba[23311]: Copyright Andrew Tridgell and the Samba Team 1992-2014


root@impala:/usr/sbin(311)# ps -ef | grep nmb
root     23988 17351  0 09:03 pts/5    00:00:00 grep --colour=auto nmb
root@impala:/usr/sbin(312)

One access with 'smbclient -U rose //impala/tmp' from impala without entering a password was possible. All subsequent attemps to do 'smbclient -U rose //impala/tmp' from impala or other systems with or without entering a password
failed with:

root@impala:/usr/sbin(314)# smbclient -U rose //impala/tmp/
Enter rose's password: 
Connection to impala failed (Error NT_STATUS_CONNECTION_REFUSED)
Comment 3 Juergen Rose 2016-03-27 07:16:03 UTC
I set "log file = /var/log/samba/log.%m" in /etc/samba/smb.conf. And as you can see from comment 2, I started samba.service today, i.e. at Mar 27 08:49:17, but there are no changes to the log files since yesterday:

root@impala:/root(10)# ll /var/log/samba/
total 8
-rw-r--r-- 1 root root    0 Mar 26 21:20 log.
-rw-r--r-- 1 root root    0 Mar 26 21:20 log.192.168.1.60
-rw-r--r-- 1 root root    0 Mar 26 21:20 log.leopard
-rw-r--r-- 1 root root  768 Mar 26 21:21 log.nmbd
-rw-r--r-- 1 root root 3167 Mar 26 21:51 log.smbd
Comment 4 Erik Quaeghebeur 2016-04-10 14:56:36 UTC
I can confirm that this issue still exists.
Comment 5 Ben Kohler gentoo-dev 2016-09-06 22:25:19 UTC
This samba.service is to start the Samba Active Directory Domain Controller service (aka ADDC) and the corresponding USE=addc flag is what controls whether a /usr/sbin/samba binary is installed or not.

For a regular samba fileserver, you should be starting smbd.service (and possibly nmbd.service) instead.

That said, the samba ebuild probably shouldn't be installing samba.service unless USE=addc is set.
Comment 6 Ben Kohler gentoo-dev 2019-07-10 18:49:02 UTC
*** Bug 573524 has been marked as a duplicate of this bug. ***
Comment 7 Ben Kohler gentoo-dev 2020-01-07 21:16:16 UTC
I plan to add something like this to the newer ebuilds:

--- a/net-fs/samba/samba-4.11.4-r1.ebuild
+++ b/net-fs/samba/samba-4.11.4-r1.ebuild
@@ -267,11 +267,12 @@ multilib_src_install() {
                newconfd "${CONFDIR}/samba4.confd" samba
 
                systemd_newtmpfilesd packaging/systemd/samba.conf.tmp samba.conf
+               use addc || rm "${D}/$(systemd_get_systemunitdir)/samba.service" || die
+
                # Preserve functionality for old gentoo-specific unit names
                dosym nmb.service "$(systemd_get_systemunitdir)/nmbd.service"
                dosym smb.service "$(systemd_get_systemunitdir)/smbd.service"
                dosym winbind.service "$(systemd_get_systemunitdir)/winbindd.service"
-
        fi
 
        if use pam && use winbind ; then
Comment 8 Larry the Git Cow gentoo-dev 2020-02-09 14:46:51 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6a19e6bd0004fdf91141e798b405b069412fa114

commit 6a19e6bd0004fdf91141e798b405b069412fa114
Author:     Ben Kohler <bkohler@gentoo.org>
AuthorDate: 2020-02-09 14:40:02 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2020-02-09 14:46:38 +0000

    net-fs/samba: revbump to switch to upstream's systemd units
    
    Switch to upstream's packaged systemd units with new filenames.  Add
    symlinks to preserve existing setups.  Remove unused samba.service when
    addc is disabled.  Fix minor whitespace issue in IUSE.
    
    Bug: https://bugs.gentoo.org/692602
    Closes: https://bugs.gentoo.org/573976
    Package-Manager: Portage-2.3.88, Repoman-2.3.20
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 net-fs/samba/samba-4.11.6-r1.ebuild | 314 ++++++++++++++++++++++++++++++++++++
 1 file changed, 314 insertions(+)