Hello community, here is the log from the commit of package pam-modules for openSUSE:12.1:Update:Test checked in at 2011-12-19 18:23:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:12.1:Update:Test/pam-modules (Old) and /work/SRC/openSUSE:12.1:Update:Test/.pam-modules.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "pam-modules", Maintainer is "[email protected]" Changes: -------- New Changes file: --- /dev/null 2010-08-26 16:28:41.000000000 +0200 +++ /work/SRC/openSUSE:12.1:Update:Test/.pam-modules.new/pam-modules.changes 2011-12-19 18:23:38.000000000 +0100 @@ -0,0 +1,933 @@ +------------------------------------------------------------------- +Thu Sep 22 16:32:32 CEST 2011 - [email protected] + +- Update to pam_unix2 2.9.0: Add support for + /etc/security/uname26.conf, which allows to define a set of + users which will only see kernel 2.6.40 on a linux 3.x system. + +------------------------------------------------------------------- +Wed Aug 31 10:06:03 CEST 2011 - [email protected] + +- unix2_chkpwd should call pam_acct_mgmt (bnc#707645, CVE-2011-3172) +- unix2_chkpwd should only sleep 5 sec on failed logins + +------------------------------------------------------------------- +Thu Jul 7 14:53:44 UTC 2011 - [email protected] + +- add compat mode options to deal with crypt_blowfish signedness bug + (bnc#700876) + +------------------------------------------------------------------- +Wed Jul 6 08:22:49 UTC 2011 - [email protected] + +- use crypt_gensalt_rn from glibc instead of built-in code + +------------------------------------------------------------------- +Wed Jun 29 15:55:13 CEST 2011 - [email protected] + +-Update pam_unix2 to version 2.8.2 + - Fix the last patch + +------------------------------------------------------------------- +Wed May 25 18:11:28 CEST 2011 - [email protected] + +- Update pam_pwcheck to version 3.13 + - work without xcrypt installed + - update translations + +------------------------------------------------------------------- +Wed May 18 16:43:28 CEST 2011 - [email protected] + +- Update pam_unix2 to version 2.8.1 + - better error handling + +------------------------------------------------------------------- +Thu May 12 17:03:31 CEST 2011 - [email protected] + +- Remove pam_make +- Remove xcrypt from BuildRequires + +------------------------------------------------------------------- +Wed May 11 17:16:28 CEST 2011 - [email protected] + +- Update pam_unix2 to version 2.8 + - Remove xcrypt dependency + +------------------------------------------------------------------- +Tue Mar 1 17:17:34 CET 2011 - [email protected] + +- fix pam_unix2 man page (bnc#655138) + +------------------------------------------------------------------- +Tue Mar 1 14:58:41 CET 2011 - [email protected] + +- Update pam_unix2 to version 2.7.5 + - Fix setting of password if no one was set before + +------------------------------------------------------------------- +Wed Aug 11 11:46:42 CEST 2010 - [email protected] + +- Update pam_unix2 to version 2.7.4 + - Minor bugfix in expire handling [bnc#629024] + - Add new translation for gl + - Update translations + +------------------------------------------------------------------- +Sat Dec 12 20:21:54 CET 2009 - [email protected] + +- add baselibs.conf as a source + +------------------------------------------------------------------- +Tue Dec 8 15:30:56 CET 2009 - [email protected] + +- enable parallel building + +------------------------------------------------------------------- +Fri Nov 13 13:07:09 UTC 2009 - [email protected] + +- spec mods + o sorted TAGS + o fixed build for < 1100 + enable_selinux 1 >= 1100 + enable_selinux 0 < 1100 + +------------------------------------------------------------------- +Mon Jul 20 12:01:38 CEST 2009 - [email protected] + +- Update pam_unix2 to version 2.7.3: + - honour locked shadow accounts [bnc#433008] + - Sync passwd/shadow file to disk [bnc#520125] + +------------------------------------------------------------------- +Wed Jun 24 19:25:46 CEST 2009 - [email protected] + +- Supplement pam-32bit/pam-64bit in baselibs.conf (bnc#354164). + +------------------------------------------------------------------- +Mon Jun 15 16:10:22 CEST 2009 - [email protected] + +- Update pam_pwcheck to fix some configure bugs + +------------------------------------------------------------------- +Mon Feb 9 14:59:31 CET 2009 - [email protected] + +- Update translations +- pam_unix2: Fix password change in regard to PRELIM not alwyas + executed. + +------------------------------------------------------------------- +Wed Dec 10 12:34:56 CET 2008 - [email protected] + +- use Obsoletes: -XXbit only for ppc64 to help solver during distupgrade + (bnc#437293) + +------------------------------------------------------------------- +Thu Dec 4 12:34:56 CET 2008 - [email protected] + +- obsolete old -XXbit packages (bnc#437293) + +------------------------------------------------------------------- +Tue Dec 2 16:30:36 CET 2008 - [email protected] + +- let unix2_chkpwd call pam_setcred(PAM_REFRESH_CRED) + (bnc#420060) + +------------------------------------------------------------------- +Fri Nov 21 14:18:46 CET 2008 - [email protected] + +- pam_pwcheck: Fix handling of empty passwords [bnc#447483] + +------------------------------------------------------------------- +Fri Nov 21 12:21:06 CET 2008 - [email protected] + +- Update translations + +------------------------------------------------------------------- +Thu Oct 16 14:08:22 CEST 2008 - [email protected] + +- Workaround for system account locking problem [bnc#435874] + +------------------------------------------------------------------- +Wed Oct 8 14:55:13 CEST 2008 - [email protected] + +- Update pam_unix2 to version 2.7.0: + - Add support for new passwords using SHA256 and SHA512 + - Fix lock account handling for shadow passwords [bnc#433008] + +------------------------------------------------------------------- +Fri Sep 5 12:37:10 CEST 2008 - [email protected] + +- pam_pwcheck 3.12.1: Don't export local symbols [bnc#421921] + +------------------------------------------------------------------- +Thu Sep 4 17:30:41 CEST 2008 - [email protected] + +- pam_pwcheck 3.12: Remove deprecated code + +------------------------------------------------------------------- +Thu Aug 28 17:19:02 CEST 2008 - [email protected] + +- pam_unix2: make session logging more verbose + +------------------------------------------------------------------- +Wed Aug 20 14:59:54 CEST 2008 - [email protected] + +- enabled SELinux support [Fate#303662] + +------------------------------------------------------------------- +Mon Aug 11 17:10:59 CEST 2008 - [email protected] + +- fix password change. Compare stored with entered password + if PAM_CHANGE_EXPIRED_AUTHTOK flag is set. + (bnc#414783) + +------------------------------------------------------------------- +Fri May 23 16:11:56 CEST 2008 - [email protected] + +- Update translations for pam_unix2 and pam_pwcheck + +------------------------------------------------------------------- +Fri Apr 11 11:29:37 CEST 2008 - [email protected] + +- Update pam_unix2 and pam_pwcheck: + - Adjust for new libxcrypt [bnc#378755] + - Update translations + +------------------------------------------------------------------- +Thu Apr 10 12:54:45 CEST 2008 - [email protected] ++++ 736 more lines (skipped) ++++ between /dev/null ++++ and /work/SRC/openSUSE:12.1:Update:Test/.pam-modules.new/pam-modules.changes New: ---- 0001-gettext.diff 0002-change-default-crypt-to-sha512.diff 0003-use-crypt_gensalt_rn-from-glibc.diff 0004-add-workarounds-for-blowfish-signedness-bug.diff 0005-catch-retval-magic-by-ow-crypt-libxcrypt.diff _link baselibs.conf dlopen.sh get_version_number.sh pam-modules.changes pam-modules.spec pam_homecheck-2.0.tar.bz2 pam_pwcheck-3.13.tar.bz2 pam_unix2-2.9.0.tar.bz2 unix2_chkpwd.8 unix2_chkpwd.c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ pam-modules.spec ++++++ # # spec file for package pam-modules # # Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # # norootforbuild %if %{suse_version} >= 1100 %define enable_selinux 1 %else %define enable_selinux 0 %endif Name: pam-modules Summary: Additional PAM Modules Version: 12.1 Release: 1 License: BSD3c ; GPLv2+ Group: System/Libraries AutoReqProv: on # Source0: pam_unix2-2.9.0.tar.bz2 Source1: pam_pwcheck-3.13.tar.bz2 Source2: pam_homecheck-2.0.tar.bz2 Source6: baselibs.conf Source21: unix2_chkpwd.c Source41: unix2_chkpwd.8 Source50: dlopen.sh Patch0: 0001-gettext.diff Patch1: 0002-change-default-crypt-to-sha512.diff Patch2: 0003-use-crypt_gensalt_rn-from-glibc.diff Patch3: 0004-add-workarounds-for-blowfish-signedness-bug.diff Patch4: 0005-catch-retval-magic-by-ow-crypt-libxcrypt.diff # BuildRoot: %{_tmppath}/%{name}-%{version}-build PreReq: permissions BuildRequires: pam-devel BuildRequires: cracklib-devel %if %{enable_selinux} BuildRequires: libselinux-devel %endif # bug437293 %ifarch ppc64 Obsoletes: pam-modules-64bit %endif %description PAM (Pluggable Authentication Modules) is a system security tool that allows system administrators to set authentication policies without having to recompile programs that do authentication. This package contains additional PAM Modules, which are necessary for a working SuSE Linux System: pam_unix2, pam_pwcheck and pam_homecheck %prep %setup -q -c %{name} -b1 -b2 pushd pam_unix2-* %patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 gettextize -f autoreconf -f -i popd %build for i in * ; do cd $i; CFLAGS="$RPM_OPT_FLAGS" ./configure --enable-selinux \ --libdir=/%{_lib} --mandir=%{_mandir} make %{?_smp_mflags} cd .. done gcc -o $RPM_BUILD_DIR/unix2_chkpwd -fpie $RPM_OPT_FLAGS -pie %{SOURCE21} -lpam %install mkdir -p $RPM_BUILD_ROOT/sbin install -m 755 $RPM_BUILD_DIR/unix2_chkpwd $RPM_BUILD_ROOT/sbin/ install -d -m 755 $RPM_BUILD_ROOT%{_libdir} for i in * ; do cd $i; make DESTDIR=$RPM_BUILD_ROOT install cd .. done # # Remove stuff we don't wish to have now: # rm -rf $RPM_BUILD_ROOT/usr/{include,lib} rm -rf $RPM_BUILD_ROOT/%{_lib}/security/*.la # Check for module problems. Specifically, check that every module we just # installed can actually be loaded by a minimal PAM-aware application. for module in $RPM_BUILD_ROOT/%{_lib}/security/pam*.so ; do if ! sh $RPM_SOURCE_DIR/dlopen.sh -lpam -ldl ${module} ; then exit 1 fi done # # Install READMEs of PAM modules # DOC=$RPM_BUILD_ROOT%{_defaultdocdir}/pam mkdir -p $DOC/modules for i in pam_*/README ; do cp -fpv ${i} $DOC/modules/README.`dirname ${i}` done install -m 644 $RPM_SOURCE_DIR/unix2_chkpwd.8 $RPM_BUILD_ROOT%{_mandir}/man8/ # Remove default/passwd file rm $RPM_BUILD_ROOT/etc/default/passwd # Find lang files %{find_lang} pam_unix2 %{find_lang} pam_pwcheck pam_unix2.lang %post %set_permissions /sbin/unix2_chkpwd %clean rm -rf $RPM_BUILD_ROOT %verifyscript %verify_permissions -e /sbin/unix2_chkpwd %files -f pam_unix2.lang %defattr(-,root,root,755) %doc %{_defaultdocdir}/pam #attr(644,root,root) %config(noreplace) /etc/default/passwd %verify(not mode) %attr(4755,root,shadow) /sbin/unix2_chkpwd %attr(755,root,root) /%{_lib}/security/pam_homecheck.so %attr(755,root,root) /%{_lib}/security/pam_pwcheck.so %attr(755,root,root) /%{_lib}/security/pam_unix2.so %attr(644,root,root) %doc %{_mandir}/man8/pam_pwcheck.8.gz %attr(644,root,root) %doc %{_mandir}/man8/pam_unix2.8.gz %attr(644,root,root) %doc %{_mandir}/man8/unix2_chkpwd.8.gz %changelog ++++++ 0001-gettext.diff ++++++ >From 1b5d06d15a082675e841205fcc855ddcbd88b1df Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <[email protected]> Date: Tue, 5 Jul 2011 16:12:51 +0200 Subject: [PATCH 1/4] gettext --- configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index 4a093ea..f4cdcd1 100644 --- a/configure.in +++ b/configure.in @@ -93,7 +93,7 @@ else LDFLAGS="${LDFLAGS} -G" fi -AM_GNU_GETTEXT_VERSION +AM_GNU_GETTEXT_VERSION([0.12]) AM_GNU_GETTEXT([external]) AC_SUBST(LIBPAM) -- 1.7.3.4 ++++++ 0002-change-default-crypt-to-sha512.diff ++++++ >From 81c25a0ddf92dc1568cfbf0e9c3ccb4bd243c1cf Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <[email protected]> Date: Thu, 14 Jul 2011 14:30:11 +0200 Subject: [PATCH 2/4] change default crypt to sha512 also use implicit defaults --- etc/passwd | 35 +++++++++++++++++++++++------------ src/logindefs.c | 2 +- src/unix_passwd.c | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/etc/passwd b/etc/passwd index c14bab5..bd86963 100644 --- a/etc/passwd +++ b/etc/passwd @@ -1,27 +1,38 @@ # This file contains some information for -# the passwd (1) command and other tools +# the passwd (1) command and other tools # creating or modifying passwords. -# Define default crypt hash -# CRYPT={des,md5,blowfish} -CRYPT=des +# Define default crypt hash. +# CRYPT={des,md5,blowfish,sha256,sha512} +CRYPT= -# Use another crypt hash for group passwowrds. +# Use another crypt hash for group passwords. # This is used by gpasswd, fallback is the CRYPT entry. # GROUP_CRYPT=des +# We can override the default for a specific service +# by appending the service name (FILES, YP, NISPLUS, LDAP) + +# for local files, use a more secure hash. We +# don't need to be portable here: +# CRYPT_FILES=sha512 +# +# For NIS, we should always use DES: +# CRYPT_YP=des + # We can override the default for a special service # by appending the service name (FILES, YP, NISPLUS, LDAP) # for local files, use a more secure hash. We # don't need to be portable here: -CRYPT_FILES=blowfish -# sometimes we need to specify special options for -# a hash (variable is prepended by the name of the -# crypt hash). -BLOWFISH_CRYPT_FILES=5 +# CRYPT_FILES=blowfish -# For NIS, we should always use DES: -CRYPT_YP=des +# sometimes we need to specify special options for a hash (variable +# is prepended by the name of the crypt hash). In case of blowfish +# and sha* this is the number of rounds +# blowfish: 4-31 +# BLOWFISH_CRYPT_FILES=5 +# sha256/sha512: 1000-9999999 +# SHA512_CRYPT_FILES=1000 diff --git a/src/logindefs.c b/src/logindefs.c index 452cd7e..2316ae4 100644 --- a/src/logindefs.c +++ b/src/logindefs.c @@ -82,7 +82,7 @@ search (const char *name) while (ptr != NULL) { if (strcasecmp (name, ptr->name) == 0) - return ptr->value; + return *ptr->value?ptr->value:NULL; ptr = ptr->next; } diff --git a/src/unix_passwd.c b/src/unix_passwd.c index c4bec5e..a2e2387 100644 --- a/src/unix_passwd.c +++ b/src/unix_passwd.c @@ -557,7 +557,7 @@ __do_setpass (pam_handle_t *pamh, int flags, user_t *data, if (crypt_str == NULL) { opt_str = "CRYPT"; - crypt_str = getlogindefs_str (opt_str, "DES"); + crypt_str = getlogindefs_str (opt_str, data->service == S_YP?"des":"sha512"); } if (strcasecmp (crypt_str, "des") == 0) -- 1.7.3.4 ++++++ 0003-use-crypt_gensalt_rn-from-glibc.diff ++++++ >From 97692d668c87cf67a80e4e89cf0984924bb276f7 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <[email protected]> Date: Wed, 6 Jul 2011 10:21:04 +0200 Subject: [PATCH 3/4] use crypt_gensalt_rn from glibc --- src/Makefile.am | 2 +- src/crypt_gensalt.c | 375 --------------------------------------------------- src/unix_passwd.c | 8 +- 3 files changed, 3 insertions(+), 382 deletions(-) delete mode 100644 src/crypt_gensalt.c diff --git a/src/Makefile.am b/src/Makefile.am index 46448ae..f2fa4dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,5 +24,5 @@ pam_unix2_so_LDFLAGS = -Wl,-soname,pam_unix2.so \ pam_unix2_so_SOURCES = passwd_nss.c unix_acct.c get_options.c \ unix_passwd.c yppasswd_xdr.c support.c \ unix_auth.c unix_sess.c read-files.c getuser.c copy_xattr.c \ - selinux_utils.c logindefs.c crypt_gensalt.c + selinux_utils.c logindefs.c diff --git a/src/crypt_gensalt.c b/src/crypt_gensalt.c deleted file mode 100644 index 0c63edc..0000000 --- a/src/crypt_gensalt.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Written by Solar Designer and placed in the public domain. - * See crypt_blowfish.c for more information. - * - * This file contains salt generation functions for the traditional and - * other common crypt(3) algorithms, except for bcrypt which is defined - * entirely in crypt_blowfish.c. - */ - - -#if defined(HAVE_CONFIG_H) -#include "config.h" -#endif - -#include <string.h> -#include <stdlib.h> -#include <stdio.h> - -#include <errno.h> -#ifndef __set_errno -#define __set_errno(val) errno = (val) -#endif - -#undef __CONST -#ifdef __GNUC__ -#define __CONST __const -#else -#define __CONST -#endif - -static unsigned char _xcrypt_itoa64[64 + 1] = - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -static char *_xcrypt_gensalt_traditional_rn(unsigned long count, - __CONST char *input, int size, char *output, int output_size) -{ - if (size < 2 || output_size < 2 + 1 || (count && count != 25)) { - if (output_size > 0) output[0] = '\0'; - __set_errno((output_size < 2 + 1) ? ERANGE : EINVAL); - return NULL; - } - - output[0] = _xcrypt_itoa64[(unsigned int)input[0] & 0x3f]; - output[1] = _xcrypt_itoa64[(unsigned int)input[1] & 0x3f]; - output[2] = '\0'; - - return output; -} - -static char *_xcrypt_gensalt_extended_rn(unsigned long count, - __CONST char *input, int size, char *output, int output_size) -{ - unsigned long value; - -/* Even iteration counts make it easier to detect weak DES keys from a look - * at the hash, so they should be avoided */ - if (size < 3 || output_size < 1 + 4 + 4 + 1 || - (count && (count > 0xffffff || !(count & 1)))) { - if (output_size > 0) output[0] = '\0'; - __set_errno((output_size < 1 + 4 + 4 + 1) ? ERANGE : EINVAL); - return NULL; - } - - if (!count) count = 725; - - output[0] = '_'; - output[1] = _xcrypt_itoa64[count & 0x3f]; - output[2] = _xcrypt_itoa64[(count >> 6) & 0x3f]; - output[3] = _xcrypt_itoa64[(count >> 12) & 0x3f]; - output[4] = _xcrypt_itoa64[(count >> 18) & 0x3f]; - value = (unsigned long)(unsigned char)input[0] | - ((unsigned long)(unsigned char)input[1] << 8) | - ((unsigned long)(unsigned char)input[2] << 16); - output[5] = _xcrypt_itoa64[value & 0x3f]; - output[6] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - output[7] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - output[8] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - output[9] = '\0'; - - return output; -} - -static char * -_xcrypt_gensalt_md5_rn (unsigned long count __attribute__((unused)), - const char *input, int size, - char *output, int output_size) -{ - unsigned long value; - - if (size < 3 || output_size < 3 + 4 + 1) - { - if (output_size > 0) - output[0] = '\0'; - errno = ERANGE; - return NULL; - } - - output[0] = '$'; - output[1] = '1'; - output[2] = '$'; - value = (unsigned long)(unsigned char)input[0] | - ((unsigned long)(unsigned char)input[1] << 8) | - ((unsigned long)(unsigned char)input[2] << 16); - output[3] = _xcrypt_itoa64[value & 0x3f]; - output[4] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - output[5] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - output[6] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - output[7] = '\0'; - - if (size >= 6 && output_size >= 3 + 4 + 4 + 1) { - value = (unsigned long)(unsigned char)input[3] | - ((unsigned long)(unsigned char)input[4] << 8) | - ((unsigned long)(unsigned char)input[5] << 16); - output[7] = _xcrypt_itoa64[value & 0x3f]; - output[8] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - output[9] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - output[10] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - output[11] = '\0'; - } - - return output; -} - -static char * -_xcrypt_gensalt_sha256_rn (unsigned long count, const char *input, int size, - char *output, int output_size) -{ - unsigned long value; - char *buf; - char buf2[12]; - - if (count > 0) - { - if (asprintf (&buf, "$5$rounds=%ld$", count) < 0) - { - if (output_size > 0) - output[0] = '\0'; - errno = ENOMEM; - return NULL; - } - } - else - { - if (asprintf (&buf, "$5$") < 0) - { - if (output_size > 0) - output[0] = '\0'; - errno = ENOMEM; - return NULL; - } - } - - if (size < 3 || output_size < (int)strlen (buf) + 4 + 1) - { - free (buf); - if (output_size > 0) - output[0] = '\0'; - errno = ERANGE; - return NULL; - } - - value = (unsigned long)(unsigned char)input[0] | - ((unsigned long)(unsigned char)input[1] << 8) | - ((unsigned long)(unsigned char)input[2] << 16); - buf2[0] = _xcrypt_itoa64[value & 0x3f]; - buf2[1] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - buf2[2] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - buf2[3] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - buf2[4] = '\0'; - - if (size >= 6 && output_size >= (int)strlen (buf) + 4 + 4 + 1) - { - value = (unsigned long)(unsigned char)input[3] | - ((unsigned long)(unsigned char)input[4] << 8) | - ((unsigned long)(unsigned char)input[5] << 16); - buf2[4] = _xcrypt_itoa64[value & 0x3f]; - buf2[5] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - buf2[6] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - buf2[7] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - buf2[8] = '\0'; - } - - snprintf (output, output_size, "%s%s", buf, buf2); - free (buf); - - return output; -} - -static char * -_xcrypt_gensalt_sha512_rn (unsigned long count, const char *input, int size, - char *output, int output_size) -{ - unsigned long value; - char *buf; - char buf2[12]; - - if (count > 0) - { - if (asprintf (&buf, "$6$rounds=%ld$", count) < 0) - { - if (output_size > 0) - output[0] = '\0'; - errno = ENOMEM; - return NULL; - } - } - else - { - if (asprintf (&buf, "$6$") < 0) - { - if (output_size > 0) - output[0] = '\0'; - errno = ENOMEM; - return NULL; - } - } - - if (size < 3 || output_size < (int)strlen (buf) + 4 + 1) - { - free (buf); - if (output_size > 0) - output[0] = '\0'; - __set_errno(ERANGE); - return NULL; - } - - value = (unsigned long)(unsigned char)input[0] | - ((unsigned long)(unsigned char)input[1] << 8) | - ((unsigned long)(unsigned char)input[2] << 16); - buf2[0] = _xcrypt_itoa64[value & 0x3f]; - buf2[1] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - buf2[2] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - buf2[3] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - buf2[4] = '\0'; - - if (size >= 6 && output_size >= (int)strlen (buf) + 4 + 4 + 1) - { - value = (unsigned long)(unsigned char)input[3] | - ((unsigned long)(unsigned char)input[4] << 8) | - ((unsigned long)(unsigned char)input[5] << 16); - buf2[4] = _xcrypt_itoa64[value & 0x3f]; - buf2[5] = _xcrypt_itoa64[(value >> 6) & 0x3f]; - buf2[6] = _xcrypt_itoa64[(value >> 12) & 0x3f]; - buf2[7] = _xcrypt_itoa64[(value >> 18) & 0x3f]; - buf2[8] = '\0'; - } - - snprintf (output, output_size, "%s%s", buf, buf2); - free (buf); - - return output; -} - -typedef unsigned int BF_word; -static unsigned char BF_itoa64[64 + 1] = - "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - -static void -BF_encode (char *dst, __CONST BF_word *src, int size) -{ - const unsigned char *sptr = (const unsigned char *)src; - const unsigned char *end = sptr + size; - unsigned char *dptr = (unsigned char *)dst; - unsigned int c1, c2; - - do { - c1 = *sptr++; - *dptr++ = BF_itoa64[c1 >> 2]; - c1 = (c1 & 0x03) << 4; - if (sptr >= end) { - *dptr++ = BF_itoa64[c1]; - break; - } - - c2 = *sptr++; - c1 |= c2 >> 4; - *dptr++ = BF_itoa64[c1]; - c1 = (c2 & 0x0f) << 2; - if (sptr >= end) { - *dptr++ = BF_itoa64[c1]; - break; - } - - c2 = *sptr++; - c1 |= c2 >> 6; - *dptr++ = BF_itoa64[c1]; - *dptr++ = BF_itoa64[c2 & 0x3f]; - } while (sptr < end); -} - -static char * -_xcrypt_gensalt_blowfish_rn (unsigned long count, __CONST char *input, - int size, char *output, int output_size) -{ - if (size < 16 || output_size < 7 + 22 + 1 || - (count && (count < 4 || count > 31))) { - if (output_size > 0) output[0] = '\0'; - __set_errno((output_size < 7 + 22 + 1) ? ERANGE : EINVAL); - return NULL; - } - - if (!count) count = 5; - - output[0] = '$'; - output[1] = '2'; - output[2] = 'a'; - output[3] = '$'; - output[4] = '0' + count / 10; - output[5] = '0' + count % 10; - output[6] = '$'; - - BF_encode(&output[7], (const unsigned int *)input, 16); - output[7 + 22] = '\0'; - - return output; -} - - - -char * -crypt_gensalt_r (__const char *prefix, unsigned long count, - __const char *input, int size, char *output, - int output_size) -{ - char *(*use) (unsigned long count, - __const char *input, int size, char *output, int output_size); - - /* This may be supported on some platforms in the future */ - if (!input) - { - __set_errno (EINVAL); - return NULL; - } - - if (prefix[0] == '$') - { - char *hash_id = strdup (&prefix[1]); - char *c = strchr (hash_id, '$'); - - if (c == NULL) - { - free (hash_id); - return NULL; - } - - *c = '\0'; - - if (hash_id[0] == '1') /* md5 */ - use = _xcrypt_gensalt_md5_rn; - else if (hash_id[0] == '2' && hash_id[1] == 'a') /* blowfish */ - use = _xcrypt_gensalt_blowfish_rn; - else if (hash_id[0] == '5') /* sha256 */ - use = _xcrypt_gensalt_sha256_rn; - else if (hash_id[0] == '6') /* sha512 */ - use = _xcrypt_gensalt_sha512_rn; - else - use = _xcrypt_gensalt_traditional_rn; - - free (hash_id); - } - else if (prefix[0] == '_') - use = _xcrypt_gensalt_extended_rn; - else if (!prefix[0] || - (prefix[0] && prefix[1] && - memchr (_xcrypt_itoa64, prefix[0], 64) && - memchr (_xcrypt_itoa64, prefix[1], 64))) - use = _xcrypt_gensalt_traditional_rn; - else - { - __set_errno (EINVAL); - return NULL; - } - - return use (count, input, size, output, output_size); -} diff --git a/src/unix_passwd.c b/src/unix_passwd.c index a2e2387..8491adf 100644 --- a/src/unix_passwd.c +++ b/src/unix_passwd.c @@ -63,6 +63,7 @@ #endif #if defined(HAVE_CRYPT_H) +#define _OW_SOURCE #include <crypt.h> #endif @@ -87,11 +88,6 @@ static int __do_setpass (pam_handle_t *pamh, int flags, user_t *user, options_t *options, struct crypt_data *output); -extern char * -crypt_gensalt_r (__const char *prefix, unsigned long count, - __const char *input, int size, char *output, - int output_size); - PAM_EXTERN int pam_sm_chauthtok (pam_handle_t *pamh, int flags, int argc, const char **argv) { @@ -502,7 +498,7 @@ make_crypt_salt (const char *crypt_prefix, int crypt_rounds, close (fd); - retval = crypt_gensalt_r (crypt_prefix, crypt_rounds, entropy, + retval = crypt_gensalt_rn (crypt_prefix, crypt_rounds, entropy, sizeof (entropy), output, sizeof(output)); memset (entropy, 0, sizeof (entropy)); -- 1.7.3.4 ++++++ 0004-add-workarounds-for-blowfish-signedness-bug.diff ++++++ >From 7a3e5fd2d79657674e72212ad13ea350d72e8306 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <[email protected]> Date: Wed, 13 Jul 2011 08:50:58 +0200 Subject: [PATCH 4/4] add workarounds for blowfish signedness bug The option BLOWFISH_2a2x allows to enable compat modes. --- configure.in | 18 +++++++++++++++++- etc/passwd | 16 ++++++++++++++++ src/get_options.c | 11 +++++++++++ src/public.h | 4 ++++ src/support.c | 30 ++++++++++++++++++++++++++++++ src/unix_auth.c | 8 +------- src/unix_passwd.c | 10 +++++++--- 7 files changed, 86 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index f4cdcd1..10c4e1f 100644 --- a/configure.in +++ b/configure.in @@ -48,13 +48,29 @@ dnl Should we compile with SELinux support? default: yes AC_ARG_ENABLE([selinux], AC_HELP_STRING([--disable-selinux],[Enable SELinux support (default=yes)]), WITH_SELINUX=$enableval, WITH_SELINUX=yes) -if test "$WITH_SELINUX" == "yes" ; then +if test "$WITH_SELINUX" = "yes" ; then AC_CHECK_LIB(selinux,is_selinux_enabled, [AC_DEFINE(WITH_SELINUX,1, [Define if you want to compile in SELinux support]) LIBS="$LIBS -lselinux"]) fi +AC_ARG_ENABLE([blowfish-bug-workaround], + AC_HELP_STRING([--disable-blowfish-bug-workaround],[Enable workarounds for blowfish signedness bug]), + CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS=$enableval, CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS=yes) +if test "$CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS" = "yes" ; then + AC_DEFINE(CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS,1, + [Define if you want to enable workarounds for blowfish signedness bug]) +fi + +AC_ARG_ENABLE([blowfish-bug-compatmode], + AC_HELP_STRING([--enable-blowfish-bug-compatmode],[Enable blowfish compat mode by default]), + CRYPT_BLOWFISH_COMPATMODE=$enableval, CRYPT_BLOWFISH_COMPATMODE=no) +if test "$CRYPT_BLOWFISH_COMPATMODE" = "yes" ; then + AC_DEFINE(CRYPT_BLOWFISH_COMPATMODE,1, + [Define if you want to enable blowfish compat mode by default]) +fi + dnl Check standard headers AC_HEADER_STDC AC_CHECK_HEADERS(crypt.h) diff --git a/etc/passwd b/etc/passwd index bd86963..ec6f0d4 100644 --- a/etc/passwd +++ b/etc/passwd @@ -36,3 +36,19 @@ CRYPT= # sha256/sha512: 1000-9999999 # SHA512_CRYPT_FILES=1000 +# In June 2011 it was discovered that the Linux crypt_blowfish +# implementation contained a bug that made passwords with non-ASCII +# characters easier to crack (CVE-2011-2483). Affected passwords are +# also incompatible with the original, correct OpenBSD +# implementation. Therefore the $2a hash identifier previously used +# for blowfish now is ambiguous as it could mean the hash was +# generated with the correct implementation on OpenBSD or the buggy +# one on Linux. To avoid the ambiguity two new identifier were +# introduced. $2x now explicitly identifies hashes that were +# generated with the buggy algorithm while $2y is used for hashes +# generated with the correct algorithm. New passwords are now +# generated with the $2y identifier. +# +# Setting the following option to "yes" tells the sytem that $2a +# hashes are to be treated as generated with the buggy algorithm. +BLOWFISH_2a2x= diff --git a/src/get_options.c b/src/get_options.c index faf8aa0..f899155 100644 --- a/src/get_options.c +++ b/src/get_options.c @@ -138,6 +138,17 @@ get_options (pam_handle_t *pamh, options_t *options, const char *type, /* Set some default values, which could be overwritten later. */ options->use_crypt = NONE; +#ifdef CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS + options->blowfish_2a2x = getlogindefs_bool("BLOWFISH_2a2x", +#ifdef CRYPT_BLOWFISH_COMPATMODE + 1 +#else + 0 +#endif + ); + free_getlogindefs_data(); +#endif + /* Parse parameters for module */ for ( ; argc-- > 0; argv++) parse_option (pamh, *argv, type, options); diff --git a/src/public.h b/src/public.h index 7200759..ec476b8 100644 --- a/src/public.h +++ b/src/public.h @@ -68,6 +68,7 @@ struct options_t { int nullok; int use_authtok; int use_first_pass; + int blowfish_2a2x; char **use_other_modules; char *nisdir; crypt_t use_crypt; @@ -86,6 +87,9 @@ extern int __call_other_module(pam_handle_t * pamh, int flags, const char *mod_name, const char *func_name, options_t *options); +extern int __check_password_match (const char *hash, const char *pass, + options_t *options); + extern int get_options (pam_handle_t *pamh, options_t *options, const char *type, int argc, const char **argv); diff --git a/src/support.c b/src/support.c index 6a1ce5e..b3b94c8 100644 --- a/src/support.c +++ b/src/support.c @@ -48,6 +48,11 @@ #include <security/pam_ext.h> #endif +#if defined(HAVE_CRYPT_H) +#define _OW_SOURCE +#include <crypt.h> +#endif + #include "public.h" int @@ -360,3 +365,28 @@ struct pam_module _pam_unix2_modstruct = pam_sm_chauthtok }; #endif + +int +__check_password_match (const char *hash, const char *pass, options_t *options) +{ + struct crypt_data output; + char *h = NULL; + int r; + + memset (&output, 0, sizeof (output)); + +#ifdef CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS + if ((options->blowfish_2a2x) + && !strncmp(hash, "$2a$", 4)) + { + h = strdupa(hash); + h[2] = 'x'; + hash = h; + } +#endif + + r = (strcmp (hash, crypt_r (pass, hash, &output)) == 0); + if (h) + _pam_overwrite(h); + return r; +} diff --git a/src/unix_auth.c b/src/unix_auth.c index e61c45e..e78c520 100644 --- a/src/unix_auth.c +++ b/src/unix_auth.c @@ -61,10 +61,6 @@ #include <security/pam_ext.h> #endif -#if defined(HAVE_CRYPT_H) -#include <crypt.h> -#endif - #include "public.h" @@ -124,7 +120,6 @@ int pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, const char **argv) { - struct crypt_data output; int retval; int sp_buflen = 256; char *sp_buffer = alloca (sp_buflen); @@ -141,7 +136,6 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, options_t options; int ask_user, ask_password; - memset (&output, 0, sizeof (output)); memset (&options, 0, sizeof (options)); if (get_options (pamh, &options, "auth", argc, argv) < 0) @@ -325,7 +319,7 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, *cp = '\0'; } - if (strcmp (crypt_r (password, salt, &output), salt) != 0) + if (!__check_password_match(salt, password, &options)) { if (options.debug) pam_syslog (pamh, LOG_DEBUG, "wrong password, return PAM_AUTH_ERR"); diff --git a/src/unix_passwd.c b/src/unix_passwd.c index 8491adf..e00615b 100644 --- a/src/unix_passwd.c +++ b/src/unix_passwd.c @@ -257,8 +257,7 @@ pam_sm_chauthtok (pam_handle_t *pamh, int flags, int argc, const char **argv) /* Check if the old password was correct. */ if ((getuid () || (flags & PAM_CHANGE_EXPIRED_AUTHTOK)) && - strcmp (data->oldpassword, - crypt_r (oldpass, data->oldpassword, &output)) != 0) + !__check_password_match(data->oldpassword, oldpass, &options)) { if (options.debug) pam_syslog (pamh, LOG_DEBUG, @@ -686,7 +685,12 @@ __do_setpass (pam_handle_t *pamh, int flags, user_t *data, case BLOWFISH: salt = make_crypt_salt ("$2a$", options->crypt_rounds, pamh, flags); if (salt != NULL) - newpassword = crypt_r (data->newpassword, salt, output); + { +#ifdef CRYPT_BLOWFISH_SIGNEDNESS_BUG_WORKAROUNDS + salt[2] = 'y'; +#endif + newpassword = crypt_r (data->newpassword, salt, output); + } else { __write_message (pamh, flags, PAM_ERROR_MSG, -- 1.7.3.4 ++++++ 0005-catch-retval-magic-by-ow-crypt-libxcrypt.diff ++++++ >From f0e1dcc08789da62c26236e3bc0e3b68ba6d0fd0 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <[email protected]> Date: Wed, 20 Jul 2011 11:16:56 +0200 Subject: [PATCH pam_unix2] catch retval magic by ow-crypt/libxcrypt Instead of returning NULL ow-crypt's retval magic returns "*0" or "*1". --- src/unix_passwd.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/unix_passwd.c b/src/unix_passwd.c index e00615b..80319d7 100644 --- a/src/unix_passwd.c +++ b/src/unix_passwd.c @@ -729,7 +729,9 @@ __do_setpass (pam_handle_t *pamh, int flags, user_t *data, options->use_crypt); return PAM_AUTHTOK_ERR; } - if (newpassword == NULL) + if (newpassword == NULL + /* catch retval magic by ow-crypt/libxcrypt */ + || !strcmp(newpassword, "*0") || !strcmp(newpassword, "*1")) { __write_message (pamh, flags, PAM_ERROR_MSG, _("crypt_r() returns NULL pointer")); -- 1.7.3.4 ++++++ _link ++++++ <link project="openSUSE:12.1" package="pam-modules" baserev="46688f097d439bbe101586e3c3a2db6e"> <patches> <branch/> </patches> </link> ++++++ baselibs.conf ++++++ pam-modules supplements "packageand(pam-modules:pam-<targettype>)" ++++++ dlopen.sh ++++++ #!/bin/sh tempdir=`mktemp -d /tmp/dlopenXXXXXX` test -n "$tempdir" || exit 1 cat >> $tempdir/dlopen.c << _EOF #include <dlfcn.h> #include <stdio.h> #include <limits.h> #include <sys/stat.h> /* Simple program to see if dlopen() would succeed. */ int main(int argc, char **argv) { int i; struct stat st; char buf[PATH_MAX]; for (i = 1; i < argc; i++) { if (dlopen(argv[i], RTLD_NOW)) { fprintf(stdout, "dlopen() of \"%s\" succeeded.\n", argv[i]); } else { snprintf(buf, sizeof(buf), "./%s", argv[i]); if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) { fprintf(stdout, "dlopen() of \"./%s\" " "succeeded.\n", argv[i]); } else { fprintf(stdout, "dlopen() of \"%s\" failed: " "%s\n", argv[i], dlerror()); return 1; } } } return 0; } _EOF for arg in $@ ; do case "$arg" in "") ;; -I*|-D*|-f*|-m*|-g*|-O*|-W*) cflags="$cflags $arg" ;; -l*) ldflags="$ldflags $arg" ;; /*) modules="$modules $arg" ;; *) modules="$modules $arg" ;; esac done ${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags -ldl retval=0 for module in $modules ; do case "$module" in "") ;; /*) $tempdir/dlopen "$module" retval=$? ;; *) $tempdir/dlopen ./"$module" retval=$? ;; esac done rm -f $tempdir/dlopen $tempdir/dlopen.c rmdir $tempdir exit $retval ++++++ get_version_number.sh ++++++ echo ${BUILD_DISTRIBUTION_VERSION%-*} ++++++ unix2_chkpwd.8 ++++++ .\" Copyright (C) 2003 International Business Machines Corporation .\" This file is distributed according to the GNU General Public License. .\" See the file COPYING in the top level source directory for details. .\" .de Sh \" Subsection .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Ip \" List item .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .TH "UNIX2_CHKPWD" 8 "2003-03-21" "Linux-PAM 0.76" "Linux-PAM Manual" .SH NAME unix2_chkpwd \- helper binary that verifies the password of the current user .SH "SYNOPSIS" .ad l .hy 0 /sbin/unix2_chkpwd \fIservicename\fR \fIusername\fR .sp .ad .hy .SH "DESCRIPTION" .PP \fBunix2_chkpwd\fR is a helper program for applications that verifies the password of the current user. It is not intended to be run directly from the command line and logs a security violation if done so. It is typically installed setuid root or setgid shadow and called by applications, which only wishes to do an user authentification and nothing more. .SH "OPTIONS" .PP unix2_pwdchk requires the following arguments: .TP \fIpam_service\fR The name of the service using unix2_chkpwd. This is required to be one of the services in /etc/pam.d .TP \fIusername\fR The name of the user whose password you want to verify. .SH "INPUTS" .PP unix2_pwdchk expects the password via stdin. .SH "RETURN CODES" .PP \fBunix2_chkpwd\fR has the following return codes: .TP 1 unix2_chkpwd was inappropriately called from the command line or the password is incorrect. .TP 0 The password is correct. .SH "HISTORY" Written by Olaf Kirch loosely based on unix_chkpwd by Andrew Morgan .SH "SEE ALSO" .PP \fBpam\fR(8) .SH AUTHOR Emily Ratliff. ++++++ unix2_chkpwd.c ++++++ /* * Set*id helper program for PAM authentication. * * It is supposed to be called from pam_unix2's * pam_sm_authenticate function if the function notices * that it's unable to get the password from the shadow file * because it doesn't have sufficient permissions. * * Copyright (C) 2002 SuSE Linux AG * * Written by [email protected], loosely based on unix_chkpwd * by Andrew Morgan. */ #include <security/pam_appl.h> #include <security/_pam_macros.h> #include <sys/types.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> #include <pwd.h> #include <signal.h> #include <fcntl.h> #include <ctype.h> enum { UNIX_PASSED = 0, UNIX_FAILED = 1 }; static char * program_name; static char pass[64]; static int npass = -1; /* * Log error messages */ static void _log_err(int err, const char *format,...) { va_list args; va_start(args, format); openlog(program_name, LOG_CONS | LOG_PID, LOG_AUTH); vsyslog(err, format, args); va_end(args); closelog(); } static void su_sighandler(int sig) { if (sig > 0) { _log_err(LOG_NOTICE, "caught signal %d.", sig); exit(sig); } } /* * Setup signal handlers */ static void setup_signals(void) { struct sigaction action; memset((void *) &action, 0, sizeof(action)); action.sa_handler = su_sighandler; action.sa_flags = SA_RESETHAND; sigaction(SIGILL, &action, NULL); sigaction(SIGTRAP, &action, NULL); sigaction(SIGBUS, &action, NULL); sigaction(SIGSEGV, &action, NULL); action.sa_handler = SIG_IGN; action.sa_flags = 0; sigaction(SIGTERM, &action, NULL); sigaction(SIGHUP, &action, NULL); sigaction(SIGINT, &action, NULL); sigaction(SIGQUIT, &action, NULL); sigaction(SIGALRM, &action, NULL); } static int _converse(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { struct pam_response *reply; int num; if (!(reply = malloc(sizeof(*reply) * num_msg))) return PAM_CONV_ERR; for (num = 0; num < num_msg; num++) { reply[num].resp_retcode = PAM_SUCCESS; reply[num].resp = NULL; switch (msg[num]->msg_style) { case PAM_PROMPT_ECHO_ON: return PAM_CONV_ERR; case PAM_PROMPT_ECHO_OFF: /* read the password from stdin */ if (npass < 0) { npass = read(STDIN_FILENO, pass, sizeof(pass)-1); if (npass < 0) { _log_err(LOG_DEBUG, "error reading password"); return UNIX_FAILED; } pass[npass] = '\0'; } reply[num].resp = strdup(pass); break; case PAM_TEXT_INFO: case PAM_ERROR_MSG: /* ignored */ break; default: /* Must be an error of some sort... */ return PAM_CONV_ERR; } } *resp = reply; return PAM_SUCCESS; } static int _authenticate(const char *service, const char *user) { struct pam_conv conv = { _converse, NULL }; pam_handle_t *pamh; int err; err = pam_start(service, user, &conv, &pamh); if (err != PAM_SUCCESS) { _log_err(LOG_ERR, "pam_start(%s, %s) failed (errno %d)", service, user, err); return UNIX_FAILED; } err = pam_authenticate(pamh, 0); if (err != PAM_SUCCESS) _log_err(LOG_ERR, "pam_authenticate(%s, %s): %s", service, user, pam_strerror(pamh, err)); if (err == PAM_SUCCESS) { err = pam_acct_mgmt(pamh, 0); if (err == PAM_SUCCESS) { int err2 = pam_setcred(pamh, PAM_REFRESH_CRED); if (err2 != PAM_SUCCESS) _log_err(LOG_ERR, "pam_setcred(%s, %s): %s", service, user, pam_strerror(pamh, err2)); /* * ignore errors on refresh credentials. * If this did not work we use the old once. */ } else { _log_err(LOG_ERR, "pam_acct_mgmt(%s, %s): %s", service, user, pam_strerror(pamh, err)); } } pam_end(pamh, err); if (err != PAM_SUCCESS) return UNIX_FAILED; return UNIX_PASSED; } static char * getuidname(uid_t uid) { struct passwd *pw; static char username[32]; pw = getpwuid(uid); if (pw == NULL) return NULL; strncpy(username, pw->pw_name, sizeof(username)); username[sizeof(username) - 1] = '\0'; endpwent(); return username; } static int sane_pam_service(const char *name) { const char *sp; char path[128]; if (strlen(name) > 32) return 0; for (sp = name; *sp; sp++) { if (!isalnum(*sp) && *sp != '_' && *sp != '-') return 0; } snprintf(path, sizeof(path), "/etc/pam.d/%s", name); return access(path, R_OK) == 0; } int main(int argc, char *argv[]) { const char *program_name; char *service, *user; int fd; int result = UNIX_FAILED; uid_t uid; uid = getuid(); /* * Make sure standard file descriptors are connected. */ while ((fd = open("/dev/null", O_RDWR)) <= 2) ; close(fd); /* * Get the program name */ if (argc == 0) program_name = "unix2_chkpwd"; else if ((program_name = strrchr(argv[0], '/')) != NULL) program_name++; else program_name = argv[0]; /* * Catch or ignore as many signal as possible. */ setup_signals(); /* * Check argument list */ if (argc < 2 || argc > 3) { _log_err(LOG_NOTICE, "Bad number of arguments (%d)", argc); return UNIX_FAILED; } /* * Get the service name and do some sanity checks on it */ service = argv[1]; if (!sane_pam_service(service)) { _log_err(LOG_ERR, "Illegal service name '%s'", service); return UNIX_FAILED; } /* * Discourage users messing around (fat chance) */ if (isatty(STDIN_FILENO) && uid != 0) { _log_err(LOG_NOTICE, "Inappropriate use of Unix helper binary [UID=%d]", uid); fprintf(stderr, "This binary is not designed for running in this way\n" "-- the system administrator has been informed\n"); sleep(10); /* this should discourage/annoy the user */ return UNIX_FAILED; } /* * determine the caller's user name */ user = getuidname(uid); if (argc == 3 && strcmp(user, argv[2])) { user = argv[2]; } result = _authenticate(service, user); /* Discourage use of this program as a * password cracker */ usleep(500000); if (result != UNIX_PASSED && uid != 0) sleep(5); return result; } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
