]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove named_os_gethostname()
authorEvan Hunt <each@isc.org>
Thu, 9 Feb 2023 20:48:07 +0000 (12:48 -0800)
committerEvan Hunt <each@isc.org>
Sat, 18 Feb 2023 20:23:41 +0000 (20:23 +0000)
this function was just a front-end for gethostname(). it was
needed when we supported windows, which has a different function
for looking up the hostname; it's not needed any longer.

bin/named/builtin.c
bin/named/include/named/os.h
bin/named/os.c
bin/named/server.c
lib/ns/client.c
lib/ns/include/ns/server.h

index da028c032cbd4f259336bdba98c8650c3f8e870c..8d7d634cbf821af07d5e6a8248ee3bc154874215 100644 (file)
@@ -379,9 +379,8 @@ do_hostname_lookup(dns_sdblookup_t *lookup) {
                }
        } else {
                char buf[256];
-               isc_result_t result = named_os_gethostname(buf, sizeof(buf));
-               if (result != ISC_R_SUCCESS) {
-                       return (result);
+               if (gethostname(buf, sizeof(buf)) != 0) {
+                       return (ISC_R_FAILURE);
                }
                return (put_txt(lookup, buf));
        }
@@ -419,13 +418,10 @@ do_authors_lookup(dns_sdblookup_t *lookup) {
 
 static isc_result_t
 do_id_lookup(dns_sdblookup_t *lookup) {
-       if (named_g_server->sctx->gethostname != NULL) {
+       if (named_g_server->sctx->usehostname) {
                char buf[256];
-               isc_result_t result;
-
-               result = named_g_server->sctx->gethostname(buf, sizeof(buf));
-               if (result != ISC_R_SUCCESS) {
-                       return (result);
+               if (gethostname(buf, sizeof(buf)) != 0) {
+                       return (ISC_R_FAILURE);
                }
                return (put_txt(lookup, buf));
        } else if (named_g_server->sctx->server_id != NULL) {
index 4a3a5f2374f6e05944e05378e2e1c3e2827cc069..0f7c1c5385fd76355368043de58634ce6bb04050 100644 (file)
@@ -62,9 +62,6 @@ named_os_issingleton(const char *filename);
 void
 named_os_shutdown(void);
 
-isc_result_t
-named_os_gethostname(char *buf, size_t len);
-
 void
 named_os_shutdownmsg(char *command, isc_buffer_t *text);
 
index 31872b120a7508a8b3d32e8ab06ab26d08a79b4b..858ccbff3f995b3f34d52f6134264ff34b27a7fe 100644 (file)
@@ -971,14 +971,6 @@ named_os_shutdown(void) {
        cleanup_lockfile();
 }
 
-isc_result_t
-named_os_gethostname(char *buf, size_t len) {
-       int n;
-
-       n = gethostname(buf, len);
-       return ((n == 0) ? ISC_R_SUCCESS : ISC_R_FAILURE);
-}
-
 void
 named_os_shutdownmsg(char *command, isc_buffer_t *text) {
        char *last, *ptr;
index c2299675318ee76c227f5c36ccfc8058f899a460..87df9669b3ff5ee31509d6ccf9014ea21d4225d3 100644 (file)
@@ -3908,8 +3908,7 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
        if (result == ISC_R_SUCCESS && cfg_obj_isboolean(obj)) {
                /* "hostname" is interpreted as boolean true */
                char buf[256];
-               result = named_os_gethostname(buf, sizeof(buf));
-               if (result == ISC_R_SUCCESS) {
+               if (gethostname(buf, sizeof(buf)) == 0) {
                        dns_dt_setidentity(named_g_server->dtenv, buf);
                }
        } else if (result == ISC_R_SUCCESS && !cfg_obj_isvoid(obj)) {
@@ -9543,10 +9542,10 @@ load_configuration(const char *filename, named_server_t *server,
 
        obj = NULL;
        result = named_config_get(maps, "server-id", &obj);
-       server->sctx->gethostname = NULL;
+       server->sctx->usehostname = false;
        if (result == ISC_R_SUCCESS && cfg_obj_isboolean(obj)) {
                /* The parser translates "hostname" to true */
-               server->sctx->gethostname = named_os_gethostname;
+               server->sctx->usehostname = true;
                result = ns_server_setserverid(server->sctx, NULL);
        } else if (result == ISC_R_SUCCESS && !cfg_obj_isvoid(obj)) {
                /* Found a quoted string */
@@ -12190,8 +12189,7 @@ named_server_status(named_server_t *server, isc_buffer_t **text) {
                 cb);
        CHECK(putstr(text, line));
 
-       result = named_os_gethostname(hostname, sizeof(hostname));
-       if (result != ISC_R_SUCCESS) {
+       if (gethostname(hostname, sizeof(hostname)) == 0) {
                strlcpy(hostname, "localhost", sizeof(hostname));
        }
        snprintf(line, sizeof(line), "running on %s: %s\n", hostname,
index a5d3aa6aa05dfa1e35c53c6be9f08184f5b8f022..13b4b4f49be232f97dde55690b918858ffeaa8ef 100644 (file)
@@ -979,10 +979,8 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message,
        if (WANTNSID(client)) {
                if (client->manager->sctx->server_id != NULL) {
                        nsidp = client->manager->sctx->server_id;
-               } else if (client->manager->sctx->gethostname != NULL) {
-                       result = client->manager->sctx->gethostname(
-                               nsid, sizeof(nsid));
-                       if (result != ISC_R_SUCCESS) {
+               } else if (client->manager->sctx->usehostname) {
+                       if (gethostname(nsid, sizeof(nsid)) != 0) {
                                goto no_nsid;
                        }
                        nsidp = nsid;
index 431470c2eb969577f2e4341ca9b51b810bae346c..b380de9eef89b07ef3ec0392ffccd76833e35971 100644 (file)
@@ -97,8 +97,8 @@ struct ns_server {
        dns_tkeyctx_t *tkeyctx;
 
        /*% Server id for NSID */
-       char           *server_id;
-       ns_hostnamecb_t gethostname;
+       char *server_id;
+       bool  usehostname;
 
        /*% Fuzzer callback */
        isc_fuzztype_t fuzztype;