Not necessarily. You can declare the user for any launchd job, but in this case, I'm not declaring it, and thus, it is root. Therefore, I now firmly believe it is something environmental that makes the difference.
So, here is some output to hopefully validate what I'm talking about.
Firefly, I have a script named backup-exonet, as follows:
if test -d "$MOUNTDIR/$SHARE";
then
echo "$SHARE is available."
else
echo "$SHARE is not available. Mounting..."
mount_needed=1
fi
if test "$mount_needed";
then
mkdir "$MOUNTDIR/$SHARE"
sleep 1
if `mount_smbfs -o nobrowse "//$SERVERUSER:$SERVERPASS@$SERVER/$SHARE" "$MOUNTDIR/$SHARE"`;
then
echo "succeeded."
syncbackup
echo -n "Unmounting PC..."
umount "$MOUNTDIR/$SHARE"
echo "done."
else
echo "failed."
rm -rf "$MOUNTDIR/$SHARE"
fi
else
syncbackup
fi
FYI, $MOUNTDIR = "/Volumes"
So, when I just run that as root, it fails:
bash-3.2# whoami
root
bash-3.2# /usr/local/bin/backup-exonet
ExonetBackup is not available. Mounting...
mount_smbfs: server rejected the connection: Authentication error
failed.
So, I create a launchd job as follows:
<?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>Disabled</key>
<true/>
<key>Label</key>
<string>au.com.example.backup-exonet</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/backup-exonet</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Hour</key>
<integer>19</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</array>
</dict>
</plist>
Note it's set to RunAtLoad, so I load up the system log to watch what happens when I load it and I load it:
bash-3.2# tail -f /var/log/system.log | grep backup-exonet &
[1] 26811
bash-3.2# launchctl load /Library/LaunchDaemons/au.com.example.backup-exonet.plist
bash-3.2# Apr 20 08:24:00 office au.com.example.backup-exonet[26815]: ExonetBackup is not available. Mounting...
Apr 20 08:24:01 office au.com.example.backup-exonet[26815]: succeeded.
Apr 20 08:24:01 office au.com.example.backup-exonet[26815]: building file list ...
Apr 20 08:24:01 office au.com.example.backup-exonet[26815]: done
Apr 20 08:24:02 office au.com.example.backup-exonet[26815]: sent 6064 bytes received 20 bytes 12168.00 bytes/sec
Apr 20 08:24:02 office au.com.example.backup-exonet[26815]: total size is 77918564190 speedup is 12807127.58
Apr 20 08:24:02 office au.com.example.backup-exonet[26815]: Unmounting PC...
Apr 20 08:24:02 office au.com.example.backup-exonet[26815]: done.
It works!
Happy to provide more info or do a different test if it helps anyone.