Page MenuHomeFreeBSD

install: Fix METALOG ouptut for numeric -o and -g args
ClosedPublic

Authored by emaste on Fri, Jan 17, 7:40 PM.
Tags
None
Referenced Files
F109092699: D48504.diff
Fri, Jan 31, 4:29 PM
F109067162: D48504.id149661.diff
Fri, Jan 31, 9:08 AM
Unknown Object (File)
Wed, Jan 29, 6:14 AM
Unknown Object (File)
Tue, Jan 28, 11:10 PM
Unknown Object (File)
Tue, Jan 28, 5:17 PM
Unknown Object (File)
Tue, Jan 28, 10:18 AM
Unknown Object (File)
Sun, Jan 26, 8:41 PM
Unknown Object (File)
Sun, Jan 26, 12:23 PM

Details

Summary
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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste created this revision.
usr.bin/xinstall/xinstall.c
1438

unsigned long long feels more normal to me, but long long unsigned has the nice property of matching the order of the printf format llu.

Based on discussion in PR283340, do we need to have a separate option to specify whether we want uname/gname vs uid/gid in METALOG, or is it reasonable to use uname= if a name is specified and uid= if a uid is specified? I think this change is a valuable first step even if we want to add that later on.

I also think this fix is valid.
Regarding this particular implementation, as parseid() will just strtoul() the name, shouldn't the id be casted to (unsigned int) instead?:

install -U -M /dev/stdout -o -1 -g wheel /usr/bin/true /tmp
./tmp/true type=file uid=18446744073709551615 gname=wheel mode=0755 size=5120

P.S.: Once this fix is committed, I plan on submitting it to NetBSD, given it is mtree related.

usr.bin/xinstall/xinstall.c
1436

Missing newline after a definition.

1438

I think sticking to the "standard" spelling of unsigned long long is nicer. Even better would be to use uintmax_t.

Maybe I am missing something, but I still believe it should match uid_t/gid_t:

# touch /tmp/foo
# chown 4294967295:4294967295 /tmp/foo
# chown 18446744073709551615:18446744073709551615 /tmp/foo
chown: 18446744073709551615: illegal group name

Maybe I am missing something, but I still believe it should match uid_t/gid_t:

Yeah, id_t is signed so this should be as well

P.S.: Once this fix is committed, I plan on submitting it to NetBSD, given it is mtree related.

I've collaborated with @christos_netbsd.org on some changes for NetBSD in the past - he can maybe just pick this up once it lands.

P.S.: Once this fix is committed, I plan on submitting it to NetBSD, given it is mtree related.

I've collaborated with @christos_netbsd.org on some changes for NetBSD in the past - he can maybe just pick this up once it lands.

Good to know!
It already landed on NetBSD:
https://github.com/NetBSD/src/commit/58f3f0171bf4339eb1b70303b7ae894811f28968
https://github.com/NetBSD/src/commit/903bacb725f8b4533b59ea76d04d8961b3b3c282

This revision is now accepted and ready to land.Tue, Jan 21, 10:36 AM