Page MenuHomeFreeBSD

Print numeric uids and gids in user:/group: ACL entries as unsigned integers
ClosedPublic

Authored by pen_lysator.liu.se on May 22 2026, 6:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 21, 8:40 PM
Unknown Object (File)
Fri, Jun 19, 9:47 AM
Unknown Object (File)
Fri, Jun 19, 2:59 AM
Unknown Object (File)
Wed, Jun 17, 5:30 PM
Unknown Object (File)
Wed, Jun 17, 2:38 AM
Unknown Object (File)
Tue, Jun 16, 2:05 PM
Unknown Object (File)
Tue, Jun 16, 11:55 AM
Unknown Object (File)
Tue, Jun 16, 10:28 AM
Subscribers

Details

Summary

uid_t and gid_t is uint32_t (unsigned 32bit integers). They are printed as signed integers when calling getfacl (and other tools using the acl_to_text() libc function). This causes uid/gids larger than 2G (214783648) to print as negative numbers - which causes problem with setfacl since the acl_from_text() libc function fails on negative numbers.

# mkdir testdir
# chgrp 3000000005 testdir

# setfacl -x 1 -a 1 group:3000000005:full_set:fd:allow testdir 

# getfacl testdir
# file: testdir
# owner: root
# group: 3000000005
            owner@:rwxpDdaARWcCos:fd-----:allow
 group:-1294967291:rwxpDdaARWcCos:fd-----:allow
Test Plan

Make sure this does not fail:

# touch f1 f2
# setfacl -x 1 -a 1 group:3000000005:full_set::allow f1
# getfacl f1  |  setfacl -b -n -M - f2

Diff Detail

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

Event Timeline

pen_lysator.liu.se created this revision.
pen_lysator.liu.se edited the summary of this revision. (Show Details)
pen_lysator.liu.se edited the test plan for this revision. (Show Details)

Same fix is needed for both POSIX ACLs and NFS4 ACLs...

If we cast the ids to (uintmax_t) and then use %ju,
it will still work if uid_t/gid_t ever becomes 64bits.

lib/libc/posix1e/acl_id_to_name.c
70

We might want to "future proof" this by..
casting "id" to (uintmax_t) and using %ju.
(That way it will still work if uid_ becomes 64bits.)

Use %ju and (uintmax_t) to future-proof for when uid_t / gid_t becomes 64 bits...

I notice that acl_to_text() and acl_from_text() also uses the non-thread-safe variants of getpwnam/getpwuid/getgrnam/getgruid but that might be for some other patch to fix :-)

I'll commit it authored by you, since I don't recall
that you are a committer.

Thanks for doing this, rick

This revision is now accepted and ready to land.May 22 2026, 8:18 PM