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

Diff of /eclass/pam.eclass

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

Revision 1.14 Revision 1.19
1# Copyright 2004 Gentoo Foundation 1# Copyright 2004 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.14 2007/11/04 15:00:27 flameeyes Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.19 2011/02/05 22:29:40 flameeyes 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 9inherit multilib flag-o-matic
10 10
11# dopamd <file> [more files] 11# dopamd <file> [more files]
12# 12#
13# Install pam auth config file in /etc/pam.d 13# Install pam auth config file in /etc/pam.d
14dopamd() { 14dopamd() {
82# 82#
83# Returns the pam modules' directory for current implementation 83# Returns the pam modules' directory for current implementation
84getpam_mod_dir() { 84getpam_mod_dir() {
85 if has_version sys-libs/pam || has_version sys-libs/openpam; then 85 if has_version sys-libs/pam || has_version sys-libs/openpam; then
86 PAM_MOD_DIR=/$(get_libdir)/security 86 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 87 else
91 # Unable to find PAM implementation... defaulting 88 # Unable to find PAM implementation... defaulting
92 PAM_MOD_DIR=/$(get_libdir)/security 89 PAM_MOD_DIR=/$(get_libdir)/security
93 fi 90 fi
94 91
95 echo ${PAM_MOD_DIR} 92 echo ${PAM_MOD_DIR}
93}
94
95# pammod_hide_symbols
96#
97# Hide all non-PAM-used symbols from the module; this function creates a
98# simple ld version script that hides all the symbols that are not
99# necessary for PAM to load the module, then uses append-flags to make
100# sure that it gets used.
101pammod_hide_symbols() {
102 cat - > "${T}"/pam-eclass-pam_symbols.ver <<EOF
103{
104 global: pam_sm_*;
105 local: *;
106};
107EOF
108
109 append-ldflags -Wl,--version-script="${T}"/pam-eclass-pam_symbols.ver
96} 110}
97 111
98# dopammod <file> [more files] 112# dopammod <file> [more files]
99# 113#
100# Install pam module file in the pam modules' dir for current implementation 114# Install pam module file in the pam modules' dir for current implementation
128# 142#
129# This function creates a pamd file which mimics system-auth file 143# This function creates a pamd file which mimics system-auth file
130# for the given levels in the /etc/pam.d directory. 144# for the given levels in the /etc/pam.d directory.
131pamd_mimic_system() { 145pamd_mimic_system() {
132 [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments" 146 [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments"
147 pamd_mimic system-auth "$@"
148}
149
150# pamd_mimic <stack> <pamd file> [auth levels]
151#
152# This function creates a pamd file which mimics the given stack
153# for the given levels in the /etc/pam.d directory.
154pamd_mimic() {
155 [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments"
133 156
134 if hasq pam ${IUSE} && ! use pam; then 157 if hasq pam ${IUSE} && ! use pam; then
135 return 0; 158 return 0;
136 fi 159 fi
137 160
138 dodir /etc/pam.d 161 dodir /etc/pam.d
139 pamdfile=${D}/etc/pam.d/$1 162 pamdfile=${D}/etc/pam.d/$2
140 echo -e "# File autogenerated by pamd_mimic_system in pam eclass\n\n" >> \ 163 echo -e "# File autogenerated by pamd_mimic in pam eclass\n\n" >> \
141 $pamdfile 164 $pamdfile
142 165
166 originalstack=$1
143 authlevels="auth account password session" 167 authlevels="auth account password session"
144 168
145 if has_version '<sys-libs/pam-0.78'; then 169 if has_version '<sys-libs/pam-0.78'; then
146 mimic="\trequired\t\tpam_stack.so service=system-auth" 170 mimic="\trequired\t\tpam_stack.so service=${originalstack}"
147 else 171 else
148 mimic="\tinclude\t\tsystem-auth" 172 mimic="\tinclude\t\t${originalstack}"
149 fi 173 fi
150 174
151 shift 175 shift; shift
152 176
153 while [[ -n $1 ]]; do 177 while [[ -n $1 ]]; do
154 hasq $1 ${authlevels} || die "unknown level type" 178 hasq $1 ${authlevels} || die "unknown level type"
155 179
156 echo -e "$1${mimic}" >> ${pamdfile} 180 echo -e "$1${mimic}" >> ${pamdfile}
164# Cleans a pam.d file from modules that might not be present on the system 188# Cleans a pam.d file from modules that might not be present on the system
165# where it's going to be installed 189# where it's going to be installed
166cleanpamd() { 190cleanpamd() {
167 while [[ -n $1 ]]; do 191 while [[ -n $1 ]]; do
168 if ! has_version sys-libs/pam; then 192 if ! has_version sys-libs/pam; then
169 sed -i -e '/pam_shells\|pam_console/s:^:#:' ${D}/etc/pam.d/$1 193 sed -i -e '/pam_shells\|pam_console/s:^:#:' "${D}/etc/pam.d/$1"
170 fi 194 fi
171 195
172 shift 196 shift
173 done 197 done
174} 198}
203 done 227 done
204} 228}
205 229
206# Think about it before uncommenting this one, for now run it by hand 230# Think about it before uncommenting this one, for now run it by hand
207# pam_pkg_preinst() { 231# pam_pkg_preinst() {
208# local shopts=$-
209# set -o noglob # so that bash doen't expand "*" 232# eshopts_push -o noglob # so that bash doen't expand "*"
210# 233#
211# pam_epam_expand "${D}"/etc/pam.d/* 234# pam_epam_expand "${D}"/etc/pam.d/*
212# 235#
213# set +o noglob; set -$shopts # reset old shell opts 236# eshopts_pop # reset old shell opts
214# } 237# }

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.20