diff -urN orig/conf/acct dest/conf/acct --- orig/conf/acct 1970-01-01 01:00:00.000000000 +0100 +++ dest/conf/acct 2006-05-16 10:04:51.000000000 +0200 @@ -0,0 +1 @@ +user,date,b_in,b_out diff -urN orig/conf/domain dest/conf/domain --- orig/conf/domain 1970-01-01 01:00:00.000000000 +0100 +++ dest/conf/domain 2006-05-16 10:04:51.000000000 +0200 @@ -0,0 +1,2 @@ +domain,user +mydomain.com,odmr diff -urN orig/conf/user dest/conf/user --- orig/conf/user 1970-01-01 01:00:00.000000000 +0100 +++ dest/conf/user 2006-05-16 10:04:51.000000000 +0200 @@ -0,0 +1,2 @@ +user,pass +odmr,password diff -urN orig/odmrd dest/odmrd --- orig/odmrd 2006-05-16 10:04:51.000000000 +0200 +++ dest/odmrd 2006-05-16 17:58:30.000000000 +0200 @@ -29,6 +29,7 @@ # -c /path/to/conf.file specifies the location of the configuration file # -d debug mode - turns on verbose logging # -v print version and exit +# -b dbd_driver DB driver to use # ########################################################################## # @@ -42,7 +43,7 @@ use Getopt::Std; my %opts; -getopts('c:dv', \%opts); +getopts('b:c:dv', \%opts); if ($opts{'v'}) { print "$progname\n"; exit 0; @@ -105,6 +106,7 @@ $config{debug} = 1 if $opts{'d'}; $config{conf_file} = $opts{'c'} if $opts{'c'}; +$config{dbd_driver} = $opts{'b'} if $opts{'b'}; syslog(LOG_DEBUG, "$progname startup"); @@ -238,14 +240,22 @@ if ($user) { myprint("503 already authenticated"); } else { # open database connection - if (! $dbh) { - use DBD::mysql; - $dbh = DBI->connect( - "DBI:mysql:database=$config{mysql_db};$config{mysql}", - $config{mysql_user}, $config{mysql_pass}, - { PrintError => 1, RaiseError => 0, AutoCommit => 1 }); - - myprint("454 Temporary authentication failure") unless $dbh; + if (! $dbh) { + if ( $config{dbd_driver} eq 'csv' ) { + require DBD::CSV; + $dbh = DBI->connect( "dbi:CSV:f_dir=$config{data_file}"); + syslog (LOG_INFO , "Using CSV DBI Driver"); + } + elsif ( $config{dbd_driver} eq 'mysql' ) { + require DBD::mysql; + $dbh = DBI->connect( "DBI:mysql:database=$config{mysql_db};host=$config{mysql_host}", $config{mysql_user}, $config{mysql_pass}, + { PrintError => 1, RaiseError => 0, AutoCommit => 1 }); + syslog (LOG_INFO , "Using Mysql DBI Driver"); + } + else { + syslog (LOG_INFO , "DBI Driver unavalaible."); + } + myprint("454 Temporary authentication failure.") unless $dbh; } if ($dbh) { $user = auth($_, $dbh); } @@ -1513,6 +1523,8 @@ $config{lockext} = "..LCK"; $config{max_lock_age} = 6; # max. lockfile age in hours +$config{dbd_driver} = "mysql"; + # mysql db connection $config{mysql_host} = ""; # defaults to the local socket $config{mysql_port} = ""; @@ -1537,6 +1549,8 @@ # path to sendmail $config{sendmail} = "/usr/sbin/sendmail"; +$config{data_file} = "/etc/odmrd/"; + # sql statement to select user's password. # bind_value format with ? as user $config{sql_pass} = "SELECT pass FROM user WHERE user=?"; @@ -1572,10 +1586,10 @@ my @confkeys = qw{ spool hostname timeout_cmd timeout_msg max_invalid_cmds max_msg_age - debug user group sendmail conf_file lockext mysql_host mysql_port + debug user group sendmail conf_file data_file lockext mysql_host mysql_port mysql_socket mysql_user mysql_pass mysql_db mysql sql_pass sql_domainlist sql_checkdomain sql_acct_table - allow_login acct_mysql use_sendfile standalone daemon + allow_login acct_mysql use_sendfile standalone daemon dbd_driver server_ip server_port timeout_dns max_lock_age max_invalid_auth pidfile}; my @confkeys_binary = qw{ allow_login acct_mysql use_sendfile standalone daemon}; diff -urN orig/odmrd.conf dest/odmrd.conf --- orig/odmrd.conf 2006-05-16 10:04:51.000000000 +0200 +++ dest/odmrd.conf 2006-05-16 17:58:46.000000000 +0200 @@ -9,6 +9,9 @@ # shows more information in syslog (0-2) #debug 0 +########## DBD Driver ################ +# Driver to use to read conf +dbd_driver csv ##### database settings ############## # @@ -113,21 +116,23 @@ # SQL queries - if you have a non-standard db structure +data_file /etc/odmrd # sql query to get user's password. # bind_value format with ? as user -#sql_pass SELECT pass FROM user WHERE user=? +sql_pass SELECT pass FROM user WHERE user=? # sql query to get list of domains for user # bind_value format with ? as user -#sql_domainlist SELECT domain FROM domain WHERE user=? +sql_domainlist SELECT domain FROM domain WHERE user=? # sql query to check if a domain is OK for user. # bind_value format with ?, ? for user, domain (observe order!) -#sql_checkdomain SELECT count(*) FROM domain WHERE user=? AND domain=? LIMIT 1 +# limit 1 don't work with csv +sql_checkdomain SELECT count(*) FROM domain WHERE user=? AND domain=? # the table for accounting records (only if acct_mysql is 1) -#sql_acct_table acct +sql_acct_table acct ##########################