taskd.pl: be persnickety about preexisting sockets
commita12db637e5ce6bb98461fa0fd1c301eed83daa78
authorKyle J. McKay <mackyle@gmail.com>
Fri, 2 Dec 2016 04:09:35 +0000 (1 20:09 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Fri, 2 Dec 2016 04:09:35 +0000 (1 20:09 -0800)
tree790e04df614cc5f48885ec881de27812d5d51cd4
parent9d3dbfb4959a14f54f5e883db0d8fa24790153a3
taskd.pl: be persnickety about preexisting sockets

Previously taskd.pl would just blindly unlink any preexisting
socket before attempting to bind.  This is bad as it allows a
previous taskd.pl to keep running while not receiving any new
connections.

Also, during graceful restart, an open listen socket could be
passed along that did not match the actual socket node in the
filesystem which is also bad as the new, gracefully-restarted
instance would be unable to receive any new connections.

Continue to allow any unix stream listen socket in --inetd mode,
but now in non-inetd mode:

  1) Ignore any incoming listen socket for a graceful restart if
     the socket is not located where its supposed to be or its
     inode doesn't match the inode of the socket file at that location.

  2) Refuse to unlink anything but a pre-existing socket at the
     expected location when not gracefully restarting and furthermore,
     refuse to unlink an existing socket if it's still "live".

Also now use the "realpath" function when comparing socket paths to
make sure sockets are not incorrectly rejected.

With these changes only one taskd instance (per Girocco instance)
should ever be running at a time.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
taskd/taskd.pl