From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202606 header.b=pSHmdwW9; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 733CF5A0265 for ; Thu, 23 Jul 2026 05:45:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1784778321; bh=Erq0lGX85UHbdqo4GpQd8dM9VCjUx8ixTV69m4a0hk4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pSHmdwW9Ee8hvzwyQojxgyPCttDl1edNL7by6HFM4/mIz7gJNmcYr3O0pwKb01GTx 3XfR/31xX/iriw+XG7v23JLefFhMP31wWikB4A2IPdjua/LE9MFJWtcmLBMLmYWVq8 Ykm0RM6joOMwwBNcR6ftgAdDlvd/mHoS232/Ng4H4LchagK5sSsA/i4exdJOHoOSqu Nke5SHGijeSRRu2mu5mQrVmNBsThLgWbfx9147Ha2uuiXOm9Sfxy91F1aUIUeYIBuJ 0GfPZaNM/zHmx8yHJAJ/zpwfU+ASBj5UxFKuJrr4uul4lRki8wUjxYrX871MZ88Ful yUMxvKwvJ5DnQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4h5H8134Snz4wBB; Thu, 23 Jul 2026 13:45:21 +1000 (AEST) Date: Thu, 23 Jul 2026 13:44:58 +1000 From: David Gibson To: "Dwayne B. Bent" Subject: Re: [PATCH v2 1/2] pasta: Do not configure ID mappings when invoked with --netns-only Message-ID: References: <20260722153242.3704630-1-dbb@dbb.dev> <20260722153242.3704630-2-dbb@dbb.dev> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XhqqrTgL2gCBDlDP" Content-Disposition: inline In-Reply-To: <20260722153242.3704630-2-dbb@dbb.dev> Message-ID-Hash: TDRHZOJDGY3UJAZLF2WTRMSJGFH743XW X-Message-ID-Hash: TDRHZOJDGY3UJAZLF2WTRMSJGFH743XW 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: --XhqqrTgL2gCBDlDP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 22, 2026 at 11:32:41AM -0400, Dwayne B. Bent wrote: > Add a `bool` argument `config_idmaps` to `pasta_start_ns()` that guards > the logic to configure user and group ID mappings. It is set to `false` > when `netns_only` is `true`. Fixes bug 216. >=20 > Link: https://bugs.passt.top/show_bug.cgi?id=3D216 >=20 > Assisted-by: Codex:gpt-5.6-sol > Signed-off-by: Dwayne B. Bent Reviewed-by: David Gibson > --- > conf.c | 2 +- > pasta.c | 24 ++++++++++++++---------- > pasta.h | 3 ++- > 3 files changed, 17 insertions(+), 12 deletions(-) >=20 > diff --git a/conf.c b/conf.c > index 0fcba5c..2223604 100644 > --- a/conf.c > +++ b/conf.c > @@ -1945,7 +1945,7 @@ void conf(struct ctx *c, int argc, char **argv) > if (*netns) { > pasta_open_ns(c, netns); > } else { > - pasta_start_ns(c, uid, gid, > + pasta_start_ns(c, uid, gid, !netns_only, > argc - optind, argv + optind); > } > } > diff --git a/pasta.c b/pasta.c > index 4e7ee54..5aa56b7 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -236,10 +236,11 @@ static int pasta_spawn_cmd(void *arg) > * @c: Execution context > * @uid: UID we're running as in the init namespace > * @gid: GID we're running as in the init namespace > + * @config_idmaps: Whether to configure user mappings > * @argc: Number of arguments for spawned command > * @argv: Command to spawn and arguments > */ > -void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, > +void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, bool config_idm= aps, > int argc, char *argv[]) > { > char ns_fn_stack[NS_FN_STACK_SIZE] > @@ -249,7 +250,6 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t g= id, > .argv =3D argv, > .c =3D c, > }; > - char uidmap[BUFSIZ], gidmap[BUFSIZ]; > char *sh_argv[] =3D { NULL, NULL }; > char sh_arg0[PATH_MAX + 1]; > sigset_t set; > @@ -259,16 +259,20 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t= gid, > c->quiet =3D 1; > =20 > /* Configure user and group mappings */ > - if (snprintf_check(uidmap, BUFSIZ, "0 %u 1", uid)) > - die_perror("Can't build uidmap"); > + if (config_idmaps) { > + char uidmap[BUFSIZ], gidmap[BUFSIZ]; > =20 > - if (snprintf_check(gidmap, BUFSIZ, "0 %u 1", gid)) > - die_perror("Can't build gidmap"); > + if (snprintf_check(uidmap, BUFSIZ, "0 %u 1", uid)) > + die_perror("Can't build uidmap"); > =20 > - if (write_file("/proc/self/uid_map", uidmap) || > - write_file("/proc/self/setgroups", "deny") || > - write_file("/proc/self/gid_map", gidmap)) { > - warn("Couldn't configure user mappings"); > + if (snprintf_check(gidmap, BUFSIZ, "0 %u 1", gid)) > + die_perror("Can't build gidmap"); > + > + if (write_file("/proc/self/uid_map", uidmap) || > + write_file("/proc/self/setgroups", "deny") || > + write_file("/proc/self/gid_map", gidmap)) { > + warn("Couldn't configure user mappings"); > + } > } > =20 > if (argc =3D=3D 0) { > diff --git a/pasta.h b/pasta.h > index 07e04b3..edd7747 100644 > --- a/pasta.h > +++ b/pasta.h > @@ -6,12 +6,13 @@ > #ifndef PASTA_H > #define PASTA_H > =20 > +#include > #include > =20 > extern int pasta_child_pid; > =20 > void pasta_open_ns(struct ctx *c, const char *netns); > -void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, > +void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, bool config_idm= aps, > int argc, char *argv[]); > void pasta_ns_conf(struct ctx *c); > void pasta_child_handler(int signal); > --=20 > 2.55.0 >=20 --=20 David Gibson (he or they) | 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 --XhqqrTgL2gCBDlDP Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmphjjkACgkQzQJF27ox 2GcDoA//cyF3tNwkwge9+bsWrnH81lzECEqrjc0WErEr6WGAxStkDR/6y32Oasby P7un2obU7fE3i7/MOaziP204ZrLwyt8hoO7JrY/fDqpXCBjdephjDGMePk6o65Jx 6FBt43L87DIhxT7yUk3LTWjCMepDZJD9ib5aUVqq5ApxpX6YFXIzgiyYzjHlAAnP oGQZm+DzKTogYZO/Yd5IRTomIYQQ3RZMNmCiIzgdnhrMQkFr5RROp2PDTe4mzdTg V1gX/vm0+HhHObZpHgy+SZBTbjz+aPVr1tL9ilUQtcUPKVlsLfsrtjjjx0tjIYiM 5XtHeRVR+PQxDOxOcgNxduyxHDlSTEOaCrZ1+EbWoJjDhBYZT/3vcEw1cb9PEF+U +URU3UjkVDj7YbVb7QV6UeNN/LGVljJHzqY5PuWAy8IWqhXqsztXLf0RxBB7rmNf 55ogxdawT1C4AQQ3b9esOljCg2Uf/8Du6OrC/6ge7mOoWZYE4Ibh0blz/HACruNN pprdQ+KHv4yrkeiujhQtnFElgexVEm6d4Q1xj374nsPrNt97SeFzGJZHVwFqd9LC H80lXDMJX8BcN11qwbtAerERoHx97ul60mfT8FlZ/4iOG2b9lE79vGQzBbqGdvjB NSvyLZhCUF22ZXRLGbwFtr+iHX1uegonWjroNZAHixKwW/l4x0k= =eUWj -----END PGP SIGNATURE----- --XhqqrTgL2gCBDlDP--