[55476] branches/gsoc09-gui/MacPorts_Framework
juanger at macports.org
juanger at macports.org
Tue Aug 11 18:42:29 PDT 2009
Revision: 55476
http://trac.macports.org/changeset/55476
Author: juanger at macports.org
Date: 2009-08-11 18:42:28 -0700 (Tue, 11 Aug 2009)
Log Message:
-----------
Adding cancel/teminate support to BetterAuthorizationSample.
Modified Paths:
--------------
branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.c
branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.h
branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c
Modified: branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.c
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.c 2009-08-12 01:25:56 UTC (rev 55475)
+++ branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.c 2009-08-12 01:42:28 UTC (rev 55476)
@@ -2460,3 +2460,23 @@
return retval;
}
+
+extern void BASTerminateCommand (
+ AuthorizationRef auth,
+ const char * bundleID,
+ const char * installToolPath
+)
+// Terminate the HelperTool.
+{
+ // Pre-conditions
+
+ assert(auth != NULL);
+ assert(bundleID != NULL);
+ assert(installToolPath != NULL);
+
+ // Run the install tool as root using AuthorizationExecuteWithPrivileges.
+ RunInstallToolAsRoot(auth, installToolPath, kBASInstallToolTerminateCommand, bundleID, NULL);
+
+ return;
+}
+
Modified: branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.h 2009-08-12 01:25:56 UTC (rev 55475)
+++ branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLib.h 2009-08-12 01:42:28 UTC (rev 55476)
@@ -738,6 +738,12 @@
CFArrayRef descArray
);
+extern void BASTerminateCommand(
+ AuthorizationRef auth,
+ const char * bundleID,
+ const char * installToolPath
+);
+
/////////////////////////////////////////////////////////////////
#pragma mark ***** Utility Routines
@@ -763,6 +769,7 @@
#define kBASInstallToolInstallCommand "install"
#define kBASInstallToolEnableCommand "enable"
+ #define kBASInstallToolTerminateCommand "terminate"
// Magic values used to bracket the process ID returned by the install tool.
Modified: branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c 2009-08-12 01:25:56 UTC (rev 55475)
+++ branches/gsoc09-gui/MacPorts_Framework/BetterAuthorizationSampleLibInstallTool.c 2009-08-12 01:42:28 UTC (rev 55476)
@@ -395,6 +395,24 @@
return err;
}
+static int TerminateCommand(
+ const char *bundleID
+)
+// Utility function to call through to RunLaunchCtl in order to terminate a job
+// given by the path contructed from the (const char *) bundleID.
+{
+ int err;
+ char plistPath[PATH_MAX];
+
+ // Pre-condition.
+ assert(bundleID != NULL);
+
+ (void) snprintf(plistPath, sizeof(plistPath), kBASPlistPathFormat, bundleID);
+ err = RunLaunchCtl(false, "unload", plistPath);
+
+ return err;
+}
+
int main(int argc, char **argv)
{
int err;
@@ -453,10 +471,17 @@
fprintf(stderr, "usage4\n");
err = EINVAL;
}
- } else {
- fprintf(stderr, "usage2\n");
- err = EINVAL;
- }
+ } else if (strcmp(argv[1], kBASInstallToolTerminateCommand) == 0) {
+ if (argc == 3) {
+ err = TerminateCommand(argv[2]);
+ } else {
+ fprintf(stderr, "usage4\n");
+ err = EINVAL;
+ }
+ } else {
+ fprintf(stderr, "usage2\n");
+ err = EINVAL;
+ }
}
// Write "oK" to stdout and quit. The presence of the "oK" on the last
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090811/cdec3baa/attachment.html>
More information about the macports-changes
mailing list