Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 592616 - sys-auth/pambase: /etc/pam.d/sudo references `session pam_systemd.so` which breaks passwordless sudo in shell scripts
Summary: sys-auth/pambase: /etc/pam.d/sudo references `session pam_systemd.so` which b...
Status: RESOLVED DUPLICATE of bug 504492
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on: 485470
Blocks:
  Show dependency tree
 
Reported: 2016-08-31 16:22 UTC by Niklas Haas
Modified: 2020-09-10 10:33 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niklas Haas 2016-08-31 16:22:26 UTC
The `/etc/pam.d/sudo` references `session pam_systemd.so` (as included by `system-auth`) which is not supposed to be the case (and isn't the case on other distros).

For regular interactive users this is harmless because systemd just prints a warning about a session already running when using `sudo` interactively, but when using `sudo` from a script (e.g. as run by a daemon), it unnecessarily creates and tears down a login session, perhaps multiple times.

This is not only unnecessary but it also causes a few thousand kernel worker threads to be spawned in the process (see https://github.com/systemd/systemd/issues/4069).

Ideally, this should simply never be done for `sudo` since it makes little sense and even if that systemd bug gets fixed it's still completely unnecessary overhead and unexpected behavior.
Comment 1 Niklas Haas 2016-08-31 16:23:09 UTC
Note: I can work around the issue by rewriting my /etc/pam.d/sudo from this:

{{{
auth	include		system-auth
account	include		system-auth
session	include		system-auth
}}}

to this:

{{{
auth	include		system-auth
account	include		system-auth
session		required	pam_limits.so 
session		required	pam_env.so 
session		required	pam_unix.so 
session		optional	pam_permit.so
}}}
Comment 2 Mike Gilbert gentoo-dev 2016-09-03 18:27:30 UTC
Maybe we should move pam_systemd out of system-auth.
Comment 3 Niklas Haas 2016-09-04 06:42:48 UTC
Seems like the purpose of `pam_systemd.so` is creating a logind session for what would be considered an interactive login, i.e. from getty or via ssh. If `system-auth` is just for providing authentication, then it should not be referencing anything to do with login sessions.

(Instead, maybe a separate category like `system-session` would be more appropriate?)
Comment 4 Pacho Ramos gentoo-dev 2018-09-24 13:39:46 UTC
it seems it was added to system-auth in bug 485470
Comment 5 Mikle Kolyada (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2019-04-06 18:00:00 UTC
(In reply to Mike Gilbert from comment #2)
> Maybe we should move pam_systemd out of system-auth.

yes, and this should be the system-login file
Comment 6 Mikle Kolyada (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2020-09-10 10:33:41 UTC

*** This bug has been marked as a duplicate of bug 504492 ***