<div dir="ltr">hi systemd'ers , i'm sure this is known, but for the life of me i cant seems to know why.<div><br></div><div>tldr; aparently i loose all auxiliary groups of root when i execute a unit.</div><div><br></div><div>i'll explain (i try this on v238).</div><div><br></div><div>when i'm logged in as root, and i execute `id` i get all the groups that root belong to. but when i do the same in a systemd unit (e.g. under a transien unit, a la systemd-run) i loose all groups. i suspect that this is because the getgroups system call returns a different value, but for the life of me, i don't know why or how. i'll show</div><div><br></div><div>on my normal bash</div><div><br></div><div>```</div><div><div>[homex ~]# id</div><div>uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),19(log)</div><div>```</div><div><br></div><div>i get all the groups, but if i run it with systemd-run</div><div><br></div><div>```</div><div>[homex ~]# systemd-run --pty id</div><div>Running as unit: run-u207.service</div><div>Press ^] three times within 1s to disconnect TTY.</div><div>uid=0(root) gid=0(root) groups=0(root)</div></div><div>```</div><div><br></div><div>the only group i see is root, now for the semi weird part, if i execute `id root`, i do get all the groups</div><div><br></div><div>```</div><div><div>[homex ~]# systemd-run --pty id root</div><div>Running as unit: run-u220.service</div><div>Press ^] three times within 1s to disconnect TTY.</div><div>uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),19(log)</div></div><div>```</div><div><br></div><div>this is because getgroups return a diferent value if i'm in the unit or logged in</div><div><br></div><div>```</div><div><div>[homex ~]# strace id 2>&1 | grep getgroups</div><div>getgroups(0, NULL)                      = 8</div><div>getgroups(8, [0, 1, 2, 3, 4, 6, 10, 19]) = 8</div></div><div><br></div><div><div>[homex ~]# systemd-run --pty strace id 2>&1 | grep getgroups</div><div>getgroups(0, NULL)                      = 0</div><div>getgroups(0, [])                        = 0</div></div><div>```</div><div><br></div><div>and the reson why i gett all the groups when i execute `id root`, is because that does not ask for groups, but call libnss instead</div><div><br></div><div>```</div><div><div>[homex ~]# systemd-run --pty strace id root 2>&1 | grep getgroups</div><div>[homex ~]# systemd-run --pty strace id root 2>&1 | grep libnss</div><div>openat(AT_FDCWD, "/usr/lib/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3</div><div>openat(AT_FDCWD, "/usr/lib/libnss_mymachines.so.2", O_RDONLY|O_CLOEXEC) = 3</div><div>openat(AT_FDCWD, "/usr/lib/libnss_systemd.so.2", O_RDONLY|O_CLOEXEC) = 3</div></div><div>```</div><div><br></div><div>i guess i just wanna understand why this is, why this system call return different values if i'm in bash or if i'm in a unit.</div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><br></div><div>thanks guys!</div><div dir="ltr"><br></div><div dir="ltr">Alvaro Leiva Geisse<br></div></div></div></div></div>