Posted to
Mac, by curmi on the April 8th, 2008
Apple’s Leopard Server appears to have a major bug that is causing havoc for those users unlucky enough to see it occur on a daily basis.
Basically, DirectoryService is crashing on users of Leopard Server. This in itself isn’t a big problem – Leopard Server restarts DirectoryService if it fails. The problem is with AppleFileServer. AppleFileServer seems to lose the ability to authenticate users with the new instance of DirectoryService. This means Time Machine backups stop working, and users can’t mount the server using AFP.
Currently, as of 10.5.2, this has still not been fixed. Apple have apparently given users suggestions such as sending a HUP signal to AppleFileServer at regular intervals to get things back on track, but in my limited testing, this doesn’t work – leaving the user with the ability to only mount certain shares.
The only reliable solution I’ve found is to restart AFP. Obviously we don’t want to do that all the time – it should only be done when DirectoryService crashes. To do this, I’ve built the following launchd daemon. Basically, it works as follows:
The daemon watches the /Library/Logs/Crashes directory, and wait until a crash occurs. When it does, it runs a script that checks to see if the crash was a DirectoryService crash, moves these crash files away in to a sub-directory, and restarts AFP.
Not a great solution, as if someone is connected at the time, they get booted and have to remount. I’m experimenting with other fixes people have listed that don’t require AFP to be restarted, but so far I’ve found they don’t seem to work consistently.
You can download the daemon here.
Once downloaded, uncompress the file (double click in Finder). Safari may unzip it automatically for you.
From a Terminal, cd to the unzipped folder (if downloaded from Safari, by default it will be in ~/Downloads).
cd ~/Downloads/restartafp
Now, type the following. Note that you need to be logged in as an administrator, and you will be asked for the administrator password in order to do the first operation.
sudo mkdir \
/Library/Logs/CrashReporter/DirectoryService
sudo cp com.curmi.restartafp.plist \
/Library/LaunchDaemons/
sudo cp restartafpondscrash.sh \
/usr/local/bin/
sudo chmod a+x \
/usr/local/bin/restartafpondscrash.sh
sudo launchctl load \
/Library/LaunchDaemons/com.curmi.restartafp.plist
To test this is working, you can do the following, and check /var/logs/system.log to see if it mentions the restart.
sudo touch \
/Library/Logs/CrashReporter/DirectoryService_trigger.crash
If for some reason you want to uninstall, run the following commands from the Terminal.
sudo launchctl unload \
/Library/LaunchDaemons/com.curmi.restartafp.plist
sudo rm \
/Library/LaunchDaemons/com.curmi.restartafp.plist
sudo rm /usr/local/bin/restartafpondscrash.sh
sudo mv \
/Library/Logs/CrashReporter/DirectoryService/* \
/Library/Logs/CrashReporter
sudo rmdir \
/Library/Logs/CrashReporter/DirectoryService
I hope this is useful to others out there. I’ve filed this bug with apple (radar bug report number 5836741), and I hope Apple fixes it soon.
The fix I’m currently trialling was listed here, and suggests that rather than doing:
serveradmin stop afp
serveradmin start afp
in the script, we do:
serveradmin settings afp:authenticationMode = "standard"
serveradmin settings afp:authenticationMode = "standard_and_kerberos"
I’ve tested this and it didn’t seem to work, but I’ll try it again just in case. I’m sure DirectoryService will crash on us sometime tomorrow to confirm if the fix works or not.