From 1fa7d39f5b9d27483c84ef5646cf1ff462b5c5ae Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 28 Jan 2015 14:50:12 +0100 Subject: [PATCH] priv: rename "gethostbyname" priv function to "gethostname" Because, it is not a wrapper around `gethostbyname()` but a way to get local hostname. It currently uses `gethostbyname()` and therefore relies on the presence of an IPv4 address in the system. --- src/daemon/lldpd.c | 2 +- src/daemon/lldpd.h | 2 +- src/daemon/priv.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 153514be..f868fc78 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1030,7 +1030,7 @@ lldpd_update_localchassis(struct lldpd *cfg) log_debug("localchassis", "use overridden system name `%s`", cfg->g_config.c_hostname); hp = cfg->g_config.c_hostname; } else { - if ((hp = priv_gethostbyname()) == NULL) + if ((hp = priv_gethostname()) == NULL) fatal("localchassis", "failed to get system name"); } free(LOCAL_CHASSIS(cfg)->c_name); diff --git a/src/daemon/lldpd.h b/src/daemon/lldpd.h index 9f986f31..1e5ae287 100644 --- a/src/daemon/lldpd.h +++ b/src/daemon/lldpd.h @@ -224,7 +224,7 @@ client_handle_client(struct lldpd *cfg, void priv_init(const char*, int, uid_t, gid_t); void priv_wait(void); void priv_ctl_cleanup(const char *ctlname); -char *priv_gethostbyname(void); +char *priv_gethostname(void); #ifdef HOST_OS_LINUX int priv_open(char*); void asroot_open(void); diff --git a/src/daemon/priv.c b/src/daemon/priv.c index a8ac50da..f660bafd 100644 --- a/src/daemon/priv.c +++ b/src/daemon/priv.c @@ -96,9 +96,9 @@ priv_ctl_cleanup(const char *ctlname) must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int)); } -/* Proxy for gethostbyname */ +/* Proxy for gethostname */ char * -priv_gethostbyname() +priv_gethostname() { static char *buf = NULL; int rc; @@ -213,7 +213,7 @@ asroot_ctl_cleanup() } static void -asroot_gethostbyname() +asroot_gethostname() { struct utsname un; struct hostent *hp; @@ -380,7 +380,7 @@ struct dispatch_actions { static struct dispatch_actions actions[] = { {PRIV_PING, asroot_ping}, {PRIV_DELETE_CTL_SOCKET, asroot_ctl_cleanup}, - {PRIV_GET_HOSTNAME, asroot_gethostbyname}, + {PRIV_GET_HOSTNAME, asroot_gethostname}, #ifdef HOST_OS_LINUX {PRIV_OPEN, asroot_open}, {PRIV_ETHTOOL, asroot_ethtool}, -- 2.39.5