Can the mount_afp command in Leopard use Keychain as it did in Tiger?
Has anyone been able to use a keychain password with the mount_afp command in Leopard?
I had this working in Tiger, but in Leopard all of my remote mounts are being stored in the keychain as network passwords identified by URL rather than as AppleShare passwords. I tried adding /sbin/mount_afp to the list of allowed applications for these network passwords as I did in Tiger, and mount_afp can't find the keychain items, even when the URL in the keychain item is identical to the URL I specify on the command line.
These keychain items do work in the Finder (via NetAuthAgent), even after I modify the URLs, adding such things as port numbers and usernames.
I found a workaround for this by writing a program that uses the Security framework to grab the password from the keychain, calls /sbin/mount_afp via execve, and pipes the password to the stdin of the mount_afp process. This isn't as good a solution as having mount_afp use the keychain directly, as it foregoes the checksum of the process image, and hence would not detect a malicious program substituted for mount_afp.
If this functionality were present in mount_afp for Leopard, I'd still find it useful.
The following C program should be compiled with the Security framework as follows:
cc -framework Security -o mountwrapper mountwrapper.c
This program works only under Leopard, and requires that you have an AFP Internet password in your keychain with the exact hostname, username, and port number you specify on the command line. It does not look for approximate or ambiguous matches.