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=npk3DLf7; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id B9FC15A0265 for ; Wed, 22 Jul 2026 07:16:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1784697407; bh=zHohE8BvAuld/516N6ey59gKP9pRX5VxZ3xVSFaHPno=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=npk3DLf7ItTbsqvbPpYzLrQhsTdqGxrRbH5DUenM/0Xxf166cGT2qYAQ5v1z0v4JE ilro0yER+l7tgRtXAJkF/3OqMzKF67F3KwBaKy8IV1x5xgZ9/IhoiDRbwNpMagHAQN lZoSyGZ/gA0w+VVTSspCTgComK4ZYvbNOeyb5uXnupAsbcyc8CysycPTqB+I7kBOQY 2+fGcz0bvCh+Q463JgzYVLSPVrDKFvhV2OcJtVqrPsXVETrZb9U5MGuqsDBt4ayrB8 ENqWgouY86l+5t6VUz4JqU/4iJ5k9Yg1hC/PVMlCG4YllybF/e1y1jylgk0Q6P8zHa bpEZfuTcAU5nw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4h4jCz3LWYz4w1f; Wed, 22 Jul 2026 15:16:47 +1000 (AEST) Date: Wed, 22 Jul 2026 14:40:07 +1000 From: David Gibson To: "Dwayne B. Bent" Subject: Re: [PATCH 2/2] pasta: Do not configure ID mappings when invoked with --netns-only Message-ID: References: <20260721153727.2173831-1-dbb@dbb.dev> <20260721153727.2173831-3-dbb@dbb.dev> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="CHsy8pnrkKBpa1Fh" Content-Disposition: inline In-Reply-To: <20260721153727.2173831-3-dbb@dbb.dev> Message-ID-Hash: 4TZC5EQXRFMNZJRI5BXFPZXBC7QDJ6I6 X-Message-ID-Hash: 4TZC5EQXRFMNZJRI5BXFPZXBC7QDJ6I6 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: --CHsy8pnrkKBpa1Fh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 21, 2026 at 11:37:27AM -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 > Assisted-by: Codex:gpt-5.6-sol > Signed-off-by: Dwayne B. Bent Needs a Link: https://bugs.passt.top/show_bug.cgi?id=3D216 line. Otherwise looks fine to me. > --- > 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 --CHsy8pnrkKBpa1Fh Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpgSaAACgkQzQJF27ox 2GfF2w//Z+9DxMlHQw/rQDesXVsWFgDE+ifp5I31nT4fvDLKWIDJRa6dOJnJEJt9 P9lY98IVdwPmJaBrJG3iKafI0Sc8TXW2xCGtNiCP6+bUIvRJdMXtBjDETeYzCs0y rMywrMj3aWHKHx2YkS9Q5YdBxrGZUL38UQWuCHgJ0dEiQDw9Jq8houuVemQwOoAO lDuWKhZm5oF6jSbdokqVmGU0jv2+9+ogIPma6AwqMdG2Cy8tvCrGFiSYiTUm8kND lEK+g8kVXPnRul74yHxQhjQrifxJ+5bW13O+DVdw5xDANz3jEcbcedP1ERq0reyj d0AWu94JIjzDuLEVATvBY5ZKxOUtfwxYBuL5sX1Ud3xE4GUGdchDlTvPmaW7XDPc EHq6gIyVKiA8PpfcLHiypK2a9xYajF1ZllR6j0EMlhCDYWpiYqedGQJx+lmXTI5g hdj+QGx6JLRECxPEZrCdRkjxkoNP61ASEgreWGlEIXezHYhwk7V32UPd58CKzepj xXEaIY6yfLR7bnG0DBzIrtHukwwQHueiQtjk1tIqHsBPKZRsrAUJVy00umEqG3bO YKJ9161+Yi0fM/WuiZrDUIJ3wtE6azpxbQZHimtNGjOHavEmDNiZ0Rpjoe99jYQ6 9gNt7aon4EnSeT/Dk+vMQRBsaXu+wmXto6YUxRFcv2JGpL5J3BE= =/5Zf -----END PGP SIGNATURE----- --CHsy8pnrkKBpa1Fh--