6 Commits

Author SHA1 Message Date
Andrew G. Morgan
70998415a8 Reviewed license information and adde SPDX ids.
Günther Noack reported some issues with automated dependency checking in

  https://bugzilla.kernel.org/show_bug.cgi?id=216609

Perhaps these additional lines will help assist those things.

I did find a typo in pam_cap/execable.c so I've fixed that.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-10-19 19:05:11 -07:00
Andrew G. Morgan
2c3b8949f4 Another attempt at supporting Ambient vector setting from pam_cap.so.
While the session idea worked with contrib/sucap/su.c, it failed on
more traditional PAM apps. For a second (likely last) attempt to find a
path, I've deleted the session support and now attempt to do the setting
via a PAM data item cleanup() callback. In the contrib/sucap/su.c code,
evolved from the original SimplePAMApps 'su', there is a

   pam_end(pamh, PAM_SUCCESS | PAM_DATA_SILENT)

from within the fork()d launcher code, so I hope this convention is
standard for all the PAM apps that came after.

The suggested config for this module for an app, that wants to support
the Ambient vector, is thus now:

    #%PAM-1.0
    auth            required pam_cap.so keepcaps defer
    auth            required pam_unix.so
    account         required pam_unix.so
    password        required pam_unix.so
    session         required pam_unix.so

This is all part of an effort to address:

   https://bugzilla.kernel.org/show_bug.cgi?id=214377

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-14 19:45:59 -07:00
Andrew G. Morgan
fc6253b9de Add PAM "session" support to pam_cap.so.
This is an attempt to address:

  https://bugzilla.kernel.org/show_bug.cgi?id=214377

The basic structure is you configure PAM with a config like this:

#%PAM-1.0
auth            required pam_cap.so use_session keepcaps
auth		required pam_unix.so
account		required	pam_unix.so
password		required	pam_unix.so
session		required pam_unix.so
session         optional pam_cap.so

Here the "auth" part prepares the application with "keepcaps", and the
"use_session" instructs the module to apply any IAB tuple for the user
at session open time and not during the setcred (auth) flow.

This has been tested against the contrib/sucap implementation of su.
The "use_session" support should work with more standard PAM enabled
apps too, but I'll wait for some positive feedback (see the bug)
before declaring it stable.

FWIW the contrib/sucap/su app also supports this config for Ambient
vector setting (without a "session" invocation of pam_cap.so):

#%PAM-1.0
auth            required pam_cap.so
auth		required pam_unix.so
account		required	pam_unix.so
password		required	pam_unix.so
session		required pam_unix.so

but that is because the sucap/su app is more tightly integrated with
libcap than the standard PAM apps.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-13 21:08:42 -07:00
Andrew G. Morgan
552db8f411 More fixes for static analysis issues.
Further observations from Zoltan Fridrich's static analysis of libcap.
This commit also includes a fix for something I broke with the last
round of "fixing", and a test to make sure I don't make that mistake
again.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-27 10:26:59 -07:00
Andrew G. Morgan
fdd53759d8 Allow for systems with no /proc/self/cmdline file.
If /proc/ isn't mounted, the command line won't be available there.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-07-13 19:32:45 -07:00
Andrew G. Morgan
efd293947f Support running pam_cap.so as a simple binary.
This prints module information and supports the sole optional
argument --help.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-07-12 21:23:47 -07:00