[comp.os.vms] DECServer port numbers

GILBY@ECC.tased.oz (John Gilbert) (11/24/87)

System managers frequently complain (at least some do) that they are not able
to find what DECServer port is being used when someone logs in. This is 
important if you wish, as we do, to add security checks based on terminal
port.

Since version 4.6 of VMS (and maybe before) it has been possible to do this.
The 4.6 release notes document two modifiers to the the IO$_TTY_PORT function
for $QIO, but they do not document a 3rd modifier IO$M_LT_READPORT. I 
discovered this in STARLET.REQ. Even if you do not have BLISS on your system 
it is well worth looking at this.

The program below (a very cut down but complete BLISS program) finds the 
DECServer port and node name and prints it on the terminal. The critical bit 
of code is marked with !***** and can be converted to any language and used 
in your security software.

Note that the DECServer port and node name are returned in the QIO buffer as
two concatenated counted strings.

John Gilbert

Elizabeth Computer Centre, 
Corner Warwick and Murray Streets,
Tasmania 7000, Australia.

gilby@ecc.tased.oz.au


MODULE lt_port (MAIN = lt_port,
                ADDRESSING_MODE (EXTERNAL = GENERAL),
                ADDRESSING_MODE (NONEXTERNAL = WORD_RELATIVE)) =
BEGIN
FORWARD ROUTINE lt_port, fao_call;
LIBRARY 'SYS$LIBRARY:STARLET';
MACRO out_fao (ctrstr) [] =                     ! Easy FAO and output call
    lib$put_output( fao_call( %ASCID %STRING(ctrstr)
        %IF %LENGTH GTR 1 %THEN , %REMAINING %FI )) %;
EXTERNAL ROUTINE  lib$put_output;
ROUTINE lt_port =
    BEGIN
    LOCAL
        status, lt_chan, buffer : VECTOR [128, BYTE];
    $assign (chan = lt_chan, devnam = %ASCID'sys$command');
    status = $qiow (                                                    !*****
        chan = .lt_chan,                                                !*****
        func = io$_tty_port OR io$m_lt_readport,                        !*****
        p1 = buffer,                                                    !*****
        p2 = 128);                                                      !*****
    IF .status EQL ss$_illiofunc
        THEN (out_fao ('Not a LAT device'); RETURN 1);
    IF NOT .status THEN RETURN .status;
    out_fao ('Node: !AC, Port: !AC', buffer [.buffer [0] + 1], buffer [0]);
    RETURN 1;
    END;
ROUTINE fao_call (ctrstr, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) =
    BEGIN
    OWN outstr : VECTOR [256,BYTE],
        outstr_dsc : VECTOR [2] INITIAL (256, outstr);
    outstr_dsc [0] = 256;
    $fao (.ctrstr,outstr_dsc, outstr_dsc,
        .p1, .p2, .p3, .p4, .p5, .p6, .p7, .p8, .p9, .p10);
    RETURN outstr_dsc;
    END;
END                                                                     !End of module
ELUDOM