/usr/bin/sreview-user is in sreview-common 0.3.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/perl -w
use SReview::Config::Common;
use DBI;
use Getopt::Long;
my $config = SReview::Config::Common::setup;
my $dbh = DBI->connect($config->get('dbistring'));
my $action = "";
my $admin = 0;
my $user = "";
my $volunteer = 0;
GetOptions(
"user|u=s" => \$user,
"admin|d" => \$admin,
"action|a=s" => \$action,
);
=head1 NAME
sreview-user - SReview user management
=head1 SYNOPSIS
sreview-user [--user|-u username] [--admin|-d] [--action|-a ACTION]
=head1 DESCRIPTION
sreview-user is a simple script to manage SReview users. It allows you
to create, destroy, and set passwords for users. Optionally, it also
allows to mark newly-created users as administrators.
More detailed user management should be done through the SReview
webinterface, however.
=cut
if($action eq "create") {
open PASSWORD, "pwgen -s 10 -n 1|";
my $password=<PASSWORD>;
close(PASSWORD);
chomp $password;
$dbh->prepare("INSERT INTO users(email,password,isadmin) VALUES(?,crypt(?, gen_salt('bf', 8)),?)")->execute($user,$password,$admin ? "true" : "false") or die $!;
print "New password is $password\n";
} elsif ($action eq "delete") {
$dbh->prepare("DELETE FROM users WHERE email = ?")->execute($user) or die $!;
} elsif ($action eq "pwreset") {
open PASSWORD, "pwgen -s 10 -n 1|";
my $password=<PASSWORD>;
close(PASSWORD);
chomp $password;
$dbh->prepare("UPDATE users SET password=crypt(?,gen_salt('bf',8)) WHERE email=?")->execute($password, $user) or die $!;
print "New password is $password\n";
} else {
die "unknown action";
}
|