Skip to content

Commit

Permalink
cocoasudo - initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Kardell committed Oct 26, 2009
0 parents commit 5216698
Show file tree
Hide file tree
Showing 52 changed files with 2,355 additions and 0 deletions.
Binary file added build/Release/cocoasudo
Binary file not shown.
20 changes: 20 additions & 0 deletions build/Release/cocoasudo.dSYM/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.cocoasudo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Debug/cocoasudo.build/Objects-normal/i386/cocoasudo.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions build/cocoasudo.build/Debug/cocoasudo.build/cocoasudo.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
f0c617ecf96161e8ba717223a1a42510 704d8e86c441ba74c3c8d50eb62ca907 ffffffffffffffffffffffffffffffff 17336 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/Debug/cocoasudo
0cf41a98484ad8301ba74433ad19a727 fc320d74fb504212a1d636100d7a23d9 ffffffffffffffffffffffffffffffff 8396 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Debug/cocoasudo.build/Objects-normal/i386/cocoasudo.o
000000000367548f0000000000006986 0cf41a984eeb578b1ba74433ad19a403 ffffffffffffffffffffffffffffffff 26692748 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-fekcfawkzrazzccdjibngettvamz/cocoasudo_Prefix.pch.gch
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/i386/cocoasudo.o
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/ppc/cocoasudo.o
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/ppc64/cocoasudo.o
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/x86_64/cocoasudo.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions build/cocoasudo.build/Release/cocoasudo.build/cocoasudo.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
00000000000000000000000000000000 9fc2538ed74ae1cd63ff53f68b033b8a ffffffffffffffffffffffffffffffff 102 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/Release/cocoasudo.dSYM
bcc469d4706199e54054a69fca4ecaae c104f9226a160856a96077c81756298e ffffffffffffffffffffffffffffffff 62768 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/Release/cocoasudo
a360a5ce5e59f4f918a2eb1a2c59dcd6 d5a6f3269d3966f7a60a40c71d946aac ffffffffffffffffffffffffffffffff 9520 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/ppc64/cocoasudo
ad8b5fa3df8ee14fad80cc47e1d97212 78e2824338ab2c7717aecb76cb1d7129 ffffffffffffffffffffffffffffffff 13428 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/ppc/cocoasudo
c1fb6d231fbe8baa7e011735041ed96f 7d342c4515ad574411abf4a8c16bce0c ffffffffffffffffffffffffffffffff 9464 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/x86_64/cocoasudo
b3a95d4368fdb0bb0278a588b29cc6b5 100dfef936caaa8629004c66a6aeae39 ffffffffffffffffffffffffffffffff 17432 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/i386/cocoasudo
4ab00f01555e2874fd1f4fd8e175393a e9d0aacf417c2747e5bda4c2cceb4402 ffffffffffffffffffffffffffffffff 13600 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/ppc64/cocoasudo.o
078d3ab846887aa76bf1d104435b2243 aa06651bd37d6022c6711d43a345f1bf ffffffffffffffffffffffffffffffff 11824 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/ppc/cocoasudo.o
221c4503b706e5c689aed025cbe203eb e3e72820e2c395a6f7afc710ce3b7b6a ffffffffffffffffffffffffffffffff 12092 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/x86_64/cocoasudo.o
2436fd76a4008ed9a1ac13f204ae7643 979fa0358686c5a8a3d4b67ab7f51118 ffffffffffffffffffffffffffffffff 10288 /Users/akardell/Documents/Projects/connected-etl/client/macinstaller/cocoasudo/build/cocoasudo.build/Release/cocoasudo.build/Objects-normal/i386/cocoasudo.o
000000000367548f0000000000006986 4ab00f0153ff9bc7fd1f4fd8e175331c ffffffffffffffffffffffffffffffff 23206772 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-cdyrwvezsgqtdgavaxitoyoqxbow/cocoasudo_Prefix.pch.gch
000000000367548f0000000000006986 078d3ab84029c9146bf1d104435b2865 ffffffffffffffffffffffffffffffff 25082852 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-gvwooomnxyilpgbglzckcogwtkou/cocoasudo_Prefix.pch.gch
000000000367548f0000000000006986 221c4503b1a7567589aed025cbe209cd ffffffffffffffffffffffffffffffff 24861724 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-caaimqlbpdmbkscyrmyytupmxwwa/cocoasudo_Prefix.pch.gch
000000000367548f0000000000006986 2436fd76a2a13d6aa1ac13f204ae7c65 ffffffffffffffffffffffffffffffff 26668172 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-eommggubxpcvdgbnvpwlavmpzokg/cocoasudo_Prefix.pch.gch
0000000045f5c61d0000000000006e9a dc01907b1ab787f01541b44c314e1451 ffffffffffffffffffffffffffffffff 0 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-eiofplczavupmreaqrnecusqgqsf/cocoasudo_Prefix.pch.gch
0000000045f5c61d0000000000006e9a a090967f6be0dbfc941ce4d320d318a7 ffffffffffffffffffffffffffffffff 0 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-ebmmhglqdphkaobnjtuguyosanfx/cocoasudo_Prefix.pch.gch
0000000045f5c61d0000000000006e9a aa734f8ad8f1393276a196d4df48d6c2 ffffffffffffffffffffffffffffffff 23884552 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-fjwwckbfeibxtigbuqodcvpqeqjr/cocoasudo_Prefix.pch.gch
0000000045f5c61d0000000000006e9a 1170525475d59d958018f84887aafa5f ffffffffffffffffffffffffffffffff 22225560 /var/folders/38/38ImciEdELOJN4+W8wBJsE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/cocoasudo_Prefix-cndwgaqxzvwwzsfvrjmgjoarnabn/cocoasudo_Prefix.pch.gch
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
79 changes: 79 additions & 0 deletions cocoasudo.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
.\"See Also:
.\"man mdoc.samples for a complete listing of options
.\"man mdoc for the short list of editing options
.\"/usr/share/misc/mdoc.template
.Dd 10/19/09 \" DATE
.Dt cocoasudo 1 \" Program name and manual section number
.Os Darwin
.Sh NAME \" Section Header - required - don't modify
.Nm cocoasudo,
.\" The following lines are read in generating the apropos(man -k) database. Use only key
.\" words here as the database is built based on the words here and in the .ND line.
.Nm Other_name_for_same_program(),
.Nm Yet another name for the same program.
.\" Use .Nm macro to designate other names for the documented program.
.Nd This line parsed for whatis database.
.Sh SYNOPSIS \" Section Header - required - don't modify
.Nm
.Op Fl abcd \" [-abcd]
.Op Fl a Ar path \" [-a path]
.Op Ar file \" [file]
.Op Ar \" [file ...]
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
arg2 ... \" Arguments
.Sh DESCRIPTION \" Section Header - required - don't modify
Use the .Nm macro to refer to your program throughout the man page like such:
.Nm
Underlining is accomplished with the .Ar macro like this:
.Ar underlined text .
.Pp \" Inserts a space
A list of items with descriptions:
.Bl -tag -width -indent \" Begins a tagged list
.It item a \" Each item preceded by .It macro
Description of item a
.It item b
Description of item b
.El \" Ends the list
.Pp
A list of flags and their descriptions:
.Bl -tag -width -indent \" Differs from above in tag removed
.It Fl a \"-a flag as a list item
Description of -a flag
.It Fl b
Description of -b flag
.El \" Ends the list
.Pp
.\" .Sh ENVIRONMENT \" May not be needed
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
.\" .It Ev ENV_VAR_1
.\" Description of ENV_VAR_1
.\" .It Ev ENV_VAR_2
.\" Description of ENV_VAR_2
.\" .El
.Sh FILES \" File used or created by the topic of the man page
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
.It Pa /usr/share/file_name
FILE_1 description
.It Pa /Users/joeuser/Library/really_long_file_name
FILE_2 description
.El \" Ends the list
.\" .Sh DIAGNOSTICS \" May not be needed
.\" .Bl -diag
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .El
.Sh SEE ALSO
.\" List links in ascending order by section, alphabetically within a section.
.\" Please do not reference files that do not exist without filing a bug report
.Xr a 1 ,
.Xr b 1 ,
.Xr c 1 ,
.Xr a 2 ,
.Xr b 2 ,
.Xr a 3 ,
.Xr b 3
.\" .Sh BUGS \" Document known, unremedied bugs
.\" .Sh HISTORY \" Document history if command behaves in a unique manner
146 changes: 146 additions & 0 deletions cocoasudo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
//
// cocoasudo.m
//
// Created by Aaron Kardell on 10/19/2009.
// Copyright 2009 Performant Design, LLC. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

int retVal = 1;
int programArgsStartAt = 1;
char *icon = NULL;
char *prompt = NULL;

for (; programArgsStartAt < argc; programArgsStartAt++)
{
if (!strncmp("--icon=", argv[programArgsStartAt], 7))
{
icon = argv[programArgsStartAt] + 7;
}
else if (!strncmp("--prompt=", argv[programArgsStartAt], 9))
{
prompt = argv[programArgsStartAt] + 9;
size_t promptLen = strlen(prompt);
char *newPrompt = malloc(sizeof(char) * (promptLen + 2));
strcpy(newPrompt, prompt);
newPrompt[promptLen] = '\n';
newPrompt[promptLen + 1] = '\n';
newPrompt[promptLen + 2] = '\0';
prompt = newPrompt;
}
else
{
break;
}
}

OSStatus status;
AuthorizationRef authRef;

AuthorizationItem right = { "com.performant.cocoasudo", 0, NULL, 0 };
AuthorizationRights rightSet = { 1, &right };

AuthorizationEnvironment myAuthorizationEnvironment;
AuthorizationItem kAuthEnv[2];
myAuthorizationEnvironment.items = kAuthEnv;

if (prompt && icon)
{
kAuthEnv[0].name = kAuthorizationEnvironmentPrompt;
kAuthEnv[0].valueLength = strlen(prompt);
kAuthEnv[0].value = prompt;
kAuthEnv[0].flags = 0;

kAuthEnv[1].name = kAuthorizationEnvironmentIcon;
kAuthEnv[1].valueLength = strlen(icon);
kAuthEnv[1].value = icon;
kAuthEnv[1].flags = 0;

myAuthorizationEnvironment.count = 2;
}
else if (prompt)
{
kAuthEnv[0].name = kAuthorizationEnvironmentPrompt;
kAuthEnv[0].valueLength = strlen(prompt);
kAuthEnv[0].value = prompt;
kAuthEnv[0].flags = 0;

myAuthorizationEnvironment.count = 1;
}
else if (icon)
{
kAuthEnv[0].name = kAuthorizationEnvironmentIcon;
kAuthEnv[0].valueLength = strlen(icon);
kAuthEnv[0].value = icon;
kAuthEnv[0].flags = 0;

myAuthorizationEnvironment.count = 1;
}
else
{
myAuthorizationEnvironment.count = 0;
}

if (AuthorizationCreate(NULL, &myAuthorizationEnvironment/*kAuthorizationEmptyEnvironment*/, kAuthorizationFlagDefaults, &authRef) != errAuthorizationSuccess)
{
NSLog(@"Could not create authorization reference object.");
status = errAuthorizationBadAddress;
}
else
{
status = AuthorizationCopyRights(authRef, &rightSet, &myAuthorizationEnvironment/*kAuthorizationEmptyEnvironment*/,
kAuthorizationFlagDefaults | kAuthorizationFlagPreAuthorize
| kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights,
NULL);
}

if (status == errAuthorizationSuccess)
{
status = AuthorizationExecuteWithPrivileges(authRef, argv[programArgsStartAt], 0, argv + programArgsStartAt + 1, NULL);

pid_t pid;
int pidStatus;
do {
pid = wait(&pidStatus);
} while (pid != -1);

if (status == errAuthorizationSuccess)
{
retVal = 0;
}
}
else
{
AuthorizationFree(authRef, kAuthorizationFlagDestroyRights);
authRef = NULL;
if (status != errAuthorizationCanceled)
{
// pre-auth failed
NSLog(@"Pre-auth failed");
}
}

if (prompt) {
free(prompt);
}

[pool release];
return retVal;
}
Binary file added cocoasudo.xcodeproj/TemplateIcon.icns
Binary file not shown.
Loading

0 comments on commit 5216698

Please sign in to comment.