Our users frequently encounter an issue where at login, they are repeatedly asked for the "Local Items" keychain password. Apple details the problem and solution here, which works well , but I would love to script it and make it a Self Service or pushable item.
I wrote the following simple Bash script, which works, however only if ran locally:
#!/bin/bash
if test -e ~/library/keychains/????????-????-????-????-????????????; then
echo "Local Items keychain found"
rm -rf ~/library/keychains/????????-????-????-????-????????????
else
echo "No local items keychain found"
exit 1
fi
This is because Casper runs scripts as root, so if pushed through Remote it won't do anything to the logged in user's Keychain folder. I took a look at this discussion on JAMFnation and wrote the following, but it doesn't work whether ran locally or remotely:
#!/bin/bash
current_user=finger -s -l | grep Login | cut -c 8-25
if test -e /Users/$current_user/library/keychains/????????-????-????-????-????????????; then
echo "Local Items keychain found"
rm -rf /Users/$current_user/library/keychains/????????-????-????-????-????????????
else
echo "No local items keychain found"
exit 1
fi
If I run the
finger -s -l | grep Login | cut -c 8-25
section in Terminal it echoes my username just fine, but it seems like it doesn't store that variable and regardless of whether or not the Local Items folder is present, the script just echoes my username then "No local items keychain found". I know that normally you can use the $3 variable as the user home, but this only works with login/out hooks, and I would like this to be usable in self service or Remote. Does anyone have any ideas on how to fix this script? Any help is much appreciated. I also realize that the folder name for the Local Items is actually the UUID and not random characters, so the whole business with ? wildcards is kind of kludgey.