Bug 16080 - Large Unix gid numbers prints as negative numbers "net groupmap list"
Summary: Large Unix gid numbers prints as negative numbers "net groupmap list"
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.24.2
Hardware: All All
: P5 minor (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-20 14:08 UTC by Peter Eriksson
Modified: 2026-05-21 08:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Eriksson 2026-05-20 14:08:51 UTC
# /liu/bin/net groupmap  list
Guests (S-1-5-32-546) -> -1294967288
Administrators (S-1-5-32-544) -> -1294967290
Users (S-1-5-32-545) -> -1294967289

# /liu/bin/net groupmap  list verbose
Guests
	SID       : S-1-5-32-546
	Unix gid  : 3000000008
	Unix group: -1294967288
	Group type: Local Group
	Comment   :
Administrators
	SID       : S-1-5-32-544
	Unix gid  : 3000000006
	Unix group: -1294967290
	Group type: Local Group
	Comment   :
Users
	SID       : S-1-5-32-545
	Unix gid  : 3000000007
	Unix group: -1294967289
	Group type: Local Group
	Comment   :

The "problem" is located in source3/lib/util.c: gidtoname() and uidtoname() 
where there is a talloc_asprintf(... "%d", (int) gid) in gidtoname() if can't make the gid to a valid group name. (and "%ld" in uidtoname).

Perhaps should be changed to "%u" (optionally with a check for some "small" negative numbers like (int)gid == -1 (and -2 which might be easier to read when printed as negative numbers...
Comment 1 Rowland Penny 2026-05-21 08:01:28 UTC
(In reply to Peter Eriksson from comment #0)

Hi Peter, could this be a freeBSD problem ?
I ask this because on Debian, using Samba 4.23.6 with 'idmap config * : range = 3000000000-3100000000' in the smb.conf file, I get:

$ sudo net groupmap list
Guests (S-1-5-32-546) -> BUILTIN\guests
Administrators (S-1-5-32-544) -> BUILTIN\administrators
Users (S-1-5-32-545) -> BUILTIN\users

$ sudo net groupmap list verbose
Guests
	SID       : S-1-5-32-546
	Unix gid  : 3000000002
	Unix group: BUILTIN\guests
	Group type: Local Group
	Comment   : 
Administrators
	SID       : S-1-5-32-544
	Unix gid  : 3000000000
	Unix group: BUILTIN\administrators
	Group type: Local Group
	Comment   : 
Users
	SID       : S-1-5-32-545
	Unix gid  : 3000000001
	Unix group: BUILTIN\users
	Group type: Local Group
	Comment   :