[PATCH] Run 'samba' daemon in foreground

Andrew Bartlett abartlet at samba.org
Tue Nov 28 10:38:02 UTC 2017


On Tue, 2017-11-28 at 10:59 +0100, Andreas Schneider wrote:
> On Monday, 27 November 2017 22:33:22 CET Andrew Bartlett via samba-technical 
> wrote:
> > On Mon, 2017-11-27 at 19:43 +0100, Andreas Schneider via samba-
> > 
> > technical wrote:
> > > Hi,
> > > 
> > > attached is a patch to address an issue with systemd and Samba daemons
> > > running in notify mode. In this mode we should not double fork. So we
> > > should start the daemons with --foreground. Also systemd will take care
> > > of the process group we should not handle that in Samba.
> > > 
> > > For this I've added --foreground to the 'samba' daemon.
> > > 
> > > 
> > > Review is much appreciated. If OK please push.
> > 
> > My main question comes from not really understanding what a session ID
> > is in unix.  Your patch makes --no-process-group also change us to call
> > getsid(), which was unconditionally false previously.
> > 
> > Is that reasonable?  If so, can you just write up what exactly it means
> > in the commit message?
> 
> If you have a SysV Daemon, you should call setsid() to detach from any 
> terminal and create an independent session.
> 
> If we are running in systemd we should run in forground mode and not call 
> setsid()!
> 
> See
> 
> https://www.freedesktop.org/software/systemd/man/daemon.html
> 
> how SysV Daemons should be implemented.
> 
> > The options here are a confusing mess, so noting the differences with
> > -i (--interactive) would be helpful.  As I read it, the only difference
> > is that with -i logs got to STDOUT and with --foreground
> > become_daemon() is called, potentially allowing --no-process-group to
> > trigger the setsid()?
> 
> No, --no-process-group does NOT trigger setsid()!
> 
> samba --no-process-group:
> no_process_group=true  =>  become_daemon(no_session=true)
> 
> if (!no_session) {
>   setsid()
> }
> 
> Updated patchset attached.

Thanks!  

Reviewed-by: Andrew Bartlett <abartlet at samba.org>

In autobuild now.

Thanks to you and everyone else pitching in for all the recent tidy-up
and portability work.  It is nice to see this improved.

Andrew Bartlett
-- 
Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba




More information about the samba-technical mailing list