##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
##
use DBI;
-? Print this help message.
-1 One-shot mode: push the file to database and exit.
-b database Name of the database to use.
- -d sql_driver Driver to use: mysql, pg.
+ -d sql_driver Driver to use: mysql, pg, oracle.
+ -f file Read password from file, instead of command line.
-h host Connect to host.
-P port Port number to use for connection.
-p passord Password to use when connecting to server.
p => 'radius',
u => 'radius',
);
-my $ret = getopts("b:d:fh:P:p:u:x1?", \%args);
+my $ret = getopts("b:d:f:h:P:p:u:x1?", \%args);
if (!$ret or @ARGV != 1) {
usage();
exit 1;
$data_source = "DBI:mysql:database=$args{b};host=$args{h}";
} elsif (lc($args{d}) eq 'pg') {
$data_source = "DBI:Pg:dbname=$args{b};host=$args{h}";
+} elsif (lc($args{d}) eq 'oracle') {
+ $data_source = "DBI:Oracle:$args{b}";
} else {
print STDERR "error: SQL driver not supported yet: $args{d}\n";
exit 1;
}
$data_source .= ";port=$args{P}" if $args{'P'};
+my $pw;
+if($args{f}) {
+ open(FILE, "< $args{f}") or die "error: Couldn't open $args{f}: $!\n";
+ $pw = <FILE>;
+ chomp($pw);
+ close(FILE);
+} else {
+ # args{p} is always defined.
+ $pw = $args{p};
+}
+
$SIG{INT} = \&got_signal;
$SIG{TERM} = \&got_signal;
my %dbinfo = (
base => $data_source,
user => $args{u},
- pass => $args{p},
+ pass => $pw,
);
connect_wait(\%dbinfo);