github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

acdha / pymacadmin

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 7
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 649dae5

click here to add a description

click here to add a homepage

  • Branches (3)
    • crankd_refactor
    • keychain_overhaul
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Python tools for Mac system administration — Read more

  cancel

http://pymacadmin.googlecode.com/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Keychain cleanup 
acdha (author)
Sat Mar 21 13:55:16 -0700 2009
commit  649dae5c16e380d8ac36c8430e4dcca81ab57fe7
tree    e1ac9330caa88f2bbefe5ff4d4cf1d70fc40a20a
parent  60630dbdb99c37193673c100c7239c80a8b90527
pymacadmin / lib / PyMacAdmin / Security / __init__.py lib/PyMacAdmin/Security/__init__.py
100755 60 lines (55 sloc) 2.58 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# encoding: utf-8
import PyMacAdmin
import ctypes
import struct
import sys
 
# This is not particularly elegant but to avoid everything having to load the
# Security framework we use a single copy hanging of this module so everything
# else can simply use Security.lib.SecKeychainFoo(…)
lib = PyMacAdmin.load_carbon_framework('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
 
CSSM_DB_RECORDTYPE_APP_DEFINED_START = 0x80000000
CSSM_DL_DB_RECORD_X509_CERTIFICATE = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x1000
 
# This is somewhat gross: we define a bunch of module-level constants based on
# the SecKeychainItem.h defines (FourCharCodes) by passing them through
# struct.unpack and converting them to ctypes.c_long() since we'll never use
# them for non-native APIs
 
CARBON_DEFINES = {
    'kSecCreationDateItemAttr': 'cdat',
    'kSecModDateItemAttr': 'mdat',
    'kSecDescriptionItemAttr': 'desc',
    'kSecCommentItemAttr': 'icmt',
    'kSecCreatorItemAttr': 'crtr',
    'kSecTypeItemAttr': 'type',
    'kSecScriptCodeItemAttr': 'scrp',
    'kSecLabelItemAttr': 'labl',
    'kSecInvisibleItemAttr': 'invi',
    'kSecNegativeItemAttr': 'nega',
    'kSecCustomIconItemAttr': 'cusi',
    'kSecAccountItemAttr': 'acct',
    'kSecServiceItemAttr': 'svce',
    'kSecGenericItemAttr': 'gena',
    'kSecSecurityDomainItemAttr': 'sdmn',
    'kSecServerItemAttr': 'srvr',
    'kSecAuthenticationTypeItemAttr': 'atyp',
    'kSecPortItemAttr': 'port',
    'kSecPathItemAttr': 'path',
    'kSecVolumeItemAttr': 'vlme',
    'kSecAddressItemAttr': 'addr',
    'kSecSignatureItemAttr': 'ssig',
    'kSecProtocolItemAttr': 'ptcl',
    'kSecCertificateType': 'ctyp',
    'kSecCertificateEncoding': 'cenc',
    'kSecCrlType': 'crtp',
    'kSecCrlEncoding': 'crnc',
    'kSecAlias': 'alis',
    'kSecInternetPasswordItemClass': 'inet',
    'kSecGenericPasswordItemClass': 'genp',
    'kSecAppleSharePasswordItemClass': 'ashp',
    'kSecCertificateItemClass': CSSM_DL_DB_RECORD_X509_CERTIFICATE
}
 
for k in CARBON_DEFINES:
    v = CARBON_DEFINES[k]
    if isinstance(v, str):
        assert(len(v) == 4)
        v = ctypes.c_ulong(struct.unpack(">L", v)[0])
    setattr(sys.modules[__name__], k, v)
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server