install -U -M can pass the owner and group through to the METALOG: $ install -U -M /dev/stdout -o root -g wheel /usr/bin/true /tmp ./tmp/true type=file uname=root gname=wheel mode=0755 size=5008 install also accepts numeric uid and gid. These should produce uid= and gid= in the METALOG, but we still get uname and gname: $ install -U -M /dev/stdout -o 0 -g 0 /usr/bin/true /tmp ./tmp/true type=file uname=0 gname=0 mode=0755 size=5008 In normal (non -U) mode we attempt to look up the name, and parse it as an id if that fails: if (owner != NULL && !dounpriv) { if (uid_from_user(owner, &uid) == -1) { id_t id; if (!parseid(owner, &id)) errx(1, "unknown user %s", owner); uid = id; } } else uid = (uid_t)-1; Something similar is needed for -U -M mode
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4b04f5d7e8a2bb0488ad5804ecaf45cef5b1d46f commit 4b04f5d7e8a2bb0488ad5804ecaf45cef5b1d46f Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-01-17 19:14:22 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-01-21 12:47:48 +0000 install: Fix METALOG ouptut for numeric -o and -g args install's -o and -g flags both accept a name or a numeric argument. In -U -M (non-root METALOG) mode it always emitted uname= and gname= in the METALOG, but these are not appropriate for numeric IDs. If the -o and/or -u arguments parse as an ID, emit uid= and/or gid= respectively. Note that if an argument is valid as both a name and numeric ID we will prefer the name in normal (non -U -M) mode and the ID in -U -M mode. We don't want to require a passwd db in non-root mode, and entirely-numeric user or group names are a terrible idea so just accept this discrepancy. PR: 284119 Reviewed by: jlduran Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48504 usr.bin/xinstall/xinstall.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
NetBSD committed a different version of this patch. I imagine we will have more changes here (for PR 283355, and the ability to select one or both of uid/gid and uname/gname), so left it like this for now.
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=90702fb5de14c34e2404bd1f58706a067ac459bc commit 90702fb5de14c34e2404bd1f58706a067ac459bc Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-01-17 19:14:22 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-02-11 21:27:17 +0000 install: Fix METALOG ouptut for numeric -o and -g args install's -o and -g flags both accept a name or a numeric argument. In -U -M (non-root METALOG) mode it always emitted uname= and gname= in the METALOG, but these are not appropriate for numeric IDs. If the -o and/or -u arguments parse as an ID, emit uid= and/or gid= respectively. Note that if an argument is valid as both a name and numeric ID we will prefer the name in normal (non -U -M) mode and the ID in -U -M mode. We don't want to require a passwd db in non-root mode, and entirely-numeric user or group names are a terrible idea so just accept this discrepancy. PR: 284119 Reviewed by: jlduran Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48504 (cherry picked from commit 4b04f5d7e8a2bb0488ad5804ecaf45cef5b1d46f) usr.bin/xinstall/xinstall.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)