From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id A19F45A0272 for ; Thu, 6 Apr 2023 04:50:14 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PsQvz6RzDz4xFl; Thu, 6 Apr 2023 12:50:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680749407; bh=E6+HLqPHrXKNAhJbW6BBV+QeGJYQNTOi6x8cOIPm0Ds=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lFH7ujtstp08nZLavYujK6biU65bA09fvwaPkDFKoDegI5kNoUJjzkRRrdpZpWJU+ 59VdS1b0Ps8zKyyujiHtnxG8u8xZ4p1zZjNhoIrcNMDJHNI8cXQ6a38nM4tB38CvCW tmKW7B+KSNjuXTr1Ozvb0jkZrnex9eOgndp51QQc= Date: Thu, 6 Apr 2023 11:11:02 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 10/14] nstool: Add --keep-caps option to nstool exec Message-ID: References: <20230404014638.3225556-1-david@gibson.dropbear.id.au> <20230404014638.3225556-11-david@gibson.dropbear.id.au> <20230405135903.24139711@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ILvGoOc8KO4z5ARd" Content-Disposition: inline In-Reply-To: <20230405135903.24139711@elisabeth> Message-ID-Hash: YCPN6DVEP4V4BFYR6PPLQEPKG2SLXG43 X-Message-ID-Hash: YCPN6DVEP4V4BFYR6PPLQEPKG2SLXG43 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --ILvGoOc8KO4z5ARd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 05, 2023 at 01:59:02PM +0200, Stefano Brivio wrote: > On Tue, 4 Apr 2023 11:46:34 +1000 > David Gibson wrote: >=20 > > This allows you to run commands within a user namespace with the > > privilege that comes from owning that userns. > >=20 > > Signed-off-by: David Gibson > > --- > > test/nstool.c | 89 +++++++++++++++++++++++++++++++++++++++++++++------ > > 1 file changed, 79 insertions(+), 10 deletions(-) > >=20 > > diff --git a/test/nstool.c b/test/nstool.c > > index 25079aa..3ecc456 100644 > > --- a/test/nstool.c > > +++ b/test/nstool.c > > @@ -18,11 +18,15 @@ > > #include > > #include > > #include > > +#include > > +#include > > #include > > #include > > +#include > > +#include > > #include > > -#include > > #include > > +#include > > =20 > > #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0]))) > > =20 > > @@ -75,11 +79,13 @@ static void usage(void) > > " nstool info [-pw] pid SOCK\n" > > " Print information about the nstool hold process with control= \n" > > " socket at SOCK\n" > > - " -p Print just the holder's PID as seen by the caller\n" > > - " -w Retry connecting to SOCK until it is ready\n" > > - " nstool exec SOCK [COMMAND [ARGS...]]\n" > > + " -p Print just the holder's PID as seen by the cal= ler\n" > > + " -w Retry connecting to SOCK until it is ready\n" > > + " nstool exec [--keep-caps] SOCK [COMMAND [ARGS...]]\n" > > " Execute command or shell in the namespaces of the nstool hol= d\n" > > " with control socket at SOCK\n" > > + " --keep-caps Give all possible capabilities to COMMAND via\= n" > > + " the ambient capability mask\n" > > " nstool stop SOCK\n" > > " Instruct the nstool hold with control socket at SOCK to\n" > > " terminate.\n"); > > @@ -275,7 +281,6 @@ static void cmd_info(int argc, char *argv[]) > > } while (opt !=3D -1); > > =20 > > if (optind !=3D argc - 1) { > > - fprintf(stderr, "B\n"); > > usage(); > > } > > =20 > > @@ -356,21 +361,82 @@ static void wait_for_child(pid_t pid) > > die("Unexpected status for child %d\n", pid); > > } > > =20 > > +static void caps_to_ambient(void) > > +{ > > + /* Use raw system calls to avoid the overly complex caps > > + * libraries. */ >=20 > Bad indentation here. More pasted spaces. Fixing. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --ILvGoOc8KO4z5ARd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmQuHCAACgkQzQJF27ox 2Gco0Q//ULEbEgUx2kurJfix7puxhtKOYUZLeIustO4RzSlPN6OcrdSAkMiMXPyq ck0YANZQpy31clVvR9NguITZjNo61o0diywNq3TrE6wq6/kbqHUhHwhOVOMkI4lY REJzRHtpUzVdX6To31PYwqw0vAlximT7Dy/deErGrwZUWL6g8+e7SjnqGwCvNAPo WpbOuFKMVD9L+q4J6ps7SmCTgdxvE/ZFGrNaQjtiuAd2Kinp4Kfdj5TMm+DIIIBQ FRrQurVgDpY85uOvzKu6ybwRfG20ybD/3Tb5uRKwNKML0aIOdWsWpRoEWz3Tyv1R xfcEY1H5zB6HoIlzo/5wtJKcCUkjMDvCxqNK7gUZfWRDXiRfEfTcOheawPcJBknR CDn2Bu4XuZD5cyQtRR9UY2ALlkNcj6SejM9gITjN+j5PaR/x9d/eCzYiGvf6ZCVF 2hDp3Xi5brRmytOlN6kOqgQJw3gu5ash7TwDLLTPmRNHDwusPo+jUyy5KWwSZ00b 6AwUor8Gyr7jgvFkOASPxsEs86Nit+UZyUUC0/FO57sUdGOQuhzlL6dau6z5HsUf fsAxbVlEo/2tnQTDzsNmgxyJkJrNZagOnC+4NzZT3e3ln509vF3Bd580s3orEud+ OOMEYPzud0IX8XgtJ3UzRVTWQvJrHRQDLybsX4GMPUCTFN8aNJ8= =MQ8q -----END PGP SIGNATURE----- --ILvGoOc8KO4z5ARd--