#!/usr/bin/perl
# This Program was written by Lennart Hansen
 
$user_file = "/usr/local/squid/etc/users/user";
$passwd_file = "/usr/local/squid/etc/passwd";
$squid = "/usr/local/squid/bin/squid";
 
# Modify the above lines to fit your own configuration.
#
# I hope you enjoy this program, please do NOT modify and code below, unless
# you got my premission, please send feedback to lennart@edb.ihnykf.dk          


die "usage: $0 [user name] [password]" if $#ARGV != 1;

$user = $ARGV[0];
$password = $ARGV[1];

@saltair= split
  //,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789./";

sub get_salt {
  srand();
  $iOff = int(rand($#saltair));
  $iOff2 = int(rand($#saltair));
  return join("",$saltair[$iOff],$saltair[$iOff2]);
}

$cpassword = crypt($password,get_salt());

system("echo \"$user\" >> $user_file");
system("echo \"$user:$cpassword\" >> $passwd_file");

system("$squid -k reconfigure");

