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

Diff of /eclass/pam.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.22 Revision 1.23
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 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.22 2011/12/27 17:55:12 fauli Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.23 2012/08/05 15:34:20 jlec Exp $
5# 4#
5
6# @ECLASS: pam.eclass
7# @MAINTAINER:
8# pam-bugs@gentoo.org
9# @AUTHOR:
10# Diego Pettenò <flameeyes@gentoo.org>
11# @BLURB: Handles pam related tasks
12# @DESCRIPTION:
6# This eclass contains functions to install pamd configuration files and 13# This eclass contains functions to install pamd configuration files and
7# pam modules. 14# pam modules.
8 15
9if [[ ${___ECLASS_ONCE_PAM} != "recur -_+^+_- spank" ]] ; then 16if [[ ${___ECLASS_ONCE_PAM} != "recur -_+^+_- spank" ]] ; then
10___ECLASS_ONCE_PAM="recur -_+^+_- spank" 17___ECLASS_ONCE_PAM="recur -_+^+_- spank"
11 18
12inherit multilib flag-o-matic 19inherit flag-o-matic multilib
13 20
21# @FUNCTION: dopamd
14# dopamd <file> [more files] 22# @USAGE: <file> [more files]
15# 23# @DESCRIPTION:
16# Install pam auth config file in /etc/pam.d 24# Install pam auth config file in /etc/pam.d
17dopamd() { 25dopamd() {
18 [[ -z $1 ]] && die "dopamd requires at least one argument" 26 [[ -z $1 ]] && die "dopamd requires at least one argument"
19 27
20 if has pam ${IUSE} && ! use pam; then 28 if has pam ${IUSE} && ! use pam; then
27 doins "$@" 35 doins "$@"
28 ) || die "failed to install $@" 36 ) || die "failed to install $@"
29 cleanpamd "$@" 37 cleanpamd "$@"
30} 38}
31 39
40# @FUNCTION: newpamd
32# newpamd <old name> <new name> 41# @USAGE: <old name> <new name>
33# 42# @DESCRIPTION:
34# Install pam file <old name> as <new name> in /etc/pam.d 43# Install pam file <old name> as <new name> in /etc/pam.d
35newpamd() { 44newpamd() {
36 [[ $# -ne 2 ]] && die "newpamd requires two arguments" 45 [[ $# -ne 2 ]] && die "newpamd requires two arguments"
37 46
38 if has pam ${IUSE} && ! use pam; then 47 if has pam ${IUSE} && ! use pam; then
45 newins "$1" "$2" 54 newins "$1" "$2"
46 ) || die "failed to install $1 as $2" 55 ) || die "failed to install $1 as $2"
47 cleanpamd $2 56 cleanpamd $2
48} 57}
49 58
59# @FUNCTION: dopamsecurity
50# dopamsecurity <section> <file> [more files] 60# @USAGE: <section> <file> [more files]
51# 61# @DESCRIPTION:
52# Installs the config files in /etc/security/<section>/ 62# Installs the config files in /etc/security/<section>/
53dopamsecurity() { 63dopamsecurity() {
54 [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments" 64 [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments"
55 65
56 if has pam ${IUSE} && ! use pam; then 66 if has pam ${IUSE} && ! use pam; then
62 insopts -m 0644 72 insopts -m 0644
63 doins "${@:2}" 73 doins "${@:2}"
64 ) || die "failed to install ${@:2}" 74 ) || die "failed to install ${@:2}"
65} 75}
66 76
77# @FUNCTION: newpamsecurity
67# newpamsecurity <section> <old name> <new name> 78# @USAGE: <section> <old name> <new name>
68# 79# @DESCRIPTION:
69# Installs the config file <old name> as <new name> in /etc/security/<section>/ 80# Installs the config file <old name> as <new name> in /etc/security/<section>/
70newpamsecurity() { 81newpamsecurity() {
71 [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments" 82 [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments"
72 83
73 if has pam ${IUSE} && ! use pam; then 84 if has pam ${IUSE} && ! use pam; then
79 insopts -m 0644 90 insopts -m 0644
80 newins "$2" "$3" 91 newins "$2" "$3"
81 ) || die "failed to install $2 as $3" 92 ) || die "failed to install $2 as $3"
82} 93}
83 94
84# getpam_mod_dir 95# @FUNCTION: getpam_mod_dir
85# 96# @DESCRIPTION:
86# Returns the pam modules' directory for current implementation 97# Returns the pam modules' directory for current implementation
87getpam_mod_dir() { 98getpam_mod_dir() {
88 if has_version sys-libs/pam || has_version sys-libs/openpam; then 99 if has_version sys-libs/pam || has_version sys-libs/openpam; then
89 PAM_MOD_DIR=/$(get_libdir)/security 100 PAM_MOD_DIR=/$(get_libdir)/security
90 else 101 else
93 fi 104 fi
94 105
95 echo ${PAM_MOD_DIR} 106 echo ${PAM_MOD_DIR}
96} 107}
97 108
98# pammod_hide_symbols 109# @FUNCTION: pammod_hide_symbols
99# 110# @DESCRIPTION:
100# Hide all non-PAM-used symbols from the module; this function creates a 111# Hide all non-PAM-used symbols from the module; this function creates a
101# simple ld version script that hides all the symbols that are not 112# simple ld version script that hides all the symbols that are not
102# necessary for PAM to load the module, then uses append-flags to make 113# necessary for PAM to load the module, then uses append-flags to make
103# sure that it gets used. 114# sure that it gets used.
104pammod_hide_symbols() { 115pammod_hide_symbols() {
110EOF 121EOF
111 122
112 append-ldflags -Wl,--version-script="${T}"/pam-eclass-pam_symbols.ver 123 append-ldflags -Wl,--version-script="${T}"/pam-eclass-pam_symbols.ver
113} 124}
114 125
115# dopammod <file> [more files] 126# @FUNCTION: dopammod
116# 127# @USAGE: <file> [more files]
128# @DESCRIPTION:
117# Install pam module file in the pam modules' dir for current implementation 129# Install pam module file in the pam modules' dir for current implementation
118dopammod() { 130dopammod() {
119 [[ -z $1 ]] && die "dopammod requires at least one argument" 131 [[ -z $1 ]] && die "dopammod requires at least one argument"
120 132
121 if has pam ${IUSE} && ! use pam; then 133 if has pam ${IUSE} && ! use pam; then
124 136
125 exeinto $(getpam_mod_dir) 137 exeinto $(getpam_mod_dir)
126 doexe "$@" || die "failed to install $@" 138 doexe "$@" || die "failed to install $@"
127} 139}
128 140
141# @FUNCTION: newpammod
129# newpammod <old name> <new name> 142# @USAGE: <old name> <new name>
130# 143# @DESCRIPTION:
131# Install pam module file <old name> as <new name> in the pam 144# Install pam module file <old name> as <new name> in the pam
132# modules' dir for current implementation 145# modules' dir for current implementation
133newpammod() { 146newpammod() {
134 [[ $# -ne 2 ]] && die "newpammod requires two arguements" 147 [[ $# -ne 2 ]] && die "newpammod requires two arguements"
135 148
139 152
140 exeinto $(getpam_mod_dir) 153 exeinto $(getpam_mod_dir)
141 newexe "$1" "$2" || die "failed to install $1 as $2" 154 newexe "$1" "$2" || die "failed to install $1 as $2"
142} 155}
143 156
144# pamd_mimic_system <pamd file> [auth levels] 157# @FUNCTION: pamd_mimic_system
145# 158# @USAGE: <pamd file> [auth levels]
159# @DESCRIPTION:
146# This function creates a pamd file which mimics system-auth file 160# This function creates a pamd file which mimics system-auth file
147# for the given levels in the /etc/pam.d directory. 161# for the given levels in the /etc/pam.d directory.
148pamd_mimic_system() { 162pamd_mimic_system() {
149 [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments" 163 [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments"
150 pamd_mimic system-auth "$@" 164 pamd_mimic system-auth "$@"
151} 165}
152 166
167# @FUNCTION: pamd_mimic
153# pamd_mimic <stack> <pamd file> [auth levels] 168# @USAGE: <stack> <pamd file> [auth levels]
154# 169# @DESCRIPTION:
155# This function creates a pamd file which mimics the given stack 170# This function creates a pamd file which mimics the given stack
156# for the given levels in the /etc/pam.d directory. 171# for the given levels in the /etc/pam.d directory.
157pamd_mimic() { 172pamd_mimic() {
158 [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments" 173 [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments"
159 174
184 199
185 shift 200 shift
186 done 201 done
187} 202}
188 203
189# cleanpamd <pamd file> 204# @FUNCTION: cleanpamd
190# 205# @USAGE: <pamd file>
206# @DESCRIPTION:
191# Cleans a pam.d file from modules that might not be present on the system 207# Cleans a pam.d file from modules that might not be present on the system
192# where it's going to be installed 208# where it's going to be installed
193cleanpamd() { 209cleanpamd() {
194 while [[ -n $1 ]]; do 210 while [[ -n $1 ]]; do
195 if ! has_version sys-libs/pam; then 211 if ! has_version sys-libs/pam; then
198 214
199 shift 215 shift
200 done 216 done
201} 217}
202 218
219# @FUNCTION: pam_epam_expand
220# @USAGE: <pamd file>
221# @DESCRIPTION:
222# Steer clear, deprecated, don't use, bad experiment
203pam_epam_expand() { 223pam_epam_expand() {
204 sed -n -e 's|#%EPAM-\([[:alpha:]-]\+\):\([-+<>=/.![:alnum:]]\+\)%#.*|\1 \2|p' \ 224 sed -n -e 's|#%EPAM-\([[:alpha:]-]\+\):\([-+<>=/.![:alnum:]]\+\)%#.*|\1 \2|p' \
205 "$@" | sort -u | while read condition parameter; do 225 "$@" | sort -u | while read condition parameter; do
206 226
207 disable="yes" 227 disable="yes"

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.20