diff --git a/codepot/docker/build-rocky84.sh b/codepot/docker/build-rocky84.sh index 0fe217c1..1bff4527 100755 --- a/codepot/docker/build-rocky84.sh +++ b/codepot/docker/build-rocky84.sh @@ -8,7 +8,7 @@ dnf install -y \ mariadb-server mariadb httpd \ php php-mysqli php-gd \ perl-Digest-SHA \ - perl-DBD-MySQL perl-LDAP \ + perl-DBD-MySQL perl-DBD-SQLite perl-LDAP \ mod_dav_svn mod_perl diffutils dnf install -y \ diff --git a/codepot/docker/build-ubnt2004.sh b/codepot/docker/build-ubnt2004.sh index a6093880..ecee4493 100755 --- a/codepot/docker/build-ubnt2004.sh +++ b/codepot/docker/build-ubnt2004.sh @@ -6,7 +6,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ php libapache2-mod-php php-mysql php-gd \ libapache2-mod-perl2 libapache2-mod-svn \ libswitch-perl libconfig-simple-perl libdigest-sha-perl \ - libdbd-mysql-perl libnet-ldap-perl libsvn-perl libmail-sendmail-perl \ + libdbd-mysql-perl libdbd-sqlite3-perl libnet-ldap-perl libsvn-perl libmail-sendmail-perl \ php-dev libsvn-dev make svn co http://code.miflux.com/svn/codepot/trunk/codepot && \ diff --git a/codepot/etc/perl/Codepot/AccessHandler.pm b/codepot/etc/perl/Codepot/AccessHandler.pm index c78d9135..07d8628f 100644 --- a/codepot/etc/perl/Codepot/AccessHandler.pm +++ b/codepot/etc/perl/Codepot/AccessHandler.pm @@ -236,6 +236,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -246,6 +247,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; diff --git a/codepot/etc/post-commit.in b/codepot/etc/post-commit.in index 97f26ae9..21f1e4b4 100644 --- a/codepot/etc/post-commit.in +++ b/codepot/etc/post-commit.in @@ -75,6 +75,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -86,6 +87,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; diff --git a/codepot/etc/post-revprop-change.in b/codepot/etc/post-revprop-change.in index 4b46929e..1ecd3b15 100644 --- a/codepot/etc/post-revprop-change.in +++ b/codepot/etc/post-revprop-change.in @@ -58,6 +58,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -69,6 +70,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; diff --git a/codepot/etc/pre-commit.in b/codepot/etc/pre-commit.in index 0fb2f07e..c86f1aab 100644 --- a/codepot/etc/pre-commit.in +++ b/codepot/etc/pre-commit.in @@ -73,6 +73,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -84,6 +85,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; diff --git a/codepot/etc/pre-revprop-change.in b/codepot/etc/pre-revprop-change.in index 95a5a951..cf695ca6 100644 --- a/codepot/etc/pre-revprop-change.in +++ b/codepot/etc/pre-revprop-change.in @@ -56,6 +56,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -67,6 +68,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; diff --git a/codepot/etc/start-commit.in b/codepot/etc/start-commit.in index 17e5e602..0d0df9df 100644 --- a/codepot/etc/start-commit.in +++ b/codepot/etc/start-commit.in @@ -46,6 +46,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -57,6 +58,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; diff --git a/codepot/sbin/codepot-user.in b/codepot/sbin/codepot-user.in index 25ba6d4f..82622d28 100644 --- a/codepot/sbin/codepot-user.in +++ b/codepot/sbin/codepot-user.in @@ -51,6 +51,7 @@ sub open_database if ($dbtype eq 'postgre') { $dbtype = 'Pg'; } elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; } elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; } + elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; } my $dbstr; my $dbuser; @@ -62,6 +63,12 @@ sub open_database $dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost; $dbpass = ''; } + elsif ($dbtype eq 'SQLite') + { + $dbstr = "DBI:$dbtype:database=$dbhost;"; + $dbuser = $cfg->{database_username}; + $dbpass = $cfg->{database_password}; + } else { $dbstr = "DBI:$dbtype:database=$dbname;"; @@ -185,12 +192,12 @@ sub toggle_user $dbh->begin_work (); - my $query = $dbh->prepare ("UPDATE ${QC}${prefix}user_account${QC} SET ${QC}enabled${QC}=? WHERE ${QC}userid${QC}=?"); - if (!$query || !$query->execute ($enabled, $userid) || $query->rows() <= 0) + my $query = $dbh->prepare("UPDATE ${QC}${prefix}user_account${QC} SET ${QC}enabled${QC}=? WHERE ${QC}userid${QC}=?"); + if (!$query || !(my $execok = $query->execute($enabled, $userid)) || $query->rows() <= 0) { - my $errstr = $dbh->errstr(); + my $errstr = $execok? "user not found": $dbh->errstr(); $dbh->rollback (); - print (STDERR "Cannot enable/disable a user - $errstr\n"); + print (STDERR "Cannot enable/disable the user '$userid' - $errstr\n"); return -1; } @@ -262,7 +269,7 @@ if ($op <= 0) exit (2); } -my $cfg = get_config (); +my $cfg = get_config(); if (!defined($cfg)) { print (STDERR "Cannot load codepot configuration file\n"); @@ -294,7 +301,7 @@ if ($allowed_to_execute == 0) exit (1); } -my $dbh = open_database ($cfg); +my $dbh = open_database($cfg); if (!defined($dbh)) { printf (STDERR "Cannot open database - %s\n", $DBI::errstr); @@ -303,10 +310,10 @@ if (!defined($dbh)) switch ($op) { - case 1 { $ret = add_user ($dbh, $cfg->{database_prefix}, $USERID, $PASSWD, $EMAIL); } - case 2 { $ret = delete_user ($dbh, $cfg->{database_prefix}, $USERID); } - case 3 { $ret = toggle_user ($dbh, $cfg->{database_prefix}, $USERID, 'Y'); } - case 4 { $ret = toggle_user ($dbh, $cfg->{database_prefix}, $USERID, 'N'); } + case 1 { $ret = add_user($dbh, $cfg->{database_prefix}, $USERID, $PASSWD, $EMAIL); } + case 2 { $ret = delete_user($dbh, $cfg->{database_prefix}, $USERID); } + case 3 { $ret = toggle_user($dbh, $cfg->{database_prefix}, $USERID, 'Y'); } + case 4 { $ret = toggle_user($dbh, $cfg->{database_prefix}, $USERID, 'N'); } } close_database ($dbh);