Re: [PATCH v3] sys-tools: Enhance unshare command to support the switching of namespaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 28, 2012 at 11:22:18AM -0500, Neil Horman wrote:
>  sys-utils/unshare.1 | 34 +++++++++++++++---------
>  sys-utils/unshare.c | 74 ++++++++++++++++++++++++++++++++++++++++++-----------
>  2 files changed, 81 insertions(+), 27 deletions(-)

 Applied with some changes, please check/verify the changes in git, thanks.

> +static void close_files(void)
> +{
> +	int i;
> +	for (i=0; ns_pids[i] > 0; i++)
> +		close(ns_pids[i]);
> +	close_stdout();
> +}

 this is unnecessary, but O_CLOEXEC is probably good idea

> +	while((c = getopt_long(argc, argv, "hVm:u:i:n:", longopts, NULL)) != -1) {
> +		ns = NULL;

 optional argument means "::" not ":"

> +		if (optarg && ns) {
> +				if (nscount >= NUM_ENTRIES)
> +					err(EXIT_FAILURE, _("Too many new namespaces specified"));
> +				pid = strtoul(optarg, NULL, 10);

 for the short options the 'optarg' starts with '=', so you need
 optarg++

> +	for (nscount = 0; ns_pids[nscount] > 0; nscount++)
> +		if (-1 == setns(ns_pids[nscount], 0))
> +			err(EXIT_FAILURE, _("setns failed"));
> +	
>  	if(-1 == unshare(unshare_flags))
>  		err(EXIT_FAILURE, _("unshare failed"));

 it seems that unshare() should not be called if unshare_flags == 0

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux