Created attachment 8351 [details]
This is the patche for this bug
When we start winbindd with -s /etc/samba/smb2.conf, winbindd will create a pid file named /var/run/samba/winband-smb2.conf.pid. If this pid file already exists when starting the winbindd, winbindd will failed to start.
From the log file, we can get this error message:
ERROR: can't open /var/run/samba/winbindd-smb2.conf.pid: Error was File exists.
The root cause is that:
During the start, winbindd will invoke the function - pidfile_pid(const char *program_name) in pidfile_create(const char *program_name) to test if itself was already running. In this pidfile_pid function, it will unlink the pidfile if the pidfile exists but the process don't exist. The pidfile's name is created from the program_name that if the program is started with a none default configuration file name, it will add a suffix to the program_name. However, before the winbindd invokes the pidfile_pid function, the program_name has been added a suffix. This mean that the pidfile_pid function get a pidfile name which has double suffix. So pidfile_pid function finds that this pidfile don't exist, so it don't need to nulink it.So the really pidfile is not unlink too. After invoke the pidfile_pid, the winbindd will open the pidfile with O_CREAT and O_EXCL flags, so it failed.