Skip to content

Instantly share code, notes, and snippets.

@alexisakers
Last active Nov 16, 2017
Embed
What would you like to do?
Get the description of a Security OSStatus
#!/usr/bin/swift
import Foundation
import Security
guard CommandLine.arguments.count > 1 else {
print("USAGE: osstatus [code]")
exit(-1)
}
guard let code = OSStatus(CommandLine.arguments[1]) else {
print("Not a valid status code.")
exit(-1)
}
guard let description = SecCopyErrorMessageString(code, nil) else {
print("Unknown error")
exit(-1)
}
print(description)
exit(0)
@alexisakers
Copy link
Author

macOS script to get the description of Security error codes.

Install

$ swiftc osstatus.swift
$ cp -f ./osstatus /usr/local/bin/osstatus

Usage

$ osstatus -25300
The specified item could not be found in the keychain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment