interface: set a default hostname property
This commit is contained in:
parent
aec7dad1c1
commit
a210cf6a66
1 changed files with 8 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
#include "libifupdown/interface.h"
|
||||
#include "libifupdown/config-file.h"
|
||||
|
||||
|
@ -121,6 +122,13 @@ lif_interface_init(struct lif_interface *interface, const char *ifname)
|
|||
/* keep the 'vlan' executor as a config hint for backwards compatibility */
|
||||
if (strchr(ifname, '.') != NULL)
|
||||
lif_interface_use_executor(interface, "vlan");
|
||||
|
||||
/* learn a reasonable default hostname */
|
||||
struct utsname un;
|
||||
if (uname(&un) < 0)
|
||||
return;
|
||||
|
||||
lif_dict_add(&interface->vars, "hostname", strdup(un.nodename));
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue