Bug 9505 - winbindd can' restart with -s parameter when its pid file exist
winbindd can' restart with -s parameter when its pid file exist
Status: NEW
Product: Samba 3.6
Classification: Unclassified
Component: Winbind
All All
: P5 normal
: ---
Assigned To: Michael Adam
Samba QA Contact
Depends on:
  Show dependency treegraph
Reported: 2012-12-17 01:29 UTC by Aucean
Modified: 2012-12-20 08:06 UTC (History)
1 user (show)

See Also:

This is the patche for this bug (4.56 KB, text/plain)
2012-12-17 01:29 UTC, Aucean
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aucean 2012-12-17 01:29:42 UTC
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.