From 333a4c2c6341555d4f42072761f9bcd3b70098c5 Mon Sep 17 00:00:00 2001 From: Davide Berardi Date: Fri, 31 Jan 2020 21:25:33 +0100 Subject: [PATCH] [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. --- PostInstall.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PostInstall.cmake b/PostInstall.cmake index 6dc0523..9c6a9a5 100644 --- a/PostInstall.cmake +++ b/PostInstall.cmake @@ -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"