Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11164

launchd service provider fails if a parsable but invalid LaunchAgent or LaunchDaemon plist file exists

    XMLWordPrintable

Details

    • Night's Watch
    • 1
    • NW - 2021-07-28
    • Needs Assessment
    • ccaviness
    • Bug Fix
    • Fix an issue where the `launchd` service provider would fail if a parsable but invalid LaunchAgent or LaunchDaemon plist file exists.
    • Needs Assessment

    Description

      If a file in the LaunchAgents or LaunchDaemons paths is encountered that's parseable by Puppet::Util::Plist.read_plist_from_file but not a valid launchd plist file, then Puppet will crash with an error.

      To reproduce:

      # echo "aaa" >/Library/LaunchDaemons/invalid.txt
      # puppet resource service
      Error: Could not run: undefined method `has_key?' for "aaa":String
      

      In launchd.rb line 141, the parsed plist (job) is checked with .has_key? to ensure a Label is present. If the parsed plist is not a Hash, though, this will fail.

      I expect the correct course of action is to add a job.is_a?(Hash) check first.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ccaviness Clay Caviness
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support