[lxc-devel] [PATCH 17/17] Fix lxc-user-nic to work on bionic

Serge Hallyn serge.hallyn at ubuntu.com
Fri Aug 16 15:42:04 UTC 2013


Quoting Stéphane Graber (stgraber at ubuntu.com):
> 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>

Acked-by: Serge E. Hallyn <serge.hallyn 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
> 
> 
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead. 
> Download for free and get started troubleshooting in minutes. 
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list