]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Add local definition of sethostname to lxc_unshare
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 15 Jan 2014 23:29:57 +0000 (18:29 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 15 Jan 2014 23:29:57 +0000 (18:29 -0500)
sethostname doesn't exist on bionic, so copy/paste the definition of it
we have in conf.c

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxc_unshare.c

index 946cdaee9df12acdbde3c629216c2b7c05beb5d2..792bfd9ae2ee10907b6711c6c2beef2e4095920a 100644 (file)
 #define _GNU_SOURCE
 #include <stdio.h>
 #undef _GNU_SOURCE
-#include <stdlib.h>
-#include <unistd.h>
-#include <libgen.h>
+#include <errno.h>
 #include <getopt.h>
-#include <string.h>
+#include <libgen.h>
+#include <netinet/in.h>
+#include <pwd.h>
 #include <signal.h>
-#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <pwd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include <unistd.h>
 
 #include "caps.h"
+#include "cgroup.h"
+#include "config.h"
+#include "error.h"
 #include "log.h"
 #include "namespace.h"
 #include "network.h"
 #include "utils.h"
-#include "cgroup.h"
-#include "error.h"
+
+/* Define sethostname() if missing from the C library */
+#ifndef HAVE_SETHOSTNAME
+static int sethostname(const char * name, size_t len)
+{
+#ifdef __NR_sethostname
+return syscall(__NR_sethostname, name, len);
+#else
+errno = ENOSYS;
+return -1;
+#endif
+}
+#endif
 
 lxc_log_define(lxc_unshare_ui, lxc);