cramer@kontron.UUCP (Clayton Cramer) (03/06/86)
I'm looking for a way for a remote user of our VAX to: 1. Dial in through our modem. 2. Give a phone number where the remote user is located (and perhaps validate the number). 3. Have the VAX call back on that phone number (to which is attached an auto-answer Hayes-compatible modem). 4. Allow the user to login in a fairly conventional manner. There doesn't seem to be anything built in to Berkeley 4.2 UNIX to do this, and I'm sure that lots of security-conscious installations have already done this. Please post the solution -- I'm sure lots of other people have a similar need for this.
perry@vu-vlsi.UUCP (Rick Perry) (03/10/86)
In article <581@kontron.UUCP>, cramer@kontron.UUCP (Clayton Cramer) writes: > I'm looking for a way for a remote user of our VAX to: > > 1. Dial in through our modem. > 2. Give a phone number where the remote user is located... > 3. Have the VAX call back on that phone number... > 4. Allow the user to login in a fairly conventional manner. Here's what we came up with on our Pyramid 90x. I think the /dev/itp.. and other IPTxxx stuff in the setcarr routine is Pyramid specific, but perhaps that can be modified for vax. The program had to be installed with setuid root in order to write to /dev/itp, but I think there is a simple ioctl call for set/reset hardwired carrier (except that didn't work on Pyramid). ...Rick ...{pyrnj,psuvax1}!vu-vlsi!perry /* * ct.c - sets tty nohang, noecho and ignore carrier, * then does call back and restores tty settings */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #define NORMAL 0 #define IGNORE (!NORMAL) main (argc,argv) int argc; char *argv[]; { int nohup = LNOHANG; struct sgttyb ttystuff; if( argc != 2 ) { fprintf(stderr,"Usage: %s phone-number\n",argv[0]); exit(1); } if( setcarr(IGNORE)) { /* ignore carrier */ fprintf(stderr,"%s: error setting hardwired carrier\n",argv[0]); execl( "/bin/login", "login", (char *) 0 ); } ioctl( 0, TIOCGETP, &ttystuff); ttystuff.x_flags = ttystuff.sg_flags &= (~ECHO); /* stty noecho */ ioctl( 0, TIOCSETP, &ttystuff); ioctl( 0, TIOCLBIS, &nohup); /* stty nohang */ setbuf(stdout,NULL); sleep(2); /* kill buffering */ printf("+++"); sleep(2); printf("ATH\r"); sleep(2); printf("ATDT %s\r",argv[1]); sleep(15); ttystuff.x_flags = ttystuff.sg_flags |= ECHO; /* stty echo */ ioctl( 0, TIOCSETP, &ttystuff); ioctl( 0, TIOCLBIC, &nohup); /* stty hang */ setcarr(NORMAL); /* normal carrier detect */ execl( "/bin/login", "login", (char *) 0 ); } setcarr(enable) int enable; { int ifd, iunit, action, carrbit; char buf[32]; struct stat sbuf; if (fstat(0, &sbuf) == -1) return (-1); action = (enable == NORMAL) ? ITPCLEARCARR : ITPSETCARR; iunit = minor(sbuf.st_rdev) >> 4; sprintf(buf, "/dev/itp%d", iunit); carrbit = 1 << (minor(sbuf.st_rdev) & 0xf); if ((ifd = open(buf, 2)) == -1) return(-1); if (ioctl(ifd, action, &carrbit) == -1) return(-1); close(ifd); return(0); }