#! /usr/bin/perl

#
#  Commandline Password entry system for WSNET.NET
#


use Mysql;

if ($ARGV[1] eq '') {
    print "\nWWWUser v1.0\n";
    print "Copyright 1998 G. E. Terry\n\n";
    print "Usage: wwwuser username password\n\n";
    exit(1);
}

# variables
$username = $ARGV[0];
$passwd = $ARGV[1];

&CryptPass;

my $dbh = Mysql->Connect(localhost);
die "connect failed" unless $dbh;

my $rv = $dbh->SelectDB (wwwauth);
die "SelectDB failed" unless $rv;

my $sh =  $dbh->query ("insert into mysql_auth (username, passwd, groups, datestamp) values ('$username', '$password', 'admin', '20001131235959')");
die "query failed: ", $dbh->errmsg unless $sh;
undef $sh;


sub CryptPass {
            $password = crypt($passwd, Mx);
            }
exit;