Bug 1891217 - Samba services in 4.13 time out when run under systemd due to NotifyAccess=main and no status reporting in foreground mode
Summary: Samba services in 4.13 time out when run under systemd due to NotifyAccess=ma...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: samba
Version: 33
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
Assignee: Guenther Deschner
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-10-24 14:12 UTC by Alexander Bokovoy
Modified: 2020-10-28 02:01 UTC (History)
11 users (show)

Fixed In Version: samba-4.13.0-13 samba-4.13.0-13.fc33
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-28 02:01:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Alexander Bokovoy 2020-10-24 14:12:42 UTC
Copying my bug report from Samba upstream: https://bugzilla.samba.org/show_bug.cgi?id=14552

This affects Samba 4.13.x.

When systemd launches samba service, the configuration we have in samba.service expects that the main process (/usr/sbin/samba) would use sd_notify() to report back its status. However, we only use sd_notify() when running become_daemon().

As a result, samba process never reports back its status and the status updates from other daemons (smbd, winbindd, etc) are not accepted as we now have implied NotifyAccess=main since 

commit d1740fb3d5a72cb49e30b330bb0b01e7ef3e09cc
Author: Marcos Mello <marcosfrm>
Date:   Fri May 8 07:44:51 2020 -0300

    Drop NotifyAccess=all from systemd units
    
    The implicit NotifyAccess=main is enough since Samba daemons do not
    fork()/exit() anymore under systemd.
    
    Signed-off-by: Marcos Mello <marcosfrm>
    Reviewed-by: Andreas Schneider <asn>
    Reviewed-by: Alexander Bokovoy <ab>


This leads to a timeout and killing samba process by systemd. Situation is reproducible in Fedora 33, for example.

I think we should change source4/smbd/server.c:binary_smbd_main() from

        if (opt_daemon) {
                DBG_NOTICE("Becoming a daemon.\n");
                become_daemon(opt_fork, opt_no_process_group, false);
        }
....
        if (opt_daemon) {
                daemon_ready("samba");
        }

to the code that still reports its status to the systemd:

        if (opt_daemon) {
                DBG_NOTICE("Becoming a daemon.\n");
                become_daemon(opt_fork, opt_no_process_group, false);
        } else {
                daemon_status("samba", "Starting process...");
        }
....
        daemon_ready("samba");

This would give a behavior expected by systemd from such services.

Fix is included into https://gitlab.com/samba-team/samba/-/merge_requests/1643

I think we also need to fix this for smbd, nmbd, and winbindd because they also do not report their status when running in foreground under systemd.

Comment 1 Alexander Bokovoy 2020-10-25 07:58:20 UTC
I verified that my upstream patches from MR#1643 do work in COPR report abbra/samba-test.

Jeremy will review MR#1643 upstream on Monday, so I am pushing the changes to Fedora to have working setup by F33 release.

New builds for F33 and Rawhide are coming.

Comment 2 Fedora Update System 2020-10-25 09:22:25 UTC
FEDORA-2020-7ff48016a5 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-7ff48016a5

Comment 3 Fedora Update System 2020-10-25 09:22:28 UTC
FEDORA-2020-7ff48016a5 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-7ff48016a5

Comment 4 Fedora Update System 2020-10-26 01:18:00 UTC
FEDORA-2020-7ff48016a5 has been pushed to the Fedora 33 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-7ff48016a5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-7ff48016a5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2020-10-28 02:01:59 UTC
FEDORA-2020-7ff48016a5 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.