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>
#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"
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: