From 24a38325c49e7a7887aaab39804cee01d9dc49f6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 16 Jul 2015 13:10:15 +0100 Subject: [PATCH] Abolish default_db_setup_stmts and set it up in new_verifier --- cgi-auth-flexible.pm | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/cgi-auth-flexible.pm b/cgi-auth-flexible.pm index dd917c7..fe70bf1 100644 --- a/cgi-auth-flexible.pm +++ b/cgi-auth-flexible.pm @@ -31,8 +31,6 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw(); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], - - @EXPORT_OK = qw(@default_db_setup_stmts); } our @EXPORT_OK; @@ -202,18 +200,6 @@ sub gen_plain_footer_html ($$) { ''); } -our @default_db_setup_stmts = - ("CREATE TABLE $v->{S}{db_prefix}_assocs (". - " assochash VARCHAR PRIMARY KEY,". - " username VARCHAR NOT NULL,". - " last INTEGER NOT NULL". - ")" - , - "CREATE INDEX $v->{S}{db_prefix}_assocs_timeout_index". - " ON $v->{S}{db_prefix}_assocs". - " (last)" - ); - #---------- licence and source code ---------- sub srcdump_dump ($$$) { @@ -439,7 +425,6 @@ sub new_verifier { db_user => '', db_password => '', db_prefix => 'caf', - db_setup_stmts => [@_default_db_setup_statements], random_source => '/dev/urandom', secretbits => 128, # bits hash_algorithm => "SHA-256", @@ -514,6 +499,17 @@ sub new_verifier { exists $verifier->{S}{$k}; $verifier->{S}{$k} = $v; } + $verifier->{S}{db_setup_stmts} //= + ["CREATE TABLE $v->{S}{db_prefix}_assocs (". + " assochash VARCHAR PRIMARY KEY,". + " username VARCHAR NOT NULL,". + " last INTEGER NOT NULL". + ")" + , + "CREATE INDEX $v->{S}{db_prefix}_assocs_timeout_index". + " ON $v->{S}{db_prefix}_assocs". + " (last)" + ]; bless $verifier, $class; $verifier->_dbopen(); $verifier->_ch('srcdump_prepare'); @@ -556,7 +552,7 @@ sub _dbopen ($) { } $v->{Dbh} = $dbh; - foreach my $stmt (@default_db_setup_stmts) { + foreach my $stmt (@{ $v->{S}{db_setup_stmts} }) { $v->_db_setup_do($stmt); } return $dbh; -- 2.30.2