New server, FileBin instead of $ENV{BFConfDir}, and custom Captcha
[buildfarm-server.git] / scripts / show_passwords.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use DBI;
6 use Data::Dumper;
7
8 use vars qw($dbhost $dbname $dbuser $dbpass $dbport
9             $user_list_format
10 );
11
12 use FindBin qw($RealBin);
13 require "$RealBin/../BuildFarmWeb.pl";
14
15 die "no dbname" unless $dbname;
16 die "no dbuser" unless $dbuser;
17
18 my $dsn="dbi:Pg:dbname=$dbname";
19 $dsn .= ";host=$dbhost" if $dbhost;
20 $dsn .= ";port=$dbport" if $dbport;
21
22 my $db = DBI->connect($dsn,$dbuser,$dbpass);
23
24 die $DBI::errstr unless $db;
25
26 my $sth = $db->prepare(q[ 
27        SELECT name, secret
28        FROM buildsystems AS b
29        ORDER BY name ASC
30       ]);
31 $sth->execute();
32
33 $user_list_format = "%-20s %s\n";
34 printf $user_list_format, "SysName", "Secret";
35 while (my $row = $sth->fetchrow_hashref)
36 {
37   printf $user_list_format, $row->{name}, $row->{secret};
38 }
39 $db->disconnect();