Calling SMJobBless with valid AuthorizationRef

Kunal Parmar <[email protected]> Sun, 4 Nov 2012 17:59:07 -0800
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <CAB2uBpjs6gDWVePa6skVefXkg=iiSao3jmcrH2fWzNJmpjyR3Q@mail.gmail.com>
I'm getting an error when calling SMJobBless - "ValueError: depythonifying
'pointer', got 'LP_c_void_p'". I've tried a few things without luck. Any
help will be appreciated.

Here's my code -

from ServiceManagement import (
    kSMDomainSystemLaunchd,
    SMJobBless,
)

security = ctypes.cdll.LoadLibrary(ctypes.util.find_library('Security'))

class AuthorizationItem(ctypes.Structure):
    _fields_ = [
        ('name', ctypes.c_char_p),
        ('valueLength', ctypes.c_uint32),
        ('value', ctypes.c_void_p),
        ('flags', ctypes.c_uint32),
    ]

class AuthorizationRights(ctypes.Structure):
    _fields_ = [
        ('count', ctypes.c_uint32),
        ('items', ctypes.POINTER(AuthorizationItem)),
    ]

authorization_item = AuthorizationItem(
    name='com.apple.ServiceManagement.blesshelper',
    valueLength=0,
    value=None,
    flags=0,
)
authorization_rights = AuthorizationRights(
    count=1,
    items=ctypes.pointer(authorization_item),
)
authorization_flags = 19
authorization_ref = ctypes.POINTER(ctypes.c_void_p)()
status = security.AuthorizationCreate(
    ctypes.pointer(authorization_rights),
    None,
    authorization_flags,
    ctypes.pointer(authorization_ref),
)
SMJobBless(
    kSMDomainSystemLaunchd,
    'app.helper',
    authorization_ref,
    None,
)

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d

_______________________________________________
Pyobjc-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev