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

Diff of /eclass/pam.eclass

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

Revision 1.16 Revision 1.22
1# Copyright 2004 Gentoo Foundation 1# Copyright 1999-2011 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> 3# Author Diego Pettenò <flameeyes@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.16 2008/03/20 23:21:37 eva Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.22 2011/12/27 17:55:12 fauli Exp $
5# 5#
6# This eclass contains functions to install pamd configuration files and 6# This eclass contains functions to install pamd configuration files and
7# pam modules. 7# pam modules.
8 8
9inherit multilib 9if [[ ${___ECLASS_ONCE_PAM} != "recur -_+^+_- spank" ]] ; then
10___ECLASS_ONCE_PAM="recur -_+^+_- spank"
11
12inherit multilib flag-o-matic
10 13
11# dopamd <file> [more files] 14# dopamd <file> [more files]
12# 15#
13# Install pam auth config file in /etc/pam.d 16# Install pam auth config file in /etc/pam.d
14dopamd() { 17dopamd() {
15 [[ -z $1 ]] && die "dopamd requires at least one argument" 18 [[ -z $1 ]] && die "dopamd requires at least one argument"
16 19
17 if hasq pam ${IUSE} && ! use pam; then 20 if has pam ${IUSE} && ! use pam; then
18 return 0; 21 return 0;
19 fi 22 fi
20 23
21 ( # dont want to pollute calling env 24 ( # dont want to pollute calling env
22 insinto /etc/pam.d 25 insinto /etc/pam.d
30# 33#
31# Install pam file <old name> as <new name> in /etc/pam.d 34# Install pam file <old name> as <new name> in /etc/pam.d
32newpamd() { 35newpamd() {
33 [[ $# -ne 2 ]] && die "newpamd requires two arguments" 36 [[ $# -ne 2 ]] && die "newpamd requires two arguments"
34 37
35 if hasq pam ${IUSE} && ! use pam; then 38 if has pam ${IUSE} && ! use pam; then
36 return 0; 39 return 0;
37 fi 40 fi
38 41
39 ( # dont want to pollute calling env 42 ( # dont want to pollute calling env
40 insinto /etc/pam.d 43 insinto /etc/pam.d
48# 51#
49# Installs the config files in /etc/security/<section>/ 52# Installs the config files in /etc/security/<section>/
50dopamsecurity() { 53dopamsecurity() {
51 [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments" 54 [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments"
52 55
53 if hasq pam ${IUSE} && ! use pam; then 56 if has pam ${IUSE} && ! use pam; then
54 return 0 57 return 0
55 fi 58 fi
56 59
57 ( # dont want to pollute calling env 60 ( # dont want to pollute calling env
58 insinto /etc/security/$1 61 insinto /etc/security/$1
65# 68#
66# Installs the config file <old name> as <new name> in /etc/security/<section>/ 69# Installs the config file <old name> as <new name> in /etc/security/<section>/
67newpamsecurity() { 70newpamsecurity() {
68 [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments" 71 [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments"
69 72
70 if hasq pam ${IUSE} && ! use pam; then 73 if has pam ${IUSE} && ! use pam; then
71 return 0; 74 return 0;
72 fi 75 fi
73 76
74 ( # dont want to pollute calling env 77 ( # dont want to pollute calling env
75 insinto /etc/security/$1 78 insinto /etc/security/$1
82# 85#
83# Returns the pam modules' directory for current implementation 86# Returns the pam modules' directory for current implementation
84getpam_mod_dir() { 87getpam_mod_dir() {
85 if has_version sys-libs/pam || has_version sys-libs/openpam; then 88 if has_version sys-libs/pam || has_version sys-libs/openpam; then
86 PAM_MOD_DIR=/$(get_libdir)/security 89 PAM_MOD_DIR=/$(get_libdir)/security
87 elif use ppc-macos; then
88 # OSX looks there for pam modules
89 PAM_MOD_DIR=/usr/lib/pam
90 else 90 else
91 # Unable to find PAM implementation... defaulting 91 # Unable to find PAM implementation... defaulting
92 PAM_MOD_DIR=/$(get_libdir)/security 92 PAM_MOD_DIR=/$(get_libdir)/security
93 fi 93 fi
94 94
95 echo ${PAM_MOD_DIR} 95 echo ${PAM_MOD_DIR}
96} 96}
97 97
98# pammod_hide_symbols
99#
100# 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
102# necessary for PAM to load the module, then uses append-flags to make
103# sure that it gets used.
104pammod_hide_symbols() {
105 cat - > "${T}"/pam-eclass-pam_symbols.ver <<EOF
106{
107 global: pam_sm_*;
108 local: *;
109};
110EOF
111
112 append-ldflags -Wl,--version-script="${T}"/pam-eclass-pam_symbols.ver
113}
114
98# dopammod <file> [more files] 115# dopammod <file> [more files]
99# 116#
100# Install pam module file in the pam modules' dir for current implementation 117# Install pam module file in the pam modules' dir for current implementation
101dopammod() { 118dopammod() {
102 [[ -z $1 ]] && die "dopammod requires at least one argument" 119 [[ -z $1 ]] && die "dopammod requires at least one argument"
103 120
104 if hasq pam ${IUSE} && ! use pam; then 121 if has pam ${IUSE} && ! use pam; then
105 return 0; 122 return 0;
106 fi 123 fi
107 124
108 exeinto $(getpam_mod_dir) 125 exeinto $(getpam_mod_dir)
109 doexe "$@" || die "failed to install $@" 126 doexe "$@" || die "failed to install $@"
114# Install pam module file <old name> as <new name> in the pam 131# Install pam module file <old name> as <new name> in the pam
115# modules' dir for current implementation 132# modules' dir for current implementation
116newpammod() { 133newpammod() {
117 [[ $# -ne 2 ]] && die "newpammod requires two arguements" 134 [[ $# -ne 2 ]] && die "newpammod requires two arguements"
118 135
119 if hasq pam ${IUSE} && ! use pam; then 136 if has pam ${IUSE} && ! use pam; then
120 return 0; 137 return 0;
121 fi 138 fi
122 139
123 exeinto $(getpam_mod_dir) 140 exeinto $(getpam_mod_dir)
124 newexe "$1" "$2" || die "failed to install $1 as $2" 141 newexe "$1" "$2" || die "failed to install $1 as $2"
138# This function creates a pamd file which mimics the given stack 155# This function creates a pamd file which mimics the given stack
139# for the given levels in the /etc/pam.d directory. 156# for the given levels in the /etc/pam.d directory.
140pamd_mimic() { 157pamd_mimic() {
141 [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments" 158 [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments"
142 159
143 if hasq pam ${IUSE} && ! use pam; then 160 if has pam ${IUSE} && ! use pam; then
144 return 0; 161 return 0;
145 fi 162 fi
146 163
147 dodir /etc/pam.d 164 dodir /etc/pam.d
148 pamdfile=${D}/etc/pam.d/$2 165 pamdfile=${D}/etc/pam.d/$2
159 fi 176 fi
160 177
161 shift; shift 178 shift; shift
162 179
163 while [[ -n $1 ]]; do 180 while [[ -n $1 ]]; do
164 hasq $1 ${authlevels} || die "unknown level type" 181 has $1 ${authlevels} || die "unknown level type"
165 182
166 echo -e "$1${mimic}" >> ${pamdfile} 183 echo -e "$1${mimic}" >> ${pamdfile}
167 184
168 shift 185 shift
169 done 186 done
213 done 230 done
214} 231}
215 232
216# Think about it before uncommenting this one, for now run it by hand 233# Think about it before uncommenting this one, for now run it by hand
217# pam_pkg_preinst() { 234# pam_pkg_preinst() {
218# local shopts=$-
219# set -o noglob # so that bash doen't expand "*" 235# eshopts_push -o noglob # so that bash doen't expand "*"
220# 236#
221# pam_epam_expand "${D}"/etc/pam.d/* 237# pam_epam_expand "${D}"/etc/pam.d/*
222# 238#
223# set +o noglob; set -$shopts # reset old shell opts 239# eshopts_pop # reset old shell opts
224# } 240# }
241
242fi

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

  ViewVC Help
Powered by ViewVC 1.1.20