public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: David Seifert <soap@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: David Seifert <soap@gentoo.org>
Subject: [gentoo-dev] [PATCH] pam.eclass: remove EAPI 6
Date: Wed, 26 Jul 2023 14:09:19 +0200	[thread overview]
Message-ID: <20230726120923.11560-1-soap@gentoo.org> (raw)

Signed-off-by: David Seifert <soap@gentoo.org>
---
 eclass/pam.eclass | 69 +++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/eclass/pam.eclass b/eclass/pam.eclass
index 22b59ad65e43..2516fa896587 100644
--- a/eclass/pam.eclass
+++ b/eclass/pam.eclass
@@ -6,14 +6,14 @@
 # base-system@gentoo.org
 # @AUTHOR:
 # Diego Pettenò <flameeyes@gentoo.org>
-# @SUPPORTED_EAPIS: 6 7 8
+# @SUPPORTED_EAPIS: 7 8
 # @BLURB: Handles pam related tasks
 # @DESCRIPTION:
 # This eclass contains functions to install pamd configuration files and
 # pam modules.
 
-case ${EAPI:-0} in
-	[678]) ;;
+case ${EAPI} in
+	7|8) ;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
@@ -22,6 +22,14 @@ _PAM_ECLASS=1
 
 inherit flag-o-matic
 
+# @FUNCTION: _pam_flag_disabled
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether pam support is disabled.
+_pam_flag_disabled() {
+	in_iuse pam && ! use pam
+}
+
 # @FUNCTION: dopamd
 # @USAGE: <file> [more files]
 # @DESCRIPTION:
@@ -29,15 +37,13 @@ inherit flag-o-matic
 dopamd() {
 	[[ -z $1 ]] && die "dopamd requires at least one argument"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0;
-	fi
+	_pam_flag_disabled && return 0
 
 	( # dont want to pollute calling env
 		insinto /etc/pam.d
 		insopts -m 0644
 		doins "$@"
-	) || die "failed to install $@"
+	)
 	cleanpamd "$@"
 }
 
@@ -48,15 +54,13 @@ dopamd() {
 newpamd() {
 	[[ $# -ne 2 ]] && die "newpamd requires two arguments"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0;
-	fi
+	_pam_flag_disabled && return 0
 
 	( # 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
 }
 
@@ -67,15 +71,13 @@ newpamd() {
 dopamsecurity() {
 	[[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0
-	fi
+	_pam_flag_disabled && return 0
 
 	( # dont want to pollute calling env
 		insinto /etc/security/$1
 		insopts -m 0644
 		doins "${@:2}"
-	) || die "failed to install ${@:2}"
+	)
 }
 
 # @FUNCTION: newpamsecurity
@@ -85,15 +87,13 @@ dopamsecurity() {
 newpamsecurity() {
 	[[ $# -ne 3 ]] && die "newpamsecurity requires three arguments"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0;
-	fi
+	_pam_flag_disabled && return 0
 
 	( # 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
@@ -129,12 +129,10 @@ EOF
 dopammod() {
 	[[ -z $1 ]] && die "dopammod requires at least one argument"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0;
-	fi
+	_pam_flag_disabled && return 0
 
 	exeinto $(getpam_mod_dir)
-	doexe "$@" || die "failed to install $@"
+	doexe "$@"
 }
 
 # @FUNCTION: newpammod
@@ -145,12 +143,10 @@ dopammod() {
 newpammod() {
 	[[ $# -ne 2 ]] && die "newpammod requires two arguments"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0;
-	fi
+	_pam_flag_disabled && return 0
 
 	exeinto $(getpam_mod_dir)
-	newexe "$1" "$2" || die "failed to install $1 as $2"
+	newexe "$1" "$2"
 }
 
 # @FUNCTION: pamd_mimic_system
@@ -171,26 +167,23 @@ pamd_mimic_system() {
 pamd_mimic() {
 	[[ $# -lt 3 ]] && die "pamd_mimic requires at least three arguments"
 
-	if has pam ${IUSE} && ! use pam; then
-		return 0;
-	fi
+	_pam_flag_disabled && return 0
 
 	dodir /etc/pam.d
-	pamdfile=${D}/etc/pam.d/$2
-	echo -e "# File autogenerated by pamd_mimic in pam eclass\n\n" >> \
-		$pamdfile
+	local pamdfile="${ED}/etc/pam.d/$2"
+	echo -e "# File autogenerated by pamd_mimic in pam eclass\n\n" \
+		>> "${pamdfile}" || die
 
-	originalstack=$1
-	authlevels="auth account password session"
+	local authlevels="auth account password session"
 
-	mimic="\tsubstack\t\t${originalstack}"
+	local mimic="\tsubstack\t\t$1"
 
 	shift; shift
 
 	while [[ -n $1 ]]; do
 		has $1 ${authlevels} || die "unknown level type"
 
-		echo -e "$1${mimic}" >> ${pamdfile}
+		echo -e "$1${mimic}" >> "${pamdfile}" || die
 
 		shift
 	done
@@ -204,7 +197,7 @@ pamd_mimic() {
 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" || die
+			sed -i -e '/pam_shells\|pam_console/s:^:#:' "${ED}/etc/pam.d/$1" || die
 		fi
 
 		shift
-- 
2.41.0



                 reply	other threads:[~2023-07-26 12:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230726120923.11560-1-soap@gentoo.org \
    --to=soap@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox