From: Alan Greig [a.greig@virgin.net] Sent: Tuesday, March 27, 2001 4:25 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: email failure port 113 - IDENTD_COM.TXT (0/1) On Mon, 26 Mar 2001 20:16:17 +0200, martin@radiogaga.harz.de (Martin Vorlaender) wrote: >From: agreig@river.tay.ac.uk (Alan Greig) Help, I'm in a time warp :) Here's a slightly tidied up version. Text version (which will probably wrap) and attachment as it's just a small file. $! SYS$MANAGER:IDENTD.COM $! A rapidly knocked together identd server for UCX( RFC 1413) $! No real sanity checking is done on the input and this $! isn't intended as an example of DCL good progamming style. $! Just a proof of concept... Tested under UCX 3.3 $! Through UCX 5.0 $! Inspired by Stellan Lagerström's identd.pas $! $! Alan Greig Dec 1995 - Mar 2001 $! $! a.greig@virgin.net $! $! This procedure must $! Be woken up by AUXS server on port 113 $! Read a net connection of the form $! server_socket , client_socket $! UCX SHO DEV/PORT=server_socket $! parse returnded device name (bgnnnn) $! f$getdvi("devnam","pid") $! f$getjpi(devpid,"username") $! write sys$net server_socket , " , ",client_socket, " : ", "USERID : VMS : ", - $! devuser $! close connection $! exit $! error: $! write sys$net server_socket , " , ",client_socket, " : ", "ERROR : NO-USER" $! $! $! The service is setup via the following commands. In a real production $! version the server could possibly have its own username set up $! along the lines of (say) UCX_LPD with appropriate privileges (WORLD) $! You probably don't want to log everything either. $! CREATE/DIR SYS$SYSROOT:[SYSMGR.IDENTD] $! UCX SET SERVICE IDENTD - $! /PORT=113/PROTO=TCP/PROCESS=UCX_IDENTD/USER=SYSTEM - $! /FILE=SYS$MANAGER:IDENTD.COM - $! /LOG=(file:SYS$MANAGER:IDENTD.LOG,all) $! UCX ENABLE SERVICE IDENTD $! UCX SET CONFIG ENABLE SERVICE IDENTD $! $ set noverify $ set proc/priv=all ! Only world actually needed. $ pid = f$getjpi("0","PID") $ open/read/write net sys$net $ open/write log sys$sysroot:[sysmgr.identd]identd_connections.log $ write log f$fao("!AS!%D", "Connection received at ",0) $ socket_pair = "" $ buff2 = "" $! append returned data from read until a control character other $! than tab seen. $rd: $ read/error=error net buffer $ i=0 $rd2: $ c = f$extract(i,1,buffer) $ if c .eqs. " " then c = " " !convert tab to space $ if c .lts. " " .or. c .gts. "z" then goto rd_done $ buff2 = buff2 + c $ i=i+1 $ if i .lt. f$length(buffer) then goto rd2 ! More data in this buffer $ goto rd ! buffer empty - get another $! $rd_done: $ socket_pair = buff2 $ server_socket = f$element(0,",",socket_pair) $ server_sockint = f$integer(server_socket) $ client_socket = f$element(1,",",socket_pair) $ client_sockint = f$integer(client_socket) $ write log socket_pair $ define/user sys$output sys$sysroot:[sysmgr.identd]identd_'pid'.tmp $ UCX SHO DEV/PORT='server_socket' $! Now need to parse the UCX SHOW DEV output. This better not change... $! $ on error then goto ucxend $ open/read ucxfile sys$sysroot:[sysmgr.identd]identd_'pid'.tmp $! Skip header lines $ read ucxfile ucxline $ucxlp: $ read/end=ucxend ucxfile ucxline $ ucxdevice = f$extract(2,10,ucxline) $ ucxclient_socket = f$extract(31,5,ucxline) $ ucxclient_sockint = f$integer(ucxclient_socket) $ ucxrem_host = f$extract(55,f$length(ucxline)-54,ucxline) $ if ucxclient_sockint .ne. client_sockint then goto ucxlp $! Found a match $ on warning then goto error $ ucxdevice = f$element(0," ",ucxdevice) $ userpid = f$getdvi(ucxdevice,"PID") $ username = f$getjpi(userpid,"USERNAME") $ write log ucxrem_host $ write log socket_pair, " : USERID : VMS : ", username $ write net socket_pair, " : USERID : VMS : ", username, f$fao("!/") $ goto finish $! $! exit $! $error: $ucxend: $ on error then goto finish $ write log socket_pair, " : ERROR : NO-USER" $ write net socket_pair, " : ERROR : NO-USER" ,f$fao("!/") $finish: $ set noon $ close net $ close ucxfile $ close log $ delete/nolog sys$sysroot:[sysmgr.identd]identd_'pid'.tmp.* $ wait 00:00:01 !perhaps not needed. $ exit >-- >Alan Greig Tel: (01382) 308802 >University of Abertay Dundee Email: A.Greig@tay.ac.uk > ** Never underestimate the power of human stupidity ** Before the dark days. Before the evil librarians took control of University IT policy and fell for Microsoft (with DEC's help) hook line and sinker. Just last week I read in the local press that the University email system was down for several days due to serious virus infestation. Microsoft Exchange now of course. It was PMDF on VMS back in 1996 and nothing like that ever happened. -- Alan