Move 'internal' tools to /usr/local/munki/libexec

This commit is contained in:
Greg Neagle
2025-09-11 14:21:13 -07:00
parent 3fe773fe60
commit b19e9e748e
12 changed files with 42 additions and 21 deletions

View File

@@ -119,7 +119,7 @@ func createInstallHelperLaunchDaemon(_ group: String) {
let launchDaemon: [String: Any] = [
"EnvironmentVariables": ["INSTALLHELPER_RUN_TYPE": group],
"Label": label,
"ProgramArguments": ["/usr/local/munki/installhelper"],
"ProgramArguments": ["/usr/local/munki/libexec/installhelper"],
"RunAtLoad": true,
]
// write out launchd plist

View File

@@ -109,7 +109,7 @@ struct ManagedSoftwareUpdate: AsyncParsableCommand {
let ourPid = ProcessInfo().processIdentifier
munkiLog(String(repeating: "*", count: 60))
munkiLog("\(ourName) launched as pid \(ourPid)")
munkiLog("Another instance of \(ourName) is running as pid \(proc.pid).")
munkiLog("Another instance of \(ourName) is running as pid \(proc.pid) from \(proc.path)")
munkiLog("This process (pid \(ourPid)) exiting.")
munkiLog(String(repeating: "*", count: 60))
printStderr("Another instance of \(ourName) is running. Exiting.")

View File

@@ -452,9 +452,9 @@ func startPrecachingAgent() {
return
}
// first look in same dir as the current executable
var precacheAgentPath = currentExecutableDir(appendingPathComponent: "precache_agent")
var precacheAgentPath = currentExecutableDir(appendingPathComponent: "libexec/precache_agent")
if !pathExists(precacheAgentPath) {
precacheAgentPath = "/usr/local/munki/precache_agent"
precacheAgentPath = "/usr/local/munki/libexec/precache_agent"
}
if pathExists(precacheAgentPath) {
display.info("Starting precaching agent")

View File

@@ -466,9 +466,10 @@ mkdir -m 1775 "$COREROOT"
mkdir -m 755 "$COREROOT/usr"
mkdir -m 755 "$COREROOT/usr/local"
mkdir -m 755 "$COREROOT/usr/local/munki"
mkdir -m 755 "$COREROOT/usr/local/munki/libexec"
# Copy command line utilities.
# edit this if list of tools changes!
for TOOL in authrestartd launchapp logouthelper removepackages managedsoftwareupdate precache_agent
for TOOL in removepackages managedsoftwareupdate
do
cp -X "$MUNKIROOT/code/build/binaries/$TOOL" "$COREROOT/usr/local/munki/" 2>&1
# sign tool
@@ -485,10 +486,28 @@ do
fi
fi
done
for TOOL in authrestartd launchapp logouthelper precache_agent
do
cp -X "$MUNKIROOT/code/build/binaries/$TOOL" "$COREROOT/usr/local/munki/libexec/" 2>&1
# sign tool
if [ "$APPSIGNINGCERT" != "" ]; then
echo "Signing $TOOL..."
/usr/bin/codesign -f -s "$APPSIGNINGCERT" \
--preserve-metadata=entitlements \
--options runtime --timestamp --verbose \
"$COREROOT/usr/local/munki/libexec/$TOOL"
SIGNING_RESULT="$?"
if [ "$SIGNING_RESULT" -ne 0 ]; then
echo "Error signing $TOOL: $SIGNING_RESULT"
exit 2
fi
fi
done
# Set permissions.
chmod -R go-w "$COREROOT/usr/local/munki"
chmod +x "$COREROOT/usr/local/munki"
chmod +x "$COREROOT/usr/local/munki/libexec"
# make paths.d file
mkdir -m 755 "$COREROOT/private"
@@ -675,6 +694,7 @@ mkdir -m 755 "$LAUNCHDROOT/Library/LaunchDaemons"
mkdir -m 755 "$LAUNCHDROOT/usr"
mkdir -m 755 "$LAUNCHDROOT/usr/local"
mkdir -m 755 "$LAUNCHDROOT/usr/local/munki"
mkdir -m 755 "$LAUNCHDROOT/usr/local/munki/libexec"
# Copy launch daemons and launch agents.
cp -X "$MUNKIROOT/launchd/LaunchAgents/"*.plist "$LAUNCHDROOT/Library/LaunchAgents/"
@@ -686,11 +706,11 @@ chmod 644 "$LAUNCHDROOT/Library/LaunchDaemons/"*
# edit this if list of tools changes!
for TOOL in installhelper
do
cp -X "$MUNKIROOT/code/build/binaries/$TOOL" "$LAUNCHDROOT/usr/local/munki/" 2>&1
cp -X "$MUNKIROOT/code/build/binaries/$TOOL" "$LAUNCHDROOT/usr/local/munki/libexec/" 2>&1
# sign tool
if [ "$APPSIGNINGCERT" != "" ]; then
echo "Signing $TOOL..."
/usr/bin/codesign -f -s "$APPSIGNINGCERT" --options runtime --timestamp --verbose "$LAUNCHDROOT/usr/local/munki/$TOOL"
/usr/bin/codesign -f -s "$APPSIGNINGCERT" --options runtime --timestamp --verbose "$LAUNCHDROOT/usr/local/munki/libexec/$TOOL"
SIGNING_RESULT="$?"
if [ "$SIGNING_RESULT" -ne 0 ]; then
echo "Error signing $TOOL: $SIGNING_RESULT"
@@ -701,6 +721,7 @@ done
# Set permissions.
chmod -R go-w "$LAUNCHDROOT/usr/local/munki"
chmod +x "$LAUNCHDROOT/usr/local/munki"
chmod +x "$LAUNCHDROOT/usr/local/munki/libexec"
# copy in launchd cleanup scripts
if [ -d "$MUNKIROOT/code/tools/pkgresources/launchd_cleanup_scripts/" ] ; then
@@ -726,6 +747,7 @@ mkdir -m 755 "$APPUSAGEROOT/Library/LaunchDaemons"
mkdir -m 755 "$APPUSAGEROOT/usr"
mkdir -m 755 "$APPUSAGEROOT/usr/local"
mkdir -m 755 "$APPUSAGEROOT/usr/local/munki"
mkdir -m 755 "$APPUSAGEROOT/usr/local/munki/libexec"
# Copy launch agent, launch daemon, daemon, and agent
# LaunchAgent
cp -X "$MUNKIROOT/launchd/app_usage_LaunchAgent/"*.plist "$APPUSAGEROOT/Library/LaunchAgents/"
@@ -737,11 +759,11 @@ chmod 644 "$APPUSAGEROOT/Library/LaunchDaemons/"*
# edit this if list of tools changes!
for TOOL in appusaged app_usage_monitor installhelper
do
cp -X "$MUNKIROOT/code/build/binaries/$TOOL" "$APPUSAGEROOT/usr/local/munki/" 2>&1
cp -X "$MUNKIROOT/code/build/binaries/$TOOL" "$APPUSAGEROOT/usr/local/munki/libexec/" 2>&1
# sign tool
if [ "$APPSIGNINGCERT" != "" ]; then
echo "Signing $TOOL..."
/usr/bin/codesign -f -s "$APPSIGNINGCERT" --options runtime --timestamp --verbose "$APPUSAGEROOT/usr/local/munki/$TOOL"
/usr/bin/codesign -f -s "$APPSIGNINGCERT" --options runtime --timestamp --verbose "$APPUSAGEROOT/usr/local/munki/libexec/$TOOL"
SIGNING_RESULT="$?"
if [ "$SIGNING_RESULT" -ne 0 ]; then
echo "Error signing $TOOL: $SIGNING_RESULT"
@@ -752,6 +774,7 @@ done
# Set permissions.
chmod -R go-w "$APPUSAGEROOT/usr/local/munki"
chmod +x "$APPUSAGEROOT/usr/local/munki"
chmod +x "$APPUSAGEROOT/usr/local/munki/libexec"
# copy in app_usage cleanup scripts
if [ -d "$MUNKIROOT/code/tools/pkgresources/app_usage_cleanup_scripts/" ] ; then

View File

@@ -8,9 +8,8 @@
# Only execute postinstall actions if we're installing on a live system.
if [ "$3" = "/" ]
then
installHelper='/usr/local/munki/installhelper'
if [ -f "${installHelper}" ]
then
installHelper='/usr/local/munki/libexec/installhelper'
if [ -f "${installHelper}" ] ; then
/bin/echo "Loading ${installHelper}..."
"${installHelper}" appusage &
else

View File

@@ -8,9 +8,8 @@
# Only execute postinstall actions if we're installing on a live system.
if [ "$3" = "/" ]
then
installHelper='/usr/local/munki/installhelper'
if [ -f "${installHelper}" ]
then
installHelper='/usr/local/munki/libexec/installhelper'
if [ -f "${installHelper}" ] ; then
/bin/echo "Loading ${installHelper}..."
"${installHelper}" launchd
else

View File

@@ -18,7 +18,7 @@
</array>
<key>ProgramArguments</key>
<array>
<string>/usr/local/munki/launchapp</string>
<string>/usr/local/munki/libexec/launchapp</string>
<string>-a</string>
<string>/Applications/Managed Software Center.app</string>
</array>

View File

@@ -18,7 +18,7 @@
</array>
<key>ProgramArguments</key>
<array>
<string>/usr/local/munki/launchapp</string>
<string>/usr/local/munki/libexec/launchapp</string>
<string>-a</string>
<string>/Applications/Managed Software Center.app/Contents/Helpers/munki-notifier.app</string>
</array>

View File

@@ -6,7 +6,7 @@
<string>com.googlecode.munki.authrestartd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/munki/authrestartd</string>
<string>/usr/local/munki/libexec/authrestartd</string>
</array>
<key>Sockets</key>
<dict>

View File

@@ -6,7 +6,7 @@
<string>com.googlecode.munki.logouthelper</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/munki/logouthelper</string>
<string>/usr/local/munki/libexec/logouthelper</string>
</array>
</dict>
</plist>

View File

@@ -8,7 +8,7 @@
<string>com.googlecode.munki.app_usage_monitor</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/munki/app_usage_monitor</string>
<string>/usr/local/munki/libexec/app_usage_monitor</string>
</array>
<key>RunAtLoad</key>
<true/>

View File

@@ -6,7 +6,7 @@
<string>com.googlecode.munki.appusaged</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/munki/appusaged</string>
<string>/usr/local/munki/libexec/appusaged</string>
</array>
<key>Sockets</key>
<dict>