[CMake] nologin no longer tied to /sbin

It seems that the distributions places nologin in different
places (e.g. deb based distribution in /usr/sbin, rpm based and gentoo
in /sbin).  This patch fixes this behaviour searching for nologin in
the PATH environment variable.
This commit is contained in:
Davide Berardi 2020-01-31 21:25:33 +01:00
parent f2cc3c9724
commit 333a4c2c63
1 changed files with 6 additions and 3 deletions

View File

@ -1,17 +1,20 @@
execute_process(COMMAND bash -c "\
execute_process(COMMAND bash -euc "\
if ! getent group _cado >/dev/null 2>&1; then
groupadd \
--system \
_cado;
fi"
ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND bash -c "\
execute_process(COMMAND bash -euc "\
# get nologin path
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NOLOGIN=\"\$(which nologin)\"
if ! getent passwd _cado >/dev/null 2>&1; then
useradd \
--no-create-home \
--home-dir /nonexistent \
--system \
--shell /sbin/nologin \
--shell \"\$NOLOGIN\" \
-g _cado \
_cado;
fi"