about summary refs log tree commit diff
path: root/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/getdomainname.c10
-rw-r--r--src/misc/setdomainname.c8
2 files changed, 17 insertions, 1 deletions
diff --git a/src/misc/getdomainname.c b/src/misc/getdomainname.c
index 7eb113d7..59df566d 100644
--- a/src/misc/getdomainname.c
+++ b/src/misc/getdomainname.c
@@ -1,9 +1,17 @@
+#define _GNU_SOURCE
 #include <unistd.h>
 #include <sys/utsname.h>
 #include <string.h>
+#include <errno.h>
 
 int getdomainname(char *name, size_t len)
 {
-	*name = 0;
+	struct utsname temp;
+	uname(&temp);
+	if (!len || strlen(temp.domainname) >= len) {
+		errno = EINVAL;
+		return -1;
+	}
+	strcpy(name, temp.domainname);
 	return 0;
 }
diff --git a/src/misc/setdomainname.c b/src/misc/setdomainname.c
new file mode 100644
index 00000000..22d3f746
--- /dev/null
+++ b/src/misc/setdomainname.c
@@ -0,0 +1,8 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+
+int setdomainname(const char *name, size_t len)
+{
+	return syscall(SYS_setdomainname, name, len);
+}