summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2022-12-21 14:44:58 -0500
committerMike Gilbert <floppym@gentoo.org>2022-12-25 17:10:41 -0500
commit22e986ce87b4f983e9508803b83466c5183cde65 (patch)
treedcf8aef328e8c8111f1a19269760a8718ba07778 /eclass/acct-user.eclass
parentsys-libs/libnvme: remove needless python-utils-r1 inherit (diff)
downloadgentoo-22e986ce87b4f983e9508803b83466c5183cde65.tar.gz
gentoo-22e986ce87b4f983e9508803b83466c5183cde65.tar.bz2
gentoo-22e986ce87b4f983e9508803b83466c5183cde65.zip
acct-user.eclass: always fix homedir permissions in pkg_preinst
Closes: https://bugs.gentoo.org/886147 Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'eclass/acct-user.eclass')
-rw-r--r--eclass/acct-user.eclass51
1 files changed, 25 insertions, 26 deletions
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index a37e12121f83..14fda76ced73 100644
--- a/eclass/acct-user.eclass
+++ b/eclass/acct-user.eclass
@@ -339,36 +339,35 @@ acct-user_pkg_preinst() {
if egetent passwd "${ACCT_USER_NAME}" >/dev/null; then
elog "User ${ACCT_USER_NAME} already exists"
- return
- fi
-
- local groups=( ${_ACCT_USER_GROUPS} )
- local aux_groups=${groups[*]:1}
- local opts=(
- --system
- --no-create-home
- --no-user-group
- --comment "${_ACCT_USER_COMMENT}"
- --home-dir "${_ACCT_USER_HOME}"
- --shell "${_ACCT_USER_SHELL}"
- --gid "${groups[0]}"
- --groups "${aux_groups// /,}"
- )
+ else
+ local groups=( ${_ACCT_USER_GROUPS} )
+ local aux_groups=${groups[*]:1}
+ local opts=(
+ --system
+ --no-create-home
+ --no-user-group
+ --comment "${_ACCT_USER_COMMENT}"
+ --home-dir "${_ACCT_USER_HOME}"
+ --shell "${_ACCT_USER_SHELL}"
+ --gid "${groups[0]}"
+ --groups "${aux_groups// /,}"
+ )
+
+ if [[ ${_ACCT_USER_ID} -ne -1 ]] &&
+ ! egetent passwd "${_ACCT_USER_ID}" >/dev/null
+ then
+ opts+=( --uid "${_ACCT_USER_ID}" )
+ fi
- if [[ ${_ACCT_USER_ID} -ne -1 ]] &&
- ! egetent passwd "${_ACCT_USER_ID}" >/dev/null
- then
- opts+=( --uid "${_ACCT_USER_ID}" )
- fi
+ if [[ -n ${ROOT} ]]; then
+ opts+=( --prefix "${ROOT}" )
+ fi
- if [[ -n ${ROOT} ]]; then
- opts+=( --prefix "${ROOT}" )
+ elog "Adding user ${ACCT_USER_NAME}"
+ useradd "${opts[@]}" "${ACCT_USER_NAME}" || die
+ _ACCT_USER_ADDED=1
fi
- elog "Adding user ${ACCT_USER_NAME}"
- useradd "${opts[@]}" "${ACCT_USER_NAME}" || die
- _ACCT_USER_ADDED=1
-
if [[ ${_ACCT_USER_HOME} != /dev/null ]]; then
# default ownership to user:group
if [[ -z ${_ACCT_USER_HOME_OWNER} ]]; then