launchd Informational Web Server

One of the things that I meant to show during the demo, but failed actually do was this little tidbit...

If you perform a search of your system drive (using locate or find...not Spotlight), you'll find a man page for "launchd_debugd".  Or,if, as mentioned in the session, you use the source code for launchd (available from macosforge.org) as documentation, you'll see a plist called launchd_helper.  Sounds promising.  However, you're instructed,

'To enable (as root): "launchctl load -w /System/Library/LaunchDaemons/com.apple.launchd_helperd.plist"'

If you try this, though, you'll find that said plist does not exist.  Back to the source, and you'll find it.  If you're not into downloading the source for this one file, here's its contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.apple.launchd_debugd</string>
        <key>ProgramArguments</key>
        <array>
                <string>launchd_debugd</string>
        </array>
        <key>ServiceIPC</key>
        <true/>
        <key>Sockets</key>
        <dict>
                <key>Listeners</key>
                <array>
                        <dict>
                                <key>SockPassive</key>
                                <true/>
                                <key>SockServiceName</key>
                                <integer>12345</integer>
                                <key>SockType</key>
                                <string>SOCK_STREAM</string>
                        </dict>
                </array>
        </dict>
</dict>
</plist>

Save this as a text file as "/System/Library/LaunchDaemons/com.apple.launchd_helperd.plist".  Then go ahead and, as root:

load /System/Library/LaunchDaemons/com.apple.launchd_helperd.plist

What now?  Open up a web browser, point it at the machine (or 127.0.0.1, if you're local) and port 12345, and you'll get a  listing of all jobs loaded into launchd.  I haven't found too much practical use for this for troubleshooting, as I'd normally have ssh access anyway, and could just use launchctl to list the same jobs.  However, I toyed with using this as an automated way to find new and unexpected jobs running on corporate machines.  I stopped, however, as again, I'll just shell script this.  Of course, if you have systems that really like HTML input to parse, this just might be the trick!

Enjoy.