File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,5 +178,5 @@ export function buildLaunchAgentPlist({
178178 ? `\n <key>Comment</key>\n <string>${ plistEscape ( comment . trim ( ) ) } </string>`
179179 : "" ;
180180 const envXml = renderEnvDict ( environment ) ;
181- return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n <dict>\n <key>Label</key>\n <string>${ plistEscape ( label ) } </string>\n ${ commentXml } \n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/ >\n <key>ThrottleInterval</key>\n <integer>${ LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS } </integer>\n <key>Umask</key>\n <integer>${ LAUNCH_AGENT_UMASK_DECIMAL } </integer>\n <key>ProgramArguments</key>\n <array>${ argsXml } \n </array>\n ${ workingDirXml } \n <key>StandardOutPath</key>\n <string>${ plistEscape ( stdoutPath ) } </string>\n <key>StandardErrorPath</key>\n <string>${ plistEscape ( stderrPath ) } </string>${ envXml } \n </dict>\n</plist>\n` ;
181+ return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n <dict>\n <key>Label</key>\n <string>${ plistEscape ( label ) } </string>\n ${ commentXml } \n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <dict>\n <key>SuccessfulExit</key>\n <false/>\n </dict >\n <key>ThrottleInterval</key>\n <integer>${ LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS } </integer>\n <key>Umask</key>\n <integer>${ LAUNCH_AGENT_UMASK_DECIMAL } </integer>\n <key>ProgramArguments</key>\n <array>${ argsXml } \n </array>\n ${ workingDirXml } \n <key>StandardOutPath</key>\n <string>${ plistEscape ( stdoutPath ) } </string>\n <key>StandardErrorPath</key>\n <string>${ plistEscape ( stderrPath ) } </string>${ envXml } \n </dict>\n</plist>\n` ;
182182}
Original file line number Diff line number Diff line change @@ -527,7 +527,7 @@ describe("launchd install", () => {
527527 expect ( state . dirModes . get ( tmpDir ) ) . toBe ( 0o700 ) ;
528528 } ) ;
529529
530- it ( "writes KeepAlive=true policy with restrictive umask" , async ( ) => {
530+ it ( "writes KeepAlive SuccessfulExit=false policy with restrictive umask" , async ( ) => {
531531 const env = createDefaultLaunchdEnv ( ) ;
532532 await installLaunchAgent ( {
533533 env,
@@ -538,8 +538,9 @@ describe("launchd install", () => {
538538 const plistPath = resolveLaunchAgentPlistPath ( env ) ;
539539 const plist = state . files . get ( plistPath ) ?? "" ;
540540 expect ( plist ) . toContain ( "<key>KeepAlive</key>" ) ;
541- expect ( plist ) . toContain ( "<true/>" ) ;
542- expect ( plist ) . not . toContain ( "<key>SuccessfulExit</key>" ) ;
541+ expect ( plist ) . toContain ( "<key>SuccessfulExit</key>" ) ;
542+ expect ( plist ) . toContain ( "<false/>" ) ;
543+ expect ( plist ) . not . toContain ( "<key>KeepAlive</key>\n <true/>" ) ;
543544 expect ( plist ) . toContain ( "<key>Umask</key>" ) ;
544545 expect ( plist ) . toContain ( `<integer>${ LAUNCH_AGENT_UMASK_DECIMAL } </integer>` ) ;
545546 expect ( plist ) . toContain ( "<key>ThrottleInterval</key>" ) ;
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ async function auditLaunchdPlist(
188188 }
189189
190190 const hasRunAtLoad = / < k e y > R u n A t L o a d < \/ k e y > \s * < t r u e \s * \/ > / i. test ( content ) ;
191- const hasKeepAlive = / < k e y > K e e p A l i v e < \/ k e y > \s * < t r u e \s * \/ > / i. test ( content ) ;
191+ const hasKeepAlive =
192+ / < k e y > K e e p A l i v e < \/ k e y > \s * < t r u e \s * \/ > / i. test ( content ) ||
193+ / < k e y > K e e p A l i v e < \/ k e y > \s * < d i c t > \s * < k e y > S u c c e s s f u l E x i t < \/ k e y > \s * < f a l s e \s * \/ > \s * < \/ d i c t > / i. test ( content ) ;
192194 if ( ! hasRunAtLoad ) {
193195 issues . push ( {
194196 code : SERVICE_AUDIT_CODES . launchdRunAtLoad ,
@@ -200,7 +202,7 @@ async function auditLaunchdPlist(
200202 if ( ! hasKeepAlive ) {
201203 issues . push ( {
202204 code : SERVICE_AUDIT_CODES . launchdKeepAlive ,
203- message : "LaunchAgent is missing KeepAlive=true " ,
205+ message : "LaunchAgent is missing KeepAlive policy " ,
204206 detail : plistPath ,
205207 level : "recommended" ,
206208 } ) ;
You can’t perform that action at this time.
0 commit comments