| 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.19 2011/02/05 22:29:40 flameeyes Exp $ |
4 | # $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.20 2011/07/08 11:35:01 ssuominen 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 | |
| 9 | inherit multilib flag-o-matic |
9 | inherit multilib flag-o-matic |
| … | |
… | |
| 12 | # |
12 | # |
| 13 | # Install pam auth config file in /etc/pam.d |
13 | # Install pam auth config file in /etc/pam.d |
| 14 | dopamd() { |
14 | dopamd() { |
| 15 | [[ -z $1 ]] && die "dopamd requires at least one argument" |
15 | [[ -z $1 ]] && die "dopamd requires at least one argument" |
| 16 | |
16 | |
| 17 | if hasq pam ${IUSE} && ! use pam; then |
17 | if has pam ${IUSE} && ! use pam; then |
| 18 | return 0; |
18 | return 0; |
| 19 | fi |
19 | fi |
| 20 | |
20 | |
| 21 | ( # dont want to pollute calling env |
21 | ( # dont want to pollute calling env |
| 22 | insinto /etc/pam.d |
22 | insinto /etc/pam.d |
| … | |
… | |
| 30 | # |
30 | # |
| 31 | # Install pam file <old name> as <new name> in /etc/pam.d |
31 | # Install pam file <old name> as <new name> in /etc/pam.d |
| 32 | newpamd() { |
32 | newpamd() { |
| 33 | [[ $# -ne 2 ]] && die "newpamd requires two arguments" |
33 | [[ $# -ne 2 ]] && die "newpamd requires two arguments" |
| 34 | |
34 | |
| 35 | if hasq pam ${IUSE} && ! use pam; then |
35 | if has pam ${IUSE} && ! use pam; then |
| 36 | return 0; |
36 | return 0; |
| 37 | fi |
37 | fi |
| 38 | |
38 | |
| 39 | ( # dont want to pollute calling env |
39 | ( # dont want to pollute calling env |
| 40 | insinto /etc/pam.d |
40 | insinto /etc/pam.d |
| … | |
… | |
| 48 | # |
48 | # |
| 49 | # Installs the config files in /etc/security/<section>/ |
49 | # Installs the config files in /etc/security/<section>/ |
| 50 | dopamsecurity() { |
50 | dopamsecurity() { |
| 51 | [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments" |
51 | [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments" |
| 52 | |
52 | |
| 53 | if hasq pam ${IUSE} && ! use pam; then |
53 | if has pam ${IUSE} && ! use pam; then |
| 54 | return 0 |
54 | return 0 |
| 55 | fi |
55 | fi |
| 56 | |
56 | |
| 57 | ( # dont want to pollute calling env |
57 | ( # dont want to pollute calling env |
| 58 | insinto /etc/security/$1 |
58 | insinto /etc/security/$1 |
| … | |
… | |
| 65 | # |
65 | # |
| 66 | # Installs the config file <old name> as <new name> in /etc/security/<section>/ |
66 | # Installs the config file <old name> as <new name> in /etc/security/<section>/ |
| 67 | newpamsecurity() { |
67 | newpamsecurity() { |
| 68 | [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments" |
68 | [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments" |
| 69 | |
69 | |
| 70 | if hasq pam ${IUSE} && ! use pam; then |
70 | if has pam ${IUSE} && ! use pam; then |
| 71 | return 0; |
71 | return 0; |
| 72 | fi |
72 | fi |
| 73 | |
73 | |
| 74 | ( # dont want to pollute calling env |
74 | ( # dont want to pollute calling env |
| 75 | insinto /etc/security/$1 |
75 | insinto /etc/security/$1 |
| … | |
… | |
| 113 | # |
113 | # |
| 114 | # 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 |
| 115 | dopammod() { |
115 | dopammod() { |
| 116 | [[ -z $1 ]] && die "dopammod requires at least one argument" |
116 | [[ -z $1 ]] && die "dopammod requires at least one argument" |
| 117 | |
117 | |
| 118 | if hasq pam ${IUSE} && ! use pam; then |
118 | if has pam ${IUSE} && ! use pam; then |
| 119 | return 0; |
119 | return 0; |
| 120 | fi |
120 | fi |
| 121 | |
121 | |
| 122 | exeinto $(getpam_mod_dir) |
122 | exeinto $(getpam_mod_dir) |
| 123 | doexe "$@" || die "failed to install $@" |
123 | doexe "$@" || die "failed to install $@" |
| … | |
… | |
| 128 | # Install pam module file <old name> as <new name> in the pam |
128 | # Install pam module file <old name> as <new name> in the pam |
| 129 | # modules' dir for current implementation |
129 | # modules' dir for current implementation |
| 130 | newpammod() { |
130 | newpammod() { |
| 131 | [[ $# -ne 2 ]] && die "newpammod requires two arguements" |
131 | [[ $# -ne 2 ]] && die "newpammod requires two arguements" |
| 132 | |
132 | |
| 133 | if hasq pam ${IUSE} && ! use pam; then |
133 | if has pam ${IUSE} && ! use pam; then |
| 134 | return 0; |
134 | return 0; |
| 135 | fi |
135 | fi |
| 136 | |
136 | |
| 137 | exeinto $(getpam_mod_dir) |
137 | exeinto $(getpam_mod_dir) |
| 138 | newexe "$1" "$2" || die "failed to install $1 as $2" |
138 | newexe "$1" "$2" || die "failed to install $1 as $2" |
| … | |
… | |
| 152 | # This function creates a pamd file which mimics the given stack |
152 | # This function creates a pamd file which mimics the given stack |
| 153 | # for the given levels in the /etc/pam.d directory. |
153 | # for the given levels in the /etc/pam.d directory. |
| 154 | pamd_mimic() { |
154 | pamd_mimic() { |
| 155 | [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments" |
155 | [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments" |
| 156 | |
156 | |
| 157 | if hasq pam ${IUSE} && ! use pam; then |
157 | if has pam ${IUSE} && ! use pam; then |
| 158 | return 0; |
158 | return 0; |
| 159 | fi |
159 | fi |
| 160 | |
160 | |
| 161 | dodir /etc/pam.d |
161 | dodir /etc/pam.d |
| 162 | pamdfile=${D}/etc/pam.d/$2 |
162 | pamdfile=${D}/etc/pam.d/$2 |
| … | |
… | |
| 173 | fi |
173 | fi |
| 174 | |
174 | |
| 175 | shift; shift |
175 | shift; shift |
| 176 | |
176 | |
| 177 | while [[ -n $1 ]]; do |
177 | while [[ -n $1 ]]; do |
| 178 | hasq $1 ${authlevels} || die "unknown level type" |
178 | has $1 ${authlevels} || die "unknown level type" |
| 179 | |
179 | |
| 180 | echo -e "$1${mimic}" >> ${pamdfile} |
180 | echo -e "$1${mimic}" >> ${pamdfile} |
| 181 | |
181 | |
| 182 | shift |
182 | shift |
| 183 | done |
183 | done |