]> granicus.if.org Git - linux-pam/commit
pam_loginuid: Ignore failure in user namespaces
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 8 Jan 2014 00:12:03 +0000 (16:12 -0800)
committerSteve Langasek <steve.langasek@canonical.com>
Fri, 10 Jan 2014 08:09:34 +0000 (00:09 -0800)
commit24f3a88e7de52fbfcb7b8a1ebdae0cdbef420edf
treef1f0e3288db6fd5758f7a16bb1371c8b45b9b359
parent5825450540e6620ac331c64345b42fdcbb1d6e87
pam_loginuid: Ignore failure in user namespaces

When running pam_loginuid in a container using the user namespaces, even
uid 0 isn't allowed to set the loginuid property.

This change catches the EACCES from opening loginuid, checks if the user
is in the host namespace (by comparing the uid_map with the host's one)
and only if that's the case, sets rc to 1.

Should uid_map not exist or be unreadable for some reason, it'll be
assumed that the process is running on the host's namespace.

The initial reason behind this change was failure to ssh into an
unprivileged container (using a 3.13 kernel and current LXC) when using
a standard pam profile for sshd (which requires success from
pam_loginuid).

I believe this solution doesn't have any drawback and will allow people
to use unprivileged containers normally. An alternative would be to have
all distros set pam_loginuid as optional but that'd be bad for any of
the other potential failure case which people may care about.

There has also been some discussions to get some of the audit features
tied with the user namespaces but currently none of that has been merged
upstream and the currently proposed implementation doesn't cover
loginuid (nor is it clear how this should even work when loginuid is set
as immutable after initial write).

Signed-off-by: Steve Langasek <vorlon@debian.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
modules/pam_loginuid/pam_loginuid.c