Differences between revisions 5 and 6
Revision 5 as of 2007-10-20 00:12:59
Size: 1109
Editor: DavidBoddie
Comment:
Revision 6 as of 2008-09-30 11:23:34
Size: 1259
Editor: port-169
Comment: Compiling on Leopard
Deletions are marked like this. Additions are marked like this.
Line 41: Line 41:

== Leopard ==

This will not compile directly on Leopard. You will need to change line 14 of Authorization.pxi from "raise" to "raise _err"

Authorization

  • Authorization is a Python wrapper for Apple's Authorization API. Basically, it allows you to spawn arbitrary processes as root after successfully authenticating as an administrator. This is useful for installers, twiddling kernel settings (via sysctl or the like), etc.

status

Authorization is currently at its first public release, 0.1.

examples

   1 import os, sys, struct, tempfile
   2 from Authorization import Authorization, kAuthorizationFlagDestroyRights
   3 
   4 AUTHORIZEDTOOL = "#!%s\n%s" % (sys.executable,
   5 r"""
   6 import os
   7 print os.getuid(), os.geteuid()
   8 os.setuid(0)
   9 print "I'm root!"
  10 """)
  11 
  12 def main():
  13     auth = Authorization(destroyflags=(kAuthorizationFlagDestroyRights,))
  14     fd, name = tempfile.mkstemp('.py')
  15     os.write(fd, AUTHORIZEDTOOL)
  16     os.close(fd)
  17     os.chmod(name, 0700)
  18     try:
  19         pipe = auth.executeWithPrivileges(name)
  20         sys.stdout.write(pipe.read())
  21         pipe.close()
  22     finally:
  23         os.unlink(name)
  24 
  25 if __name__=='__main__':
  26     main()

Leopard

This will not compile directly on Leopard. You will need to change line 14 of Authorization.pxi from "raise" to "raise _err"

homepage

MacPython/Authorization (last edited 2008-11-15 14:00:31 by localhost)

Unable to edit the page? See the FrontPage for instructions.