mirror of https://github.com/CISOfy/lynis.git
Run `brew` as regular user in place of root
This commit is contained in:
parent
3c9b37986a
commit
9a86c00373
|
@ -91,6 +91,7 @@
|
||||||
# ReportManual Log manual actions to report file
|
# ReportManual Log manual actions to report file
|
||||||
# ReportSuggestion Add a suggestion to report file
|
# ReportSuggestion Add a suggestion to report file
|
||||||
# ReportWarning Add a warning and priority to report file
|
# ReportWarning Add a warning and priority to report file
|
||||||
|
# RunBrewCmd Run Homebrew commands as a normal user instead of root
|
||||||
# SafeFile Security tests to perform on a file before using it
|
# SafeFile Security tests to perform on a file before using it
|
||||||
# SafePerms Check if a file has safe permissions
|
# SafePerms Check if a file has safe permissions
|
||||||
# SafeInput Test provided string to see if it contains unwanted characters
|
# SafeInput Test provided string to see if it contains unwanted characters
|
||||||
|
@ -3036,6 +3037,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Name : RunBrewCmd()
|
||||||
|
# Description : Run Homebrew commands as a normal user instead of root
|
||||||
|
#
|
||||||
|
# Parameters : $@ = Homebrew command arguments
|
||||||
|
# Returns : None (executes the command as the appropriate user)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
RunBrewCmd() {
|
||||||
|
case "$(id -u)" in
|
||||||
|
0) sudo -u "$SUDO_USER" brew "$@" ;;
|
||||||
|
*) brew "$@"
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Name : SafeInput()
|
# Name : SafeInput()
|
||||||
# Description : Test provided string to see if it contains unwanted characters
|
# Description : Test provided string to see if it contains unwanted characters
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
LogText "Test: Querying brew to get package list"
|
LogText "Test: Querying brew to get package list"
|
||||||
Display --indent 4 --text "- Querying brew for installed packages"
|
Display --indent 4 --text "- Querying brew for installed packages"
|
||||||
LogText "Output:"; LogText "-----"
|
LogText "Output:"; LogText "-----"
|
||||||
GPACKAGES=$(brew list --versions)
|
GPACKAGES=$(RunBrewCmd list --versions)
|
||||||
while IFS= read -r PKG; do
|
while IFS= read -r PKG; do
|
||||||
PACKAGE_NAME=$(echo ${PKG} | ${CUTBINARY} -d ' ' -f1)
|
PACKAGE_NAME=$(echo ${PKG} | ${CUTBINARY} -d ' ' -f1)
|
||||||
PACKAGE_VERSION=$(echo ${PKG} | ${CUTBINARY} -d ' ' -f2)
|
PACKAGE_VERSION=$(echo ${PKG} | ${CUTBINARY} -d ' ' -f2)
|
||||||
|
@ -183,7 +183,7 @@ EOF
|
||||||
PACKAGE_VERSION=$(defaults read "$CS/Contents/Info" CFBundleShortVersionString 2>/dev/null || echo "N/A")
|
PACKAGE_VERSION=$(defaults read "$CS/Contents/Info" CFBundleShortVersionString 2>/dev/null || echo "N/A")
|
||||||
LogText "Found CoreServices: ${PACKAGE_NAME} (version: ${PACKAGE_VERSION})"
|
LogText "Found CoreServices: ${PACKAGE_NAME} (version: ${PACKAGE_VERSION})"
|
||||||
INSTALLED_PACKAGES="${INSTALLED_PACKAGES}|${PACKAGE_NAME},${PACKAGE_VERSION}"
|
INSTALLED_PACKAGES="${INSTALLED_PACKAGES}|${PACKAGE_NAME},${PACKAGE_VERSION}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
Loading…
Reference in New Issue