int getdtablesize(void);
int sethostname(const char *, size_t);
int getdomainname(char *, size_t);
+int setdomainname(const char *, size_t);
int setgroups(size_t, const gid_t []);
char *getpass(const char *);
int daemon(int, int);
+#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;
}
--- /dev/null
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+
+int setdomainname(const char *name, size_t len)
+{
+ return syscall(SYS_setdomainname, name, len);
+}