Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAM: support the authentication facility #14789

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

valpackett
Copy link
Contributor

Motivation and Context

In the system I'm working on, I'd like to exclusively use the ZFS dataset passphrase for user authentication, in order to avoid extra sources of persistent state (in this case /etc/shadow style files). Seems like this could be useful for others too so I'd like to upstream it.

Description

Implement the pam_sm_authenticate method, using the noop argument of lzc_load_key to do a passphrase check without actually loading the key.

This allows using ZFS as the source of truth for user passwords, without storing any password hashes in /etc or using other PAM modules.

Notes for Other PRs

If #13050 is to land after this, it should either extract the "already mounted" check up to pam_sm_open_session or skip that check in noop mode.

How Has This Been Tested?

Adding these to /etc/pam.d/su

auth            sufficient      pam_zfs_key.so          debug homes=testpool prop_mountpoint

session         optional        pam_zfs_key.so          debug homes=testpool prop_mountpoint

and adding a test user with a home directory pointing to an encrypted dataset (using vipw),

then verifying that su uzer correctly checks the passphrase but doesn't mount anything, while su -l uzer (-l for "Simulate a full login" that does open a session) does also mount and unmount the home dataset.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Apr 24, 2023
@behlendorf
Copy link
Contributor

@felixdoerre would you mind taking a look at this PR.

contrib/pam_zfs_key/pam_zfs_key.c Outdated Show resolved Hide resolved
contrib/pam_zfs_key/pam_zfs_key.c Outdated Show resolved Hide resolved
contrib/pam_zfs_key/pam_zfs_key.c Outdated Show resolved Hide resolved
contrib/pam_zfs_key/pam_zfs_key.c Outdated Show resolved Hide resolved
Implement the pam_sm_authenticate method, using the noop argument of
lzc_load_key to do a passphrase check without actually loading the key.

This allows using ZFS as the source of truth for user passwords,
without storing any password hashes in /etc or using other PAM modules.

Signed-off-by: Val Packett <val@packett.cool>
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 26, 2023
@behlendorf behlendorf merged commit ae0d0f0 into openzfs:master Apr 27, 2023
@valpackett valpackett deleted the pam_auth branch April 28, 2023 02:52
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request May 1, 2023
Implement the pam_sm_authenticate method, using the noop argument of
lzc_load_key to do a passphrase check without actually loading the key.

This allows using ZFS as the source of truth for user passwords,
without storing any password hashes in /etc or using other PAM modules.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Felix Dörre <felix@dogcraft.de>
Signed-off-by: Val Packett <val@packett.cool>
Closes openzfs#14789
@valpackett valpackett mentioned this pull request May 6, 2023
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants