Extract is_user() and is_group() functions

This commit is contained in:
Jérémy Lecour 2020-05-04 23:16:19 +02:00 committed by Jérémy Lecour
parent 09c1a7a579
commit a30be3872f
2 changed files with 10 additions and 2 deletions

View file

@ -18,7 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Rename internal function usage() to show_usage()
* More readable variable names
* verify_ca_password() looks for a previously set password and verifies it
* Extract function cert_end_date()
* Extract cert_end_date() function
* Extract is_user() and is_group() functions
### Deprecated

View file

@ -612,6 +612,13 @@ check() {
done
}
is_user() {
getent passwd "${1}" >/dev/null
}
is_group() {
getent group "${1}" >/dev/null
}
main() {
# default config
# TODO : override with /etc/default/shellpki
@ -657,7 +664,7 @@ main() {
OPENSSL_BIN=$(command -v openssl)
SUFFIX=$(/bin/date +"%s")
if ! getent passwd "${PKI_USER}" >/dev/null ! getent group "${PKI_USER}" >/dev/null; then
if ! is_user "${PKI_USER}" || ! is_group "${PKI_USER}"; then
error "You must create ${PKI_USER} user and group !"
fi