home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / authconv.zip / authconv.cmd next >
OS/2 REXX Batch file  |  1999-10-05  |  5KB  |  155 lines

  1. /*                                                                                            */
  2. /* This program converts the trusers file (TCPIP 3.0) to tcpnbk.lst from TCP/IP 4.21 (AURORA) */
  3. /*  Needs rexx_md5.zip from Daniel Hellerstein, located on hobbes.nmsu.edu/pub/os2/dev/rexx   */
  4. /*                                                                                            */
  5. /*             Written in 1999 from Marc Schneider (macke@macke.org)                          */
  6. /*                                                                                            */
  7.  
  8. /* Global parameters begin           */
  9. /* Change this to your favorites ... */
  10. Parameter.comment        = ''
  11. Parameter.uid            = ''
  12. Parameter.gid            = ''
  13. Parameter.shell          = 'telnetd.cmd'
  14. Parameter.shell.parms    = ''
  15. Parameter.shell.break    = 0
  16. Parameter.homedir        = 'c:\'
  17. Parameter.active         = 1
  18. Parameter.log            = 'logall'
  19. Parameter.idletimeout    = 900
  20. Parameter.ftpd.active    = 1
  21. Parameter.telnetd.active = 0
  22. Parameter.rexecd.active  = 0
  23. Parameter.nfsd.active    = 0
  24. /*  Global parameters end            */
  25.  
  26.  
  27. /*    No user servicable parts inside - from here !   */
  28. /* Be sure to disconnect the powercord before editing */
  29.  
  30. if rxfuncquery('srx_sha')=1  then do
  31.   rc = RXFuncAdd('SRXLoadFuncs', 'SRXFUNC', 'SRXLoadFuncs')
  32.   if rc \= 1 then Signal DLL
  33.   rc = SRXLoadFuncs()
  34. end
  35.  
  36.  
  37. parse arg infile outfile
  38. if infile = '' | outfile = '' then Signal usage
  39.  
  40. if srx_sha('a') == '86F7E437 FAA5A7FC E15D1DDC B9EAEAEA 377667B8' then nop
  41. else Signal wrong
  42.  
  43. call get_infile
  44. say Line.0 'Users will be converted...'
  45. call put_outfile
  46. say Line.0 'Users are converted !'
  47.  
  48. exit 0
  49.  
  50.  
  51. get_infile: Procedure Expose infile Line. Userid.
  52.   a = 1
  53.   if stream(infile,'C', 'QUERY EXISTS') \= '' then do until Lines(infile) = 0
  54.      Line.a = STRIP(Linein(infile))
  55.      if Line.a = '' then iterate
  56.      parse value Line.a with hash':'Userid.a Userid.a.Password
  57.      if TRANSLATE(hash) \= 'USER' then iterate
  58.      else do 
  59.         parse value linein(infile) with Userid.a.read
  60.         parse value linein(infile) with Userid.a.write
  61.      end /* do */
  62.      a = a + 1
  63.   end /* do */
  64.   else Signal NO_IN
  65.   Line.0 = a - 1
  66. Return
  67.  
  68. put_outfile: procedure Expose Line. outfile Userid. Parameter.
  69.   do a = 1 to Line.0
  70.  
  71.      if POS('^',Userid.a.read)  > 0 then Readmaster = 0
  72.      else Readmaster = 1
  73.  
  74.      if WORD(userid.a.read,2) = '' then Noreaddir = 1
  75.      else Noreaddir = 0
  76.  
  77.      if POS('^',Userid.a.write) > 0 then Writemaster = 0
  78.      else Writemaster = 1
  79.  
  80.      if WORD(userid.a.write,2) = '' then Nowritedir = 1
  81.      else Nowritedir = 0
  82.  
  83.      rc = lineout(outfile,'SRVRUSR=(')
  84.      rc = lineout(outfile,'    USERID='Userid.a)
  85.      rc = lineout(outfile,'    password='SPACE(srx_sha(Userid.a.Password),0))
  86.      rc = lineout(outfile,'    comment='parameter.comment)
  87.      rc = lineout(outfile,'    uid='parameter.uid)
  88.      rc = lineout(outfile,'    gid='parameter.gid)
  89.      if parameter.shell.break then break_shell = '/C '
  90.      else break_shell = ' '
  91.      rc = lineout(outfile,'    shell='break_shell||parameter.shell||parameter.shell.parms)
  92.      if \Noreaddir then rc = lineout(outfile,'    homedir='WORD(Userid.a.read,2))
  93.                    else rc = lineout(outfile,'    homedir='parameter.homedir)
  94.      rc = lineout(outfile,'    FTPD=(')
  95.      rc = lineout(outfile,'         active='Parameter.ftpd.active)
  96.      if Noreaddir then rc = lineout(outfile,'         read=')
  97.                   else rc = lineout(outfile,'         read='WORD(userid.a.read,2))
  98.      rc = lineout(outfile,'         canread='Readmaster)
  99.      if Nowritedir then rc = lineout(outfile,'         write=')
  100.                    else rc = lineout(outfile,'         write='WORD(userid.a.write,2))
  101.      rc = lineout(outfile,'         canwrite='Writemaster)
  102.      rc = lineout(outfile,'         log='parameter.log)
  103.      rc = lineout(outfile,'         idletimeout='parameter.idletimeout)
  104.      rc = lineout(outfile,'    )')
  105.      rc = lineout(outfile,'    TELNETD=(')
  106.      rc = lineout(outfile,'         active='parameter.telnetd.active)
  107.      rc = lineout(outfile,'    )')
  108.      rc = lineout(outfile,'    rexecd=(')
  109.      rc = lineout(outfile,'         active='parameter.rexecd.active)
  110.      rc = lineout(outfile,'    )')
  111.      rc = lineout(outfile,'    nfsd=(')
  112.      rc = lineout(outfile,'         active='parameter.nfsd.active)
  113.      rc = lineout(outfile,'    )')
  114.      rc = lineout(outfile,')')
  115.      rc = lineout(outfile)
  116.   end /* do */
  117.  
  118. Return
  119.  
  120.  
  121. usage:
  122.   parse Source with . prg
  123.   say ''
  124.   say ' Usage:'
  125.   say ''
  126.   say ' 'FILESPEC('name',prg) 'input-file output-file'
  127.   say ' '
  128.   say ' Examples:'
  129.   say ' 'FILESPEC('name',prg) '\\SRV01\C$\MPTN\ETC\TRUSERS \\SRV02\C$\MPTN\ETC\TCPNBK.LST'
  130.   say ' 'FILESPEC('name',prg) 'C:\DOWNLOAD\TRUSERS C:\MPTN\ETC\TCPNBK.LST'
  131.   say ''
  132. exit -1
  133.  
  134. DLL:
  135.   say ''
  136.   say ' Missing SRXFUNC.DLL from Daniel Hellerstein, '
  137.   say ' located on hobbes.nmsu.edu/pub/os2/dev/rexx/rexx_md5.zip'
  138.   say " Maybe the DLL isn't in your LIBPATH."
  139.   say ''
  140. exit -1
  141.  
  142. Wrong:
  143.   say ''
  144.   say " Checksum isn't correct. Maybe you are using a different DLL ?"
  145.   say ''
  146.   say ' Should be: 86F7E437 FAA5A7FC E15D1DDC B9EAEAEA 377667B8'
  147.   say ' Returned :' srx_sha('a')
  148.   say ''
  149. exit -1
  150.  
  151. NO_IN:
  152.   say ''
  153.   say ' Input file does not exists ('infile').'
  154. Signal usage
  155.