touched up some perl scripts

This commit is contained in:
hyung-hwan 2022-05-30 01:28:19 +00:00
parent 13f5c2dc61
commit 01655b1dd9
4 changed files with 28 additions and 34 deletions

View File

@ -22,8 +22,6 @@ rm -rf /var/lib/codepot/* && \
sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \ sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \
-e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "sqlite"|g' \ -e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "sqlite"|g' \
-e 's|^database_use_pdo[[:space:]]*=[[:space:]]*"no"$|database_use_pdo = "yes"|g' /etc/codepot/codepot.ini && \ -e 's|^database_use_pdo[[:space:]]*=[[:space:]]*"no"$|database_use_pdo = "yes"|g' /etc/codepot/codepot.ini && \
sed -ri -e 's|Digest::SHA1|Digest::SHA|g' /usr/sbin/codepot-user && \
sed -ri -e 's|Digest::SHA1|Digest::SHA|g' /etc/codepot/perl/Codepot/AccessHandler.pm && \
mkdir -p /run/php-fpm && \ mkdir -p /run/php-fpm && \
cp -pf /etc/codepot/codepot.httpd /etc/httpd/conf.d/codepot.conf && \ cp -pf /etc/codepot/codepot.httpd /etc/httpd/conf.d/codepot.conf && \
echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/httpd/conf.d/perl.conf && \ echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/httpd/conf.d/perl.conf && \

View File

@ -25,8 +25,6 @@ rm -rf /var/lib/codepot/* && \
sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \ sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \
-e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "sqlite"|g' \ -e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "sqlite"|g' \
-e 's|^database_use_pdo[[:space:]]*=[[:space:]]*"no"$|database_use_pdo = "yes"|g' /etc/codepot/codepot.ini && \ -e 's|^database_use_pdo[[:space:]]*=[[:space:]]*"no"$|database_use_pdo = "yes"|g' /etc/codepot/codepot.ini && \
sed -ri -e 's|Digest::SHA1|Digest::SHA|g' /usr/sbin/codepot-user && \
sed -ri -e 's|Digest::SHA1|Digest::SHA|g' /etc/codepot/perl/Codepot/AccessHandler.pm && \
cp -pf /etc/codepot/codepot.httpd /etc/apache2/conf-enabled/codepot.conf && \ cp -pf /etc/codepot/codepot.httpd /etc/apache2/conf-enabled/codepot.conf && \
echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/apache2/conf-enabled/perl.conf && \ echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/apache2/conf-enabled/perl.conf && \
sed -ri -e 's|^max_execution_time[[:space:]]*=.*$|max_execution_time = 120|g' /etc/php/*/apache2/php.ini sed -ri -e 's|^max_execution_time[[:space:]]*=.*$|max_execution_time = 120|g' /etc/php/*/apache2/php.ini

View File

@ -37,10 +37,9 @@ use APR::Base64;
use Config::Simple; use Config::Simple;
use Net::LDAP; use Net::LDAP;
use Net::LDAP qw(LDAP_SUCCESS);
use URI; use URI;
use DBI; use DBI;
use Digest::SHA1 qw (sha1_hex); use Digest::SHA;
use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_UNAUTHORIZED HTTP_INTERNAL_SERVER_ERROR PROXYREQ_PROXY AUTH_REQUIRED); use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_UNAUTHORIZED HTTP_INTERNAL_SERVER_ERROR PROXYREQ_PROXY AUTH_REQUIRED);
@ -122,7 +121,7 @@ sub authenticate_ldap
my $f_filter = format_string($cfg->{ldap_userid_search_filter}, $userid, $password); my $f_filter = format_string($cfg->{ldap_userid_search_filter}, $userid, $password);
my $res = $ldap->bind($f_rootdn, password => $f_rootpw); my $res = $ldap->bind($f_rootdn, password => $f_rootpw);
if ($res->code != LDAP_SUCCESS) if ($res->code != Net::LDAP::LDAP_SUCCESS)
{ {
$r->log_error ("Cannot bind LDAP as $f_rootdn - " . $res->error()); $r->log_error ("Cannot bind LDAP as $f_rootdn - " . $res->error());
$ldap->unbind(); $ldap->unbind();
@ -130,7 +129,7 @@ sub authenticate_ldap
} }
$res = $ldap->search(base => $f_basedn, scope => 'sub', filter => $f_filter); $res = $ldap->search(base => $f_basedn, scope => 'sub', filter => $f_filter);
if ($res->code != LDAP_SUCCESS) if ($res->code != Net::LDAP::LDAP_SUCCESS)
{ {
$ldap->unbind(); $ldap->unbind();
return 0; return 0;
@ -152,7 +151,7 @@ sub authenticate_ldap
$passwd = format_string ($cfg->{ldap_password_format}, $userid, $password); $passwd = format_string ($cfg->{ldap_password_format}, $userid, $password);
my $res = $ldap->bind ($binddn, password => $passwd); my $res = $ldap->bind ($binddn, password => $passwd);
if ($res->code != LDAP_SUCCESS) if ($res->code != Net::LDAP::LDAP_SUCCESS)
{ {
#$r->log_error ("Cannot bind LDAP as $binddn - " . $res->error()); #$r->log_error ("Cannot bind LDAP as $binddn - " . $res->error());
$ldap->unbind(); $ldap->unbind();
@ -172,7 +171,7 @@ sub authenticate_ldap
my $f_filter = '(objectClass=*)'; my $f_filter = '(objectClass=*)';
$res = $ldap->search(base => $binddn, scope => 'base', filter => $f_filter, @attrs); $res = $ldap->search(base => $binddn, scope => 'base', filter => $f_filter, @attrs);
if ($res->code == LDAP_SUCCESS) if ($res->code == Net::LDAP::LDAP_SUCCESS)
{ {
search_loop: search_loop:
foreach my $entry ($res->entries) foreach my $entry ($res->entries)
@ -220,7 +219,7 @@ sub authenticate_database
my $hexsalt = substr($db_pw, -10); my $hexsalt = substr($db_pw, -10);
my $binsalt = pack('H*', $hexsalt); my $binsalt = pack('H*', $hexsalt);
my $fmt_pw = '{ssha1}' . sha1_hex ($password . $binsalt) . $hexsalt; my $fmt_pw = '{ssha1}' . Digest::SHA::sha1_hex($password . $binsalt) . $hexsalt;
return (($fmt_pw eq $db_pw? 1: 0), undef); return (($fmt_pw eq $db_pw? 1: 0), undef);
} }

View File

@ -8,8 +8,7 @@ use strict;
use Switch; use Switch;
use Config::Simple; use Config::Simple;
use DBI; use DBI;
use Digest::SHA1 qw (sha1_hex); use Digest::SHA;
my $CFG_FILE = '@CFGDIR@/codepot.ini'; my $CFG_FILE = '@CFGDIR@/codepot.ini';
my $QC = ''; my $QC = '';
@ -112,7 +111,7 @@ sub rand_string
sub format_passwd sub format_passwd
{ {
my ($password, $binsalt, $hexsalt) = @_; my ($password, $binsalt, $hexsalt) = @_;
my $fmt_pw = '{ssha1}' . sha1_hex ($password . $binsalt) . $hexsalt; my $fmt_pw = '{ssha1}' . Digest::SHA::sha1_hex($password . $binsalt) . $hexsalt;
return $fmt_pw; return $fmt_pw;
} }