summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2007-07-10 12:54:32 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2007-07-10 12:54:32 +0000
commitf2017bc239da733e6e657ae7ef1a975cc57fc86d (patch)
treee2429b92c79f8170a7637ac034637a081061290a /eclass/pam.eclass
parentAdd ~alpha wrt #172789, thanks to Tobias Klausmann for testing (diff)
downloadhistorical-f2017bc239da733e6e657ae7ef1a975cc57fc86d.tar.gz
historical-f2017bc239da733e6e657ae7ef1a975cc57fc86d.tar.bz2
historical-f2017bc239da733e6e657ae7ef1a975cc57fc86d.zip
Add pam_epam_expand function to expand the EPAM "syntax" in the pam.d configuration files. sys-libs/pam will be the first user of this.
Diffstat (limited to 'eclass/pam.eclass')
-rw-r--r--eclass/pam.eclass37
1 files changed, 36 insertions, 1 deletions
diff --git a/eclass/pam.eclass b/eclass/pam.eclass
index 50d265264df5..c7e946abe200 100644
--- a/eclass/pam.eclass
+++ b/eclass/pam.eclass
@@ -1,7 +1,7 @@
# Copyright 2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# Author Diego Pettenò <flameeyes@gentoo.org>
-# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.11 2007/04/07 08:52:46 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/pam.eclass,v 1.12 2007/07/10 12:54:32 flameeyes Exp $
#
# This eclass contains functions to install pamd configuration files and
# pam modules.
@@ -172,3 +172,38 @@ cleanpamd() {
shift
done
}
+
+pam_epam_expand() {
+ sed -n -e 's|#%EPAM-\([[:alpha:]-]\+\):\([-+<>=/.[:alnum:]]\+\)%#.*|\1 \2|p' \
+ "$@" | sort -u | while read condition parameter; do
+
+ disable="# "
+
+ case "$condition" in
+ If-Has)
+ message="This can be used only if you have ${parameter} installed"
+ has_version "$parameter" && disable=""
+ ;;
+ Use-Flag)
+ message="This can be used only if you enabled the ${parameter} USE flag"
+ use "$parameter" && disable=""
+ ;;
+ *)
+ eerror "Unknown EPAM condition '${condition}' ('${parameter}')"
+ die "Unknown EPAM condition '${condition}' ('${parameter}')"
+ ;;
+ esac
+
+ sed -i -e "s|#%EPAM-${condition}:${parameter}%#|# ${message}\n${disable}|" "$@"
+ done
+}
+
+# Think about it before uncommenting this one, for nwo run it by hand
+# pam_pkg_preinst() {
+# local shopts=$-
+# set -o noglob # so that bash doen't expand "*"
+#
+# pam_epam_expand "${D}"/etc/pam.d/*
+#
+# set +o noglob; set -$shopts # reset old shell opts
+# }