home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / in4wjcxu / other / irc / ircd / crypt / crypter next >
Encoding:
Text File  |  1996-08-14  |  1.6 KB  |  53 lines

  1. #!/usr/local/bin/perl
  2. #************************************************************************
  3. #*   IRC - Internet Relay Chat, ircd/crypt/crypter
  4. #*   Copyright (C) 1991 Sean Batt
  5. #*
  6. #*   This program is free software; you can redistribute it and/or modify
  7. #*   it under the terms of the GNU General Public License as published by
  8. #*   the Free Software Foundation; either version 1, or (at your option)
  9. #*   any later version.
  10. #*
  11. #*   This program is distributed in the hope that it will be useful,
  12. #*   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #*   GNU General Public License for more details.
  15. #*
  16. #*   You should have received a copy of the GNU General Public License
  17. #*   along with this program; if not, write to the Free Software
  18. #*   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. #*/
  20.  
  21. #From Sean Batt sean@coombs.anu.edu.au
  22. #
  23. #Temporary output file
  24. #
  25. $tmpfile = "/tmp/ircd.conf.tmp";
  26.  
  27. #
  28. #Original ircd.conf file
  29. #
  30. $ircdconf = @ARGV[0];
  31.  
  32. print "crypting ",$ircdconf,"\n";
  33. @saltset = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '.', '/');
  34.  
  35. umask(0077);
  36. open ($ircdout, ">/tmp/ircd.conf.tmp") || die "open $!";
  37.  
  38. while ($text = <>) {
  39. #if its not an "O" line we can ignore it
  40.     $text =~ /^o/i || print ($ircdout $text) && next;
  41.     chop($text);
  42.     @oline = split(':', $text);
  43.     $salt = $saltset[rand(time)%64].$saltset[(rand(time)>>6)%64];
  44.     $oline[2] = crypt(@oline[2], $salt);
  45.     print ($ircdout join(':',@oline)."\n");
  46. }
  47. close ($ircdout);
  48. close ($ircdin);
  49. print "/bin/cp ",$tmpfile," ",$ircdconf,"\n";
  50. (fork()==0) ? exec("/bin/cp", $tmpfile, $ircdconf) : wait;
  51.  
  52. #unlink($tmpfile);
  53.