* [gentoo-dev] [PATCH] acct-user.eclass: always fix homedir permissions in pkg_preinst
@ 2022-12-21 19:53 Mike Gilbert
0 siblings, 0 replies; only message in thread
From: Mike Gilbert @ 2022-12-21 19:53 UTC (permalink / raw
To: gentoo-dev; +Cc: Mike Gilbert
Closes: https://bugs.gentoo.org/886147
Closes: https://github.com/gentoo/gentoo/pull/28744
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
---
eclass/acct-user.eclass | 51 ++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index a37e12121f8..14fda76ced7 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
--
2.39.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-21 19:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-21 19:53 [gentoo-dev] [PATCH] acct-user.eclass: always fix homedir permissions in pkg_preinst Mike Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox