From: Conrad Hoffmann Date: Mon, 28 Jul 2014 21:22:43 +0000 (+0200) Subject: BUG/MINOR: Fix search for -p argument in systemd wrapper. X-Git-Tag: v1.6-dev1~344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb2cf45b72a7e14c581276247381dc1ac76be2c0;p=thirdparty%2Fhaproxy.git BUG/MINOR: Fix search for -p argument in systemd wrapper. Searching for the pid file in the list of arguments did not take flags without parameters into account, like e.g. -de. Because of this, the wrapper would use a different pid file than haproxy if such an argument was specified before -p. The new version can still yield a false positive for some crazy situations, like your config file name starting with "-p", but I think this is as good as it gets without using getopt or some library. Signed-off-by: Conrad Hoffmann --- diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c index ba07ebe01c..529b2136df 100644 --- a/src/haproxy-systemd-wrapper.c +++ b/src/haproxy-systemd-wrapper.c @@ -130,11 +130,8 @@ static void sigint_handler(int signum __attribute__((unused))) static void init(int argc, char **argv) { while (argc > 1) { - if (**argv == '-') { - char *flag = *argv + 1; - --argc; ++argv; - if (*flag == 'p') - pid_file = *argv; + if ((*argv)[0] == '-' && (*argv)[1] == 'p') { + pid_file = *(argv + 1); } --argc; ++argv; }