/[gentoo-x86]/eclass/pam.eclass
Gentoo

Diff of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.9
1# Copyright 2004 Gentoo Foundation 1# Copyright 2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License, v2 or later
3# Author Diego Pettenò <flameeyes@gentoo.org> 3# Author Diego Pettenò <flameeyes@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.3 2005/05/20 15:54:34 flameeyes Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.9 2005/09/09 10:31:35 flameeyes Exp $
5# 5#
6# This eclass contains functions to install pamd configuration files and 6# This eclass contains functions to install pamd configuration files and
7# pam modules. 7# pam modules.
8 8
9inherit multilib 9inherit multilib
10ECLASS="pam"
11INHERITED="$INHERITED $ECLASS"
12 10
13# dopamd <file> [more files] 11# dopamd <file> [more files]
14# 12#
15# Install pam auth config file in /etc/pam.d 13# Install pam auth config file in /etc/pam.d
16dopamd() { 14dopamd() {
20 return 0; 18 return 0;
21 fi 19 fi
22 20
23 INSDESTTREE=/etc/pam.d \ 21 INSDESTTREE=/etc/pam.d \
24 doins "$@" || die "failed to install $@" 22 doins "$@" || die "failed to install $@"
23 cleanpamd "$@"
25} 24}
26 25
27# newpamd <old name> <new name> 26# newpamd <old name> <new name>
28# 27#
29# Install pam file <old name> as <new name> in /etc/pam.d 28# Install pam file <old name> as <new name> in /etc/pam.d
34 return 0; 33 return 0;
35 fi 34 fi
36 35
37 INSDESTTREE=/etc/pam.d \ 36 INSDESTTREE=/etc/pam.d \
38 newins "$1" "$2" || die "failed to install $1 as $2" 37 newins "$1" "$2" || die "failed to install $1 as $2"
38 cleanpamd $2
39} 39}
40 40
41# dopamsecurity <section> <file> [more files] 41# dopamsecurity <section> <file> [more files]
42# 42#
43# Installs the config files in /etc/security/<section>/ 43# Installs the config files in /etc/security/<section>/
47 if hasq pam ${IUSE} && ! use pam; then 47 if hasq pam ${IUSE} && ! use pam; then
48 return 0; 48 return 0;
49 fi 49 fi
50 50
51 INSDESTTREE=/etc/security/$1 \ 51 INSDESTTREE=/etc/security/$1 \
52 shift
53 doins "$@" || die "failed to install $@" 52 doins "${@:2}" || die "failed to install ${@:2}"
54} 53}
55 54
56# newpamsecurity <section> <old name> <new name> 55# newpamsecurity <section> <old name> <new name>
57# 56#
58# Installs the config file <old name> as <new name> in /etc/security/<section>/ 57# Installs the config file <old name> as <new name> in /etc/security/<section>/
69 68
70# getpam_mod_dir 69# getpam_mod_dir
71# 70#
72# Returns the pam modules' directory for current implementation 71# Returns the pam modules' directory for current implementation
73getpam_mod_dir() { 72getpam_mod_dir() {
74 if has_version sys-libs/pam; then 73 if has_version sys-libs/pam || has_version sys-libs/openpam; then
75 PAM_MOD_DIR=/$(get_libdir)/security 74 PAM_MOD_DIR=/$(get_libdir)/security
76 elif has_version sys-libs/openpam; then 75 elif use ppc-macos; then
76 # OSX looks there for pam modules
77 PAM_MOD_DIR=/usr/$(get_libdir) 77 PAM_MOD_DIR=/usr/lib/pam
78 else 78 else
79 # Unable to find PAM implementation... defaulting 79 # Unable to find PAM implementation... defaulting
80 PAM_MOD_DIR=/$(get_libdir)/security 80 PAM_MOD_DIR=/$(get_libdir)/security
81 fi 81 fi
82 82
125 125
126 dodir /etc/pam.d 126 dodir /etc/pam.d
127 pamdfile=${D}/etc/pam.d/$1 127 pamdfile=${D}/etc/pam.d/$1
128 echo -e "# File autogenerated by pamd_mimic_system in pam eclass\n\n" >> \ 128 echo -e "# File autogenerated by pamd_mimic_system in pam eclass\n\n" >> \
129 $pamdfile 129 $pamdfile
130 130
131 authlevels="auth account password session" 131 authlevels="auth account password session"
132
133 if has_version '<sys-libs/pam-0.78'; then
134 mimic="\trequired\t\tpam_stack.so service=system-auth"
135 else
136 mimic="\tinclude\t\tsystem-auth"
137 fi
132 138
133 shift 139 shift
134 140
135 while [[ -n $1 ]]; do 141 while [[ -n $1 ]]; do
136 hasq $1 ${authlevels} || die "unknown level type" 142 hasq $1 ${authlevels} || die "unknown level type"
137 143
138 echo -e "$1\tinclude\t\tsystem-auth" >> ${pamdfile} 144 echo -e "$1${mimic}" >> ${pamdfile}
139 145
140 shift 146 shift
141 done 147 done
142} 148}
149
150# cleanpamd <pamd file>
151#
152# Cleans a pam.d file from modules that might not be present on the system
153# where it's going to be installed
154cleanpamd() {
155 while [[ -n $1 ]]; do
156 if ! has_version sys-libs/pam; then
157 sed -i -e '/pam_shells\|pam_console/s:^:#:' ${D}/etc/pam.d/$1
158 fi
159
160 shift
161 done
162}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20