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

Contents of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Tue Jun 7 11:33:39 2005 UTC (9 years, 1 month ago) by flameeyes
Branch: MAIN
Changes since 1.4: +2 -3 lines
Fixed dopamsecurity() function. Thanks to Ed Catmur in #95294.

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.4 2005/06/04 19:01:11 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 doins "${@:2}" || die "failed to install ${@:2}"
53 }
54
55 # newpamsecurity <section> <old name> <new name>
56 #
57 # Installs the config file <old name> as <new name> in /etc/security/<section>/
58 newpamsecurity() {
59 [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments"
60
61 if hasq pam ${IUSE} && ! use pam; then
62 return 0;
63 fi
64
65 INSDESTTREE=/etc/security/$1 \
66 newins "$2" "$3" || die "failed to install $2 as $3"
67 }
68
69 # getpam_mod_dir
70 #
71 # Returns the pam modules' directory for current implementation
72 getpam_mod_dir() {
73 if has_version sys-libs/pam || has_version sys-libs/openpam; then
74 PAM_MOD_DIR=/$(get_libdir)/security
75 elif use ppc-macos; then
76 # OSX looks there for pam modules
77 PAM_MOD_DIR=/usr/lib/pam
78 else
79 # Unable to find PAM implementation... defaulting
80 PAM_MOD_DIR=/$(get_libdir)/security
81 fi
82
83 echo ${PAM_MOD_DIR}
84 }
85
86 # dopammod <file> [more files]
87 #
88 # Install pam module file in the pam modules' dir for current implementation
89 dopammod() {
90 [[ -z $1 ]] && die "dopammod requires at least one argument"
91
92 if hasq pam ${IUSE} && ! use pam; then
93 return 0;
94 fi
95
96 exeinto $(getpam_mod_dir)
97 doexe "$@" || die "failed to install $@"
98 }
99
100 # newpammod <old name> <new name>
101 #
102 # Install pam module file <old name> as <new name> in the pam
103 # modules' dir for current implementation
104 newpammod() {
105 [[ $# -ne 2 ]] && die "newpammod requires two arguements"
106
107 if hasq pam ${IUSE} && ! use pam; then
108 return 0;
109 fi
110
111 exeinto $(getpam_mod_dir)
112 newexe "$1" "$2" || die "failed to install $1 as $2"
113 }
114
115 # pamd_mimic_system <pamd file> [auth levels]
116 #
117 # This function creates a pamd file which mimics system-auth file
118 # for the given levels in the /etc/pam.d directory.
119 pamd_mimic_system() {
120 [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments"
121
122 if hasq pam ${IUSE} && ! use pam; then
123 return 0;
124 fi
125
126 dodir /etc/pam.d
127 pamdfile=${D}/etc/pam.d/$1
128 echo -e "# File autogenerated by pamd_mimic_system in pam eclass\n\n" >> \
129 $pamdfile
130
131 authlevels="auth account password session"
132
133 shift
134
135 while [[ -n $1 ]]; do
136 hasq $1 ${authlevels} || die "unknown level type"
137
138 echo -e "$1\tinclude\t\tsystem-auth" >> ${pamdfile}
139
140 shift
141 done
142 }

  ViewVC Help
Powered by ViewVC 1.1.20