-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: implement a zfs_key pam module #9903
Conversation
@behlendorf do you already have some feedback for this? Do you have some hints on how to include this into the overall building process?
and then installed it with |
Codecov Report
@@ Coverage Diff @@
## master #9903 +/- ##
==========================================
- Coverage 79% 66% -13%
==========================================
Files 386 304 -82
Lines 122448 105121 -17327
==========================================
- Hits 97036 69899 -27137
- Misses 25412 35222 +9810
Continue to review full report at Codecov.
|
Thanks for tackling this! Just FYI, I came across this repository recently: https://github.com/BenKerry/zfscrypt |
695790f
to
969b790
Compare
I have updated the PAM module to:
|
969b790
to
ea435a0
Compare
It seems most of the build-servers miss pam development headers. On debian they are in |
6cec28a
to
f44bdfe
Compare
00ba991
to
7c05a38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On debian they are in libpam0g-dev. How can I ensure they are installed?
I've opened PR openzfs/zfs-buildbot#181 against the zfs-buildbot repository which adds the missing dependency. Can you just confirm that we don't need anything else besides the libpam0g-dev / pam-devel packages?
We definitely want to make sure this gets build by the CI. It would be good if we could also perform some basic testing with it. But I'm not sure how easy it would be to automate this kind of testing.
a365482
to
d3c5f7e
Compare
765440f
to
85b5f20
Compare
bcadf82
to
56487ff
Compare
%if 0%{?_pam} | ||
%{_pammoduledir}/* | ||
%{_pamconfigsdir}/* | ||
%endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Distributions might possibly put these in separate subpackages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you would suggest to move them to a libpam_zfs_key
and pam_zfs_key
package in a new files -n
-section
9629bd0
to
0b0e902
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jengelh for your review! I (hopefully) resolved the missing error checks and replied with some quick follow-up questions.
contrib/pam_zfs_key/pam_zfs_key.c
Outdated
return (PAM_SERVICE_ERR); | ||
} | ||
struct sigaction oldact; | ||
sigchild_default(&oldact); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for which I needed/added these new processes/forks was that they were required for mounting to work. Otherwise I would receive an error:
mount: only root can use the --no-canonicalize option
as a note: (regarding child processes) libzfs already invokes a child process on linux to do the real mount anyways:
zfs/lib/libzfs/os/linux/libzfs_mount_os.c
Line 302 in 4bc7219
do_mount(const char *src, const char *mntpt, char *opts, int flags) |
so we should rewrite the zfsutil code to use libmount1
instead of spawning a real mount process?
%if 0%{?_pam} | ||
%{_pammoduledir}/* | ||
%{_pamconfigsdir}/* | ||
%endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you would suggest to move them to a libpam_zfs_key
and pam_zfs_key
package in a new files -n
-section
Hi @felixdoerre, could you make unmounting the dataset and unloading the key at the end of the session optional (like pam_fscrypt does, for example)? It’s not the common case and it certainly shouldn’t be the default but It could be useful in some situations. |
44c47d6
to
78dc01b
Compare
bf36043
to
555424c
Compare
Would it be possible to use the ZFS passphrase as the only password? i.e. |
@myfreeweb Although this is currently not implemented, I believe this this could be possible. One would call |
Is it currently not unlocking at
Isn't that just how PAM works in general? I would expect all modules to be queried in config order, until one of them says yes. |
password checking still needs to work when the dataset is unlocked. I believe you need |
} | ||
zfs_key_config config; | ||
zfs_key_config_load(pamh, &config, argc, argv); | ||
if (config.uid < 1000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment.
} | ||
zfs_key_config config; | ||
zfs_key_config_load(pamh, &config, argc, argv); | ||
if (config.uid < 1000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment.
It would be great if you could also rebase this on the latest version of master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can improve the FreeBSD logging later.
currently the pam module does: * load a zfs key and mounts the dataset when a session opens * unmounts the dataset and unloads the key when the session closes * when the user is logged on and changes the password, the modules changes the encryption key. Signed-off-by: Felix Dörre <felix@dogcraft.de> Closes openzfs#9886
This PAM module allows unlocking encrypted user home datasets when logging in (and changing passphrase when changing the account password), see openzfs/zfs#9903 Also supposed to unload the key when the last session for the user is done, but there are EBUSY issues: openzfs/zfs#11222 (comment) Submitted by: Greg V <greg_unrelenting.technology> Reviewed by: mm MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28018
This PAM module allows unlocking encrypted user home datasets when logging in (and changing passphrase when changing the account password), see openzfs/zfs#9903 Also supposed to unload the key when the last session for the user is done, but there are EBUSY issues: openzfs/zfs#11222 (comment) Submitted by: Greg V <greg_unrelenting.technology> Reviewed by: mm Differential Revision: https://reviews.freebsd.org/D28018 (cherry picked from commit ee21ee1)
This PAM module allows unlocking encrypted user home datasets when logging in (and changing passphrase when changing the account password), see openzfs/zfs#9903 Also supposed to unload the key when the last session for the user is done, but there are EBUSY issues: openzfs/zfs#11222 (comment) Submitted by: Greg V <greg_unrelenting.technology> Reviewed by: mm Differential Revision: https://reviews.freebsd.org/D28018 (cherry picked from commit ee21ee1)
Implements a pam module for automatically loading zfs encryption keys for home datasets. The pam module: - loads a zfs key and mounts the dataset when a session opens. - unmounts the dataset and unloads the key when the session closes. - when the user is logged on and changes the password, the module changes the encryption key. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: @jengelh <jengelh@inai.de> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Felix Dörre <felix@dogcraft.de> Closes openzfs#9886 Closes openzfs#9903
Implements a pam module for automatically loading zfs encryption keys for home datasets. The pam module: - loads a zfs key and mounts the dataset when a session opens. - unmounts the dataset and unloads the key when the session closes. - when the user is logged on and changes the password, the module changes the encryption key. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: @jengelh <jengelh@inai.de> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Felix Dörre <felix@dogcraft.de> Closes openzfs#9886 Closes openzfs#9903
This PAM module allows unlocking encrypted user home datasets when logging in (and changing passphrase when changing the account password), see openzfs/zfs#9903 Also supposed to unload the key when the last session for the user is done, but there are EBUSY issues: openzfs/zfs#11222 (comment) Submitted by: Greg V <greg_unrelenting.technology> Reviewed by: mm MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28018
Implements a pam module for automatically loading zfs encryption keys for home datasets. Currently the pam module does:
changes the encryption key.
See also implement pam_zfs_key #9886
How Has This Been Tested?
I've tested this locally after compiling with:
Types of changes
Checklist:
Signed-off-by
.