]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix lxc-user-nic to work on bionic
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 16 Aug 2013 14:55:40 +0000 (16:55 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 19 Aug 2013 12:33:36 +0000 (14:33 +0200)
This adds a couple of missing includes, uses the local version of
getline on bionic and replaces getpwuid_r by getpwuid.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc_user_nic.c

index 26bae54226882c2d6b396a8c6ac7f0f7b4419a0e..6c3a09e98f9893f61957e2bb9c02aa3a28bdcf63 100644 (file)
@@ -28,6 +28,7 @@
 #include <alloca.h>
 #include <string.h>
 #include <sys/mman.h>
+#include <sys/socket.h>
 #include <errno.h>
 #include <ctype.h>
 #include <sys/stat.h>
 #include <linux/if_bridge.h>
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
+#include "config.h"
+
+#ifndef HAVE_GETLINE
+#ifdef HAVE_FGETLN
+#include <../include/getline.h>
+#endif
+#endif
 
 #if ISTEST
 #define CONF_FILE "/tmp/lxc-usernet"
@@ -116,16 +124,14 @@ int open_and_lock(char *path)
 
 char *get_username(char **buf)
 {
-       struct passwd pwd;
-       struct passwd *result;
-       int ret = getpwuid_r(getuid(), &pwd, *buf, 400, &result);
+       struct passwd *pwd = getpwuid(getuid());
 
-       if (ret < 0) {
-               perror("getpwuid_r");
+       if (pwd == NULL) {
+               perror("getpwuid");
                return NULL;
        }
 
-       return pwd.pw_name;
+       return pwd->pw_name;
 }
 
 /* The configuration file consists of lines of the form: