Need help authorizing tool with root privileges

So i've read apples docs on AuthorizationServices many times but they're examples leave a lot out (or maybe im just overlooking things) Can anyone provide a simple example of how to give an application root privileges, im trying to create a cleaning tool that removes caches etc.

You can't really "give an application root privileges". You can execute a tool with root privileges. I use the following:
#import "Authorization.h"
#import <Security/Authorization.h>
#import <Security/AuthorizationTags.h>
@implementation Authorization
// Constructor.
- (id) init
self = [super init];
if(self)
AuthorizationFlags flags = kAuthorizationFlagDefaults;
OSStatus status =
AuthorizationCreate(
0, kAuthorizationEmptyEnvironment, flags, & myAuthorizationRef);
if(status != errAuthorizationSuccess)
@throw
[NSException
exceptionWithName: @"AuthorizationCreateFailure"
reason: [NSString stringWithFormat: @"Error code: %d", status]
userInfo: nil];
return self;
// Destructor.
- (void) dealloc
if(myAuthorizationRef)
AuthorizationFree(myAuthorizationRef, kAuthorizationFlagDefaults);
[super dealloc];
// Execute a privileged task.
// Returns YES if the task executed successfully, NO otherwise.
- (BOOL) run: (NSString *) executable
withArguments: (NSArray *) arguments
output: (NSString **) output
AuthorizationItem items = { kAuthorizationRightExecute, 0, 0, 0 };
AuthorizationRights rights = { 1, & items };
AuthorizationFlags flags =
kAuthorizationFlagDefaults
| kAuthorizationFlagInteractionAllowed
| kAuthorizationFlagPreAuthorize
| kAuthorizationFlagExtendRights;
OSStatus status = AuthorizationCopyRights(
myAuthorizationRef, & rights, 0, flags, 0);
if(status != errAuthorizationSuccess)
@throw
[NSException
exceptionWithName: @"AuthorizationCopyRightsFailure"
reason: [NSString stringWithFormat: @"Error code: %d", status]
userInfo: nil];
char ** args = (char **)malloc([arguments count] + 1);
int index = 0;
for(NSString * argument in arguments)
args[index++] = (char *)[argument UTF8String];
args[index] = 0;
FILE * pipe = 0;
flags = kAuthorizationFlagDefaults;
status =
AuthorizationExecuteWithPrivileges(
myAuthorizationRef,
[executable UTF8String],
flags,
args,
& pipe);
free(args);
if(output)
NSMutableString * results = [NSMutableString new];
char buf[128];
while(true)
int bytesRead = read (fileno(pipe), buf, sizeof(buf) - 1);
if(bytesRead < 1)
break;
buf[bytesRead] = 0;
[results appendString: [NSString stringWithUTF8String: buf]];
[results autorelease];
*output = results;
return status == errAuthorizationSuccess;
// Execute a privileged task.
// Returns YES if the task executed successfully, NO otherwise.
+ (BOOL) execute: (NSString *) executable
withArguments: (NSArray *) arguments
output: (NSString **) output
Authorization * authorization = [Authorization new];
BOOL result =
[authorization run: executable withArguments: arguments output: output];
[authorization release];
return result;
@end

Similar Messages

  • Help authoring tools with SharePoint

    Long time ago I used to use Help Authoring tools such as RoboHelp and ForeHelp. These were for Visual Basic applications. Wondering what would be a good help authoring tool for SharePoint 2010 applications that can help users understand SharePoint
    features? Thanks so much.
    Mayank

    Try Component One’s Doc-To-Help (D2H)
    http://blog.accusoft.com/2013/february/top-4-help-tools-that-integrate-with-sharepoint
    http://blog.infotech.com/advisory/sharepoint-and-help-authoring/

  • Applying a patch with root privilege through terminal

    Hey there. I need a little help.
    I am beta testing a new open source media player for a friend of a friend. He added a series of codecs to be tested in a patch. He said in the email that the patch needs to be applied to the program via terminal with root privilege. Unfortunately, he never said how, and he's being slow in responding to my email.
    So how do I do it? Is it just a couple of commands I type in to terminal? What are the commands?

    There's absolutely no way anyone other than the author can answer that question for you.
    Since you're beta testing the app it's not likely to be an app that other people have. Since patch installation is at the whim (and mercy) of the developer, each app could install patches a different way - some might just be files you need to manually copy to a specific location, others would have an install script that copies files for you while others might update the application at the binary level.
    Without knowing the app, and without knowing the patch method, no one here can answer for sure.

  • Help Authoring Tool Options & Enhancements

    I have been using RoboHelp x5 since 2005. For this year's
    budget meeting I have to provide options/cost comparison on other
    tools that are available. One thing that is of crucial importance
    is that my background is not in computer/technical (no can do code,
    scripting, etc), which is why RoboHelp was chosen in the first
    place.
    1) Can anyone offer an "addon products" to use with RoboHelp
    (i.e. to enhance search function, etc)
    2) Can anyone offer any advice (pros and/or cons) about any
    of the following Help Author Tools?
    • AuthorIT
    • Doc-To-Help
    • chm2web
    • FAR
    • Help & Manual
    • Help Generator
    • HelpConsole 2008
    • HelpNDoc
    • HelpServer
    • HelpStudio
    • HelpTron
    • HyperText Studio
    • Macrobject Word-2-CHM
    • Macrobject Word-2-Web
    • MadCap Flare
    • Mif2Go
    • WinCHM
    Any assistance will be MUCH appreciated!
    Cindi

    Hi, Cindi,
    If you're an experienced RoboHelp user and happy with the
    output that you're getting with it then I would question the
    benefit of switching to another help authoring tool. This may be
    necessary in some circumstances —- for example, if you need
    to output your help content in a format that RoboHelp does not
    support, such as Microsoft Help 2.0 -— but for the most part
    the time and effort required to learn the new tool and convert your
    existing content for use with it will outweigh the benefits of
    switching to it.
    Here are a few notes on the tools you listed.
    > chm2web
    > Help Generator
    > HelpConsole 2008
    > HelpNDoc
    > HelpServer
    > HelpTron
    > Macrobject Word-2-CHM
    > Macrobject Word-2-Web
    > WinCHM
    I see little or no mention of these tools in any of the
    Help-related forums that I frequent. This isn't necessarily a bad
    thing, of course, but I believe it indicates that few professional
    help authors are using them. I'd expect the cheaper of these tools
    to provide few or no editing facilities, and in some cases they may
    be designed to perform a single, very specific function, such as
    compiling a set of existing HTML files into a .chm file.
    > FAR
    This is an excellent tool for performing search-and-replace
    operations across a set of HTML files and compiling them into a
    .chm file or Help 2.0 file. It provides no facilities for creating
    and maintaining your topic content, however, so you should really
    only view it as a potentially useful add-on to RoboHelp.
    > Mif2Go
    This is like WebWorks Publisher (not on your list): an
    application that takes source content authored with Adobe
    FrameMaker and converts it into a number of different help formats.
    If you've already authored a lot of content with RoboHelp then
    moving it into FrameMaker and setting up the Mif2Go or WebWorks
    templates appropriately could be a big undertaking.
    > HyperText Studio
    This was up-and-coming five or ten years ago but, for
    whatever reason, it seems to have dropped completely from view
    (though I'm aware that it is still for sale).
    > HelpStudio
    This is a quite heavy-duty application that appears to be
    more popular with software developers than with full-time help
    authors. A "lite" version is now being given away with Visual
    Studio.
    > AuthorIT
    > Doc-To-Help
    > Help & Manual
    > MadCap Flare
    These are all significant players. I've used AuthorIT only
    and, while it's certainly a powerful tool, the learning curve is
    quite steep.
    You can read detailed reviews of many of these applications
    at the Writers UA site (
    http://www.writersua.com).
    Pete

  • RoboHelp vs. SharePoint as Help Authoring Tool

    Hello All,
    I'm currently looking at RoboHelp to replace our old help
    guides. Right now our guides are accessed though a 2 frame page
    with an asp driven TOC on the left. The TOC just links to some html
    pages that display in the right fram and others that are just
    downloads of word, excel and PDF docs.
    We will be purchasing Microsoft SharePoint next year and it
    has been suggested to use that as our help authoring tool. I don't
    know much about RoboHelp (other than I've been using the demo for a
    couple days and love it's ease of use) and SharePoint and was
    wondering if anyone out there has used both as a help authoring
    tool and what your experiences were.
    Are they pretty much similar, does anyone use them in
    conjunction, any pros and cons to each?
    Any help would be greatly appreciated.

    Welcome to our community, mschallmo
    I'm not a Sharepoint user and I didn't stay at a Holiday Inn
    Express last night, so I can't claim to be one.
    I think you are comparing Spiders to Hedgehogs here. RoboHelp
    is a Help Authoring Tool (HAT). Sharepoint is a product that might
    display what RoboHelp created, but will not facilitate actually
    creating the content you would later display as RoboHelp will.
    Unless someone more experienced with Sharepoint steps up to
    refute this, my understanding is that you would need
    Both RoboHelp
    AND Sharepoint. RoboHelp to author the content and
    Sharepoint to present it to your users.
    Cheers... Rick

  • Help Authoring Tool

    I would like to add a comprehensive help feature to the application I'm creating. Ideally, I would like a "mini website" which the user would access via a link from the navigation bar. If it's possible, I'd like to program the link to be context sensitive (i.e. pull up help for the given page, but once the user is in the help website, he/she can use a search tool or jump to the Table Of Contents or Index).
    Is there a help authoring tool (e.g. Adobe's Robohelp or something similar) that works particularly well with APEX? Is there something built into APEX that I haven't found yet? (note: I'm new to APEX programming). Any advice on any of the tools would be greatly appreciated.
    Thanks in advance,
    Rob

    APEX includes built-in features to develop a help system for your application.
    http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/app_comp.htm#CHDCDBFB

  • How to launch an App with Root privileges - without enabling "root" user ac

    Is there a reliable way to launch an Application so that it can run with "root" privileges, but without enabling the OSX root account and logging in to that account?
    There is an old (and, presumably, obsolete) application called "Pseudo" which used to facilitate this, but I doubt it would be safe or reliable under OSX 10.5.
    So, does anyone have any suggestions?

    For a more permanent method, run the following command on the same file:
    sudo chmod u+s
    if the item is owned by root. This may be undone by the repair permissions command.
    (27138)

  • Need help to start with some file and text manipulation

    Hello script mavens,
    I need help with starting a script that does the following:
    -within a base folder it takes an inventory (list?) of all the files (which happen to be image files).
    -creates a new folder inside the base folder and calls it imagesX where X increases by one every time the script is run
    -moves all the files into the images folder
    -within the base folder it creates a new text file and calls it imagesX.js
    -writes a "//-" into imagesX.js
    -then writes the list of filenames into the imagesX.js twice, separated by an empty line, and adds a semicolon to the end of each filename and saves imagesX.js
    -from a folder a level above the base folder it copies a file called index.html into the base folder and renames in indexX.html
    -in indexX.html it replaces a string "replaceThis" with "imagesX.js"
    The task is more complex but this would help me tremendously do the rest.
    If I am asking for too much on this forum please let me know

    This should get you started.
    The description of how you want to write the data isn't clear, but the rest should work (untested):
    property imageNum : 0 -- last used ImageNumber
    -- within a base folder it takes an inventory (list?) of all the files (which happen to be image files).
    -- get the folder:
    set baseFolder to (choose folder)
    -- now get the files within it:
    tell application "Finder"
    set fileList to every file of folder baseFolder as alias list
    end tell
    --creates a new folder inside the base folder and calls it imagesX where X increases by one every time the script is run
    tell application "Finder"
    set imageNum to imageNum + 1
    set newImageFolder to make new folder at baseFolder with properties {name:"images" & imageNum}
    -- moves all the files into the images folder
    move every file of folder baseFolder to newImageFolder
    --within the base folder it creates a new text file and calls it imagesX.js
    set textFile to (open for access file (baseFolder as text) & "images" & imageNum & ".js" with write permission)
    --writes a "//-" into imagesX.js
    write "//-" to textFile
    -- then writes the list of filenames into the imagesX.js twice, separated by an empty line, and adds a semicolon to the end of each filename and saves imagesX.js
    -- need more info here
    -- a blank line between each instance of the file name? or all file names, blank line, all file names again?
    -- an example, please
    close access textFile
    --from a folder a level above the base folder it copies a file called index.html into the base folder
    --and renames in indexX.html
    --in indexX.html it replaces a string "replaceThis" with "imagesX.js"
    -- the easiest way of doing this is to read the file and write a new copy with the changes - that's easier than changing it in situ:
    set indexHTML to (read file "index.html" of folder (container of baseFolder))
    set {oldTIDs, my text item delimiters} to {my text item delimiters, "replaceThis"}
    set indexHTML to text items of indexHTML
    set my text item delimiters to "imagesX.js"
    set indexHTML to indexHTML as text
    set my text item delimiters to oldTIDs
    set indexFile to (open for access file ("index" & imageNum & ".html") with write permission)
    write indexHTML to indexFile
    close access indexFile
    end tell

  • NEED HELP IN MATRIX WITH GROUP REPORT

    Dear All,
    I need small help in MATRIX WITH GROUP REPORT In Report Builder Test Report
    In my report, having periods as rows and location as columns as shown below,
    1) LOC-A
    JAN-10 FEB-10
    ITEM-GROUP -1 1 2
    ITEM-GROUP-2 3 4
    ITEM-GROUP 3 5 6
    2) LOC- B
    MAR-10 APR-10
    ITEM-GROUP -1 7 8
    ITEM-GROUP-2 9 10
    ITEM-GROUP-3 11 12
    But comming to my requirement, the periods should be in fix in matrix as shown below
    1) JAN-10 FEB-10 MAR-10 APR-10
    LOC-A
    ITEM-GROUP -1 1 2
    ITEM-GROUP-2 3 4
    ITEM-GROUP 3 5 6
    LOC- B
    ITEM-GROUP -1 0 0 7 8
    ITEM-GROUP-2 0 0 9 10
    ITEM-GROUP-3 0 0 11 12
    I am unable to get this kind of output format
    Please kindly waiting for reply from our team....
    Regards
    krishna.P

    For the periods, create a seperate dummy query and then use it as column group in the multi query matrix.

  • Is there an HTML help authoring tool for LV?

    Ideally one tool fits all, LabView, C# and MSVC++.
    I know RoboHelp is a good tool for non-LV languages, does any one know other good tools? Thanks

    The standard Common User Access (CUA) states that the key F1 will open help. Unfortunatly you cannot associate this key with a help file and topic as you can in other development systems.
    On windows systems the behaviour seem to be common with what I have tested with MS Outlook, MS Internet explorer, LV and my favourite Help authouring tool (HAT). All open the default topic of the help file.
    On IBMs AS /400, now iSeries, F1 will open a window which depends on the field where the cursor is. On GUI system this is related to the control who has the key focus. If the cursor is outside any field a help window explaining the current screen will be opened.
    LV allows you to simulate this using the event structure. Make a event case for "Key up". Look into help for scan codes and how the keys are mapped to the values in this case. This event exists for the VI and for each control/indicator. If you have detected a F1 key you can open the help file with the corresponding topic.
    The other way of context sensitiv help is Shift-F1. This works different in different applications. MS Outlook will open a popup window depending on the part where the mouse cursor is. MS IE will open the default topic of the help. My HAT will change the cursor and when you click somewhere you get a corresponding popup window. LV will ignore this key. The best way LV has for that is the "Tip" or "Tip Strip".
    I think that NI will not make a new property to VIs and controls containing help file information and to associate the F1 key with that properties because you can connect F1 to a control using Key Navigation. This is another method of providing help. Place a control outside the visible aera and connect it with F1 using key navigation. This way you can open a help file with a topic with the context sensitivity of the window.
    Another thing I have to comment is that why will you use HTML files instead of HTML based help (Win98, this is the same help LV uses)? If you have a medium sized application you will have to be careful to deploy a lot of files (more than 30 I would expect, 1 for ech topic and two or three for the frame, navigation and table of contents). You have to take into concern various browsers (4 Versions of MS IE, some versions of Netscape, some versions of Opera) with various versions of JavaScript if you will use a dynamic table of contents. And you will loose such things like Search and Favourites. Win98-Help looks always the same because there is only one viewer installed with every Windows and there are no third party products doing some things different. The only answer I would really accept is you are not on a windows platform.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Finder-based account with root privileges?

    Is there anyway to give the Admin account root privileges? Or is there a true Root account in the Finder?
    There are times when I need to move/change files in other accounts. Can this be done through the Finder? Or do I have to use Unix and the Terminal?
    Thanks in advance.
    Eric

    "OS X" does have a "root" account, but it is disabled by default for security reasons, and to prevent inexperienced users from messing up their systems. For knowlegable users, it can be enabled as described here:
    http://docs.info.apple.com/article.html?artnum=106290
    It is also possible for an "admin" user to launch "Finder" as "root", but this would usually require a trip to the command line, which you seem to want to avoid.
    It is encouraged that "root" be disabled immediately after finishing whatever tasks required its activation.

  • Need help  Pagination Suppourt with DataGrid

    Hi ,
    When i do a search Operation , the data from Database is huge and i think if i display all of them at a Time it will be a performance and response Time issue .
    So the question i am asking is that , can any body please give me a basic idea as how to implement Pagination with DataGrid Results ??
    Need help with Datgrid and Pagination suppourt .
    Thnaks in advnace .

    Hi Kiran,
    Try referring to the below link...
    http://www.flexicious.com/
    Thanks,
    Bhasker Chari.S

  • Replaced hard drive in compaq presario cq62, need help recovering it with out disks

    Recently replaced the hard drive in my notebook due to failure of original.  Need help recovering it without disks

    If you are wanting to install the original copy of Windows it came with, you will need a set of recovery disks.
    Otherwise, you can purchase a copy of Windows to install and download the appropriate drivers from http://goo.gl/hOm3. Just make sure the copy of Windows that is installed is at least the same family of Windows to ensure that drivers are available.
    What is the exact model of the notebook and product number?
    NOTE: Do not provide the serial number.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • Need help from somebody with the "MSI KT6 Delta-FIS2R" motherboard

    Hi everybody!
    I really need some help from somebody with the MSI KT6 Delta-FIS2R motherboard (the one with onboard LAN, Audio, RAID, S-ATA and IEEE1394 firewire). You see. I've got this board myself but it's been destroyd. Some values for the onboard devices in my board has been overwritten so that windows no longer recognizes the onboard LAN and Audio controller anymore. I really need some help from somebody with this board.
    I need to see what the values for the onboard devices should be. I hope someone can help me by sending me a repport from the Everest home edition: http://www.lavalys.com/products/overview.php?pid=1&lang=en
    If anyone could do me this favour, I would be VERRY thankfull

    Quote from: HYSTERIAH on 12-November-05, 06:24:20
    I really need some help from somebody with the MSI KT6 Delta-FIS2R motherboard
    HYSTERIAH,
    With 76 Replies and 277 Views on your original thread, it looks to me like people have been trying to help you.
    So there is no confusion, I am locking this thread so all your help and advice you receive will be in the same place, so people do not need to jump between threads to keep track of what has already been suggested for this mobo of yours.
    Richard

  • Need help understanding communicating with a thread

    I am trying to write a library of a MUD engine that runs in its separate thread, but I am new to Java and not sure I have the concepts right. The heart of it is a class called Game, that implements the Runnable Interface and has 2 key methods - void DoCommand(String command) and String GetUpdates(String lastUpdate).
    * The Run() method runs an infinite loop that processes queued commands when they are due, and pauses (wait() or sleep()) in between. The results are queued in an update list.
    * The DoCommand() method queues commands to be processed in Run().
    * The GetUpdates() method pulls updates from the update list one at a time.
    Will there be a problem if DoCommand() or GetUpdates() are called while Run() is paused or running?
    How do I get DoCommand() to wake Run() when a new command is received?
    BTW: I am new to Java so please make the answers simple enough for me to understand.
    My theoretical code skeleton is below, but I am not confident in it given these questions I have.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package me.org.prototype;
    import java.util.ArrayList;
    /** Definition of the game engine. The engine runs in its own threat, updating
    * and maintaining its state, objects, etc. IO is handled through a separate
    * interface (GUI or something else) that communicates with this object. NOTE:
    * this interface is the game interface and not a Java interface.
    * <P> Usage create a Game instance and a place it in a thread. Once started you
    * can pass in input via the DoCommand(...) method, and get updates from its
    * GetUpdates(...) method. To exit interrupt the thread or call
    * DoCommand("quit");
    * @author atbudd
    public class Game implements Runnable {
        /** Next time (computer time) that a game action is to be run. Use 0 to
         * indicate no action pending.
        int nextRunTime = 0;
        /** Boolean indicating running state of game. */
        boolean gameRunning = true;
        /** List of game updates. */
        ArrayList<String> updateList = new ArrayList<String>();
        /** Perform's game's main loop. */
        public void run() {
            // Main loop code.
            while (gameRunning) {
                // Process game objects and pending actions.
                try {
                    // Pause until next action due.
                    if (nextRunTime > 0) {
                        wait(nextRunTime - System.nanoTime());
                    } // Otherwise wait until action specified. NOTE: action specified elsewhere.
                    else {
                        wait();
                } catch (InterruptedException exception) {
                    // If quit command received...
                    if (exception.getMessage().equalsIgnoreCase("quit")) {
                        gameRunning = false;
                    /* Otherwise new command received. wait(...)interrupted and loop
                     * resumed so that nextRunTime can be updated to when new
                     * command due.
        /** Peforms specified command.
         * @param command Command to be processed.
        public void DoCommand(String command) throws InterruptedException {
            // Process command.
            if (command.equalsIgnoreCase("quit")) {
                // Interrupt game with exit interrupt.
                throw new InterruptedException(command);
            else if ((nextRunTime == 0) /* || command due before nextRunTime */) {
                // Add command to a processing queue.
                // Interrupt game to schedule / process command.
                throw new InterruptedException("new command");
        /** Returns updates since update specified.
         * @param lastUpdate Last update received from game. Use "" if not updates
         * received yet.
        public String GetUpdates(String lastUpdate) {
            // Update string
            String updateString = null;
            /* (TODO) Get updates from update list that come after last update and
             * place in update string.
            // Return update string.
            return updateString;
    }

    Furrage wrote:
    OK cotton.m. I will try that and see what happens.
    What about my question about which thread DoCommand() will run in (my second post in this message thread)? Any answers? I think that's key to me understanding what is needed to get my code to work the way I want, but I don't know how to test which thread it is running in.Possibly by interrupt.
    Or possibly by adding the command to a command queue which in turn would notify a thread waiting on the queue for the next command.

Maybe you are looking for