AuthorizationExecuteWithPrivileges question

  • Gentlepeople,

    While writing a small personal hack I need to temporarily change the
    privileges on a root owned file and then back again to root. For this
    I use AEWP to run a small tool that calls chown to do its thing. This
    tool works as intended on PPC based Mac (G5) both in Tiger and Leo.
    To my surprice it did not work on Intel neither in Tiger or Leo. In
    my tool I the first line of code checks for the correct number of
    parameters by looking at the first parameter to the tool as in
    int main(int argc, char *argv[])

    To my surprice the value of argc differs between Intel and PPC. On
    Intel it differs between calls to the tool, I have not seen that
    happen on PPC. The docs for AEWP state: " The arguments you pass in
    the arguments parameter are relayed to the new process’s argv
    parameter." It does not say anything about argc.
    My conclusion is that argc is not set to reflect the number of
    parameters passed. Is this behavior of AEWP known to the subscribers
    of this list and am I just struck by the bewilderment of ignorance ?
  • On Feb 9, 2008 5:56 AM, Stefán Kristjánsson <stefan...> wrote:

    > My conclusion is that argc is not set to reflect the number of
    > parameters passed. Is this behavior of AEWP known to the subscribers
    > of this list and am I just struck by the bewilderment of ignorance ?

    I doubt it is AEWP I have a feeling the way you are constructing the
    parameters you give to AEWP could be at fault.

    Can you list that part of your code?

    -Shawn
  • On Feb 9, 2008 5:56 AM, Stefán Kristjánsson <stefan...> wrote:
    > Gentlepeople,
    >
    > While writing a small personal hack I need to temporarily change the
    > privileges on a root owned file and then back again to root. For this
    > I use AEWP to run a small tool that calls chown to do its thing. This
    > tool works as intended on PPC based Mac (G5) both in Tiger and Leo.
    > To my surprice it did not work on Intel neither in Tiger or Leo. In
    > my tool I the first line of code checks for the correct number of
    > parameters by looking at the first parameter to the tool as in
    > int main(int argc, char *argv[])

    Ah you aren't terminating the args vector you supply to AEWP.

    char* args[3];
    args[0] = "foo";
    args[1] = "bar";
    args[2] = NULL;

    ...or...

    char* args = {"foo", "bar", NULL};

    -Shawn