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

Diff of /eclass/pam.eclass

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

Revision 1.1.1.1 Revision 1.3
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.1.1.1 2005/11/30 09:59:31 chriswhite Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.3 2005/05/20 15:54:34 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"
10 12
11# dopamd <file> [more files] 13# dopamd <file> [more files]
12# 14#
13# Install pam auth config file in /etc/pam.d 15# Install pam auth config file in /etc/pam.d
14dopamd() { 16dopamd() {
17 if hasq pam ${IUSE} && ! use pam; then 19 if hasq pam ${IUSE} && ! use pam; then
18 return 0; 20 return 0;
19 fi 21 fi
20 22
21 INSDESTTREE=/etc/pam.d \ 23 INSDESTTREE=/etc/pam.d \
22 INSOPTIONS="-m 0644" \
23 doins "$@" || die "failed to install $@" 24 doins "$@" || die "failed to install $@"
24 cleanpamd "$@"
25} 25}
26 26
27# newpamd <old name> <new name> 27# newpamd <old name> <new name>
28# 28#
29# Install pam file <old name> as <new name> in /etc/pam.d 29# Install pam file <old name> as <new name> in /etc/pam.d
33 if hasq pam ${IUSE} && ! use pam; then 33 if hasq pam ${IUSE} && ! use pam; then
34 return 0; 34 return 0;
35 fi 35 fi
36 36
37 INSDESTTREE=/etc/pam.d \ 37 INSDESTTREE=/etc/pam.d \
38 INSOPTIONS="-m 0644" \
39 newins "$1" "$2" || die "failed to install $1 as $2" 38 newins "$1" "$2" || die "failed to install $1 as $2"
40 cleanpamd $2
41} 39}
42 40
43# dopamsecurity <section> <file> [more files] 41# dopamsecurity <section> <file> [more files]
44# 42#
45# Installs the config files in /etc/security/<section>/ 43# Installs the config files in /etc/security/<section>/
49 if hasq pam ${IUSE} && ! use pam; then 47 if hasq pam ${IUSE} && ! use pam; then
50 return 0; 48 return 0;
51 fi 49 fi
52 50
53 INSDESTTREE=/etc/security/$1 \ 51 INSDESTTREE=/etc/security/$1 \
54 INSOPTIONS="-m 0644" \ 52 shift
55 doins "${@:2}" || die "failed to install ${@:2}" 53 doins "$@" || die "failed to install $@"
56} 54}
57 55
58# newpamsecurity <section> <old name> <new name> 56# newpamsecurity <section> <old name> <new name>
59# 57#
60# Installs the config file <old name> as <new name> in /etc/security/<section>/ 58# Installs the config file <old name> as <new name> in /etc/security/<section>/
64 if hasq pam ${IUSE} && ! use pam; then 62 if hasq pam ${IUSE} && ! use pam; then
65 return 0; 63 return 0;
66 fi 64 fi
67 65
68 INSDESTTREE=/etc/security/$1 \ 66 INSDESTTREE=/etc/security/$1 \
69 INSOPTIONS="-m 0644" \
70 newins "$2" "$3" || die "failed to install $2 as $3" 67 newins "$2" "$3" || die "failed to install $2 as $3"
71} 68}
72 69
73# getpam_mod_dir 70# getpam_mod_dir
74# 71#
75# Returns the pam modules' directory for current implementation 72# Returns the pam modules' directory for current implementation
76getpam_mod_dir() { 73getpam_mod_dir() {
77 if has_version sys-libs/pam || has_version sys-libs/openpam; then 74 if has_version sys-libs/pam; then
78 PAM_MOD_DIR=/$(get_libdir)/security 75 PAM_MOD_DIR=/$(get_libdir)/security
79 elif use ppc-macos; then 76 elif has_version sys-libs/openpam; then
80 # OSX looks there for pam modules
81 PAM_MOD_DIR=/usr/lib/pam 77 PAM_MOD_DIR=/usr/$(get_libdir)
82 else 78 else
83 # Unable to find PAM implementation... defaulting 79 # Unable to find PAM implementation... defaulting
84 PAM_MOD_DIR=/$(get_libdir)/security 80 PAM_MOD_DIR=/$(get_libdir)/security
85 fi 81 fi
86 82
129 125
130 dodir /etc/pam.d 126 dodir /etc/pam.d
131 pamdfile=${D}/etc/pam.d/$1 127 pamdfile=${D}/etc/pam.d/$1
132 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" >> \
133 $pamdfile 129 $pamdfile
134 130
135 authlevels="auth account password session" 131 authlevels="auth account password session"
136
137 if has_version '<sys-libs/pam-0.78'; then
138 mimic="\trequired\t\tpam_stack.so service=system-auth"
139 else
140 mimic="\tinclude\t\tsystem-auth"
141 fi
142 132
143 shift 133 shift
144 134
145 while [[ -n $1 ]]; do 135 while [[ -n $1 ]]; do
146 hasq $1 ${authlevels} || die "unknown level type" 136 hasq $1 ${authlevels} || die "unknown level type"
147 137
148 echo -e "$1${mimic}" >> ${pamdfile} 138 echo -e "$1\tinclude\t\tsystem-auth" >> ${pamdfile}
149 139
150 shift 140 shift
151 done 141 done
152} 142}
153
154# cleanpamd <pamd file>
155#
156# Cleans a pam.d file from modules that might not be present on the system
157# where it's going to be installed
158cleanpamd() {
159 while [[ -n $1 ]]; do
160 if ! has_version sys-libs/pam; then
161 sed -i -e '/pam_shells\|pam_console/s:^:#:' ${D}/etc/pam.d/$1
162 fi
163
164 shift
165 done
166}

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

  ViewVC Help
Powered by ViewVC 1.1.20