From 37fc7b9e2eca60e838bf5bf061bd8a8206e4fa9d Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Graber?= Date: Fri, 16 Aug 2013 16:55:40 +0200 Subject: [PATCH] Fix lxc-user-nic to work on bionic MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/lxc/lxc_user_nic.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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: -- 2.47.3