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
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
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.
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
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