* Return-Path: <owner-info-multinet@tgv.com>; Received: from TGV.COM by Not-Craw--Craw.TGV.COM with SMTP; /           Wed, 25 Jan 1995 18:02:16 -0700 (MST) J Received: from foghorn.tgv.com ([161.44.192.53]) by TGV.COM via INTERNET ;%           Wed, 25 Jan 95 17:02:11 PST < X-ListName: MultiNet discussion list <Info-MultiNet@tgv.com> Warnings-To: <> & Errors-To: owner-info-multinet@tgv.com# Sender: owner-info-multinet@tgv.com O Received: from TGV.COM by Cone-Of-Silence.TGV.Com (MX V4.1 VAX) with SMTP; Mon, "           23 Jan 1995 23:51:35 PSTM Received: from MVB.SAIC.COM ([204.115.176.10]) by TGV.COM via INTERNET ; Mon,             23 Jan 95 23:51:31 PST, From: zagar@names.maricopa.edu (Chris Zagar)0 Reply-To: zagar@names.maricopa.edu (Chris Zagar)- X-Newsgroups: vmsnet.networks.tcp-ip.multinet P Subject: Re: A program that will autologin to a specific account over a TCP port  Date: 23 Jan 1995 21:29:13 -0700) Organization: Maricopa Community Colleges 
 Lines: 372+ Message-ID: <3g1vmp$4ch@names.maricopa.edu> % NNTP-Posting-Host: names.maricopa.edu  To: INFO-MULTINET@TGV.COM  X-Gateway-Source-Info: USENET   6 In article <950120143428.266021ae@wcsub.ctstateu.edu>,W Rich Parmalee, Information Systems - Tech. Support <PARMALEE@WCSUB.CTSTATEU.EDU> wrote: P >There was a discussion a few months back (Sept. 16, 1994 or so) on how to setupF >a service over a TCP port that would autologin to a specific account. > O >What I am looking for is anyone who has successfully implemented this service. O >I have sent a message to Adelman@tgv.com about his example program and what my O >problem was when I tried to use it. But have now decided to see if anyone that 7 >was looking for a way to do this, has been successful.   A The following are my modifications to the sample autologin telnet D client I received from TGV.  The additions include everything neededG to compile, the assignment of the usernames based on service names, and 6 a check to see if interactive logins permit the login.  ? IT IS IMPORTANT TO NOTE THAT THIS CODE COMPLETELY OVERRIDES VMS C AUTHORIZATION FOR LOGIN.  I know it overrides passwords, and it may C very well permit login to expired accounts, disabled accounts, etc. 4 If you choose to use it, you do so at your own risk!  E In the following, "username" should be replaced with the username you H want used for auto-login and "###" should be replaced by the port number you want to use.   1.  Compile the program using:       $ CC AUTOTELNET      $ MACRO USERNAME1     $ LINK AUTOTELNET,USERNAME,SYS$INPUT:/OPTIONS      SYS$SHARE:VAXCRTL/SHARE      SYS$SYSTEM:SYS.STB/SEL*     MULTINET:MULTINET_SOCKET_LIBRARY/SHARE%     $ COPY AUTOTELNET.EXE SYS$SYSTEM:   5 2.  Add a service definition with commands like this:         $ MULTINET CONFIGURE /SERVER     SERVER-CONFIG> ADD username      Protocol: [TCP] TCP      TCP Port number: ###-     Program to run: SYS$SYSTEM:AUTOTELNET.EXE      SERVER-CONFIG> SAVE      SERVER-CONFIG> EXIT   @ 3.  Edit the MULTINET:HOSTS.LOCAL file and add a line like this:  $     SERVICE : TCP : ### : username :  6 4.  Issue these commands to complete the installation:  !     $ MULTINET HOST_TABLE COMPILE !     $ @MULTINET:INSTALL_DATABASES      $ @MULTINET:START_SERVER  D After START_SERVER is run, it may take a minute before your MultinetC services are all running.  Once this is done, though, you should be  able to issue the command:        $ TELNET LOCALHOST /PORT=###  ' to check that all is working correctly.   . Repeat steps 2 - 4 to add additional services.   ----- USERNAME.MAR -----    		.LIBRARY "SYS$LIBRARY:LIB.MLB"  , 		$PHDDEF				; Define process header offsets, 		$PLVDEF				; Define PLV offsets and values( 		$SSDEF				; Define system status codesO                 $pcbdef                         ; Process Control Block offsets O                 $jibdef                         ; Job Information Block offsets 	 		$prvdef 	 		$rmsdef 	 		$strdef 	 		$jpidef 	 		$psldef   " 		.entry		set_username,^m<r10,r11>  ?                 movl		g^ctl$gl_pcb, r11         ; get PCB addr  4 		movl		pcb$l_jib(r11), r10       ; pick up JIB addr) 		movc3		#12, @4(AP), jib$t_username(r10) & 		movc3		#12, @4(AP), g^ctl$t_username   		movl		#SS$_NORMAL,r0 		ret    		.END   ----- AUTOTELNET.C -----   /*3  *	Copyright (C) 1984, 1985, 1986	SRI International 9  *	Copyright (C) 1988, 1989, 1990, 1992 TGV, Incorporated   */    #include <varargs.h> #include <stdlib.h>  #include <stdio.h>  ( globalref unsigned short SYS$GW_IJOBCNT;( globalref unsigned short SYS$GW_IJOBLIM;  6 #include "multinet_root:[multinet.include.sys]types.h"7 #include "multinet_root:[multinet.include.sys]socket.h" 7 #include "multinet_root:[multinet.include.netinet]in.h" 2 #include "multinet_root:[multinet.include]netdb.h" #include <prcdef.h> : #include "multinet_root:[multinet.include.vms]inetiodef.h" #include <descrip.h> #include <jpidef.h>   ! #define NETPTY_PROTOCOL       (1) ! #define NETPTY_INITIAL_STRING (2) ! #define NETPTY_ACCPORNAM      (3) ! #define NETPTY_CREATE_VTA     (5) & #define NETPTY_UNIT_NTY       (0x8000)& #define NETPTY_UNIT_VTA       (0x8001)   /*,  *	This is a "user-written" TELNET server...  */      sayopr(format, va_alist)
 char *format;  va_dcl { 
   va_list ap; &   char buff[200] = "\3\1\0\0\0\0\0\0";   struct   {      long int length;     long int bufadr;
   } buffdesc;      va_start(ap); !   vsprintf(buff + 8, format, ap); 
   va_end(ap); )   buffdesc.length = 8 + strlen(buff + 8);    buffdesc.bufadr = &buff;   SYS$SNDOPR(&buffdesc, 0);  }    void set_username();  C void set_jib_username(char *new, int newlen, char *old, int oldlen)  {    int i;   long args[2]; 
   int len;   char altname[12]; 
   struct item    { 
     short bl; 
     short ic;      void  *ba;     void  *ra;A   } il[] = { { oldlen, JPI$_USERNAME, old, 0 }, { 0, 0, 0, 0 } };    long stat;     memset(old, 0, oldlen); ,   stat = sys$getjpiw(0, 0, 0, &il, 0, 0, 0);   memset(altname, ' ', 12); $   len = (newlen > 12 ? 12 : newlen);   memmove(altname, new, len);    args[0] = 1;   args[1] = &altname; "   sys$cmkrnl(set_username, &args); }    main() {  	unsigned short int Channel; 	register int Status;  	unsigned short int IOSB[4]; 	char Name[256];+ 	struct sockaddr_in Peer_Socket, My_Socket;  	int i, NTY_Unit, VTA_Unit;  	char NTY_Name[32]; 2 	char Validation_Username[64], Saved_Username[64],( 	     Saved_PSB_Username[64], Dummy[64]; 	int Validation_OK=0;  	struct hostent *hp;1 	static int Protocol=1;	    /* TELNET protocol */ 	 	struct {  	    unsigned short Length;  	    unsigned short Code;  	    char *Ptr;  	    unsigned short *RetLen; 	} ItmLst[8], *Itm=ItmLst; 	short myport;' 	$DESCRIPTOR(sys$output, "SYS$OUTPUT"); . 	$DESCRIPTOR(loginout, "SYS$SYSTEM:LOGINOUT");" 	struct dsc$descriptor_s nty_desc; 	struct servent *s; 
 	char *upper;     	Itm->Length = sizeof(Protocol); 	Itm->Code   = NETPTY_PROTOCOL;  	Itm->Ptr    = &Protocol;  	Itm->RetLen = 0;  	Itm++;     	Itm->Length = sizeof(VTA_Unit); 	Itm->Code   = NETPTY_UNIT_VTA;  	Itm->Ptr    = &VTA_Unit;  	Itm->RetLen = 0;  	Itm++;     	Itm->Length = sizeof(NTY_Unit); 	Itm->Code   = NETPTY_UNIT_NTY;  	Itm->Ptr    = &NTY_Unit;  	Itm->RetLen = 0;  	Itm++;    	/*  	 *	Get a channel to the socket  	 */  / 	Status = SYS$ASSIGN(&sys$output,&Channel,0,0); # 	if (!(Status&1)) SYS$EXIT(Status);    	/* " 	 *	Get the remote peer's sockaddr 	 */ 	i = sizeof(Peer_Socket); 3 	if (getpeername(Channel, &Peer_Socket, &i) >= 0) {  	    /* ? 	     *	    Find the 'name' of the remote port and pass this to A 	     *	    the kernel. This will be used by the VMS V5 kernel to 1 	     *	    fill in the terminal ACCPORNAM field. 4 	     *	    Note this is passed as a counted string. 	     */H 	    if (hp=gethostbyaddr(&Peer_Socket.sin_addr, sizeof(struct in_addr), 				 AF_INET)) { 		strcpy(Name, hp->h_name); 
 	    } else { > 		sprintf(Name,"[%s]",inet_ntoa(Peer_Socket.sin_addr.s_addr)); 	    }  	    Itm->Length = strlen(Name);" 	    Itm->Code	= NETPTY_ACCPORNAM; 	    Itm->Ptr	= Name;  	    Itm->RetLen = 0;  	    Itm++;  	}     	/* ' 	 *	Here we do the special validation..  	 */  / 	if (getsockname(Channel, &My_Socket, &i) >= 0)  	{% 		myport = ntohs(My_Socket.sin_port); # 		s = getservbyport(myport, "tcp");  		if (s != NULL) 		{ * 			strcpy(Validation_Username, s->s_name);5 			for (upper = Validation_Username; *upper; upper++) + 				if ((*upper >= 'a') && (*upper <= 'z'))  					*upper -= 32; 			Validation_OK = 1;  		}  	}   	if (Validation_OK) { * 	    if (SYS$GW_IJOBCNT >= SYS$GW_IJOBLIM) 	    {R 	        char *msg = "Interactive logins are disabled; please try back later\r\n";* 		socket_write(Channel, msg, strlen(msg));
 		exit(1); 	    }4 	    socket_write(Channel, "One moment...\r\n", 15); 	    Itm->Length = 0; # 	    Itm->Code	= NETPTY_CREATE_VTA;  	    Itm->Ptr	= 0; 	    Itm->RetLen = 0;  	    Itm++; 	 	} else {  	    Itm->Length = 1; ' 	    Itm->Code	= NETPTY_INITIAL_STRING;  	    Itm->Ptr	= "\r",  	    Itm->RetLen = 0;  	    Itm++;  	} 	Itm->Length = Itm->Code = 0;  	/*  	 *	Connect the NET PTY  	 */ 	Status = SYS$QIOW(0, 
 			  Channel,  			  IO$_NETWORK_PTY, 
 			  IOSB, 			  0,  			  0,  			  0,  			  0,  			  0,  			  0,  			  0, 
 			  ItmLst);  	if (!(Status & 1) ||  	    !(IOSB[0] & 1)) {2 		socket_write(Channel, "Sorry, No PTYS\r\n", 16);
 		exit(1); 	}   	/* 7 	 *	If we are supposed to autologin a user, then create 9 	 *	the process now. If not, then JOB_CONTROL has already  	 *	done it for us.  	 */     	if (Validation_OK) {  	    /* A 	     *	    Figure out the name of the terminal to $CREPRC it on.  	     */ 	    if (VTA_Unit) {) 		sprintf(NTY_Name, "_VTA%d:", VTA_Unit); 
 	    } else { ) 		sprintf(NTY_Name, "_NTY%d:", NTY_Unit);  	    } 	    /* - 	     *	    Activate LOGINOUT to start up DCL . 	     *	    (need to check Activation status!) 	     */* 	    set_jib_username(Validation_Username,$ 			     strlen(Validation_Username), 			     Saved_Username,  			     sizeof(Saved_Username),  			     Validation_Username,$ 			     sizeof(Validation_Username), 			     Saved_PSB_Username, $ 			     sizeof(Saved_PSB_Username));. 	    nty_desc.dsc$w_length = strlen(NTY_Name);* 	    nty_desc.dsc$b_dtype = DSC$K_DTYPE_T;* 	    nty_desc.dsc$b_class = DSC$K_CLASS_S;( 	    nty_desc.dsc$a_pointer = &NTY_Name; 	    Status = SYS$CREPRC(0,  				&loginout, 				&nty_desc, 				&nty_desc, 				&nty_desc, 				0, 				0, 				&nty_desc, 				4,			    /* Priority     */ ' 				0x00010004,		    /* UIC = [1,4]  */  				0,			    /* Term MBX     */ " 				PRC$M_INTER|PRC$M_NOPASSWORD); 	    /* $ 	     *	    Restore the old username 	     */% 	    set_jib_username(Saved_Username,  			     sizeof(Saved_Username),  			     Dummy, 			     sizeof(Dummy), 			     Saved_PSB_Username, $ 			     sizeof(Saved_PSB_Username));' 	    if (!(Status&1)) SYS$EXIT(Status);  	} 	/*  	 *	Dump the NETWORK Channel 	 */ 	socket_close(Channel); 	 	exit(1);  }    ----- END -----   K --------------------------------------------------------------------------- K   /\   /\    Chris Zagar                        Maricopa Community Colleges K  /  \ /  \   Director, Instructional Technology       2411 West 14th Street K / /\// /\ \  Bitnet: ZAGAR@MARICOPA                        Tempe, AZ  85281 K \/   \/  \/  Internet: zagar@names.maricopa.edu              (602) 731-8838 