[lxc-devel] [PATCH 17/17] Fix lxc-user-nic to work on bionic
Stéphane Graber
stgraber at ubuntu.com
Fri Aug 16 15:14:03 UTC 2013
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 at ubuntu.com>
---
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 26bae54..6c3a09e 100644
--- a/src/lxc/lxc_user_nic.c
+++ b/src/lxc/lxc_user_nic.c
@@ -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>
@@ -40,6 +41,13 @@
#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:
--
1.8.3.2
More information about the lxc-devel
mailing list