[ale] Process Group leaders

Chris Fowler cfowler at outpostsentinel.com
Thu Dec 13 11:02:22 EST 2001


Understanding process groups is killing me.  I have this simple program that will allow a user to su as root. If I do not fork it will work correctly.  If I do fork I get
tcsetpgr() Inappropriate ioctl for device errors from the shell it executes.  It basically executes the ladsh which uses job control.  Can someone tell me what I need to 
change in order to not have conflicts with the ladsh.  Below is the function that actuallty becomes root.  This program also have permissions of 4755 allowing it to 
accomplish the setuid() and setgid() calls.  Any help on this cut of code will be appreciated.  Pointers will be especially appreciated.


/* void become_root(void)
 *
 * Do the actual job of seting the uid->0 and gid->0.
 * Fork and wait till the shell is exited.
 */
void
become_root(void)
{
        int pid;

        log_info("user->admin succeeded by %s", getlogin());

        /* Setup Signal Handling so that we will not be killed by
         * there signals
         */
        signal(SIGQUIT, SIG_IGN);
        signal(SIGINT,  SIG_IGN);
        signal(SIGHUP,  SIG_DFL);

        pid = fork();

        if(pid < 0)
                err_quit("fork");

        if(pid == 0)
        {
                extern char **environ;

                chdir("/");
                setgid(0);
                setuid(0);

                execle(SHELL, SHELL,0, environ);
                err_quit("exec");
        }

        waitpid(pid, NULL, 0);

        log_info("user->admin exited by: %s", getlogin());

        exit(0);
}





---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list