mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-08 10:52:03 +01:00
eclass/acct-user: Sync with Gentoo
It's from Gentoo commit e6f14e5d76fff757860691c7aa2f94172018711a.
This commit is contained in:
parent
344b3c68b5
commit
f02722d477
@ -362,7 +362,7 @@ acct-user_pkg_preinst() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
elog "Adding user ${ACCT_USER_NAME}"
|
elog "Adding user ${ACCT_USER_NAME}"
|
||||||
useradd "${opts[@]}" "${ACCT_USER_NAME}" || die
|
useradd "${opts[@]}" "${ACCT_USER_NAME}" || die "useradd failed with status $?"
|
||||||
_ACCT_USER_ADDED=1
|
_ACCT_USER_ADDED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -432,12 +432,30 @@ acct-user_pkg_postinst() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
elog "Updating user ${ACCT_USER_NAME}"
|
elog "Updating user ${ACCT_USER_NAME}"
|
||||||
if ! usermod "${opts[@]}" "${ACCT_USER_NAME}" 2>"${T}/usermod-error.log"; then
|
# usermod outputs a warning if unlocking the account would result in an
|
||||||
# usermod outputs a warning if unlocking the account would result in an
|
# empty password. Hide stderr in a text file and display it if usermod fails.
|
||||||
# empty password. Hide stderr in a text file and display it if usermod
|
usermod "${opts[@]}" "${ACCT_USER_NAME}" 2>"${T}/usermod-error.log"
|
||||||
# fails.
|
local status=$?
|
||||||
|
if [[ ${status} -ne 0 ]]; then
|
||||||
cat "${T}/usermod-error.log" >&2
|
cat "${T}/usermod-error.log" >&2
|
||||||
die "usermod failed"
|
if [[ ${status} -eq 8 ]]; then
|
||||||
|
# usermod refused to update the home directory
|
||||||
|
# for a uid with active processes.
|
||||||
|
eerror "Failed to update user ${ACCT_USER_NAME}"
|
||||||
|
eerror "This user currently has one or more running processes."
|
||||||
|
eerror "Please update this user manually with the following command:"
|
||||||
|
|
||||||
|
# Surround opts with quotes.
|
||||||
|
# With bash-5 (EAPI 8), we can use "${opts[@]@Q}" instead.
|
||||||
|
local q="'"
|
||||||
|
local optsq=( "${opts[@]/#/${q}}" )
|
||||||
|
optsq=( "${optsq[@]/%/${q}}" )
|
||||||
|
|
||||||
|
eerror " usermod ${optsq[*]} ${ACCT_USER_NAME}"
|
||||||
|
else
|
||||||
|
eerror "$(<"${T}/usermod-error.log")"
|
||||||
|
die "usermod failed with status ${status}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +502,7 @@ acct-user_pkg_prerm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
elog "Locking user ${ACCT_USER_NAME}"
|
elog "Locking user ${ACCT_USER_NAME}"
|
||||||
usermod "${opts[@]}" "${ACCT_USER_NAME}" || die
|
usermod "${opts[@]}" "${ACCT_USER_NAME}" || die "usermod failed with status $?"
|
||||||
}
|
}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user