RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1745147 - GDM does not prevent users with login shell /sbin/nologin from logging on
Summary: GDM does not prevent users with login shell /sbin/nologin from logging on
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gdm
Version: 8.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 8.0
Assignee: Ray Strode [halfline]
QA Contact: Desktop QE
URL:
Whiteboard:
Depends On:
Blocks: 1752493 2015519
TreeView+ depends on / blocked
 
Reported: 2019-08-23 17:40 UTC by Steffen Froemer
Modified: 2023-03-24 15:19 UTC (History)
8 users (show)

Fixed In Version: gnome-session-3.28.1-7.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1752493 2015519 (view as bug list)
Environment:
Last Closed: 2020-04-28 16:09:41 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-27243 0 None None None 2021-10-19 12:26:13 UTC
Red Hat Product Errata RHSA-2020:1766 0 None None None 2020-04-28 16:10:01 UTC

Description Steffen Froemer 2019-08-23 17:40:00 UTC
Description of problem:
A user with login-shell set to /sbin/nologin is still able to login using GDM

Version-Release number of selected component (if applicable):
gdm-3.28.3-20.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
1. RHEL 8
2. useradd -s /sbin/nologin -m user2
3. login via GDM

Actual results:
The user is able to login

Expected results:
The user should not be able to login

Additional info:
# grep user2 /etc/passwd
user2:x:1001:1001::/home/user2:/sbin/nologin

# w
 17:39:27 up 30 min,  2 users,  load average: 0,80, 0,17, 0,07
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    172.16.100.100   17:09    1.00s  0.11s  0.01s w
user2    :1       :1               17:39   ?xdm?  16.42s  0.02s /usr/libexec/gdm-x-session gnome-session

# su - user2
Last login: Fr Aug 23 17:39:24 UTC 2019 on tty2
This account is currently not available.

Comment 1 Ding-Yi Chen 2019-09-13 03:33:44 UTC
I can reproduce it with gdm-3.28-3-20.el8.x86_64

Comment 3 Ray Strode [halfline] 2019-10-21 14:30:52 UTC
So this is an interesting bug.

For console logins, they get the lock out for "free", because they're just handing off to the shell which is /sbin/nologin.

For graphical logins, we're starting a graphical desktop, not the users shell.

We do still run a shell, however, as part of the login process.  /usr/bin/gnome-session is a shell script that does:

if [ "x$XDG_SESSION_TYPE" = "xwayland" ] &&
   [ "x$XDG_SESSION_CLASS" != "xgreeter" ] &&
   [  -n "$SHELL" ] &&
   grep -q "$SHELL" /etc/shells &&
   ! (echo "$SHELL" | grep -q "false") &&
   ! (echo "$SHELL" | grep -q "nologin"); then
  if [ "$1" != '-l' ]; then
    exec bash -c "exec -l '$SHELL' -c '$0 -l $*'"
  else
    shift
  fi
fi

See it runs exec -l '$SHELL' to execute the users shell as a "login shell" so all the appropriate startup scripts get run.

But also see it explicitly avoids this step for the "nologin" shell. The reasoning for this is discussed upstream here:

https://bugzilla.gnome.org/show_bug.cgi?id=736660#c58

Namely, the login screen itself uses gnome-session and has its shell set to nologin!

But i think we're still safe to remove the check because we also check XDG_SESSION_CLASS to make sure it's not a login screen before proceeding.
In other words, we had redundant checks to skip the script loading for the login screen and dropping one shouldn't hurt anything.

Dropping it, will mean that we try to run nologin as the users shell during login.  it will fail and login will be aborted which is the desired behavior.

devack+

Comment 10 errata-xmlrpc 2020-04-28 16:09:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:1766


Note You need to log in before you can comment on or make changes to this bug.