summaryrefslogtreecommitdiff
path: root/eclass/acct-user.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-05-12 16:42:50 +0300
committerV3n3RiX <venerix@koprulu.sector>2022-05-12 16:42:50 +0300
commit752d6256e5204b958b0ef7905675a940b5e9172f (patch)
tree330d16e6362a49cbed8875a777fe641a43376cd3 /eclass/acct-user.eclass
parent0c100b7dd2b30e75b799d806df4ef899fd98e1ea (diff)
gentoo resync : 12.05.2022
Diffstat (limited to 'eclass/acct-user.eclass')
-rw-r--r--eclass/acct-user.eclass53
1 files changed, 41 insertions, 12 deletions
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index f2aaefc2ee39..c87b27f3ccaa 100644
--- a/eclass/acct-user.eclass
+++ b/eclass/acct-user.eclass
@@ -141,7 +141,7 @@ readonly ACCT_USER_NAME
# << Boilerplate ebuild variables >>
: ${DESCRIPTION:="System user: ${ACCT_USER_NAME}"}
: ${SLOT:=0}
-: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris}
+: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 ~loong m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris}
S=${WORKDIR}
@@ -195,8 +195,15 @@ eislocked() {
*)
# NB: 'no password' and 'locked' are indistinguishable
# but we also expire the account which is more clear
- [[ $(getent shadow "$1" | cut -d: -f2) == '!'* ]] &&
- [[ $(getent shadow "$1" | cut -d: -f8) == 1 ]]
+ local shadow
+ if [[ -n "${ROOT}" ]]; then
+ shadow=$(grep "^$1:" "${ROOT}/etc/shadow")
+ else
+ shadow=$(getent shadow "$1")
+ fi
+
+ [[ $( echo ${shadow} | cut -d: -f2) == '!'* ]] &&
+ [[ $(echo ${shadow} | cut -d: -f8) == 1 ]]
;;
esac
}
@@ -223,14 +230,22 @@ elockuser() {
eislocked "$1"
[[ $? -eq 0 ]] && return 0
+ local opts
+ [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" )
+
case ${CHOST} in
*-freebsd*|*-dragonfly*)
- pw lock "$1" || die "Locking account $1 failed"
- pw user mod "$1" -e 1 || die "Expiring account $1 failed"
+ pw lock "${opts[@]}" "$1" || die "Locking account $1 failed"
+ pw user mod "${opts[@]}" "$1" -e 1 || die "Expiring account $1 failed"
;;
*-netbsd*)
- usermod -e 1 -C yes "$1" || die "Locking account $1 failed"
+ if [[ -n "${ROOT}" ]]; then
+ ewarn "NetBSD's usermod does not support --prefix <dir> option."
+ ewarn "Please use: usermod ${opts[@]} -e 1 -C yes \"$1\" in a chroot"
+ else
+ usermod "${opts[@]}" -e 1 -C yes "$1" || die "Locking account $1 failed"
+ fi
;;
*-openbsd*)
@@ -238,7 +253,7 @@ elockuser() {
;;
*)
- usermod -e 1 -L "$1" || die "Locking account $1 failed"
+ usermod "${opts[@]}" -e 1 -L "$1" || die "Locking account $1 failed"
;;
esac
@@ -266,14 +281,22 @@ eunlockuser() {
eislocked "$1"
[[ $? -eq 1 ]] && return 0
+ local opts
+ [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" )
+
case ${CHOST} in
*-freebsd*|*-dragonfly*)
- pw user mod "$1" -e 0 || die "Unexpiring account $1 failed"
- pw unlock "$1" || die "Unlocking account $1 failed"
+ pw user mod "${opts[@]}" "$1" -e 0 || die "Unexpiring account $1 failed"
+ pw unlock "${opts[@]}" "$1" || die "Unlocking account $1 failed"
;;
*-netbsd*)
- usermod -e 0 -C no "$1" || die "Unlocking account $1 failed"
+ if [[ -n "${ROOT}" ]]; then
+ ewarn "NetBSD's usermod does not support --prefix <dir> option."
+ ewarn "Please use: \"usermod ${opts[@]} -e 0 -C no $1\" in a chroot"
+ else
+ usermod "${opts[@]}" -e 0 -C no "$1" || die "Unlocking account $1 failed"
+ fi
;;
*-openbsd*)
@@ -282,7 +305,7 @@ eunlockuser() {
*)
# silence warning if account does not have a password
- usermod -e "" -U "$1" 2>/dev/null || die "Unlocking account $1 failed"
+ usermod "${opts[@]}" -e "" -U "$1" 2>/dev/null || die "Unlocking account $1 failed"
;;
esac
@@ -418,7 +441,13 @@ acct-user_pkg_preinst() {
# default ownership to user:group
if [[ -z ${_ACCT_USER_HOME_OWNER} ]]; then
local group_array=( ${_ACCT_USER_GROUPS} )
- _ACCT_USER_HOME_OWNER=${ACCT_USER_NAME}:${group_array[0]}
+ if [[ -n "${ROOT}" ]]; then
+ local euid=$(egetent passwd ${ACCT_USER_NAME} | cut -d: -f3)
+ local egid=$(egetent passwd ${ACCT_USER_NAME} | cut -d: -f4)
+ _ACCT_USER_HOME_OWNER=${euid}:${egid}
+ else
+ _ACCT_USER_HOME_OWNER=${ACCT_USER_NAME}:${group_array[0]}
+ fi
fi
# Path might be missing due to INSTALL_MASK, etc.
# https://bugs.gentoo.org/691478