CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 17 Jul 2025 19:23:23 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20081222105101
location: https://web.archive.org/web/20081222105101/https://wiki.python.org/moin/MacPython/Authorization
server-timing: captures_list;dur=0.669824, exclusion.robots;dur=0.027424, exclusion.robots.policy;dur=0.012284, esindex;dur=0.012407, cdx.remote;dur=123.528730, LoadShardBlock;dur=471.118988, PetaboxLoader3.datanode;dur=76.393543, PetaboxLoader3.resolve;dur=368.627159
x-app-server: wwwb-app215
x-ts: 302
x-tr: 624
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app215; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 17 Jul 2025 19:23:23 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Mon, 22 Dec 2008 10:51:01 GMT
x-archive-orig-server: Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 mod_python/3.3.1 Python/2.5.2 mod_wsgi/2.3
x-archive-orig-vary: Cookie,User-Agent,Accept-Language
x-archive-orig-content-length: 19573
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Mon, 22 Dec 2008 10:51:01 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Mon, 05 Nov 2007 09:09:13 GMT", ; rel="prev memento"; datetime="Wed, 05 Dec 2007 17:37:54 GMT", ; rel="memento"; datetime="Mon, 22 Dec 2008 10:51:01 GMT", ; rel="next memento"; datetime="Sun, 07 Aug 2011 05:56:41 GMT", ; rel="last memento"; datetime="Thu, 07 Jul 2022 06:44:21 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 50_7_20081222025518_crawl103-c/50_7_20081222103813_crawl107.arc.gz
server-timing: captures_list;dur=0.593329, exclusion.robots;dur=0.023028, exclusion.robots.policy;dur=0.012005, esindex;dur=0.013050, cdx.remote;dur=16.764993, LoadShardBlock;dur=58.857704, PetaboxLoader3.datanode;dur=112.354057, load_resource;dur=201.183509, PetaboxLoader3.resolve;dur=115.783637
x-app-server: wwwb-app215
x-ts: 200
x-tr: 328
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
MacPython/Authorization - PythonInfo Wiki
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".
The following shows a concrete example for using this with Leopard.
# This has been tested on a Mac OS X 10.5.5 Leopard stock Python installation # on October 25, 2008 # The following is sufficient for using Pyrex, # it doesn't need to be installed export PATH=$HOME/Downloads/Pyrex-0.9.8.5:$PATH export PYTHONPATH=$HOME/Downloads/Pyrex-0.9.8.5:$PYTHONPATH cd $HOME/Downloads/Authorization-0.1 # Solve "Use __cinit__ instead" perl -pi -e 's/__new__/__cinit__/g' ./src/Authorization.pxi # Solve "Reraise not inside except clause" perl -pi -e 's/raise /#raise /g' ./src/Authorization.pxi # Compile, but do not install python ./setup.py build_ext --inplace # Solve "cannot import name kAuthorizationFlagDestroyRights" perl -pi -e 's/, kAuthorizationFlagDestroyRights//g' ./test/test.py perl -pi -e 's/destroyflags=\(kAuthorizationFlagDestroyRights,\)//g' ./test/test.py # Test export PYTHONPATH=./lib/:$PYTHONPATH python test/test.py # should give: # I'm root!
homepage
EditText (last edited 2008-11-15 14:00:31 by localhost)