Skip to content

Commit fda154e

Browse files
committed
pam: implement a zfs_key pam module
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 <[email protected]> Closes #9886
1 parent 1c08fa8 commit fda154e

File tree

19 files changed

+1054
-2
lines changed

19 files changed

+1054
-2
lines changed

config/user-pam.m4

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
AC_DEFUN([ZFS_AC_CONFIG_USER_PAM], [
2+
AC_ARG_ENABLE([pam],
3+
AS_HELP_STRING([--enable-pam],
4+
[install pam_zfs_key module [[default: check]]]),
5+
[enable_pam=$enableval],
6+
[enable_pam=check])
7+
8+
AC_ARG_WITH(pammoduledir,
9+
AS_HELP_STRING([--with-pammoduledir=DIR],
10+
[install pam module in dir [[$libdir/security]]]),
11+
[pammoduledir="$withval"],[pammoduledir=$libdir/security])
12+
13+
AC_ARG_WITH(pamconfigsdir,
14+
AS_HELP_STRING([--with-pamconfigsdir=DIR],
15+
[install pam-config files in dir [[/usr/share/pamconfigs]]]),
16+
[pamconfigsdir="$withval"],[pamconfigsdir=/usr/share/pam-configs])
17+
18+
AS_IF([test "x$enable_pam" != "xno"], [
19+
AC_CHECK_HEADERS([security/pam_modules.h], [
20+
enable_pam=yes
21+
], [
22+
AS_IF([test "x$enable_pam" == "xyes"], [
23+
AC_MSG_FAILURE([
24+
*** security/pam_modules.h missing, libpam0g-dev package required
25+
])
26+
],[
27+
enable_pam=no
28+
])
29+
])
30+
])
31+
AS_IF([test "x$enable_pam" == "xyes"], [
32+
DEFINE_PAM='--with "pam" --define "_pamconfigsdir $(pamconfigsdir)"'
33+
])
34+
AC_SUBST(DEFINE_PAM)
35+
AC_SUBST(pammoduledir)
36+
AC_SUBST(pamconfigsdir)
37+
])

config/user.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
1717
ZFS_AC_CONFIG_USER_LIBUDEV
1818
ZFS_AC_CONFIG_USER_LIBSSL
1919
ZFS_AC_CONFIG_USER_LIBAIO
20+
ZFS_AC_CONFIG_USER_PAM
2021
ZFS_AC_CONFIG_USER_RUNSTATEDIR
2122
ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS
2223
ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV

config/zfs-build.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ AC_DEFUN([ZFS_AC_CONFIG], [
223223
[test "x$qatsrc" != x ])
224224
AM_CONDITIONAL([WANT_DEVNAME2DEVID], [test "x$user_libudev" = xyes ])
225225
AM_CONDITIONAL([WANT_MMAP_LIBAIO], [test "x$user_libaio" = xyes ])
226+
AM_CONDITIONAL([PAM_ZFS_ENABLED], [test "x$enable_pam" = xyes])
226227
])
227228

228229
dnl #
@@ -284,6 +285,7 @@ AC_DEFUN([ZFS_AC_RPM], [
284285
RPM_DEFINE_UTIL+=' $(DEFINE_INITRAMFS)'
285286
RPM_DEFINE_UTIL+=' $(DEFINE_SYSTEMD)'
286287
RPM_DEFINE_UTIL+=' $(DEFINE_PYZFS)'
288+
RPM_DEFINE_UTIL+=' $(DEFINE_PAM)'
287289
RPM_DEFINE_UTIL+=' $(DEFINE_PYTHON_VERSION)'
288290
RPM_DEFINE_UTIL+=' $(DEFINE_PYTHON_PKG_VERSION)'
289291

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ AC_CONFIG_FILES([
9898
contrib/initramfs/hooks/Makefile
9999
contrib/initramfs/scripts/Makefile
100100
contrib/initramfs/scripts/local-top/Makefile
101+
contrib/pam_zfs_key/Makefile
101102
contrib/pyzfs/Makefile
102103
contrib/pyzfs/setup.py
103104
contrib/zcp/Makefile
@@ -351,6 +352,7 @@ AC_CONFIG_FILES([
351352
tests/zfs-tests/tests/functional/no_space/Makefile
352353
tests/zfs-tests/tests/functional/nopwrite/Makefile
353354
tests/zfs-tests/tests/functional/online_offline/Makefile
355+
tests/zfs-tests/tests/functional/pam/Makefile
354356
tests/zfs-tests/tests/functional/persist_l2arc/Makefile
355357
tests/zfs-tests/tests/functional/pool_checkpoint/Makefile
356358
tests/zfs-tests/tests/functional/pool_names/Makefile

contrib/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ SUBDIRS = bash_completion.d pyzfs zcp
22
if BUILD_LINUX
33
SUBDIRS += bpftrace dracut initramfs
44
endif
5-
DIST_SUBDIRS = bash_completion.d bpftrace dracut initramfs pyzfs zcp
5+
if PAM_ZFS_ENABLED
6+
SUBDIRS += pam_zfs_key
7+
endif
8+
DIST_SUBDIRS = bash_completion.d bpftrace dracut initramfs pam_zfs_key pyzfs zcp

contrib/pam_zfs_key/Makefile.am

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
include $(top_srcdir)/config/Rules.am
2+
3+
pammodule_LTLIBRARIES=pam_zfs_key.la
4+
5+
pam_zfs_key_la_SOURCES = pam_zfs_key.c
6+
7+
pam_zfs_key_la_LIBADD = \
8+
$(top_builddir)/lib/libnvpair/libnvpair.la \
9+
$(top_builddir)/lib/libuutil/libuutil.la \
10+
$(top_builddir)/lib/libzfs/libzfs.la \
11+
$(top_builddir)/lib/libzfs_core/libzfs_core.la
12+
13+
pam_zfs_key_la_LDFLAGS = -version-info 1:0:0 -avoid-version -module -shared
14+
15+
pam_zfs_key_la_LIBADD += -lpam $(LIBSSL)
16+
17+
pamconfigs_DATA = zfs_key
18+
EXTRA_DIST = $(pamconfigs_DATA)

0 commit comments

Comments
 (0)