From: Stéphane Graber Date: Fri, 16 Aug 2013 14:55:40 +0000 (+0200) Subject: Fix lxc-user-nic to work on bionic X-Git-Tag: lxc-1.0.0.alpha1~1^2~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37fc7b9e2eca60e838bf5bf061bd8a8206e4fa9d;p=thirdparty%2Flxc.git Fix lxc-user-nic to work on bionic 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 Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c index 26bae5422..6c3a09e98 100644 --- a/src/lxc/lxc_user_nic.c +++ b/src/lxc/lxc_user_nic.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,13 @@ #include #include #include +#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: