[collectd] [PATCH] unixsock: remove a possible leftover unix socket file before creating

Sebastian Harl sh at tokkee.org
Wed Mar 24 13:09:48 CET 2010


Hi Peter,

On Wed, Mar 24, 2010 at 12:59:04PM +0100, Peter Warasin wrote:
> There was an unlink() of that socket file before bind(), but it is
> commented out.
> Re-introducing it (what the attached patch does) fixes the problem, at
> least for me.
> 
> I wonder if there's a good reason why this has been commented out, and
> if it can be unlink()'d safely, without side-effects?

Well, we cannot be sure that the socket file was created by some other
instance of collectd before. So, since collectd is usually running with
root privileges, we could possibly remove unrelated data.

At the very least (imho), we should check if that file is a UNIX socket,
and possibly (I'm not sure if that's possible [in a portable way]) check
if the socket is not in use. If both of that is the case, we can be
fairly sure that removing the file is safe.

Cheers,
Sebastian

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20100324/96b950a1/attachment.pgp 


More information about the collectd mailing list