]>
git.saurik.com Git - apple/security.git/blob - utilities/src/iOSforOSX.c
5 // Created by J Osborne on 11/13/12.
6 // Copyright (c) 2012 Apple Inc. All rights reserved.
9 #include <TargetConditionals.h>
11 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
13 #include <CoreFoundation/CoreFoundation.h>
14 #include <AssertMacros.h>
15 #include <utilities/SecCFWrappers.h>
17 #include <sys/types.h>
19 #include <uuid/uuid.h>
20 #include "iOSforOSX.h"
24 #include ".././libsecurity_keychain/lib/SecBase64P.c"
26 CFURLRef
SecCopyKeychainDirectoryFile(CFStringRef file
)
28 struct passwd
*passwd
= getpwuid(getuid());
32 CFURLRef pathURL
= NULL
;
33 CFURLRef fileURL
= NULL
;
34 CFStringRef home
= NULL
;
35 CFStringRef filePath
= CFStringCreateWithFormat(kCFAllocatorDefault
, NULL
, CFSTR("%s/%@"), "Library/Keychains", file
);
36 require(filePath
, xit
);
39 home
= CFStringCreateWithCString(NULL
, passwd
->pw_dir
, kCFStringEncodingUTF8
);
41 pathURL
= CFURLCreateWithFileSystemPath(NULL
, home
?home
:CFSTR("/"), kCFURLPOSIXPathStyle
, true);
43 fileURL
= CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault
, pathURL
, filePath
, false);
46 CFReleaseSafe(filePath
);
47 CFReleaseSafe(pathURL
);
52 // XXX: do we still need this? see securityd_files?
53 CFURLRef
PortableCFCopyHomeDirectoryURL(void)
55 char *path
= getenv("HOME");
57 struct passwd
*pw
= getpwuid(getuid());
60 CFStringRef path_cf
= CFStringCreateWithCStringNoCopy(NULL
, path
, kCFStringEncodingUTF8
, kCFAllocatorNull
);
61 CFURLRef path_url
= CFURLCreateWithFileSystemPath(NULL
, path_cf
, kCFURLPOSIXPathStyle
, true);