aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eriksson <pen_lysator.liu.se>2026-05-25 19:44:41 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2026-05-25 19:44:41 +0000
commit6e7c10c79deac3c6bb6ad3bd12c8e0ad68bb59f0 (patch)
tree5e3520f3a905317ac515d87903de6931ec50fb55
parent4d80d4913e79c8b5918b1f04c1c7b38e6c76b9b4 (diff)
acl_id_to_name.c: Fix printing of uids and gids
uid_t and gid_t are 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. Reviewed by: rmacklem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D57179
-rw-r--r--lib/libc/posix1e/acl_id_to_name.c4
-rw-r--r--lib/libc/posix1e/acl_to_text_nfs4.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/posix1e/acl_id_to_name.c b/lib/libc/posix1e/acl_id_to_name.c
index 78e050a8648a..c90e6083cca1 100644
--- a/lib/libc/posix1e/acl_id_to_name.c
+++ b/lib/libc/posix1e/acl_id_to_name.c
@@ -67,7 +67,7 @@ _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf,
else
p = getpwuid(id);
if (!p)
- i = snprintf(buf, buf_len, "%d", id);
+ i = snprintf(buf, buf_len, "%ju", (uintmax_t)id);
else
i = snprintf(buf, buf_len, "%s", p->pw_name);
@@ -83,7 +83,7 @@ _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf,
else
g = getgrgid(id);
if (g == NULL)
- i = snprintf(buf, buf_len, "%d", id);
+ i = snprintf(buf, buf_len, "%ju", (uintmax_t)id);
else
i = snprintf(buf, buf_len, "%s", g->gr_name);
diff --git a/lib/libc/posix1e/acl_to_text_nfs4.c b/lib/libc/posix1e/acl_to_text_nfs4.c
index 157215c9dd52..4f19f3a9a7b2 100644
--- a/lib/libc/posix1e/acl_to_text_nfs4.c
+++ b/lib/libc/posix1e/acl_to_text_nfs4.c
@@ -69,7 +69,7 @@ format_who(char *str, size_t size, const acl_entry_t entry, int numeric)
else
pwd = NULL;
if (pwd == NULL)
- snprintf(str, size, "user:%d", (unsigned int)*id);
+ snprintf(str, size, "user:%ju", (uintmax_t)*id);
else
snprintf(str, size, "user:%s", pwd->pw_name);
acl_free(id);
@@ -89,7 +89,7 @@ format_who(char *str, size_t size, const acl_entry_t entry, int numeric)
else
grp = NULL;
if (grp == NULL)
- snprintf(str, size, "group:%d", (unsigned int)*id);
+ snprintf(str, size, "group:%ju", (uintmax_t)*id);
else
snprintf(str, size, "group:%s", grp->gr_name);
acl_free(id);