]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
priv: rename "gethostbyname" priv function to "gethostname"
authorVincent Bernat <vincent@bernat.im>
Wed, 28 Jan 2015 13:50:12 +0000 (14:50 +0100)
committerVincent Bernat <vincent@bernat.im>
Wed, 28 Jan 2015 13:57:23 +0000 (14:57 +0100)
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
src/daemon/lldpd.h
src/daemon/priv.c

index 153514bed4bc155d3347fdf14fa47b62d5738351..f868fc781c66dcb8d31cb38375b65dd819571ef4 100644 (file)
@@ -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);
index 9f986f3171e3eb210725702c04cc9b26c097f867..1e5ae287d9e71db5c483ee38eefee333e5d753c7 100644 (file)
@@ -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);
index a8ac50da80398efb094cd7a6e5171c800706651c..f660bafda2e4d2291ee30967a1193a9f11e4d843 100644 (file)
@@ -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},