[Keychain-commit] SF.net SVN: keychain: [449] trunk/Applications
Status: Abandoned
Brought to you by:
wadetregaskis
|
From: <wad...@us...> - 2007-12-13 07:22:40
|
Revision: 449
http://keychain.svn.sourceforge.net/keychain/?rev=449&view=rev
Author: wadetregaskis
Date: 2007-12-12 23:22:44 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
* Adding 'keychain' command-line utility. Currently can only list ACLs for all items in a given keychain, but will be fleshed out over time.
Added Paths:
-----------
trunk/Applications/keychain/
trunk/Applications/keychain/keychain.1
trunk/Applications/keychain/keychain.m
trunk/Applications/keychain/keychain.xcodeproj/
trunk/Applications/keychain/keychain.xcodeproj/project.pbxproj
trunk/Applications/keychain/keychain_Prefix.pch
Added: trunk/Applications/keychain/keychain.1
===================================================================
--- trunk/Applications/keychain/keychain.1 (rev 0)
+++ trunk/Applications/keychain/keychain.1 2007-12-13 07:22:44 UTC (rev 449)
@@ -0,0 +1,79 @@
+.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
+.\"See Also:
+.\"man mdoc.samples for a complete listing of options
+.\"man mdoc for the short list of editing options
+.\"/usr/share/misc/mdoc.template
+.Dd 11/12/07 \" DATE
+.Dt keychain 1 \" Program name and manual section number
+.Os Darwin
+.Sh NAME \" Section Header - required - don't modify
+.Nm keychain,
+.\" The following lines are read in generating the apropos(man -k) database. Use only key
+.\" words here as the database is built based on the words here and in the .ND line.
+.Nm Other_name_for_same_program(),
+.Nm Yet another name for the same program.
+.\" Use .Nm macro to designate other names for the documented program.
+.Nd This line parsed for whatis database.
+.Sh SYNOPSIS \" Section Header - required - don't modify
+.Nm
+.Op Fl abcd \" [-abcd]
+.Op Fl a Ar path \" [-a path]
+.Op Ar file \" [file]
+.Op Ar \" [file ...]
+.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
+arg2 ... \" Arguments
+.Sh DESCRIPTION \" Section Header - required - don't modify
+Use the .Nm macro to refer to your program throughout the man page like such:
+.Nm
+Underlining is accomplished with the .Ar macro like this:
+.Ar underlined text .
+.Pp \" Inserts a space
+A list of items with descriptions:
+.Bl -tag -width -indent \" Begins a tagged list
+.It item a \" Each item preceded by .It macro
+Description of item a
+.It item b
+Description of item b
+.El \" Ends the list
+.Pp
+A list of flags and their descriptions:
+.Bl -tag -width -indent \" Differs from above in tag removed
+.It Fl a \"-a flag as a list item
+Description of -a flag
+.It Fl b
+Description of -b flag
+.El \" Ends the list
+.Pp
+.\" .Sh ENVIRONMENT \" May not be needed
+.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
+.\" .It Ev ENV_VAR_1
+.\" Description of ENV_VAR_1
+.\" .It Ev ENV_VAR_2
+.\" Description of ENV_VAR_2
+.\" .El
+.Sh FILES \" File used or created by the topic of the man page
+.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
+.It Pa /usr/share/file_name
+FILE_1 description
+.It Pa /Users/joeuser/Library/really_long_file_name
+FILE_2 description
+.El \" Ends the list
+.\" .Sh DIAGNOSTICS \" May not be needed
+.\" .Bl -diag
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .El
+.Sh SEE ALSO
+.\" List links in ascending order by section, alphabetically within a section.
+.\" Please do not reference files that do not exist without filing a bug report
+.Xr a 1 ,
+.Xr b 1 ,
+.Xr c 1 ,
+.Xr a 2 ,
+.Xr b 2 ,
+.Xr a 3 ,
+.Xr b 3
+.\" .Sh BUGS \" Document known, unremedied bugs
+.\" .Sh HISTORY \" Document history if command behaves in a unique manner
\ No newline at end of file
Added: trunk/Applications/keychain/keychain.m
===================================================================
--- trunk/Applications/keychain/keychain.m (rev 0)
+++ trunk/Applications/keychain/keychain.m 2007-12-13 07:22:44 UTC (rev 449)
@@ -0,0 +1,154 @@
+#import <Foundation/Foundation.h>
+#import <Keychain/Keychain.h>
+#import <Keychain/KeychainItem.h>
+#import <Keychain/Access.h>
+#import <Keychain/AccessControlList.h>
+#import <Keychain/TrustedApplication.h>
+#import <Keychain/KeychainSearch.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <errno.h>
+
+
+
+
+int main (int argc, char * const argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Keychain *keychain = nil;
+ int ch;
+ BOOL listACLs = NO;
+
+ static struct option longopts[] = {
+ { "list-acls", no_argument, NULL, 'a' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ while (-1 != (ch = getopt_long(argc, argv, "a", longopts, NULL))) {
+ switch (ch) {
+ case 'a': // --list-acls
+ listACLs = YES; break;
+ case 0:
+ break;
+ default:
+ printUsage();
+ return EINVAL;
+ }
+
+ argc -= optind;
+ argv += optind;
+ }
+
+ if (argc > 1) {
+ NSString *keychainPath = [NSString stringWithUTF8String:argv[1]];
+
+ keychain = [Keychain keychainAtPath:keychainPath];
+
+ if (nil == keychain) {
+ fprintf(stderr, "Unable to open keychain file \"%s\".\n", argv[1]);
+ return EIO;
+ }
+
+ ++argc;
+ --argv;
+ }
+
+ if (argc > 1) {
+ // TODO: support selection of a particular keychain item.
+ }
+
+ if (nil == keychain) {
+ keychain = [Keychain defaultKeychain];
+
+ if (nil == keychain) {
+ fprintf(stderr, "Could not find default keychain.\n");
+ return ENOENT;
+ }
+ }
+
+ printf("Keychain: %s\n", [[keychain path] UTF8String]);
+
+ if (listACLs) {
+ // Start with the keychain itself.
+ Access *keychainAccess = [keychain access];
+
+ printf("Access: %s\n", ((nil != keychainAccess) ? [[keychainAccess description] UTF8String] : "(none)"));
+
+ NSArray *keychainItems = [[KeychainSearch keychainSearchWithKeychains:[NSArray arrayWithObject:keychain]] anySearchResults];
+
+ if (nil == keychainItems) {
+ fprintf(stderr, "Unable to access contents of keychain.\n");
+ return EPERM;
+ }
+
+ unsigned long numberOfKeychainItems = [keychainItems count];
+
+ // Now iterate over the items and show the Access/ACLs for them.
+ printf("\nContents (%ld item%s):\n",
+ numberOfKeychainItems,
+ ((1 == numberOfKeychainItems) ? "" : "s"));
+
+ NSEnumerator *keychainItemsEnumerator = [keychainItems objectEnumerator];
+ KeychainItem *currentKeychainItem;
+ Access *currentAccess;
+ NSArray *ACLs;
+ NSEnumerator *ACLsEnumerator;
+ AccessControlList *currentACL;
+ unsigned int ACLIndex;
+ NSArray *trustedApplications;
+ NSEnumerator *trustedApplicationsEnumerator;
+ TrustedApplication *currentApplication;
+
+ while (currentKeychainItem = [keychainItemsEnumerator nextObject]) {
+ printf("%s:", [[currentKeychainItem description] UTF8String]);
+
+ currentAccess = [currentKeychainItem access];
+
+ if (nil != currentAccess) {
+ printf("\n");
+
+ ACLs = [currentAccess accessControlLists];
+
+ if (0 < [ACLs count]) {
+ ACLsEnumerator = [ACLs objectEnumerator];
+
+ ACLIndex = 0;
+
+ while (currentACL = [ACLsEnumerator nextObject]) {
+ printf("\t%u: %s%s\n\t\tAuthorises: %s\n\t\tApplications:",
+ ACLIndex,
+ [[currentACL name] UTF8String],
+ ([currentACL requiresPassphrase] ? " (requires user authorisation)" : ""),
+ [descriptionOfAuthorizations([currentACL authorizations]) UTF8String]);
+
+ trustedApplications = [currentACL applications];
+
+ if (0 < [trustedApplications count]) {
+ trustedApplicationsEnumerator = [trustedApplications objectEnumerator];
+
+ printf("\n");
+
+ while (currentApplication = [trustedApplicationsEnumerator nextObject]) {
+ printf("\t\t\t%s\n", [[currentApplication path] UTF8String]);
+ }
+ } else {
+ printf(" (any)\n");
+ }
+
+ ++ACLIndex;
+ }
+ } else {
+ printf("\t(empty)\n");
+ }
+ } else {
+ printf(" (none)\n");
+ }
+ }
+ }
+
+ [pool release];
+
+ return 0;
+}
Added: trunk/Applications/keychain/keychain.xcodeproj/project.pbxproj
===================================================================
--- trunk/Applications/keychain/keychain.xcodeproj/project.pbxproj (rev 0)
+++ trunk/Applications/keychain/keychain.xcodeproj/project.pbxproj 2007-12-13 07:22:44 UTC (rev 449)
@@ -0,0 +1,247 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 42;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 75628A5D0D0FBC480038880C /* Keychain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75628A5C0D0FBC480038880C /* Keychain.framework */; };
+ 8DD76F9A0486AA7600D96B5E /* keychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* keychain.m */; settings = {ATTRIBUTES = (); }; };
+ 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
+ 8DD76F9F0486AA7600D96B5E /* keychain.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* keychain.1 */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXBuildStyle section */
+ 014CEA4F0018CE4811CA2923 /* Debug */ = {
+ isa = PBXBuildStyle;
+ buildSettings = {
+ };
+ name = Debug;
+ };
+ 014CEA500018CE4811CA2923 /* Release */ = {
+ isa = PBXBuildStyle;
+ buildSettings = {
+ };
+ name = Release;
+ };
+/* End PBXBuildStyle section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 8;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ 8DD76F9F0486AA7600D96B5E /* keychain.1 in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 08FB7796FE84155DC02AAC07 /* keychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = keychain.m; sourceTree = "<group>"; };
+ 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 32A70AAB03705E1F00C91783 /* keychain_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keychain_Prefix.pch; sourceTree = "<group>"; };
+ 75628A5C0D0FBC480038880C /* Keychain.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Keychain.framework; path = /Library/Frameworks/Keychain.framework; sourceTree = "<absolute>"; };
+ 8DD76FA10486AA7600D96B5E /* keychain */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = keychain; sourceTree = BUILT_PRODUCTS_DIR; };
+ C6859EA3029092ED04C91782 /* keychain.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = keychain.1; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */,
+ 75628A5D0D0FBC480038880C /* Keychain.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 08FB7794FE84155DC02AAC07 /* keychain */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB7795FE84155DC02AAC07 /* Source */,
+ C6859EA2029092E104C91782 /* Documentation */,
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
+ 1AB674ADFE9D54B511CA2CBB /* Products */,
+ );
+ name = keychain;
+ sourceTree = "<group>";
+ };
+ 08FB7795FE84155DC02AAC07 /* Source */ = {
+ isa = PBXGroup;
+ children = (
+ 32A70AAB03705E1F00C91783 /* keychain_Prefix.pch */,
+ 08FB7796FE84155DC02AAC07 /* keychain.m */,
+ );
+ name = Source;
+ sourceTree = "<group>";
+ };
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
+ isa = PBXGroup;
+ children = (
+ 75628A5C0D0FBC480038880C /* Keychain.framework */,
+ 08FB779EFE84155DC02AAC07 /* Foundation.framework */,
+ );
+ name = "External Frameworks and Libraries";
+ sourceTree = "<group>";
+ };
+ 1AB674ADFE9D54B511CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8DD76FA10486AA7600D96B5E /* keychain */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ C6859EA2029092E104C91782 /* Documentation */ = {
+ isa = PBXGroup;
+ children = (
+ C6859EA3029092ED04C91782 /* keychain.1 */,
+ );
+ name = Documentation;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8DD76F960486AA7600D96B5E /* keychain */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "keychain" */;
+ buildPhases = (
+ 8DD76F990486AA7600D96B5E /* Sources */,
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */,
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ buildSettings = {
+ };
+ dependencies = (
+ );
+ name = keychain;
+ productInstallPath = "$(HOME)/bin";
+ productName = keychain;
+ productReference = 8DD76FA10486AA7600D96B5E /* keychain */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 08FB7793FE84155DC02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "keychain" */;
+ buildSettings = {
+ };
+ buildStyles = (
+ 014CEA4F0018CE4811CA2923 /* Debug */,
+ 014CEA500018CE4811CA2923 /* Release */,
+ );
+ hasScannedForEncodings = 1;
+ mainGroup = 08FB7794FE84155DC02AAC07 /* keychain */;
+ projectDirPath = "";
+ targets = (
+ 8DD76F960486AA7600D96B5E /* keychain */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8DD76F990486AA7600D96B5E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8DD76F9A0486AA7600D96B5E /* keychain.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB927508733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = keychain_Prefix.pch;
+ INSTALL_PATH = "$(HOME)/bin";
+ PRODUCT_NAME = keychain;
+ ZERO_LINK = YES;
+ };
+ name = Debug;
+ };
+ 1DEB927608733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = (
+ ppc,
+ i386,
+ );
+ GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = keychain_Prefix.pch;
+ INSTALL_PATH = "$(HOME)/bin";
+ PRODUCT_NAME = keychain;
+ };
+ name = Release;
+ };
+ 1DEB927908733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "${FRAMEWORK_SEARCH_PATHS}",
+ /Library/Frameworks/,
+ );
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+ };
+ name = Debug;
+ };
+ 1DEB927A08733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "keychain" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927508733DD40010E9CD /* Debug */,
+ 1DEB927608733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "keychain" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927908733DD40010E9CD /* Debug */,
+ 1DEB927A08733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
Added: trunk/Applications/keychain/keychain_Prefix.pch
===================================================================
--- trunk/Applications/keychain/keychain_Prefix.pch (rev 0)
+++ trunk/Applications/keychain/keychain_Prefix.pch 2007-12-13 07:22:44 UTC (rev 449)
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'keychain' target in the 'keychain' project.
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|