You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

  1. From 715e9b892f564e58489f86c125aed2a8994f16e9 Mon Sep 17 00:00:00 2001
  2. From: Conrad Hoffmann <conrad@soundcloud.com>
  3. Date: Mon, 28 Jul 2014 23:22:43 +0200
  4. Subject: [PATCH 2/3] BUG/MINOR: Fix search for -p argument in systemd wrapper.
  5. Searching for the pid file in the list of arguments did not
  6. take flags without parameters into account, like e.g. -de. Because
  7. of this, the wrapper would use a different pid file than haproxy
  8. if such an argument was specified before -p.
  9. The new version can still yield a false positive for some crazy
  10. situations, like your config file name starting with "-p", but
  11. I think this is as good as it gets without using getopt or some
  12. library.
  13. Signed-off-by: Conrad Hoffmann <conrad@soundcloud.com>
  14. (cherry picked from commit eb2cf45b72a7e14c581276247381dc1ac76be2c0)
  15. ---
  16. src/haproxy-systemd-wrapper.c | 7 ++-----
  17. 1 file changed, 2 insertions(+), 5 deletions(-)
  18. diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
  19. index ba07ebe..529b213 100644
  20. --- a/src/haproxy-systemd-wrapper.c
  21. +++ b/src/haproxy-systemd-wrapper.c
  22. @@ -130,11 +130,8 @@ static void sigint_handler(int signum __attribute__((unused)))
  23. static void init(int argc, char **argv)
  24. {
  25. while (argc > 1) {
  26. - if (**argv == '-') {
  27. - char *flag = *argv + 1;
  28. - --argc; ++argv;
  29. - if (*flag == 'p')
  30. - pid_file = *argv;
  31. + if ((*argv)[0] == '-' && (*argv)[1] == 'p') {
  32. + pid_file = *(argv + 1);
  33. }
  34. --argc; ++argv;
  35. }
  36. --
  37. 1.8.5.5