Bug 1809489
| Summary: | python3 grp library functions grp.getgrnam() & grp.getgrgid() returning incorrect gr_mem information | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Abhishek <abmsharm> |
| Component: | sssd | Assignee: | SSSD Maintainers <sssd-maint> |
| Status: | CLOSED DUPLICATE | QA Contact: | sssd-qe <sssd-qe> |
| Severity: | urgent | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 8.1 | CC: | bugproxy, codonell, dikonoor, grajaiya, hannsj_uhl, jhrozek, lslebodn, mzidek, pbrezina, tscherf, vstinner |
| Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
| Target Release: | 8.3 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-03-12 10:52:19 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1776265 | ||
|
Description
Abhishek
2020-03-03 09:00:48 UTC
It seems to work as expected on RHEL8 and Fedora 31: --- $ sudo groupadd starwars $ sudo usermod -aG starwars nobody $ sudo usermod -aG starwars root $ getent group starwars starwars:x:1001:nobody,root $ python3 # Python 3.6.8 on RHEL8, Python 3.7.6 on Fedora 31 >>> import grp >>> grp.getgrnam('starwars') grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1000, gr_mem=['nobody', 'root']) >>> [gr for gr in grp.getgrall() if gr.gr_name == 'starwars'] [grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1000, gr_mem=['nobody', 'root'])] --- Would you mind to provide a full procedure to reproduce your issue? Can you also your group user another tool than python3, like getenv (as shown in my example)? It seems like root is not part of your starwars group. On RHEL8, I tested: # rpm -q python36 python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64 I am getting the issue in my rhel8 env.. root & nobody are part of starwars group. $ sudo groupadd starwars $ sudo usermod -aG starwars nobody $ sudo usermod -aG starwars root $ getent group starwars starwars:x:1011:nobody $ cat /etc/group | grep star starwars:x:1011:nobody,root [root@biplabrhel8 ~]# python3 Python 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import grp >>> grp.getgrnam('starwars') grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1011, gr_mem=['nobody']) >>> grp.getgrall() grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1011, gr_mem=['nobody', 'root'])] $ rpm -q python36 python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64 So, 'getent group starwars' is also not showing root user. I am wondering if there is any setting newly introduced on rhel8 that hides the root user from being shown in the output. Sorry, I'm not a sysadmin, I don't know how users and groups are usually setup and why you get such behavior.
Would you mind to attach your /etc/nsswitch.conf file to the issue?
Example on RHEL 8 (without comments):
---
# sed '/^#/D; /^$/D' /etc/nsswitch.conf
passwd: sss files systemd
group: sss files systemd
netgroup: sss files
automount: sss files
services: sss files
shadow: files sss
hosts: files dns myhostname
aliases: files
ethers: files
gshadow: files
networks: files dns
protocols: files
publickey: files
rpc: files
---
Note: On my Fedora 31, I get the same configuration for groups:
---
$ grep ^group /etc/nsswitch.conf
group: sss files systemd
---
Just in case, you might have a look at the sssd service:
systemctl status sssd.service
and:
journalctl -u sssd.service --reverse
/etc/nsswitch.conf file output ignoring comments,
passwd: sss files systemd
group: sss files systemd
netgroup: sss files
automount: sss files
services: sss files
shadow: files sss
hosts: files dns myhostname
bootparams: files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
publickey: files
aliases: files
Here also the config for groups is the same.
---
# systemctl status sssd.service
● sssd.service - System Security Services Daemon
Loaded: loaded (/usr/lib/systemd/system/sssd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-03-04 00:43:25 EST; 5 days ago
Main PID: 1569 (sssd)
Tasks: 3 (limit: 26213)
Memory: 81.9M
CGroup: /system.slice/sssd.service
├─1569 /usr/sbin/sssd -i --logger=files
├─1615 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
└─1627 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
---
# journalctl -u sssd.service --reverse
-- Logs begin at Mon 2020-03-09 07:35:27 EDT, end at Mon 2020-03-09 23:19:11 EDT. --
-- No entries --
Can you please provide the following package versions? Run "rpm -q kernel glibc glibc-common python36 sssd-common". I failed to reproduce the issue on: # cat /etc/redhat-release Red Hat Enterprise Linux release 8.2 Beta (Ootpa) # rpm -q kernel glibc glibc-common python36 sssd-common kernel-4.18.0-185.el8.x86_64 glibc-2.28-101.el8.x86_64 glibc-common-2.28-101.el8.x86_64 python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64 sssd-common-2.2.3-18.el8.x86_64 sssd-common provides /usr/bin.sssd. glibc-common provides /usr/bin/getenv. Create the starwars group with nobody and root users: # sudo groupadd starwars # sudo usermod -aG starwars nobody # sudo usermod -aG starwars root /etc/group and getent group agree: # grep ^starwars: /etc/group starwars:x:1000:nobody,root # getent group starwars starwars:x:1000:nobody,root Python 3 agree as well: # python3 Python 3.6.8 (default, Dec 5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import grp >>> grp.getgrnam('starwars') grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1000, gr_mem=['nobody', 'root']) >>> [gr for gr in grp.getgrall() if gr.gr_name == 'starwars'] [grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1000, gr_mem=['nobody', 'root'])] User/group database configuration: # sed '/^#/D; /^$/D' /etc/nsswitch.conf passwd: sss files systemd group: sss files systemd netgroup: sss files automount: sss files services: sss files shadow: files sss hosts: files dns myhostname aliases: files ethers: files gshadow: files networks: files dns protocols: files publickey: files rpc: files I change the component to sssd since "getent group" also has the issue: it's not specific to Python. It may be sssd's filter_users, filter_groups (in the [nss] section) which can be used to filter out 'root' from NSS requests. While I'm just a glibc developer... I'd ask that you provide the /etc/sssd/sssd.conf so we can see if you are filtering users. Does it work if you switch the order of 'sss files' to 'files sss' in /etc/nsswitch.conf? In general, SSSD, even though it handles local users and groups now, does not handle root user and group (it is automatically added to filter_users and filter_groups). From a quick test, it is indeed causing troubles and this should be marked as duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1794607. # rpm -q kernel glibc glibc-common python36 sssd-common kernel-4.18.0-147.el8.x86_64 glibc-2.28-42.el8.x86_64 glibc-common-2.28-42.el8.x86_64 python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64 sssd-common-2.2.0-19.el8.x86_64 There is no /etc/sssd/sssd.conf file on this rhel8 system. [root@xxxxrhel8 ~]# cd /etc/sssd/conf.d/ [root@xxxxrhel8 conf.d]# ls [root@xxxxrhel8 conf.d]# cd ../pki/ [root@xxxxrhel8 pki]# ls [root@xxxxrhel8 pki]# cd [root@xxxxrhel8 ~]# [root@xxxxrhel8 ~]# cd /etc/sssd/ conf.d/ pki/ [root@xxxxrhel8 ~]# cd /etc/sssd/conf.d/ [root@xxxxrhel8 conf.d]# ls [root@xxxxrhel8 conf.d]# cd ../pki/ [root@xxxxrhel8 pki]# Changing order of 'sss files' to 'files sss' in /etc/nsswitch.conf did the trick. Now it works.
# python3
Python 3.6.8 (default, Oct 11 2019, 15:04:54)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import grp
>>> grp.getgrnam('starwars')
grp.struct_group(gr_name='starwars', gr_passwd='x', gr_gid=1011, gr_mem=['nobody', 'root'])
# getent group starwars
starwars:x:1011:nobody,root
Thank you for confirmation. I will close this as duplication of 1794607. *** This bug has been marked as a duplicate of bug 1794607 *** |