0

I've installed Samba3 from MacPorts. (following this guide) To run it I execute sudo /opt/local/sbin/smbd -D && sudo /opt/local/sbin/nmbd -D in a Terminal window and everything works fine.

I've attempted to create a LaunchAgent to run samba with the system, rather than having to invoke it manually. My plist file is called com.samba3.plist and consists of the following:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.samba3</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/sbin/smbd</string>
<string>-D</string>
<string>&amp;&amp;</string>
<string>/opt/local/sbin/nmbd</string>
<string>-D</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

However, on system startup samba is not being run.

Coxy
  • 101
  • 4

1 Answers1

1

I see several things that need fixing:

  1. This should be installed as a LaunchDaemon, not a LaunchAgent. The difference is that an agent runs inside a user login session, as the user; a daemon runs independent of who is or isn't logged in, and generally runs as root (which you need here).
  2. The ProgramArgument list isn't parsed by a shell, so && doesn't do what you want -- it's just passed as an argument to smbd. You really should make two launchd items, one for smbd and one for nmbd.
  3. The -D flag to each program tells it to daemonize, i.e. detach and run in the background; launchd expects the things it launches to stay connected so it can monitor them (and in fact will think a program has quit if it daemonizes). Remove the -D flags, and use -F instead.

Also, if you have Snow Leopard (installed or available) take a look at the launchd items that start the system's version of smbd and nmbd; they're /System/Library/LaunchDaemons/smbd.plist and .../nmbd.plist. They contain some additional tricks which you may find useful. Most notably, nmbd is set to auto-relaunch if the network is up, and smbd is only launched on demand when a connection is received.