[comp.unix.questions] h

csmoko@NSWC-OAS.arpa (07/30/87)

>    At our site we are running Ultrik 2.0 on a vax 8600.  We have
> created several group accounts that people (if they are in the right
> group) access through a setuid program that has the same name as the
> group account.
>    The program sets up a environment for them and then execs /bin/sh.
> The person is then placed in that group account.  What I would like to
> do is have the shell execute the .profile and possibly /etc/profile.
> Is there any way I can tell /bin/sh to execute .profile or
> /etc/profile?  I know I can have the user type . .profile but I do not
> want this.

Dennis,
The method that I use is for /bin/csh but it should be similar for 
/bin/sh.  When I want to exec a .login with /bin/csh, it must be fooled 
into thinking someone is logging on.  When csh starts it tests to see 
if it was invoked as -csh.  If so it first gets it commands from 
.login .  I would guess that /bin/sh does a similar thing.  The trick 
that I use involves changing the name of the process with the 
following program.  I use the line ' $ exec execv /bin/csh -csh ' as 
the invoking command, because my machine has no chsh command.  I can't 
assure you that your machine handles things this way but this may help. 

						Chuck Smoko

--------------------------------- Cut ------------------------
#include <stdio.h>

main(argc,argv)
char **argv; 
{
    if (argc < 3 )
    {
        fprintf(stderr,"usage: execv path arg0 [arg ....]\n");
        exit(1);
    }
    execv(argv[1],&argv[2]);
    fprintf(stderr,"ERROR can't exec %s\n",argv[1]);
    exit(1);
}