diff options
author | Mike Gilbert <floppym@gentoo.org> | 2022-10-17 16:23:55 -0400 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2022-10-19 12:47:30 -0400 |
commit | bb98008712b030180bcfc7f987ad3e8790268441 (patch) | |
tree | 132d7b22d6e5abdeea71ab9741a9d848fcce580a /eclass/acct-user.eclass | |
parent | acct-user.eclass: support user override of comment (diff) | |
download | gentoo-bb98008712b030180bcfc7f987ad3e8790268441.tar.gz gentoo-bb98008712b030180bcfc7f987ad3e8790268441.tar.bz2 gentoo-bb98008712b030180bcfc7f987ad3e8790268441.zip |
acct-user.eclass: respect ACCT_USER_NO_MODIFY in pkg_prerm
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'eclass/acct-user.eclass')
-rw-r--r-- | eclass/acct-user.eclass | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index 655a7adc225d..91a262e2a7a8 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -511,28 +511,35 @@ acct-user_pkg_postinst() { acct-user_pkg_prerm() { debug-print-function ${FUNCNAME} "${@}" + if [[ -n ${REPLACED_BY_VERSION} ]]; then + return + fi + if [[ ${EUID} -ne 0 ]]; then einfo "Insufficient privileges to execute ${FUNCNAME[0]}" - return 0 + return fi if [[ ${ACCT_USER_ID} -eq 0 ]]; then elog "Refusing to lock out the superuser (UID 0)" - return 0 + return fi - if [[ -z ${REPLACED_BY_VERSION} ]]; then - if [[ -z $(egetent passwd "${ACCT_USER_NAME}") ]]; then - ewarn "User account not found: ${ACCT_USER_NAME}" - ewarn "Locking process will be skipped." - return - fi + if [[ -n ${ACCT_USER_NO_MODIFY} ]]; then + elog "Not locking user ${ACCT_USER_NAME} due to ACCT_USER_NO_MODIFY" + return + fi - esetshell "${ACCT_USER_NAME}" -1 - esetcomment "${ACCT_USER_NAME}" \ - "$(egetcomment "${ACCT_USER_NAME}"); user account removed @ $(date +%Y-%m-%d)" - elockuser "${ACCT_USER_NAME}" + if ! egetent passwd "${ACCT_USER_NAME}" >/dev/null; then + ewarn "User account not found: ${ACCT_USER_NAME}" + ewarn "Locking process will be skipped." + return fi + + esetshell "${ACCT_USER_NAME}" -1 + esetcomment "${ACCT_USER_NAME}" \ + "$(egetcomment "${ACCT_USER_NAME}"); user account removed @ $(date +%Y-%m-%d)" + elockuser "${ACCT_USER_NAME}" } fi |