summaryrefslogtreecommitdiff
path: root/utils/rd-user
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rd-user')
-rwxr-xr-xutils/rd-user32
1 files changed, 16 insertions, 16 deletions
diff --git a/utils/rd-user b/utils/rd-user
index 2a032dd..8689cb4 100755
--- a/utils/rd-user
+++ b/utils/rd-user
@@ -39,9 +39,9 @@ sub print_usage
sub list
{
- my ($dbh) = @_;
+ my ($ctx) = @_;
- my @users = RHRD::rddb::list_users($dbh);
+ my @users = RHRD::rddb::list_users($ctx);
if(!defined $users[0] && defined $users[1]) {
print STDERR "$users[1]: $users[2]";
return 1;
@@ -54,19 +54,19 @@ sub list
sub check
{
- my ($dbh, $username) = @_;
+ my ($ctx, $username) = @_;
- my ($result, $status, $errorstring) = RHRD::rddb::check_user($dbh, $username);
+ my ($result, $status, $errorstring) = RHRD::rddb::check_user($ctx, $username);
print STDERR "$result, $status: $errorstring\n";
return $result;
}
sub add
{
- my ($dbh, $username, $fullname) = @_;
+ my ($ctx, $username, $fullname) = @_;
my $token = mkpasswd(-length => 16, -minnum => 3, -minupper => 3, -minspecial => 0);
- my ($cnt, undef, $errorstring) = RHRD::rddb::add_user($dbh, $username, $token, $fullname);
+ my ($cnt, undef, $errorstring) = RHRD::rddb::add_user($ctx, $username, $token, $fullname);
unless(defined $cnt) {
print STDERR "$errorstring\n";
return 1;
@@ -77,9 +77,9 @@ sub add
sub remove
{
- my ($dbh, $username) = @_;
+ my ($ctx, $username) = @_;
- my @results = RHRD::rddb::remove_user($dbh, $username);
+ my @results = RHRD::rddb::remove_user($ctx, $username);
if(!defined $results[0] && defined $results[2]) {
print STDERR "$results[2]\n";
return 1;
@@ -100,14 +100,14 @@ my $cmd = $ARGV[0];
my $username = $ARGV[1];
my $ret = 0;
-my ($dbh, undef, $errorstring) = RHRD::rddb::opendb();
-if(defined $dbh) {
+my ($ctx, undef, $errorstring) = RHRD::rddb::init();
+if(defined $ctx) {
if($cmd eq "list") {
if($num_args != 1) {
print_usage();
$ret = 1;
} else {
- $ret = list($dbh);
+ $ret = list($ctx);
}
}
elsif($cmd eq "check") {
@@ -115,28 +115,28 @@ if(defined $dbh) {
print_usage();
$ret = 1;
} else {
- $ret = check($dbh, $username);
+ $ret = check($ctx, $username);
}
} elsif($cmd eq "add") {
if($num_args < 2 || $num_args > 3) {
print_usage();
$ret = 1;
} else {
- $ret = add($dbh, $username, $ARGV[2]);
+ $ret = add($ctx, $username, $ARGV[2]);
}
} elsif($cmd eq "remove") {
if($num_args != 2) {
print_usage();
$ret = 1;
} else {
- $ret = remove($dbh, $username);
+ $ret = remove($ctx, $username);
}
} else {
- print STDERR "unknown command\n";
+ print_usage();
$ret = 1;
}
- RHRD::rddb::closedb($dbh);
+ RHRD::rddb::destroy($ctx);
} else {
print STDERR "$errorstring\n";
$ret = 1;