Automatic startup of ClamXav Sentry at login for all users

Last modified: December 31 1969 16:00:00

Background:

Installation of ClamXav under the administrator account on OS X 10.4 (Intel MacBook) worked, and the admin user was able to configure the Folder Sentry feature to launch automatically at login. However, under a managed, non-admin-privileged "student" account, the auto-start-at-login preference refused to save, either because of privilege problems with the student account, a bug with ClamXav, or both.

The fix outlined here bypasses the default method that ClamXav uses (which involves adding the Sentry app to the user's System Preferences -> Accounts -> Login Items list). Instead, a launchd "agent" script is used to open the Sentry app (which is itself located inside the main ClamXav application, only visible via the Terminal or the "Show Package Contents" contextual menu item in the Finder.)

The startup script contains:

<?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.clamav.sentry-startup</string>
	<key>ProgramArguments</key>
	<array>
		<string>open</string>
		<string>/Applications/ClamXav.app/Contents/Resources/ClamXavSentry.app</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

(right-click or control-click here and "Save Link as...")

Prerequisites:

As admin/root:

  1. Install ClamXav app, it must be in Applications folder
  2. Run ClamXav at least once in order to install the engine.
  3. Launch ClamAV Sentry from the ClamXav Preferences section, configure preferences for folders to watch etc., then quit Sentry.
  4. Put the com.clamav.sentry-startup into /Library/LaunchAgents/
  5. Authenticate as admin user if prompted.
  6. Open Terminal and type (or copy/paste):
	launchctl load -w /Library/LaunchAgents/com.clamav.sentry-startup
The sentry service should now launch (will appear in menu), and should launch upon login by any user. This setting should persist through reboots and shutdowns, but may need to be tweaked/rerun after Software Updates.