Use of execl() - Unix

This is a discussion on Use of execl() - Unix ; Is it okay to pass something other than the pathname as argv[0] when using execl()? execl(some_exec_path, argument1, NULL); where argument1 != full_path_of_exec? -- Aaron Hsu | Jabber: arcfide@jabber.org ``Government is the great fiction through which everybody endeavors to live at ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Use of execl()

  1. Use of execl()

    Is it okay to pass something other than the pathname as argv[0] when
    using execl()?

    execl(some_exec_path, argument1, NULL);

    where argument1 != full_path_of_exec?
    --
    Aaron Hsu | Jabber: arcfide@jabber.org
    ``Government is the great fiction through which everybody endeavors to
    live at the expense of everybody else.'' - Frederic Bastiat

  2. Re: Use of execl()

    Aaron Hsu writes:
    > Is it okay to pass something other than the pathname as argv[0] when
    > using execl()?
    >
    > execl(some_exec_path, argument1, NULL);
    >
    > where argument1 != full_path_of_exec?


    Insofar you know that the program to be executed can live with that,
    yes. Eg login traditionally uses -sh as *argv to inform /bin/sh that
    it is supposed to act as a login shell. The SUS request is just that

    The argument arg0 should point to a filename that is
    associated with the process being started by one of the exec
    functions.

    meaning 'unless you have a reason to do otherwise, this would be a
    sensible choice'.


  3. Re: Use of execl()

    >Is it okay to pass something other than the pathname as argv[0] when
    >using execl()?
    >
    > execl(some_exec_path, argument1, NULL);
    >
    >where argument1 != full_path_of_exec?


    Some programs have multiple links, and use argv[0] to decide which
    command you asked for. (For example, 'sendmail' sends mail and
    'mailq' displays the mail queue, but they might be implemented as
    one executable, since sendmail with certain flags also prints the
    mail queue.)

    Some programs ignore argv[0] or only use it to display in error
    messages. These won't mind other strings but might still get upset
    over argv[0] = NULL.

    If a security-sensitive (e.g. setuid or remotely executable) program
    gets upset at a strange value for argv[0], that may well be a
    security vulnerability. It is very easy (especially if some of
    your users are black hats) to throw arbitrary crap in as argv[0].


+ Reply to Thread