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

Contents of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Sat Jun 4 19:01:11 2005 UTC (9 years, 5 months ago) by flameeyes
Branch: MAIN
Changes since 1.3: +6 -5 lines
Newer OpenPAM use the same layout as Linux-PAM. OSX uses /usr/lib/pam.

1 # Copyright 2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License, v2 or later
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 $
5 #
6 # This eclass contains functions to install pamd configuration files and
7 # pam modules.
8
9 inherit multilib
10 ECLASS="pam"
11 INHERITED="$INHERITED $ECLASS"
12
13 # dopamd <file> [more files]
14 #
15 # Install pam auth config file in /etc/pam.d
16 dopamd() {
17 [[ -z $1 ]] && die "dopamd requires at least one argument"
18
19 if hasq pam ${IUSE} && ! use pam; then
20 return 0;
21 fi
22
23 INSDESTTREE=/etc/pam.d \
24 doins "$@" || die "failed to install $@"
25 }
26
27 # newpamd <old name> <new name>
28 #
29 # Install pam file <old name> as <new name> in /etc/pam.d
30 newpamd() {
31 [[ $# -ne 2 ]] && die "newpamd requires two arguments"
32
33 if hasq pam ${IUSE} && ! use pam; then
34 return 0;
35 fi
36
37 INSDESTTREE=/etc/pam.d \
38 newins "$1" "$2" || die "failed to install $1 as $2"
39 }
40
41 # dopamsecurity <section> <file> [more files]
42 #
43 # Installs the config files in /etc/security/<section>/
44 dopamsecurity() {
45 [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments"
46
47 if hasq pam ${IUSE} && ! use pam; then
48 return 0;
49 fi
50
51 INSDESTTREE=/etc/security/$1 \
52 shift
53 doins "$@" || die "failed to install $@"
54 }
55
56 # newpamsecurity <section> <old name> <new name>
57 #
58 # Installs the config file <old name> as <new name> in /etc/security/<section>/
59 newpamsecurity() {
60 [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments"
61
62 if hasq pam ${IUSE} && ! use pam; then
63 return 0;
64 fi
65
66 INSDESTTREE=/etc/security/$1 \
67 newins "$2" "$3" || die "failed to install $2 as $3"
68 }
69
70 # getpam_mod_dir
71 #
72 # Returns the pam modules' directory for current implementation
73 getpam_mod_dir() {
74 if has_version sys-libs/pam || has_version sys-libs/openpam; then
75 PAM_MOD_DIR=/$(get_libdir)/security
76 elif use ppc-macos; then
77 # OSX looks there for pam modules
78 PAM_MOD_DIR=/usr/lib/pam
79 else
80 # Unable to find PAM implementation... defaulting
81 PAM_MOD_DIR=/$(get_libdir)/security
82 fi
83
84 echo ${PAM_MOD_DIR}
85 }
86
87 # dopammod <file> [more files]
88 #
89 # Install pam module file in the pam modules' dir for current implementation
90 dopammod() {
91 [[ -z $1 ]] && die "dopammod requires at least one argument"
92
93 if hasq pam ${IUSE} && ! use pam; then
94 return 0;
95 fi
96
97 exeinto $(getpam_mod_dir)
98 doexe "$@" || die "failed to install $@"
99 }
100
101 # newpammod <old name> <new name>
102 #
103 # Install pam module file <old name> as <new name> in the pam
104 # modules' dir for current implementation
105 newpammod() {
106 [[ $# -ne 2 ]] && die "newpammod requires two arguements"
107
108 if hasq pam ${IUSE} && ! use pam; then
109 return 0;
110 fi
111
112 exeinto $(getpam_mod_dir)
113 newexe "$1" "$2" || die "failed to install $1 as $2"
114 }
115
116 # pamd_mimic_system <pamd file> [auth levels]
117 #
118 # This function creates a pamd file which mimics system-auth file
119 # for the given levels in the /etc/pam.d directory.
120 pamd_mimic_system() {
121 [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments"
122
123 if hasq pam ${IUSE} && ! use pam; then
124 return 0;
125 fi
126
127 dodir /etc/pam.d
128 pamdfile=${D}/etc/pam.d/$1
129 echo -e "# File autogenerated by pamd_mimic_system in pam eclass\n\n" >> \
130 $pamdfile
131
132 authlevels="auth account password session"
133
134 shift
135
136 while [[ -n $1 ]]; do
137 hasq $1 ${authlevels} || die "unknown level type"
138
139 echo -e "$1\tinclude\t\tsystem-auth" >> ${pamdfile}
140
141 shift
142 done
143 }

  ViewVC Help
Powered by ViewVC 1.1.20