[lxc-devel] [PATCH 1/1] don't fail lxc-init if we couldn't mount proc

Stéphane Graber stgraber at ubuntu.com
Fri Nov 22 21:49:09 UTC 2013


On Fri, Nov 22, 2013 at 03:45:40PM -0600, Serge Hallyn wrote:
> In general proc gets mounted ahead of time, so init shouldn't
> have to do it.  Without this patch, you cannot
> 
> 	lxc-execute -n x1 -s lxc.cap.drop=sys_admin /bin/bash
> 
> (See https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1253669 for
> a bug about this)
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/lxc_init.c | 3 +--
>  src/lxc/utils.c    | 8 +++-----
>  src/lxc/utils.h    | 2 +-
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
> index 69ae3d8..968c25d 100644
> --- a/src/lxc/lxc_init.c
> +++ b/src/lxc/lxc_init.c
> @@ -154,8 +154,7 @@ int main(int argc, char *argv[])
>  		sigaction(i, &act, NULL);
>  	}
>  
> -	if (lxc_setup_fs())
> -		exit(EXIT_FAILURE);
> +	lxc_setup_fs();
>  
>  	if (lxc_caps_reset())
>  		exit(EXIT_FAILURE);
> diff --git a/src/lxc/utils.c b/src/lxc/utils.c
> index e80a782..5bfe9db 100644
> --- a/src/lxc/utils.c
> +++ b/src/lxc/utils.c
> @@ -150,10 +150,10 @@ static int mount_fs(const char *source, const char *target, const char *type)
>  	return 0;
>  }
>  
> -extern int lxc_setup_fs(void)
> +extern void lxc_setup_fs(void)
>  {
>  	if (mount_fs("proc", "/proc", "proc"))
> -		return -1;
> +		INFO("failed to remount proc");
>  
>  	/* if we can't mount /dev/shm, continue anyway */
>  	if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
> @@ -163,14 +163,12 @@ extern int lxc_setup_fs(void)
>  	/* Sure, but it's read-only per config :) */
>  	if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) {
>  		DEBUG("failed to create '/dev/mqueue'");
> -		return 0;
> +		return;
>  	}
>  
>  	/* continue even without posix message queue support */
>  	if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
>  		INFO("failed to mount /dev/mqueue");
> -
> -	return 0;
>  }
>  
>  /* borrowed from iproute2 */
> diff --git a/src/lxc/utils.h b/src/lxc/utils.h
> index 9c47560..714e74c 100644
> --- a/src/lxc/utils.h
> +++ b/src/lxc/utils.h
> @@ -34,7 +34,7 @@
>  
>  /* returns 1 on success, 0 if there were any failures */
>  extern int lxc_rmdir_onedev(char *path);
> -extern int lxc_setup_fs(void);
> +extern void lxc_setup_fs(void);
>  extern int get_u16(unsigned short *val, const char *arg, int base);
>  extern int mkdir_p(const char *dir, mode_t mode);
>  extern void remove_trailing_slashes(char *p);
> -- 
> 1.8.3.2
> 
> 
> ------------------------------------------------------------------------------
> Shape the Mobile Experience: Free Subscription
> Software experts and developers: Be at the forefront of tech innovation.
> Intel(R) Software Adrenaline delivers strategic insight and game-changing 
> conversations that shape the rapidly evolving mobile landscape. Sign up now. 
> http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131122/66301fd4/attachment.pgp>


More information about the lxc-devel mailing list