[PATCH v6 3/7] unshare: new applet

Mike Frysinger vapier at gentoo.org
Thu Mar 17 17:23:39 UTC 2016


On 17 Mar 2016 15:52, Bartosz Golaszewski wrote:
> +static void mount_procfs(const char *target)
> +{
> +	int status;
> +
> +	status = mount("none", target, NULL, MS_PRIVATE | MS_REC, NULL);
> +	if (status < 0)
> +		goto mount_err;
> +
> +	status = mount("proc", target, "proc",
> +		       MS_NOSUID | MS_NOEXEC | MS_NODEV, NULL);

each of these mount calls could do with a comment explaining what/why.
you & i might understand how /proc needs to be made private & then
freshly mounted in a new pid ns, but not everyone :).

> +	if (status < 0)
> +		goto mount_err;

general style note ... seems like this could be written:
	status = mount(...)
	if (status == 0)
		status = mount(...)
	if (status < 0)
		bb_perror_msg_and_die(...)

might be smaller code wise ?

> +	run_shell(getenv("SHELL"), 0, NULL, NULL);

if SHELL isn't set, then we just segfault ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20160317/48a06253/attachment.asc>


More information about the busybox mailing list