Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Read Me About AuthForAll.txt
Read Me About AuthForAll |
======================== |
1.1 |
This sample shows how to use Authorization Services to create a self-restricted application. The techniques shown in this sample are explained in depth in DTS Technote 2095 "Authorization for Everyone". |
<http://developer.apple.com/technotes/tn2002/tn2095.html> |
The authorization database APIs used by this sample require Mac OS X 10.3 or higher, however, the sample include a compatibility target that allows it to run on earlier systems. |
Packing List |
------------ |
The sample contains the following items: |
o Read Me About AuthForAll.txt Ñ This document. |
o AuthForAll.xcodeproj Ñ An Xcode 2.1 file for the entire sample. |
o AuthForAll_Prefix.pch Ñ The project pre-compiled header. |
o build Ñ A folder containing the project build results. |
o AuthForAll.c Ñ Source for the main application. |
o AuthForAllImpl.h Ñ Interface between the main application and the implementation. |
o AuthForAllImpl.c Ñ Source for the implementation that relies on Mac OS X 10.3 or higher. |
o AuthForAllImplCompat.c Ñ Source for the implementation that works for earlier systems. |
o main.nib Ñ Project user interface. |
o en.lproj Ñ English localized resources. |
o en_AU.lproj Ñ Australian English localised resources. |
o Info.plist Ñ Properties for the application. |
o InfoPlist.strings Ñ Localized properties |
Using the Sample |
---------------- |
To run the sample, just double click one of the applications in the build folder. If you're running on Mac OS X 10.3 or later, you can run either application. If you're running on an earlier system, you must run the AuthForAllCompat application. If you click the "Alpha" button, you should get no authorization dialog. If you click the "Beta" button, you should get the standard "authorize as an admin user" dialog. |
Building the Sample |
------------------- |
The sample was built using Xcode 2.1 on Mac OS X 10.4. The project contains three targets, AuthForAll, AuthForAllCompat, and All. The "AuthForAll" target builds an application that runs only on Mac OS X 10.3 and later. The "AuthForAllCompat" target builds an application that runs on earlier systems. The "All" target builds both applications. |
How it Works |
------------ |
For a detailed discussion of how it works, see DTS Technote 2095 "Authorization for Everyone". |
<http://developer.apple.com/technotes/tn/tn2095.html> |
Caveats |
------- |
I tested AuthForAllCompat on 10.2.6 and later. I didn't get a chance to test it on 10.1, but there's no reason why it shouldn't work. |
Mac OS X 10.4 introduced two bugs that affect this code. |
o <rdar://problem/4199765> Tiger breaks custom prompts in Auth Services -- This bug prevents the system from immediately picking up a custom prompt associated with a new right added using AuthorizationRightSet. You can work around this by touching "/etc/authorization". |
o <rdar://problem/4199768> Tiger breaks localised prompts in Auth Services -- This bug causes the system to use the wrong localization for authorization dialogs. Specifically, it breaks the Australian English example given in the "Localization" section of the technote. I don't know of any workaround. |
These problems are related to Mac OS X 10.4 and occur on all architectures. |
The AuthForAllCompat target is built for the PowerPC architecture only. This is because Xcode 2.1 does not let you use a different version of GCC for different architectures, and code built with GCC 4.0 will not run prior to Mac OS 10.3.9. You can work around this with sufficient application of lipo <x-man-page://1/lipo>, but I didn't think that this was justified for a compatibility target. |
Credits and Version History |
--------------------------- |
If you find any problems with this sample, mail <dts@apple.com> and I'll try to fix them up. |
1.0a1 (Oct 2003) was the first shipping version. |
1.1 (Aug 2005) was an update to produce a universal binary. No code changes were required. However, I did make a few minor changes to tidy up the build system and eliminate compiler warnings. |
Share and Enjoy. |
Apple Developer Technical Support |
Networking, Communications, Hardware |
1 Aug 2005 |
Copyright © 2005 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2005-10-26