summaryrefslogtreecommitdiff
path: root/sysdep
diff options
context:
space:
mode:
Diffstat (limited to 'sysdep')
-rw-r--r--sysdep/unix/main.c16
-rw-r--r--sysdep/unix/unix.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index 2c7e3cef..67e76655 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -20,6 +20,7 @@
#include <pwd.h>
#include <grp.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
#include <libgen.h>
#include "nest/bird.h"
@@ -89,6 +90,21 @@ drop_gid(gid_t gid)
}
/*
+ * Hostname
+ */
+
+char *
+get_hostname(linpool *lp)
+{
+ struct utsname uts = {};
+
+ if (uname(&uts) < 0)
+ return NULL;
+
+ return lp_strdup(lp, uts.nodename);
+}
+
+/*
* Reading the Configuration
*/
diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h
index 0f2973f0..ad85d1ea 100644
--- a/sysdep/unix/unix.h
+++ b/sysdep/unix/unix.h
@@ -24,6 +24,7 @@ extern int parse_and_exit;
void async_config(void);
void async_dump(void);
void async_shutdown(void);
+char *get_hostname(linpool *lp);
void cmd_check_config(const char *name);
void cmd_reconfig(const char *name, int type, uint timeout);
void cmd_reconfig_confirm(void);