]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: translate dot into the short hostname
authorGeorg Sauthoff <mail@gms.tf>
Fri, 24 Nov 2023 19:06:06 +0000 (20:06 +0100)
committerVincent Bernat <vincent@bernat.ch>
Fri, 24 Nov 2023 22:14:06 +0000 (23:14 +0100)
as documented in lldpcli(8):

    configure system hostname name

        Override system hostname with the provided value. By default, the
        system name is the FQDN found from the resolved value of uname
        -n.  As a special value, use "." (dot) to use the short hostname
        instead of a FQDN.

src/client/conf-system.c

index 554f6fc2302685722efeb2250cb2aa4582278f1f..57a62f85eba2a7decaa8f1a7fbb0c58e68274bab 100644 (file)
@@ -205,6 +205,9 @@ cmd_hostname(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
                        lldpctl_atom_dec_ref(config);
                        return 0;
                }
+               char *c = strchr(un.nodename, '.');
+               if (c)
+                       *c = 0;
                value = un.nodename;
        }
        if (lldpctl_atom_set_str(config, lldpctl_k_config_hostname, value) == NULL) {