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

Contents of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Fri May 20 15:54:34 2005 UTC (9 years, 5 months ago) by flameeyes
Branch: MAIN
Changes since 1.2: +5 -5 lines
Aligned pam functions to eutils ones.

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 flameeyes 1.3 # $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.2 2005/05/20 12:38:56 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     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 flameeyes 1.3 INSDESTTREE=/etc/pam.d \
24 flameeyes 1.1 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 flameeyes 1.3 INSDESTTREE=/etc/pam.d \
38 flameeyes 1.1 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 flameeyes 1.3 INSDESTTREE=/etc/security/$1 \
52 flameeyes 1.1 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 flameeyes 1.3 INSDESTTREE=/etc/security/$1 \
67 flameeyes 1.1 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; then
75     PAM_MOD_DIR=/$(get_libdir)/security
76     elif has_version sys-libs/openpam; then
77     PAM_MOD_DIR=/usr/$(get_libdir)
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