Error starting samba, missing /run/samba directory

General support questions
User avatar
Caio Narezzi
Posts: 6
Joined: 2018/02/02 00:59:00

Re: Error starting samba, missing /run/samba directory

Post by Caio Narezzi » 2018/02/02 13:02:56

Yes, unfortunately, but I got a win, I turned off the firewalld from my system and went back to \\server but only by IP not by name, I'm reading about, if I can get back to the news, but help me please

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Error starting samba, missing /run/samba directory

Post by TrevorH » 2018/02/02 16:19:36

Samba needs several ports but if you use firewalld then you just need to firewall-cmd --add-service=samba and it'll do it all for you. Oh, and again with --permanent
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
Caio Narezzi
Posts: 6
Joined: 2018/02/02 00:59:00

Re: Error starting samba, missing /run/samba directory

Post by Caio Narezzi » 2018/02/02 18:02:22

Yes, unfortunately, but I got a win, I turned off the firewalld from my system and went back to \\server but only by IP not by name, I'm reading about, if I can get back to the news, but help me please

Follow my SMB. conf:

Code: Select all

[global]
	name  bios = KING
	workgroup = GRUPO
	security = user
	map to guest = Bad user
	dns proxy = no
[hd]
	path = /hd
	browsable = yes
	writable = yes
	guest ok = yes
	read only = no
	create mask = 0777
	directory mask = 0777
[ssd]
	path = /ssd
	browsable = yes
	writable = yes
	guest ok = yes
	read only = no
	create mask = 0777
	directory mask = 0777

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Error starting samba, missing /run/samba directory

Post by TrevorH » 2018/02/02 18:10:17

Yes, you said. I'm trying to help you to re-enable firewalld since you should have a firewall running.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
Caio Narezzi
Posts: 6
Joined: 2018/02/02 00:59:00

Re: Error starting samba, missing /run/samba directory

Post by Caio Narezzi » 2018/02/02 18:19:32

Yes, sorry for anything, still not going to reactivate Firewalld, I will try to do the samba works properly and then I will reactivate the FIREWALLD :D

hous3810
Posts: 5
Joined: 2018/06/15 16:54:17

Re: Error starting samba, missing /run/samba directory

Post by hous3810 » 2018/06/15 17:13:47

I had a similar issue on a fresh install of CentOS 7. I had no issues with an earlier version of CentOS 7 using an older version of Samba. The installer I used was the minimal-1708. So I ended up installing Samba from yum after updating.

Had the same issues with the /run/samba directory not being created on reboot by systemd. I compared a version of a working samba server and the systemd boot file at /usr/lib/systemd/system/smb.service is not the same.

So I copied the smb.service that seemed to work. Now samba starts like it should.

I would assume this is due to the latest version of Samba and not the CentOS version as 1804 is out now. I will try and rebuild it with the new version as well as look at what exactly in the smb.service file is causing smbd to error out.

Lines that were different:
Environment=KRB5CCNAME=FILE:/run/samba/krb5cc_samba
changed to:
Environment=KRB5CCNAME=/run/samba/krb5cc_samba

ExecStart=/usr/sbin/smbd --foreground --no-process-group $SMBDOPTIONS
changed to:
ExecStart=/usr/sbin/smbd $SMBDOPTIONS

LimitCORE=infinity
REMOVED

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Error starting samba, missing /run/samba directory

Post by TrevorH » 2018/06/16 11:38:26

Creation of /run/samba should be handled by systemd and the tmpfiles.d service at boot time. You should have a /usr/lib/tmpfiles.d/samba.conf file containing

Code: Select all

d /var/run/samba  755 root root
d /run/samba  755 root root
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hous3810
Posts: 5
Joined: 2018/06/15 16:54:17

Re: Error starting samba, missing /run/samba directory

Post by hous3810 » 2018/06/18 16:30:10

It does create the directories if the smb.service start up script parameters are correct.

I traced it down to the parameter --no-process-group. I looked into it and there is a samba technical post from 2017 that does say that for systemd all that is needed for smb.service is --foreground as I understand it. I have yet to test with 1804 installer, will do so today. The same parameter works fine with the nmb.service for systemd. If someone else could test and let me know what I am doing wrong that would be great. I am using the samba/winbind method for binding to AD and my testparm has no errors and if I leave out --no-process-group it works just fine. I will read through the patch notes of the CentOS patches where this change was first patched and see if they mention why they implemented this change into smb.service.

Reference material:

https://lists.samba.org/archive/samba-t ... 24019.html

> 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/sy ... aemon.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.

hous3810
Posts: 5
Joined: 2018/06/15 16:54:17

Re: Error starting samba, missing /run/samba directory

Post by hous3810 » 2018/06/18 17:43:38

So I did read through the patch notes for this change and I did find some issue with parameters in the samba source as there is an extra comma:


+++ b/source4/smbd/server.c
@@ -341,6 +341,7 @@ static int binary_smbd_main(const char *binary_name,
{
bool opt_daemon = false;
bool opt_interactive = false;
+ bool opt_no_process_group = false;
int opt;
poptContext pc;
#define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
@@ -356,7 +357,8 @@ static int binary_smbd_main(const char *binary_name,
OPT_DAEMON = 1000,
OPT_INTERACTIVE,
OPT_PROCESS_MODEL,
- OPT_SHOW_BUILD
+ OPT_SHOW_BUILD,
+ OPT_NO_PROCESS_GROUP,
};

However I modified the options in the smb.service file and set it to interactive just for fun as playing with options is the only way to learn. Had to reload the daemons. This is after the latest kernel update. Then I decided to put in the --no-process-group parameter for another test and found that smb reloaded just fine and did so again on a few restarts. Maybe something in this process fixed the glitch??

Going to rebuild another system and see if it all happens again.

hous3810
Posts: 5
Joined: 2018/06/15 16:54:17

Re: Error starting samba, missing /run/samba directory

Post by hous3810 » 2018/06/20 16:07:22

So a rebuild with 1708 I had similar if not the same issues with enabling samba with the nmb/smb services and having it start.

It isn't just /run/samba not being generated. Have an issue with /run/user not generating either. I get that when I increased the logging on the smb.conf file to 5 for samba in /var/log/messages. Any time that the smb service fails due to /run/samba not being created /run/users is not created. Verified this will exist if samba starts successfully.

smb.service waits for both nmb.service and winbind.service to start. I have noted that winbindd does fail first with the /run/samba directory not existing as winbindd has a pipe there. Nmb is doing similar.

What it really looks like is a race condition. There were issues with NetworkManager causing race conditions in the past, but I get failures whether NetworkManager is running or not.

Doesn't seem to be an issue with the parameters in smb.service as it looks like something else in systemd is faiing and /run directories are not being generated and this happens with or without SELINUX on. Could be something with winbind as several samba tutorials say to shut it off if its services are not needed, however I am using winbind to bind to AD, so I need it running. Looks like if I reboot enough times eventually samba will run just frustrating that the failure isn't for certain as hard to troubleshoot where the problem actually is. Will keep investigating, could be my other file servers are affected too, but I have just been lucky so far.

Post Reply