MEDIUM: systemd-wrapper: support multiple executable versions and names
authorWilly Tarreau <w@1wt.eu>
Fri, 19 Sep 2014 13:42:30 +0000 (15:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Sep 2014 13:42:30 +0000 (15:42 +0200)
commitceaf2aec1ec1612da461c61798e944693144bee9
tree37f7acf446e95ed51498de790868ed7e7ede38a3
parente42bd96d0acc38ea7c546c8de8115ffd1dd6c3f3
MEDIUM: systemd-wrapper: support multiple executable versions and names

Having to use a hard-coded "haproxy" executable name next to the systemd
wrapper is not always convenient, as it's sometimes desirable to run with
multiple versions in parallel.

Thus this patch performs a minor change to the wrapper : if the name ends
with "-systemd-wrapper", then it trims that part off and what remains
becomes the target haproxy executable. That makes it easy to have for
example :

     haproxy-1.5.4-systemd-wrapper      haproxy-1.5.4
     haproxy-1.5.3-systemd-wrapper      haproxy-1.5.3

and so on, in a same directory.

This patch also fixes a rare bug caused by readlink() not adding the
trailing zero and leaving possible existing contents, including possibly
a randomly placed "/" which would make it unable to locate the correct
binary. This case is not totally unlikely as I got a \177 a few times
at the end of the executable names, so I could have got a '/' as well.

Back-porting to 1.5 is desirable.
src/haproxy-systemd-wrapper.c