home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / telnetd.zip / TELNETD.CMD < prev    next >
OS/2 REXX Batch file  |  1997-10-11  |  3KB  |  107 lines

  1. /* Security feature for IBM TCP/IP Telnet login.                */
  2. /* reads the last Username entry from the Telnetd-logfile       */
  3. /* and set the name to the Environment (Telnet_User).           */
  4. /*                                                              */
  5. /* Written 09.10.1997 by Marc Schneider <macke@avalon.teuto.de> */
  6.  
  7.  
  8. /* Trap detection */
  9.  
  10. SIGNAL OFF HALT
  11. SIGNAL ON ERROR NAME EXIT
  12. SIGNAL ON FAILURE NAME EXIT
  13. SIGNAL ON SYNTAX NAME EXIT
  14. SIGNAL ON NOTREADY NAME EXIT
  15.  
  16.  
  17. /* Load the functions we need */
  18.  
  19. CALL rxfuncadd 'sysloadfuncs', 'rexxutil', 'sysloadfuncs'
  20. CALL sysloadfuncs
  21.  
  22.  
  23. /* Set the definitions */
  24.  
  25. env = 'OS2ENVIRONMENT'
  26. Telnet_log = value('ATLPAC_LOG_FILE',,env)
  27. process_file = value('ETC',,env)'\PROCESS.CNF'
  28. hostname = value('hostname',,env)
  29. nothing = value('prompt', '[$l'hostname'$g-$p]', env)
  30.     if value('term',,env) = 'dumb' then do
  31.         'keys off'                              /* If the terminal 'dumb'        */
  32.     end /* if do */                             /* then disable the history keys */
  33.  
  34.  
  35. /* Read the logfile into an array */
  36.  
  37. do Counter = 1 until lines(Telnet_log) = 0
  38.     current_line.Counter = linein(Telnet_log)
  39. end /* do until */
  40. current_line.0 = Counter
  41.  
  42.  
  43. /* Look for the last username entry into ATLPAC_LOG_FILE */
  44.  
  45. Do Counter = current_line.0 by -1 to Counter = 0 until LEFT(current_line.Counter,8) = 'Username' 
  46. end /* Do Counter */
  47.  
  48.  
  49. /* Set Telnet_User=Username to the Environment */
  50.  
  51. parse value current_line.Counter with nul ': ' Username
  52. nul = value('Telnet_User', Username, env)
  53.  
  54.  
  55. /* Read the process information for the user from the process file */
  56.  
  57. do Counter = 1 until lines(process_file) = 0
  58.     process_line.Counter = linein(process_file)
  59.     process_line.Counter = SPACE(process_line.Counter,0)
  60.        if LEFT(process_line.Counter, LENGTH(Username)) = Username then do
  61.            parse value process_line.Counter with nul '=' process
  62.        end /* if do */
  63. end Counter /* do until */
  64. If process = 'PROCESS' then Signal NoName
  65.  
  66.  
  67. say ''
  68. say ''
  69. say ' Hello 'Username 'your process is 'process
  70. say ''
  71. say ' Press a key to continue'
  72. say ''
  73. nul = SysGetKey(NOECHO)
  74. '@call 'process
  75. say ''
  76. say ' Press a key to exit'
  77. say ''
  78. nul = SysGetKey(NOECHO)
  79. '@exit'
  80. exit 0
  81.  
  82. NoName:
  83. say ''
  84. say ''
  85. say 'No process found for UserID 'Username '...'
  86. EXIT:
  87. say ''
  88. say ''
  89. say 'I can not continue. There may be an error'
  90. say 'in 'process_file' or in TELNETD.CMD'
  91. say ''
  92. say 'Contact the system administrator of this host by telling him your login.'
  93. nul = SysGetKey(NOECHO)
  94. If nul = 'd' then do
  95.    say 'ENVIRONMENT    = 'env
  96.    say 'Telnet-Logfile = 'Telnet_log
  97.    say 'Process file   = 'process_file
  98.    say 'Hostname       = 'hostname
  99.    say 'Prompt         = 'nothing
  100.    say 'Terminal       = 'value('term',,env)
  101.    say 'Username       = 'Username
  102.    say 'Process        = 'process
  103. nul = SysGetKey(NOECHO)
  104. end /* do */
  105. '@exit'
  106.  
  107.