Setup diald, then you don't have to worry about starting up ppp.  It
will do it anytime you try to access the net.

Chris

Lance Hoffmeyer wrote:
> 
> IN trying to find out if there was a way to automatically login during
> boot or to login to different terminals at boot I ran across this
> program.  Not being a C programmer I don't really understand what is
> happening in this program. It looks as if a password can be accepted as
> an argument but in the example there is no password mentioned
> 
>      dboot tty userid command
> 
> Can this be used to auto login under numerous terminal under different
> user id's and passwords.
> i.e.
> 
>      dboot tty userid password command
> 
>   I usually keep three terminal open.  One as root, one as user under a
> command shell and one as user under an X terminal.  I use root because I
> haven't found out which files I need to give user rights to in order to
> PPP.
> 
> /* dboot.c - program for inittab to execute and start processes.
>              Arguments are:
>                 tty to use for console
>                 program to run (most likely login)
>                 [any program args]
> 
> example:
> 
> c1:respawn:/usr/local/bin/dboot tty1 login -f sysadmin
> 
> will startup user 'sysadmin' on console 1
> 
> By Dave Bennet, from Linux Journal Issue 33 January 1997
> 
>  o Modified by Jeremy Impson, to take one more argument, a uid that will
>    be changed to.  It is optional, assuming that the userid doesn't
> start with
>    a '/', and assuming that the command does.  July 10, 1997
> 
>    usage is now
>      /* dboot.c - program for inittab to execute and start processes.
>              Arguments are:
>                 tty to use for console
>                 program to run (most likely login)
>                 [any program args]
> 
> example:
> 
> c1:respawn:/usr/local/bin/dboot tty1 login -f sysadmin
> 
> will startup user 'sysadmin' on console 1
> 
> By Dave Bennet, from Linux Journal Issue 33 January 1997
> 
>  o Modified by Jeremy Impson, to take one more argument, a uid that will
>    be changed to.  It is optional, assuming that the userid doesn't
> start with
>    a '/', and assuming that the command does.  July 10, 1997
> 
>    usage is now
>      dboot tty userid command
>    -or-
>      dboot tty command
> 
>    Also, added syslogging facility.  Jul 10, 1997
> 
> */
> 
> #include <stdlib.h>
> #include <string.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> #include <unistd.h>
> #include <pwd.h>
> #include <syslog.h>
> 
> int main(int argc, char **argv)
> {
>         char    cdev[50];
>         char    buf[50];
>         int     fd, whicharg;
>         pid_t   pid;
>         struct  passwd  *pw_ptr;
> 
>         openlog("dboot", LOG_PID, LOG_USER);
> 
>         if ( argv[2][0] == '/') {
>                 whicharg = 2;
>         } else {
>                 whicharg = 3;
>         }
> 
>         strcpy(cdev,"/dev/");
>         strcat(cdev,argv[1]);   /* console device */
>         if (-1 == (fd = open(cdev, O_RDWR))) {
>                 syslog(LOG_ERR,"open failure\n");
>                 /* perror("open failure"); */
>                 exit(0);
>         }
> 
>         close(0);
> 
>         if (-1 == (dup(fd))) {
>                 syslog(LOG_ERR,"dup 0 failure\n");
>                 /* perror("dup 0 failure"); */
>                 exit(0);
>         }
> 
>         close(1);
> 
>         if (-1 == (dup(fd))) {
>                 syslog(LOG_ERR,"dup 1 failure\n");
>                 /* perror("dup 1 failure"); */
>                 exit(0);
>         }
> 
>         close(2);
> 
>         if (-1 == (dup(fd))) {
>                 syslog(LOG_ERR,"dup 2 failure\n");
>                 /* perror("dup 2 failure"); */
>                 exit(0);
>         }
> 
>         if (3 == whicharg) {
>                 if (NULL == (pw_ptr = getpwnam(argv[2]))) {
>                         syslog(LOG_ERR,"no pwent for %s\n",argv[2]);
>                         /* sprintf(buf,"no pwent for %s",argv[2]);
>                         perror(buf); */
>                         exit(0);
>                 }
> 
>                 if (-1 == setuid(pw_ptr->pw_uid)) {
>                         syslog(LOG_ERR,"setuid failure\n");
>                         perror("setuid failure");
>                         exit(0);
>                 }
>         }
> 
>         closelog();
> 
>         if (-1 == execvp(argv[whicharg], &argv[whicharg])) {
>                 syslog(LOG_ERR,"execvp failure\n");
>                 /* perror("execvp failure"); */
>                 exit(0);
>         }
> 
> } /* end of main */
> 
> --
> Unsubscribe?  mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to