From dc3bb983448c6da7f588014a1a0cb5f3d85d32be Mon Sep 17 00:00:00 2001 From: Britney Fransen Date: Sun, 4 Oct 2020 16:40:48 +0000 Subject: pam: update to 1.4.0 --- .../0e9b286afe1224b91ff00936058b084ad4b776e4.patch | 31 ++++++++ .../395915dae1571e10e2766c999974de864655ea3a.patch | 47 ++++++++++++ abs/core/pam/PKGBUILD | 78 +++++++++----------- .../af0faf666c5008e54dfe43684f210e3581ff1bca.patch | 85 ++++++++++++++++++++++ abs/core/pam/pam.tmpfiles | 1 + abs/core/pam/pam_unix2-glibc216.patch | 20 ----- 6 files changed, 198 insertions(+), 64 deletions(-) create mode 100644 abs/core/pam/0e9b286afe1224b91ff00936058b084ad4b776e4.patch create mode 100644 abs/core/pam/395915dae1571e10e2766c999974de864655ea3a.patch create mode 100644 abs/core/pam/af0faf666c5008e54dfe43684f210e3581ff1bca.patch create mode 100644 abs/core/pam/pam.tmpfiles delete mode 100644 abs/core/pam/pam_unix2-glibc216.patch diff --git a/abs/core/pam/0e9b286afe1224b91ff00936058b084ad4b776e4.patch b/abs/core/pam/0e9b286afe1224b91ff00936058b084ad4b776e4.patch new file mode 100644 index 0000000..5715b8f --- /dev/null +++ b/abs/core/pam/0e9b286afe1224b91ff00936058b084ad4b776e4.patch @@ -0,0 +1,31 @@ +From 0e9b286afe1224b91ff00936058b084ad4b776e4 Mon Sep 17 00:00:00 2001 +From: ikerexxe +Date: Tue, 16 Jun 2020 14:44:04 +0200 +Subject: [PATCH] pam_usertype: avoid determining if user exists + +Taking a look at the time for the password prompt to appear it was +possible to determine if a user existed in a system. Solved it by +matching the runtime until the password prompt was shown by always +checking the password hash for an existing and a non-existing user. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1629598 +--- + modules/pam_usertype/pam_usertype.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/modules/pam_usertype/pam_usertype.c b/modules/pam_usertype/pam_usertype.c +index 2807c306..d03b73b5 100644 +--- a/modules/pam_usertype/pam_usertype.c ++++ b/modules/pam_usertype/pam_usertype.c +@@ -139,8 +139,11 @@ pam_usertype_get_uid(struct pam_usertype_opts *opts, + "error retrieving information about user %s", username); + } + ++ pam_modutil_getpwnam(pamh, "root"); ++ + return PAM_USER_UNKNOWN; + } ++ pam_modutil_getpwnam(pamh, "pam_usertype_non_existent:"); + + *_uid = pwd->pw_uid; + diff --git a/abs/core/pam/395915dae1571e10e2766c999974de864655ea3a.patch b/abs/core/pam/395915dae1571e10e2766c999974de864655ea3a.patch new file mode 100644 index 0000000..d96d890 --- /dev/null +++ b/abs/core/pam/395915dae1571e10e2766c999974de864655ea3a.patch @@ -0,0 +1,47 @@ +From 395915dae1571e10e2766c999974de864655ea3a Mon Sep 17 00:00:00 2001 +From: ikerexxe +Date: Mon, 15 Jun 2020 09:52:11 +0200 +Subject: [PATCH] pam_faillock: change /run/faillock/$USER permissions to 0660 + +Nowadays, /run/faillock/$USER files have user:root ownership and 0600 +permissions. This forces the process that writes to these files to have +CAP_DAC_OVERRIDE capabilites. Just by changing the permissions to 0660 +the capability can be removed, which leads to a more secure system. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1661822 +--- + modules/pam_faillock/faillock.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/modules/pam_faillock/faillock.c b/modules/pam_faillock/faillock.c +index e492f5f9..4ea94cbe 100644 +--- a/modules/pam_faillock/faillock.c ++++ b/modules/pam_faillock/faillock.c +@@ -76,7 +76,7 @@ open_tally (const char *dir, const char *user, uid_t uid, int create) + flags |= O_CREAT; + } + +- fd = open(path, flags, 0600); ++ fd = open(path, flags, 0660); + + free(path); + +@@ -88,6 +88,18 @@ open_tally (const char *dir, const char *user, uid_t uid, int create) + if (st.st_uid != uid) { + ignore_return(fchown(fd, uid, -1)); + } ++ ++ /* ++ * If umask is set to 022, as will probably in most systems, then the ++ * group will not be able to write to the file. So, change the file ++ * permissions just in case. ++ * Note: owners of this file are user:root, so if the permissions are ++ * not changed the root process writing to this file will require ++ * CAP_DAC_OVERRIDE. ++ */ ++ if (!(st.st_mode & S_IWGRP)) { ++ ignore_return(fchmod(fd, 0660)); ++ } + } + } + diff --git a/abs/core/pam/PKGBUILD b/abs/core/pam/PKGBUILD index 63bd83d..bcad4df 100644 --- a/abs/core/pam/PKGBUILD +++ b/abs/core/pam/PKGBUILD @@ -1,70 +1,60 @@ -# $Id$ # Maintainer: Tobias Powalowski # Contributor: judd pkgname=pam -pkgver=1.3.0 -pkgrel=2 +pkgver=1.4.0 +pkgrel=3 pkgdesc="PAM (Pluggable Authentication Modules) library" -arch=('i686' 'x86_64') +arch=('x86_64') license=('GPL2') url="http://linux-pam.org" -depends=('glibc' 'cracklib' 'libtirpc' 'pambase') +depends=('glibc' 'libtirpc' 'pambase' 'audit') makedepends=('flex' 'w3m' 'docbook-xml>=4.4' 'docbook-xsl') -backup=(etc/security/{access.conf,group.conf,limits.conf,namespace.conf,namespace.init,pam_env.conf,time.conf} etc/default/passwd etc/environment) -source=(http://linux-pam.org/library/Linux-PAM-$pkgver.tar.bz2 - https://sources.archlinux.org/other/pam_unix2/pam_unix2-2.9.1.tar.bz2 - pam_unix2-glibc216.patch) -md5sums=('da4b2289b7cfb19583d54e9eaaef1c3a' - 'da6a46e5f8cd3eaa7cbc4fc3a7e2b555' - 'dac109f68e04a4df37575fda6001ea17') +backup=(etc/security/{access.conf,faillock.conf,group.conf,limits.conf,namespace.conf,namespace.init,pam_env.conf,time.conf} etc/environment) +source=(https://github.com/linux-pam/linux-pam/releases/download/v$pkgver/Linux-PAM-$pkgver.tar.xz + https://github.com/linux-pam/linux-pam/releases/download/v$pkgver/Linux-PAM-$pkgver.tar.xz.asc + 395915dae1571e10e2766c999974de864655ea3a.patch + af0faf666c5008e54dfe43684f210e3581ff1bca.patch + 0e9b286afe1224b91ff00936058b084ad4b776e4.patch + $pkgname.tmpfiles) +validpgpkeys=( + '8C6BFD92EE0F42EDF91A6A736D1A7F052E5924BB' # Thorsten Kukuk + '296D6F29A020808E8717A8842DB5BD89A340AEB7' #Dimitry V. Levin +) + +sha256sums=('cd6d928c51e64139be3bdb38692c68183a509b83d4f2c221024ccd4bcddfd034' + 'SKIP' + 'cd2440d7bec55fa91e499060c0bf248f4fd20e7a0ef613eb7a06ee083f7ce21b' + 'ac3e1d307756f5975587a7846500414c02d2b60acb271017b9c7aa6f47c89875' + '68f81b67dde5ee6003524b6b14e2d6f27edcfc0a2bde4c55a1cacbc6e299c207' + '5631f224e90c4f0459361c2a5b250112e3a91ba849754bb6f67d69d683a2e5ac') options=('!emptydirs') -prepare () { - cd $srcdir/Linux-PAM-$pkgver - - # fix pam_unix2 building - cd $srcdir/pam_unix2-2.9.1 - patch -Np1 -i "${srcdir}/pam_unix2-glibc216.patch" +prepare() { + cd Linux-PAM-$pkgver + patch -p1 -i ../395915dae1571e10e2766c999974de864655ea3a.patch + patch -p1 -i ../af0faf666c5008e54dfe43684f210e3581ff1bca.patch + patch -p1 -i ../0e9b286afe1224b91ff00936058b084ad4b776e4.patch } build() { - cd $srcdir/Linux-PAM-$pkgver + cd Linux-PAM-$pkgver ./configure --libdir=/usr/lib --sbindir=/usr/bin --disable-db make - - cd $srcdir/pam_unix2-2.9.1 - # modify flags to build against the pam compiled here, not a system lib. - ./configure \ - CFLAGS="$CFLAGS -I$srcdir/Linux-PAM-$pkgver/libpam/include/" \ - LDFLAGS="$LDFLAGS -L$srcdir/Linux-PAM-$pkgver/libpam/.libs/" \ - --libdir=/usr/lib \ - --sbindir=/usr/bin - make } package() { - cd $srcdir/Linux-PAM-$pkgver - make DESTDIR=$pkgdir SCONFIGDIR=/etc/security install - - # build pam_unix2 module - # source ftp://ftp.suse.com/pub/people/kukuk/pam/pam_unix2 - cd $srcdir/pam_unix2-2.9.1 - make DESTDIR=$pkgdir install - - # fix some missing symlinks from old pam for compatibility - cd $pkgdir/usr/lib/security - ln -s pam_unix.so pam_unix_acct.so - ln -s pam_unix.so pam_unix_auth.so - ln -s pam_unix.so pam_unix_passwd.so - ln -s pam_unix.so pam_unix_session.so + install -Dm 644 $pkgname.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/$pkgname.conf + cd Linux-PAM-$pkgver + make DESTDIR="$pkgdir" SCONFIGDIR=/etc/security install # set unix_chkpwd uid - chmod +s $pkgdir/usr/bin/unix_chkpwd + chmod +s "$pkgdir"/usr/bin/unix_chkpwd + # remove doc which is not used anymore # FS #40749 - rm $pkgdir/usr/share/doc/Linux-PAM/sag-pam_userdb.html + #rm "$pkgdir"/usr/share/doc/Linux-PAM/sag-pam_userdb.html # disable coredumps sed -i 's|# End of file||' $pkgdir/etc/security/limits.conf diff --git a/abs/core/pam/af0faf666c5008e54dfe43684f210e3581ff1bca.patch b/abs/core/pam/af0faf666c5008e54dfe43684f210e3581ff1bca.patch new file mode 100644 index 0000000..924cec3 --- /dev/null +++ b/abs/core/pam/af0faf666c5008e54dfe43684f210e3581ff1bca.patch @@ -0,0 +1,85 @@ +From af0faf666c5008e54dfe43684f210e3581ff1bca Mon Sep 17 00:00:00 2001 +From: ikerexxe +Date: Tue, 16 Jun 2020 14:32:36 +0200 +Subject: [PATCH] pam_unix: avoid determining if user exists + +Taking a look at the time for the password prompt to appear it was +possible to determine if a user existed in a system. Solved it by +matching the runtime until the password prompt was shown by always +checking the password hash for an existing and a non-existing user. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1629598 +--- + modules/pam_unix/passverify.c | 6 ++++++ + modules/pam_unix/support.c | 33 ++++++++++++++++++++++++++------- + 2 files changed, 32 insertions(+), 7 deletions(-) + +diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c +index a571b4f7..7455eae6 100644 +--- a/modules/pam_unix/passverify.c ++++ b/modules/pam_unix/passverify.c +@@ -1096,6 +1096,12 @@ helper_verify_password(const char *name, const char *p, int nullok) + if (pwd == NULL || hash == NULL) { + helper_log_err(LOG_NOTICE, "check pass; user unknown"); + retval = PAM_USER_UNKNOWN; ++ } else if (p[0] == '\0' && nullok) { ++ if (hash[0] == '\0') { ++ retval = PAM_SUCCESS; ++ } else { ++ retval = PAM_AUTH_ERR; ++ } + } else { + retval = verify_pwd_hash(p, hash, nullok); + } +diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c +index 41db1f04..dc67238c 100644 +--- a/modules/pam_unix/support.c ++++ b/modules/pam_unix/support.c +@@ -601,6 +601,8 @@ _unix_blankpasswd (pam_handle_t *pamh, unsigned long long ctrl, const char *name + char *salt = NULL; + int daysleft; + int retval; ++ int execloop = 1; ++ int nonexistent = 1; + + D(("called")); + +@@ -624,14 +626,31 @@ _unix_blankpasswd (pam_handle_t *pamh, unsigned long long ctrl, const char *name + + /* UNIX passwords area */ + +- retval = get_pwd_hash(pamh, name, &pwd, &salt); ++ /* ++ * Execute this loop twice: one checking the password hash of an existing ++ * user and another one for a non-existing user. This way the runtimes ++ * are equal, making it more difficult to differentiate existing from ++ * non-existing users. ++ */ ++ while (execloop) { ++ retval = get_pwd_hash(pamh, name, &pwd, &salt); + +- if (retval == PAM_UNIX_RUN_HELPER) { +- /* salt will not be set here so we can return immediately */ +- if (_unix_run_helper_binary(pamh, NULL, ctrl, name) == PAM_SUCCESS) +- return 1; +- else +- return 0; ++ if (retval == PAM_UNIX_RUN_HELPER) { ++ execloop = 0; ++ if(nonexistent) { ++ get_pwd_hash(pamh, "pam_unix_non_existent:", &pwd, &salt); ++ } ++ /* salt will not be set here so we can return immediately */ ++ if (_unix_run_helper_binary(pamh, NULL, ctrl, name) == PAM_SUCCESS) ++ return 1; ++ else ++ return 0; ++ } else if (retval == PAM_USER_UNKNOWN) { ++ name = "root"; ++ nonexistent = 0; ++ } else { ++ execloop = 0; ++ } + } + + /* Does this user have a password? */ diff --git a/abs/core/pam/pam.tmpfiles b/abs/core/pam/pam.tmpfiles new file mode 100644 index 0000000..f6e490b --- /dev/null +++ b/abs/core/pam/pam.tmpfiles @@ -0,0 +1 @@ +d /run/faillock 0755 root root - diff --git a/abs/core/pam/pam_unix2-glibc216.patch b/abs/core/pam/pam_unix2-glibc216.patch deleted file mode 100644 index faa6a23..0000000 --- a/abs/core/pam/pam_unix2-glibc216.patch +++ /dev/null @@ -1,20 +0,0 @@ -Index: pam_unix2-2.9.1/src/read-files.c -=================================================================== ---- pam_unix2-2.9.1.orig/src/read-files.c -+++ pam_unix2-2.9.1/src/read-files.c -@@ -30,8 +30,14 @@ - #include - #include - #include --#include -+#include - #define __libc_lock_t pthread_mutex_t -+#define __libc_lock_define_initialized(CLASS,NAME) \ -+ CLASS __libc_lock_t NAME = PTHREAD_MUTEX_INITIALIZER; -+#define __libc_lock_lock(NAME) \ -+ pthread_mutex_lock, (&(NAME)) -+#define __libc_lock_unlock(NAME) \ -+ pthread_mutex_unlock, (&(NAME)) - - #include "read-files.h" - -- cgit v0.12