#!/usr/bin/perl5.8.4
#
# CVS Info: $Id: add_user,v 1.1.1.1 2000/03/31 19:18:41 apendlet Exp $
# Filename: add_user
#   Author: Adam H. Pendleton
#

# This program works on the SARA password file and adds users
# to the file.

require 'config/sara.cf';

# Generate our random salt
# This is for grins, but it looks cool
# Random salts prevent blind password guessing
$salt = '';
foreach(0, 1) {
    $salt .= chr(ord('A') + rand(32));
}

# First let's get a username from the user
print "Please enter a username: ";
chomp( $username = <> );

print  "Please enter a password: ";
chomp( $password = <> );

open(PWDFILE, ">>$password_file") or die "Can't open $password_file: $!";

$enc_pwd = crypt($password, $salt);

print "Writing password to file $password_file\n";
print PWDFILE "$username\:$enc_pwd\n";

print "Done.\n";
