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

Contents of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20