Thursday, April 14, 2016

The new and old and obsolete and confusing ways Mac OS X starts code running.

Windows added uninstallers at least 15 years ago. MacClassic OS didn’t need them, but Mac OS X sadly does. Indeed, it needs them more as MacOS gets more complex and less well documented:

… The difference between an agent and a daemon is that an agent can display GUI if it wants to, while a daemon can’t. The difference between an agent and a regular application is that an agent typically displays no GUI (or a very limited GUI).

… Agents run in a user context; daemons are userless and purely background, without any access to a window server or other user state. That’s why the daemon vs agent distinction in the Library folder names …

… once comprehensive daemon/agent doc was last updated in 10.5 after initial authoring for 10.4

Without an uninstaller we end up doing a hunting expedition when weird things happen. Code that starts automatically is particularly hard to track down. I wrote this post as a reference for me, drawing from a few Super User and other posts:

 This list of places to look comes from the above, some of these are extremely obscure and some may not longer be used.

  • User Login Items (~/Library/Preferences/com.apple.loginitems.plist)
  • ~/Library/LaunchDaemons
  • ~/Library/LaunchAgents
  • ~/.bash_profile
  • /Library/LaunchDaemons
  • /Library/LaunchAgents
  • /Library/StartupItems
  • /System/Library/LaunchDaemons/
  • /System/Library/LaunchAgents
  • /System/Library/StartupItems
  • /Library/Preferences/loginwindow.plist can have Login Items that apply to all users
  • /etc/profile
  • /etc/mach_init.d/
  • /etc/rc/ and /etc/rc.local - totally unsupported, and not created by default (but probably still work)
  • Network/Library/LaunchDaemons, but I don’t know)?
  • /etc/mach_init_per_login_session.d/ and /etc/mach_init_per_user.d/
  • cron launched @reboot items (yes, cron is still there), this might even work for everyone’s crontabs
  • /Library/Security/SecurityAgentPlugins that have been loaded by being listed in the proper spots in /etc/authorization
  • /private/var/root/Library/Preferences/com.apple.loginwindow.plist, in the LoginHook key (runs as root, passed the username)MCX (WorkgroupManager) login hooks (runs as root, but passed the username) note: below this network home directories are more reliably available, as is a connection to the WindowsServer
  • MenuBar items from ~/Library/Preferences/com.apple.systemuiserver.plist and /Library/Preferences/com.apple.systemuiserver.plist (+MXC added items)
  • /Library/Preferences/loginwindow.plist, in the key (array of paths) AutoLaunchedApplicationDictionary (everyone gets this launched at login, runs as user) (+MXC added items)
  • LoginItems (generally GUI items) ~/Library/Preferences/com.apple.loginitems.plist and possibly /Library/Preferences/com.apple.loginitems.plist (have not tried) (+MXC added items)

Some terminal commands can help figure out what’s running:

launchctl list

2BUA8C4S2C.com.agilebits.onepassword4-helper
ch.tripmode.TripMode.169864
com.bombich.cccuseragent.132660
com.google.Chrome.44620
com.google.GoogleDrive.49732
com.google.keystone.system.agent
com.red-sweater.crashreporter.63648
com.red-sweater.marsedit.6280
com.synology.CloudStation
com.synology.CloudStationDrive
org.openbsd.ssh-agent
ws.agile.1PasswordAgent

When I edited my ~/Library/Preferences/com.apple.loginitems.plist I found references to 4 3 apps and a server, including one I removed 7-8 years and 3 machines ago:

  • LaunchBar.app
  • /Volumes/Molly_Internal
  • /Applications/Dropbox.app
  • MagicPrefs.app

I doubt they did anything, but I edited them out anyway.

Software ages like people, with increasing mutations and unhelpful complexity. OS X is late middle age, it’s been through many handoffs, each taking its toll …

See also

No comments: