@cryptotaxi247 / netdata-1 / commits / 175515ce4

Fix issues with permissions when installing from source on macOS (#17198)

Ilya Mashchenko committed Mar 20, 2024 at 09:15 UTC 175515ce497269779d11cb236213aa18e01b862a
2 files changed +14 -1
packaging/installer/functions.sh
+12 -1
@@ -934,6 +934,11 @@ portable_add_user() {
934 echo >&2 "User '${username}' already exists."
935 return 0
936 fi
937 + elif command -v dscl > /dev/null 2>&1; then
938 + if dscl . read /Users/"${username}" >/dev/null 2>&1; then
939 + echo >&2 "User '${username}' already exists."
940 + return 0
941 + fi
942 else
943 if cut -d ':' -f 1 < /etc/passwd | grep "^${username}$" 1> /dev/null 2>&1; then
944 echo >&2 "User '${username}' already exists."
@@ -952,7 +957,13 @@ portable_add_user() {
957 elif command -v adduser 1> /dev/null 2>&1; then
958 run adduser -h "${homedir}" -s "${nologin}" -D -G "${username}" "${username}" && return 0
959 elif command -v sysadminctl 1> /dev/null 2>&1; then
955 - run sysadminctl -addUser "${username}" && return 0
960 + gid=$(dscl . read /Groups/"${username}" 2>/dev/null | grep PrimaryGroupID | grep -Eo "[0-9]+")
961 + if run sysadminctl -addUser "${username}" -shell /usr/bin/false -home /var/empty -GID "$gid"; then
962 + # FIXME: I think the proper solution is to create a role account:
963 + # -roleAccount + name starting with _ and UID in 200-400 range.
964 + run dscl . create /Users/"${username}" IsHidden 1
965 + return 0
966 + fi
967 fi
968
969 warning "Failed to add ${username} user account!"
system/install-service.sh.in
+2
@@ -630,6 +630,8 @@ install_darwin_service() {
630 exit 4
631 fi
632
633 + launchctl unload /Library/LaunchDaemons/com.github.netdata.plist 2>/dev/null
634 +
635 if ! launchctl load /Library/LaunchDaemons/com.github.netdata.plist; then
636 error "Failed to load plist file."
637 exit 4