Bug 4792 - Off by one pidfile name error
Off by one pidfile name error
Product: Samba 3.0
Classification: Unclassified
Component: Build environment
All All
: P3 trivial
: none
Assigned To: Tim Potter
Samba QA Contact
Depends on:
  Show dependency treegraph
Reported: 2007-07-16 12:43 UTC by David Gajewski
Modified: 2007-07-23 14:20 UTC (History)
3 users (show)

See Also:

Patch for 3.0.25b (544 bytes, patch)
2007-07-16 12:44 UTC, David Gajewski
no flags Details
Patch for 3.0.26 (with source/lib as patch base) (294 bytes, patch)
2007-07-16 12:45 UTC, David Gajewski
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Gajewski 2007-07-16 12:43:19 UTC
When a conf file is passed on the commandline (with '-s'), different rules are used to name the pidfile.  One expects <program name>-<short conf name>.pid, however <short conf name> is missing its first letter.

   smbd -s /path/to/file/my.conf

Expected pidfile:
Actual pidfile:

The mistake is that 2 separate parts of the code are incrementing past the final '/' in the full name, in effect moving forward 2 characters. The exact same thing occurs when the conf file is in the current working directory.  This is in pidfile_create() {source/lib/pidfile.c}.
Comment 1 David Gajewski 2007-07-16 12:44:38 UTC
Created attachment 2822 [details]
Patch for 3.0.25b
Comment 2 David Gajewski 2007-07-16 12:45:51 UTC
Created attachment 2823 [details]
Patch for 3.0.26 (with source/lib as patch base)
Comment 3 Timur Bakeyev 2007-07-19 11:48:30 UTC
Hi, David!

Well spotted and fixed problem, I'm going to incorporate to my hot-fixes for the FreeBSD package of 3.0.25b.

But in general, in the first place I would question necessirity of the such twisted Samba behaviour, when it creates different PID file for the non-standart config file.

I can see rational behind of that, when you are running several Sambas on one machine, but the implementation looks like ad-hoc hack, and adding configuration  directive, that let you change pidfile name is more correct.

Moreover, if you happen to have samba1/smb.conf and samba2/smb.conf files for different setups this approach wouldn't work, as it'll map to the same file name. It also creates a head ache for the distro maintainers, as scripting location of the pidfile becomes non-trivial task.

Jeremy, Jerry - can you, please, review this piece of code and implement it differently?


That would eliminate mentioned problems.

BTW, it seems, smbcontrol is still broken in the way how it handles such non-standard pidfiles, as it looks for the processes it has to talk to base on PID files.

With best regards,
Comment 4 Volker Lendecke 2007-07-23 14:10:18 UTC
Checked in with r24008. Thanks!

Comment 5 Volker Lendecke 2007-07-23 14:20:44 UTC
Checked in with r24008. Thanks!