--- eclass/pam.eclass 2005/05/20 11:58:32 1.1 +++ eclass/pam.eclass 2005/11/30 09:59:31 1.1.1.1 @@ -1,14 +1,12 @@ # Copyright 2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later # Author Diego Pettenò -# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.1 2005/05/20 11:58:32 flameeyes Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.1.1.1 2005/11/30 09:59:31 chriswhite Exp $ # # This eclass contains functions to install pamd configuration files and # pam modules. inherit multilib -ECLASS="pam" -INHERITED="$INHERITED $ECLASS" # dopamd [more files] # @@ -20,8 +18,10 @@ return 0; fi - insinto /etc/pam.d + INSDESTTREE=/etc/pam.d \ + INSOPTIONS="-m 0644" \ doins "$@" || die "failed to install $@" + cleanpamd "$@" } # newpamd @@ -34,8 +34,10 @@ return 0; fi - insinto /etc/pam.d + INSDESTTREE=/etc/pam.d \ + INSOPTIONS="-m 0644" \ newins "$1" "$2" || die "failed to install $1 as $2" + cleanpamd $2 } # dopamsecurity
[more files] @@ -48,9 +50,9 @@ return 0; fi - insinto /etc/security/$1 - shift - doins "$@" || die "failed to install $@" + INSDESTTREE=/etc/security/$1 \ + INSOPTIONS="-m 0644" \ + doins "${@:2}" || die "failed to install ${@:2}" } # newpamsecurity
@@ -63,7 +65,8 @@ return 0; fi - insinto /etc/security/$1 + INSDESTTREE=/etc/security/$1 \ + INSOPTIONS="-m 0644" \ newins "$2" "$3" || die "failed to install $2 as $3" } @@ -71,10 +74,11 @@ # # Returns the pam modules' directory for current implementation getpam_mod_dir() { - if has_version sys-libs/pam; then + if has_version sys-libs/pam || has_version sys-libs/openpam; then PAM_MOD_DIR=/$(get_libdir)/security - elif has_version sys-libs/openpam; then - PAM_MOD_DIR=/usr/$(get_libdir) + elif use ppc-macos; then + # OSX looks there for pam modules + PAM_MOD_DIR=/usr/lib/pam else # Unable to find PAM implementation... defaulting PAM_MOD_DIR=/$(get_libdir)/security @@ -127,18 +131,36 @@ pamdfile=${D}/etc/pam.d/$1 echo -e "# File autogenerated by pamd_mimic_system in pam eclass\n\n" >> \ $pamdfile - + authlevels="auth account password session" + if has_version '> ${pamdfile} + echo -e "$1${mimic}" >> ${pamdfile} shift done +} + +# cleanpamd +# +# Cleans a pam.d file from modules that might not be present on the system +# where it's going to be installed +cleanpamd() { + while [[ -n $1 ]]; do + if ! has_version sys-libs/pam; then + sed -i -e '/pam_shells\|pam_console/s:^:#:' ${D}/etc/pam.d/$1 + fi - return 1 + shift + done }