On one of my servers, my user has a strange problem of group membership. When using id
or groups
without arguments, the list of groups includes those from the root
user, and groups common to my user and root
are duplicated, like wheel
, video
, allowssh
. Other users are unaffected.
mick@xxx ~ $ groups
root bin daemon sys adm disk wheel wheel floppy uucp cron audio cdrom dialout tape video video xfs games cdrw apache usb vboxusers portage allowssh allowssh svn users mick
mick@xxx ~ $ id
uid=1001(mick) gid=1001(mick) groupes=1001(mick),0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),14(uucp),16(cron),18(audio),19(cdrom),20(dialout),26(tape),27(video),33(xfs),35(games),80(cdrw),81(apache),85(usb),102(vboxusers),250(portage),800(allowssh),909(svn),1000(users)
When run with a login, the list is correct
mick@xxx ~ $ groups mick
wheel cron audio cdrom video xfs games cdrw apache usb vboxusers portage allowssh svn users mick
mick@xxx ~ $ groups root
root bin daemon sys adm disk wheel floppy uucp dialout tape video allowssh
mick@xxx ~ $ id mick
uid=1001(mick) gid=1001(mick) groupes=1001(mick),10(wheel),16(cron),18(audio),19(cdrom),27(video),33(xfs),35(games),80(cdrw),81(apache),85(usb),102(vboxusers),250(portage),800(allowssh),909(svn),1000(users)
mick@xxx ~ $ id root
uid=0(root) gid=0(root) groupes=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),14(uucp),20(dialout),26(tape),27(video),800(allowssh)
As far as I can tell the contents of /etc/passwd
and /etc/group
is also correct.
mick@xxx ~ $ egrep 'mick|root' /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/bin/bash
mick:x:1001:1001::/home/mick:/bin/bash
mick@xxx ~ $ egrep 'mick|root' /etc/group
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
disk:x:6:root,adm,haldaemon
wheel:x:10:root,mick,jef,apache,xfs,anne
floppy:x:11:root,haldaemon
uucp:x:14:root
cron:x:16:cron,mick,apache
audio:x:18:famille,mick,jef,juliette,victor,anne,xfs,pulse,sddm
cdrom:x:19:famille,mick,haldaemon,jef,juliette,victor,anne,xfs
dialout:x:20:root
tape:x:26:root
video:x:27:root,famille,mick,jef,juliette,victor,anne,xfs,oracle,sddm
xfs:x:33:xfs,mick,apache
games:x:35:famille,mick,jef,juliette,victor,anne,xfs
cdrw:x:80:famille,mick,haldaemon,xfs
apache:x:81:famille,jef,mick,xfs
usb:x:85:famille,mick,haldaemon,juliette,victor,anne,xfs
vboxusers:x:102:famille,vbox,mick,jef
portage:x:250:portage,famille,mick,jef,xfs,apache
allowssh:x:800:mick,jef,root,anne,juliette,victor
svn:x:909:famille,jef,mick,tracd
users:x:1000:mick,jef,apache,juliette,victor,offlineimap,xfs,anne
mick:x:1001:mick
What could cause such a behaviour ? How can I correct it ?
Edit
The difference in output between id
and id mick
happens because id
calls the syscall getgroups
in the first case, but not in the other, as I could see with strace
mick@xxx $ strace id
[...]
getgroups(0, NULL) = 29
getgroups(29, [0, 1, 2, 3, 4, 6, 10, 10, 11, 14, 16, 18, 19, 20, 26, 27, 27, 33, 35, 80, 81, 85, 102, 250, 800, 800, 909, 1000, 1001]) = 29
[...]
mick@xxx $ strace id mick
[...]
openat(AT_FDCWD, "/var/db/group.db", O_RDONLY|O_CLOEXEC) = -1 ENOENT (Aucun fichier ou dossier de ce type)
openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 3
lseek(3, 0, SEEK_CUR) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1978, ...}) = 0
read(3, "root:x:0:root\nbin:x:1:root,bin,d"..., 4096) = 1978
lseek(3, 0, SEEK_CUR) = 1978
[...repeated]
lseek(3, 0, SEEK_CUR) = 1978
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/var/db/group.db", O_RDONLY|O_CLOEXEC) = -1 ENOENT (Aucun fichier ou dossier de ce type)
openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 3
lseek(3, 0, SEEK_CUR) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1978, ...}) = 0
read(3, "root:x:0:root\nbin:x:1:root,bin,d"..., 4096) = 1978
lseek(3, 0, SEEK_CUR) = 1978
[...repeated]
lseek(3, 0, SEEK_CUR) = 1978
read(3, "", 4096) = 0
close(3) = 0
[...]
Also I observed that the list of groups is incorrect only in a KDE session, either in Konsole or xterm, but the list of groups is correct in other kinds of sessions like on a TTY or through SSH.
I can't figure what could KDE have to do with user groups !
Edit 2
I still don't know the cause of the problem, but it disappeared after an upgrade from kernel 4.14 to 4.19 and a reboot.
I looked quickly in Linux bugzilla, but there was no obvious related problem about the getgroups
syscall.