Hi,
I have met with a rather interesting phenomenon today and I couldn't figure out the reason.
As part of a script, I import certificates and for that I create a designated keychain:
security create-keychain -p "" $KEYCHAIN_NAME.keychain-db
This has so far been creating the keychain at the expected location, Users/my-user/Library/Keychains/$KEYCHAIN_NAME.keychain-db
.
However, I have noticed that since yesterday, my script has been failing with a
security: SecKeychainCreate XXXXXXXXX.keychain-db: UNIX[Permission denied]
error.
I kept investigating and noticed that the same script as given above, now tries to create the keychain on the /Library/Keychains/$KEYCHAIN_NAME.keychain-db
path (the same path where System.keychain is located).
I confirmed this in two ways:
- running the command with
sudo
no longer resulted in above UNIX error, instead created it next to the System keychain. - locally, I tried to create a keychain with an absolute path, like this:
security create-keychain -p 1234 "/Library/Keychains/new.keychain"
and got back the sameUNIX[Permission denied]
error.
I tried to poke around in the man page for security
and search online, but found nothing that would mention the default path changing for the security command (because it must be some setting for security, given that a simple XXXX.keychain would be created at ~/Library/Keychain/***.keychain, whichever folder I execute the command from.
Thanks in advance for any advice!