From 56bd759df1d0c750a065b8c845e93d5dfa6b549d Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 8 Aug 2015 13:49:04 -0700 Subject: proj/gentoo: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson X-Thanks: Alec Warner - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring - wrote much python to improve cvs2svn X-Thanks: Rich Freeman - validation scripts X-Thanks: Patrick Lauer - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed --- eclass/pam.eclass | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 eclass/pam.eclass (limited to 'eclass/pam.eclass') diff --git a/eclass/pam.eclass b/eclass/pam.eclass new file mode 100644 index 000000000000..a690e00a1034 --- /dev/null +++ b/eclass/pam.eclass @@ -0,0 +1,262 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later +# $Id$ +# + +# @ECLASS: pam.eclass +# @MAINTAINER: +# pam-bugs@gentoo.org +# @AUTHOR: +# Diego Pettenò +# @BLURB: Handles pam related tasks +# @DESCRIPTION: +# This eclass contains functions to install pamd configuration files and +# pam modules. + +if [[ -z ${_PAM_ECLASS} ]]; then +_PAM_ECLASS=1 + +inherit flag-o-matic multilib + +# @FUNCTION: dopamd +# @USAGE: [more files] +# @DESCRIPTION: +# Install pam auth config file in /etc/pam.d +dopamd() { + [[ -z $1 ]] && die "dopamd requires at least one argument" + + if has pam ${IUSE} && ! use pam; then + return 0; + fi + + ( # dont want to pollute calling env + insinto /etc/pam.d + insopts -m 0644 + doins "$@" + ) || die "failed to install $@" + cleanpamd "$@" +} + +# @FUNCTION: newpamd +# @USAGE: +# @DESCRIPTION: +# Install pam file as in /etc/pam.d +newpamd() { + [[ $# -ne 2 ]] && die "newpamd requires two arguments" + + if has pam ${IUSE} && ! use pam; then + return 0; + fi + + ( # dont want to pollute calling env + insinto /etc/pam.d + insopts -m 0644 + newins "$1" "$2" + ) || die "failed to install $1 as $2" + cleanpamd $2 +} + +# @FUNCTION: dopamsecurity +# @USAGE:
[more files] +# @DESCRIPTION: +# Installs the config files in /etc/security/
/ +dopamsecurity() { + [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments" + + if has pam ${IUSE} && ! use pam; then + return 0 + fi + + ( # dont want to pollute calling env + insinto /etc/security/$1 + insopts -m 0644 + doins "${@:2}" + ) || die "failed to install ${@:2}" +} + +# @FUNCTION: newpamsecurity +# @USAGE:
+# @DESCRIPTION: +# Installs the config file as in /etc/security/
/ +newpamsecurity() { + [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments" + + if has pam ${IUSE} && ! use pam; then + return 0; + fi + + ( # dont want to pollute calling env + insinto /etc/security/$1 + insopts -m 0644 + newins "$2" "$3" + ) || die "failed to install $2 as $3" +} + +# @FUNCTION: getpam_mod_dir +# @DESCRIPTION: +# Returns the pam modules' directory for current implementation +getpam_mod_dir() { + if has_version sys-libs/pam || has_version sys-libs/openpam; then + PAM_MOD_DIR=/$(get_libdir)/security + else + # Unable to find PAM implementation... defaulting + PAM_MOD_DIR=/$(get_libdir)/security + fi + + echo ${PAM_MOD_DIR} +} + +# @FUNCTION: pammod_hide_symbols +# @DESCRIPTION: +# Hide all non-PAM-used symbols from the module; this function creates a +# simple ld version script that hides all the symbols that are not +# necessary for PAM to load the module, then uses append-flags to make +# sure that it gets used. +pammod_hide_symbols() { + cat - > "${T}"/pam-eclass-pam_symbols.ver < [more files] +# @DESCRIPTION: +# Install pam module file in the pam modules' dir for current implementation +dopammod() { + [[ -z $1 ]] && die "dopammod requires at least one argument" + + if has pam ${IUSE} && ! use pam; then + return 0; + fi + + exeinto $(getpam_mod_dir) + doexe "$@" || die "failed to install $@" +} + +# @FUNCTION: newpammod +# @USAGE: +# @DESCRIPTION: +# Install pam module file as in the pam +# modules' dir for current implementation +newpammod() { + [[ $# -ne 2 ]] && die "newpammod requires two arguements" + + if has pam ${IUSE} && ! use pam; then + return 0; + fi + + exeinto $(getpam_mod_dir) + newexe "$1" "$2" || die "failed to install $1 as $2" +} + +# @FUNCTION: pamd_mimic_system +# @USAGE: [auth levels] +# @DESCRIPTION: +# This function creates a pamd file which mimics system-auth file +# for the given levels in the /etc/pam.d directory. +pamd_mimic_system() { + [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments" + pamd_mimic system-auth "$@" +} + +# @FUNCTION: pamd_mimic +# @USAGE: [auth levels] +# @DESCRIPTION: +# This function creates a pamd file which mimics the given stack +# for the given levels in the /etc/pam.d directory. +pamd_mimic() { + [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments" + + if has pam ${IUSE} && ! use pam; then + return 0; + fi + + dodir /etc/pam.d + pamdfile=${D}/etc/pam.d/$2 + echo -e "# File autogenerated by pamd_mimic in pam eclass\n\n" >> \ + $pamdfile + + originalstack=$1 + authlevels="auth account password session" + + if has_version '> ${pamdfile} + + shift + done +} + +# @FUNCTION: cleanpamd +# @USAGE: +# @DESCRIPTION: +# Cleans a pam.d file from modules that might not be present on the system +# where it's going to be installed +cleanpamd() { + while [[ -n $1 ]]; do + if ! has_version sys-libs/pam; then + sed -i -e '/pam_shells\|pam_console/s:^:#:' "${D}/etc/pam.d/$1" + fi + + shift + done +} + +# @FUNCTION: pam_epam_expand +# @USAGE: +# @DESCRIPTION: +# Steer clear, deprecated, don't use, bad experiment +pam_epam_expand() { + sed -n -e 's|#%EPAM-\([[:alpha:]-]\+\):\([-+<>=/.![:alnum:]]\+\)%#.*|\1 \2|p' \ + "$@" | sort -u | while read condition parameter; do + + disable="yes" + + case "$condition" in + If-Has) + message="This can be used only if you have ${parameter} installed" + has_version "$parameter" && disable="no" + ;; + Use-Flag) + message="This can be used only if you enabled the ${parameter} USE flag" + use "$parameter" && disable="no" + ;; + *) + eerror "Unknown EPAM condition '${condition}' ('${parameter}')" + die "Unknown EPAM condition '${condition}' ('${parameter}')" + ;; + esac + + if [ "${disable}" = "yes" ]; then + sed -i -e "/#%EPAM-${condition}:${parameter/\//\\/}%#/d" "$@" + else + sed -i -e "s|#%EPAM-${condition}:${parameter}%#||" "$@" + fi + + done +} + +# Think about it before uncommenting this one, for now run it by hand +# pam_pkg_preinst() { +# eshopts_push -o noglob # so that bash doen't expand "*" +# +# pam_epam_expand "${D}"/etc/pam.d/* +# +# eshopts_pop # reset old shell opts +# } + +fi -- cgit v1.2.3-65-gdbad