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

Contents of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Wed Jul 6 20:20:04 2005 UTC (9 years, 2 months ago) by agriffis
Branch: MAIN
Changes since 1.6: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

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

  ViewVC Help
Powered by ViewVC 1.1.20