From 1e0d651f6ec99fcc1ad946723a03d4216caa57c5 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 15 Jul 2013 15:46:36 +0200 Subject: [PATCH] lldpd: invoke `setproctitle_init()` when needed On some systems, we need to invoke `setproctitle_init()` before using `setproctitle()`. --- configure.ac | 4 +++- src/daemon/lldpd.c | 6 +++++- src/daemon/lldpd.h | 2 +- src/daemon/main.c | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index bec8ddc6..b95035ce 100644 --- a/configure.ac +++ b/configure.ac @@ -97,7 +97,9 @@ AC_CONFIG_LIBOBJ_DIR([src/compat]) AC_FUNC_MALLOC AC_FUNC_REALLOC AC_SEARCH_LIBS([setproctitle], [util bsd]) -AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln setproctitle]) +AC_REPLACE_FUNCS([setproctitle]) +AC_CHECK_FUNCS([setproctitle_init]) +AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln]) AC_CHECK_FUNCS([setresuid setresgid]) case " $LIBS " in diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index e07b3696..9ef39fb3 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1217,7 +1217,7 @@ lldpd_started_by_systemd() #endif int -lldpd_main(int argc, char *argv[]) +lldpd_main(int argc, char *argv[], char *envp[]) { struct lldpd *cfg; struct lldpd_chassis *lchassis; @@ -1253,6 +1253,10 @@ lldpd_main(int argc, char *argv[]) saved_argv = argv; +#if HAVE_SETPROCTITLE_INIT + setproctitle_init(argc, argv, envp); +#endif + /* * Get and parse command line options */ diff --git a/src/daemon/lldpd.h b/src/daemon/lldpd.h index 30e10357..dc16e83c 100644 --- a/src/daemon/lldpd.h +++ b/src/daemon/lldpd.h @@ -132,7 +132,7 @@ struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize, u_i void lldpd_recv(struct lldpd *, struct lldpd_hardware *, int); void lldpd_send(struct lldpd_hardware *); void lldpd_loop(struct lldpd *); -int lldpd_main(int, char **); +int lldpd_main(int, char **, char **); void lldpd_update_localports(struct lldpd *); void lldpd_cleanup(struct lldpd *); diff --git a/src/daemon/main.c b/src/daemon/main.c index cbcf9657..c2d92979 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -11,7 +11,7 @@ */ int -main(int argc, char **argv) +main(int argc, char **argv, char **envp) { - return lldpd_main(argc, argv); + return lldpd_main(argc, argv, envp); } -- 2.39.5