From ff1e2ecd0f3fd3db35399e23b7d4fa535fa9f99f Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sat, 7 Sep 2024 20:17:57 +1000 Subject: [PATCH] initial commit of file from CVS for smeserver-dl on Sat Sep 7 20:17:57 AEST 2024 --- .gitignore | 4 + Makefile | 21 ++++ README.md | 16 ++- additional/.tito/packages/.readme | 3 + additional/.tito/packages/smeserver-dl | 1 + additional/.tito/releasers.conf | 1 + additional/.tito/tito.props | 6 + additional/smeserver-dl.spec | 81 ++++++++++++ contriborbase | 1 + createlinks | 40 ++++++ root/etc/cron.daily/dl-expire | 2 + root/etc/e-smith/db/accounts/defaults/dl/type | 1 + .../db/configuration/defaults/dl/DbName | 1 + .../db/configuration/defaults/dl/DbUser | 1 + .../db/configuration/defaults/dl/access | 1 + .../db/configuration/defaults/dl/status | 1 + .../e-smith/db/configuration/defaults/dl/type | 1 + .../db/configuration/migrate/dl-database | 27 ++++ .../etc/e-smith/templates.metadata/etc/dl.php | 3 + .../etc/e-smith/sql/init/dl | 1 + root/etc/e-smith/templates/etc/dl.php/10Url | 6 + root/etc/e-smith/templates/etc/dl.php/15From | 1 + root/etc/e-smith/templates/etc/dl.php/20Spool | 1 + .../etc/e-smith/templates/etc/dl.php/25Locale | 5 + .../e-smith/templates/etc/dl.php/30Defaults | 4 + .../e-smith/templates/etc/dl.php/35ConfVer | 4 + root/etc/e-smith/templates/etc/dl.php/40Logs | 1 + root/etc/e-smith/templates/etc/dl.php/45Auth | 1 + .../e-smith/templates/etc/dl.php/50Database | 10 ++ .../etc/e-smith/templates/etc/dl.php/55Expire | 1 + .../e-smith/templates/etc/dl.php/60ClamScan | 22 ++++ .../e-smith/templates/etc/e-smith/sql/init/dl | 52 ++++++++ .../httpd/conf/httpd.conf/68FastCGIConfig15Dl | 9 ++ .../templates/etc/httpd/conf/httpd.conf/98Dl | 78 ++++++++++++ .../conf/httpd.conf/VirtualHosts/61RedirDl | 10 ++ .../templates/etc/php-fpm.d/www.conf/15Dl | 52 ++++++++ smeserver-dl.spec | 119 ++++++++++++++++++ 37 files changed, 587 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 additional/.tito/packages/.readme create mode 100644 additional/.tito/packages/smeserver-dl create mode 120000 additional/.tito/releasers.conf create mode 100644 additional/.tito/tito.props create mode 100644 additional/smeserver-dl.spec create mode 100644 contriborbase create mode 100644 createlinks create mode 100644 root/etc/cron.daily/dl-expire create mode 100644 root/etc/e-smith/db/accounts/defaults/dl/type create mode 100644 root/etc/e-smith/db/configuration/defaults/dl/DbName create mode 100644 root/etc/e-smith/db/configuration/defaults/dl/DbUser create mode 100644 root/etc/e-smith/db/configuration/defaults/dl/access create mode 100644 root/etc/e-smith/db/configuration/defaults/dl/status create mode 100644 root/etc/e-smith/db/configuration/defaults/dl/type create mode 100644 root/etc/e-smith/db/configuration/migrate/dl-database create mode 100644 root/etc/e-smith/templates.metadata/etc/dl.php create mode 100644 root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/dl create mode 100644 root/etc/e-smith/templates/etc/dl.php/10Url create mode 100644 root/etc/e-smith/templates/etc/dl.php/15From create mode 100644 root/etc/e-smith/templates/etc/dl.php/20Spool create mode 100644 root/etc/e-smith/templates/etc/dl.php/25Locale create mode 100644 root/etc/e-smith/templates/etc/dl.php/30Defaults create mode 100644 root/etc/e-smith/templates/etc/dl.php/35ConfVer create mode 100644 root/etc/e-smith/templates/etc/dl.php/40Logs create mode 100644 root/etc/e-smith/templates/etc/dl.php/45Auth create mode 100644 root/etc/e-smith/templates/etc/dl.php/50Database create mode 100644 root/etc/e-smith/templates/etc/dl.php/55Expire create mode 100644 root/etc/e-smith/templates/etc/dl.php/60ClamScan create mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/dl create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/68FastCGIConfig15Dl create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Dl create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirDl create mode 100644 root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15Dl create mode 100644 smeserver-dl.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbb3a13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tar.gz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..559ab99 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: smeserver-dl +# $Id: Makefile,v 1.1 2021/04/18 16:21:15 jpp Exp $ +NAME := smeserver-dl +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/README.md b/README.md index 8d2b81f..94a3de2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ -# smeserver-dl +# smeserver-dl -SMEServer Koozali developed git repo for smeserver-dl smecontribs \ No newline at end of file +SMEServer Koozali developed git repo for smeserver-dl smecontribs + +## Wiki +
https://wiki.koozali.org/ + +## Bugzilla +Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-dl&product=SME%20Contribs&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED) + +## Description + +
*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.* +*Once it has been checked, then this comment will be deleted* +
diff --git a/additional/.tito/packages/.readme b/additional/.tito/packages/.readme new file mode 100644 index 0000000..b9411e2 --- /dev/null +++ b/additional/.tito/packages/.readme @@ -0,0 +1,3 @@ +the .tito/packages directory contains metadata files +named after their packages. Each file has the latest tagged +version and the project's relative directory. diff --git a/additional/.tito/packages/smeserver-dl b/additional/.tito/packages/smeserver-dl new file mode 100644 index 0000000..11c5513 --- /dev/null +++ b/additional/.tito/packages/smeserver-dl @@ -0,0 +1 @@ +0.2.3-1 ./ diff --git a/additional/.tito/releasers.conf b/additional/.tito/releasers.conf new file mode 120000 index 0000000..867c32f --- /dev/null +++ b/additional/.tito/releasers.conf @@ -0,0 +1 @@ +../../tito_libs/releasers.conf \ No newline at end of file diff --git a/additional/.tito/tito.props b/additional/.tito/tito.props new file mode 100644 index 0000000..3c97442 --- /dev/null +++ b/additional/.tito/tito.props @@ -0,0 +1,6 @@ +[buildconfig] +builder = tito.builder.Builder +tagger = tito.tagger.VersionTagger +changelog_do_not_remove_cherrypick = 0 +changelog_format = %s (%ae) +lib_dir = ../tito_libs diff --git a/additional/smeserver-dl.spec b/additional/smeserver-dl.spec new file mode 100644 index 0000000..0bc7faf --- /dev/null +++ b/additional/smeserver-dl.spec @@ -0,0 +1,81 @@ +%define phpversion 56 + +Summary: sme server integration of dl +Name: smeserver-dl +Version: 0.2.3 +Release: 1%{?dist} +Epoch: 9 +License: GNU GPL version 2 +URL: http://www.thregr.org/~wavexx/software/dl/ +Group: SMEserver/addon +Source: %{name}-%{version}.tar.gz + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: %{_tmppath}/%{name}-%{version} +Requires: e-smith-base +Requires: dl +Requires: smeserver-webapps-common + +%description +smserver integration of dl + +%changelog +* Sun Jan 21 2018 Daniel Berteaud 0.2.3-1 +- Use alt php binary when expiring tickets [SME: 10495] (daniel@firewall- + services.com) + +* Sun Nov 19 2017 Daniel Berteaud 0.2.2-1 +- Prepare spec file for tito (daniel@firewall-services.com) + +* Wed Jul 26 2017 Daniel Berteaud 0.2.1-1.sme +- Add /var/lib/php/dl to open_basedir for the fpm pool +- Assume MB if no unit is specified for max file size +- Remove hardcoded PHP version, replaced at build time + +* Thu Jul 13 2017 Daniel Berteaud 0.2.0-1.sme +- Support smeserver-php-fpm + +* Tue May 31 2016 Daniel Berteaud 0.1.4-1.sme +- Fix cron job output [SME: 9116] + +* Wed Apr 23 2014 Daniel Berteaud 0.1.3-1.sme +- Fix basic auth on SME9 + +* Tue Feb 4 2014 Daniel Berteaud 0.1.2-1.sme +- Grant admin privileges to the admin user + +* Sun Nov 24 2013 Daniel Berteaud 0.1.1-1.sme +- Automatically upgrade the database + +* Fri Nov 22 2013 Daniel Berteaud 0.1.0-1.sme +- First release + +%prep +%setup -q + +%build +perl ./createlinks +find root/ -type f | xargs grep -l __PHP_VERSION__ | xargs sed -i -e "s/__PHP_VERSION__/%{phpversion}/g" +%{__mkdir_p} root/var/log/php/dl +%{__mkdir_p} root/var/lib/php/dl/{tmp,opcache,session} + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + --dir /var/log/php/dl 'attr(0770,root,www)' \ + --dir /var/lib/php/dl 'attr(0770,root,www)' \ + --dir /var/lib/php/dl/tmp 'attr(0770,root,www)' \ + --dir /var/lib/php/dl/opcache 'attr(0770,root,www)' \ + --dir /var/lib/php/dl/session 'attr(0770,root,www)' \ + > %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + +%postun diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..9b7fd51 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +contribs10 diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..cc4787e --- /dev/null +++ b/createlinks @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w +use esmith::Build::CreateLinks qw(:all); +# our event specific for updating with yum without reboot +$event = 'smeserver-dl-update'; +#add here the path to your templates needed to expand +#see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event + +foreach my $file (qw( + /etc/systemd/system-preset/49-koozali.preset + /etc/httpd/conf/httpd.conf +)) +{ + templates2events( $file, $event ); +} +#action needed in case we have a systemd unit +event_link('systemd-default', $event, '10'); +event_link('systemd-reload', $event, '50'); +#action specific to this package +#event_link('action', $event, '30'); +#services we need to restart +safe_symlink('restart',"root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.init");; + +#and Server Manager panel link +#panel_link('somefunction', 'manager'); + + +# Templates to expand +templates2events("/etc/dl.php", qw(smeserver-dl-update bootstrap-console-save webapps-update)); +templates2events("/etc/e-smith/sql/init/dl", qw(smeserver-dl-update bootstrap-console-save webapps-update)); + +# PHP header and footer +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/dl.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/dl.php/template-end"); + +#backup contrib +use esmith::Build::Backup qw(:all); +backup_includes("smeserver-dl", qw( +/var/lib/dl/ +)); diff --git a/root/etc/cron.daily/dl-expire b/root/etc/cron.daily/dl-expire new file mode 100644 index 0000000..b86ea16 --- /dev/null +++ b/root/etc/cron.daily/dl-expire @@ -0,0 +1,2 @@ +#!/bin/sh +su -s /bin/bash -c "cd /usr/share/dl/include/scripts && /usr/bin/php__PHP_VERSION__ ./expire.php" diff --git a/root/etc/e-smith/db/accounts/defaults/dl/type b/root/etc/e-smith/db/accounts/defaults/dl/type new file mode 100644 index 0000000..96cdd3b --- /dev/null +++ b/root/etc/e-smith/db/accounts/defaults/dl/type @@ -0,0 +1 @@ +url diff --git a/root/etc/e-smith/db/configuration/defaults/dl/DbName b/root/etc/e-smith/db/configuration/defaults/dl/DbName new file mode 100644 index 0000000..5c48862 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/dl/DbName @@ -0,0 +1 @@ +dl diff --git a/root/etc/e-smith/db/configuration/defaults/dl/DbUser b/root/etc/e-smith/db/configuration/defaults/dl/DbUser new file mode 100644 index 0000000..5c48862 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/dl/DbUser @@ -0,0 +1 @@ +dl diff --git a/root/etc/e-smith/db/configuration/defaults/dl/access b/root/etc/e-smith/db/configuration/defaults/dl/access new file mode 100644 index 0000000..a48cf0d --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/dl/access @@ -0,0 +1 @@ +public diff --git a/root/etc/e-smith/db/configuration/defaults/dl/status b/root/etc/e-smith/db/configuration/defaults/dl/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/dl/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/dl/type b/root/etc/e-smith/db/configuration/defaults/dl/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/dl/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/db/configuration/migrate/dl-database b/root/etc/e-smith/db/configuration/migrate/dl-database new file mode 100644 index 0000000..c4de2f6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/dl-database @@ -0,0 +1,27 @@ +{ + my $rec = $DB->get('dl') + || $DB->new_record('dl', {type => 'webapp'}); + my $pw = $rec->prop('DbPassword'); + if (not $pw or length($pw) < 57){ + use MIME::Base64 qw(encode_base64); + + $pw = "not set due to error"; + if ( open( RANDOM, "/dev/urandom" ) ){ + my $buf; + # 57 bytes is a full line of Base64 coding, and contains + # 456 bits of randomness - given a perfectly random /dev/random + if ( read( RANDOM, $buf, 57 ) != 57 ){ + warn("Short read from /dev/random: $!"); + } + else{ + $pw = encode_base64($buf); + chomp $pw; + } + close RANDOM; + } + else{ + warn "Could not open /dev/urandom: $!"; + } + $rec->set_prop('DbPassword', $pw); + } +} diff --git a/root/etc/e-smith/templates.metadata/etc/dl.php b/root/etc/e-smith/templates.metadata/etc/dl.php new file mode 100644 index 0000000..bad4258 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/dl.php @@ -0,0 +1,3 @@ +PERMS=0640 +UID="root" +GID="www" diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/dl b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/dl new file mode 100644 index 0000000..940dcf3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/dl @@ -0,0 +1 @@ +PERMS=0750 diff --git a/root/etc/e-smith/templates/etc/dl.php/10Url b/root/etc/e-smith/templates/etc/dl.php/10Url new file mode 100644 index 0000000..5238cea --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/10Url @@ -0,0 +1,6 @@ +{ +my $uri = $dl{'Uri'} || "https://$SystemName.$DomainName/dl"; +$uri .= '/' if ($uri !~ /\/$/); + +$OUT .= "\$masterPath = '$uri';"; +} diff --git a/root/etc/e-smith/templates/etc/dl.php/15From b/root/etc/e-smith/templates/etc/dl.php/15From new file mode 100644 index 0000000..517f51d --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/15From @@ -0,0 +1 @@ +$fromAddr = "{$ldap{'defaultCompany'}} "; diff --git a/root/etc/e-smith/templates/etc/dl.php/20Spool b/root/etc/e-smith/templates/etc/dl.php/20Spool new file mode 100644 index 0000000..3c5e24a --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/20Spool @@ -0,0 +1 @@ +$spoolDir = "/var/lib/dl/"; diff --git a/root/etc/e-smith/templates/etc/dl.php/25Locale b/root/etc/e-smith/templates/etc/dl.php/25Locale new file mode 100644 index 0000000..631746a --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/25Locale @@ -0,0 +1,5 @@ +{ +my $locale = $sysconfig{'Language'} || 'en_US'; +$locale = (-e "/usr/share/dl/include/locale/$locale") ? "$locale":'en_US'; +$OUT .= "\$defLocale = '$locale';"; +} diff --git a/root/etc/e-smith/templates/etc/dl.php/30Defaults b/root/etc/e-smith/templates/etc/dl.php/30Defaults new file mode 100644 index 0000000..5c88319 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/30Defaults @@ -0,0 +1,4 @@ +$defaultTicketTotalDays = 30; +$defaultTicketLastDlDays = 7; +$defaultTicketMaxDl = 0; +$defaultGrantTotalDays = 30; diff --git a/root/etc/e-smith/templates/etc/dl.php/35ConfVer b/root/etc/e-smith/templates/etc/dl.php/35ConfVer new file mode 100644 index 0000000..05e9310 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/35ConfVer @@ -0,0 +1,4 @@ +{ +my $ver = `rpm -q --qf %{version} dl`; +$OUT .= "\$cfgVersion = '$ver';"; +} diff --git a/root/etc/e-smith/templates/etc/dl.php/40Logs b/root/etc/e-smith/templates/etc/dl.php/40Logs new file mode 100644 index 0000000..ff46883 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/40Logs @@ -0,0 +1 @@ +$logFile = "/var/log/dl.log"; diff --git a/root/etc/e-smith/templates/etc/dl.php/45Auth b/root/etc/e-smith/templates/etc/dl.php/45Auth new file mode 100644 index 0000000..fee9439 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/45Auth @@ -0,0 +1 @@ +$authRealm = "dl"; diff --git a/root/etc/e-smith/templates/etc/dl.php/50Database b/root/etc/e-smith/templates/etc/dl.php/50Database new file mode 100644 index 0000000..49bfa8e --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/50Database @@ -0,0 +1,10 @@ +{ +my $dbn = $dl{'DbName'} || 'dl'; +my $dbu = $dl{'DbUser'} || 'dl'; +my $dbp = $dl{'DbPassword'} || 'secret'; +$OUT .=<<"EOF" +\$dsn = "mysql:host=localhost;dbname=$dbn"; +\$dbUser = "$dbu"; +\$dbPassword = "$dbp"; +EOF +} diff --git a/root/etc/e-smith/templates/etc/dl.php/55Expire b/root/etc/e-smith/templates/etc/dl.php/55Expire new file mode 100644 index 0000000..91c9fcd --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/55Expire @@ -0,0 +1 @@ +$gcInternal = false; diff --git a/root/etc/e-smith/templates/etc/dl.php/60ClamScan b/root/etc/e-smith/templates/etc/dl.php/60ClamScan new file mode 100644 index 0000000..a3a0640 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dl.php/60ClamScan @@ -0,0 +1,22 @@ +{ +my $clam = $clamd{'status'} || 'disabled'; +return '' unless ($clam eq 'enabled'); +my $max = $clamav{StreamMaxLength} || '25M'; +my $limit = $max; +$limit =~ s/[KMG]$//; +if ($max =~ m/G$/){ + $limit = $limit * 1024 * 1024 * 1024; +} +elsif ($max =~ m/M$/){ + $limit = $limit * 1024 * 1024; +} +elsif ($max =~ m/K$/){ + $limit = $limit * 1024; +} +# 1MB of margin to be sure we don't go over clamd limit +$limit -= 1024 * 1024; +$OUT .=<<"EOF"; +\$clamdSocket = 'unix:///var/run/clamd/clamd.socket'; +\$scanMax = $limit; +EOF +} diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/dl b/root/etc/e-smith/templates/etc/e-smith/sql/init/dl new file mode 100644 index 0000000..784c4b0 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/dl @@ -0,0 +1,52 @@ +{ +my $db = $dl{'DbName'} || 'dl'; +my $user = $dl{'DbUser'} || 'dl'; +my $pass = $dl{'DbPassword'} || 'secret'; + +my $dbstruct = `rpm -ql dl | grep mysql.sql`; + +$OUT .= <<"END"; +#! /bin/sh +if [ ! -d /var/lib/mysql/$db ]; then + /usr/bin/mysql -e 'create database $db' + /usr/bin/mysql $db < $dbstruct +else + su -s /bin/bash - www -c "cd /usr/share/dl/include/scripts && /usr/bin/php__PHP_VERSION__ ./dbupgrade.php" +fi + +/usr/bin/mysql < + SSLRequireSSL on + AuthName "dl" + AuthType Basic + AuthBasicProvider external + AuthExternal pwauth + Require valid-user + +EOF +} +if ($dl{'status'} eq 'enabled'){ + + my $php =<<_EOF; + AddType application/x-httpd-php .php + + + SetHandler "proxy:unix:/var/run/php-fpm/php__PHP_VERSION__-dl.sock|fcgi://localhost" + + + #php_admin_flag file_uploads On + #php_admin_flag magic_quotes Off + #php_admin_flag magic_quotes_gpc Off + #php_admin_value upload_max_filesize $maxupload + #php_admin_value post_max_size $maxpost + #php_admin_value memory_limit 100M + #php_admin_flag output_buffering Off + #php_admin_value max_execution_time 0 + #php_admin_value upload_tmp_dir /var/lib/dl/tmp + #php_admin_value session.save_path /var/lib/dl/tmp + #php_admin_value session.gc_maxlifetime 86400 +_EOF + if ($fastcgi_mod eq 'mod_fastcgi'){ + $php = " AddHandler phpdl-fastcgi .php\n"; + } + elsif ($fastcgi_mod eq 'mod_proxy_fcgi'){ + $php =<<'_EOF'; + + SetHandler "proxy:unix:/var/run/php-fpm/php__PHP_VERSION__-dl.sock|fcgi://localhost" + +_EOF + } + +$OUT .=<<"END" + +# dl Configuration +$alias + + + AllowOverride Limit +$php + Require $allow +$auth + + + Require all denied + + + Require all denied + +END +} +else{ + $OUT .= "# dl is disabled\n"; +} +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirDl b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirDl new file mode 100644 index 0000000..9b1caa2 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirDl @@ -0,0 +1,10 @@ +{ +my $sslport = $modSSL{'TCPPort'} || '443'; +my $status = $dl{'status'} || 'enabled'; +my $alias = $dl{'AliasOnPrimary'} || 'enabled'; + +if (($port ne $sslport) && ($status eq 'enabled') && ($alias eq 'enabled')){ + $OUT .= " RewriteEngine on\n"; + $OUT .= " RewriteRule ^/dl(/.*|\$) https://%{HTTP_HOST}/dl\$1 \[L,R\]\n"; +} +} diff --git a/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15Dl b/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15Dl new file mode 100644 index 0000000..c3ce477 --- /dev/null +++ b/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15Dl @@ -0,0 +1,52 @@ +{ + +if ($PHP_VERSION eq '__PHP_VERSION__'){ + if (($dl{'status'} || 'disabled') eq 'enabled'){ + my $max_upload_size = ($dl{MaxUploadSize} || '4096'); + $max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/); + my $id = 'dl'; + $OUT .=<<_EOF; + +[php$PHP_VERSION-$id] +user = www +group = www +listen.owner = root +listen.group = www +listen.mode = 0660 +listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock +pm = dynamic +pm.max_children = 15 +pm.start_servers = 3 +pm.min_spare_servers = 3 +pm.max_spare_servers = 4 +pm.max_requests = 1000 +php_admin_value[session.save_path] = /var/lib/php/$id/session +php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache +php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp +php_admin_value[error_log] = /var/log/php/$id/error.log +slowlog = /var/log/php/dl/slow.log +php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f php@{ $DomainName } +php_admin_flag[display_errors] = off +php_admin_flag[log_errors] = on +php_admin_value[error_log] = syslog +php_admin_value[memory_limit] = 128M +php_admin_value[max_execution_time] = 0 +php_admin_value[post_max_size] = $max_upload_size +php_admin_value[upload_max_filesize] = $max_upload_size +php_admin_value[disable_functions] = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd +php_admin_value[open_basedir] = /usr/share/dl:/etc/dl.php:/var/lib/dl:/var/log/dl.log:/var/lib/php/dl +php_admin_flag[allow_url_fopen] = off +php_admin_flag[file_upload] = on +php_admin_flag[session.cookie_httponly] = on +php_admin_flag[allow_url_include] = off +php_admin_value[session.save_handler] = files +php_admin_flag[output_buffering] = off + +_EOF + + } + else{ + $OUT .= '; Dl is disabled'; + } +} +} diff --git a/smeserver-dl.spec b/smeserver-dl.spec new file mode 100644 index 0000000..f9d79ad --- /dev/null +++ b/smeserver-dl.spec @@ -0,0 +1,119 @@ +%define phpversion 74 + +Summary: sme server integration of dl +Name: smeserver-dl +Version: 0.2.3 +Release: 9%{?dist} +Epoch: 9 +License: GNU GPL version 2 +URL: http://www.thregr.org/~wavexx/software/dl/ +Group: SMEserver/addon +Source: %{name}-%{version}.tar.xz + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: %{_tmppath}/%{name}-%{version} +Requires: e-smith-base +Requires: dl +Requires: e-smith-apache >= 2.6.0-19 +Requires: smeserver-php >= 3.0.0-43 + +%description +smserver integration of dl + +%changelog +* Sat Sep 07 2024 cvs2git.sh aka Brian Read 0.2.3-9.sme +- Roll up patches and move to git repo [SME: 12338] + +* Sat Sep 07 2024 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Thu Jul 21 2022 Jean-Philippe Pialasse 0.2.3-8.sme +- use httpd 2.4 syntax [SME: 12042] + smeserver-php provides smeserver-webapps-common +- backup contrib [SME: 12004] + +* Thu Dec 23 2021 Brian Read 0.2.3-7.sme +- Correct-clam-dir-in-60clamscan [SME: 11820] + +* Fri Dec 03 2021 John Crisp 0.2.3-6.sme +- Fix clamd path +- Fix typo + +* Wed Nov 03 2021 Brian Read 0.2.3-5.sme +- php74-dl-call-in-httpd-fragment [SME: 11567] + +* Tue Sep 28 2021 Brian Read 0.2.3-4.sme +- fix up update routine to create sql db on install [SME: 11567] +- Update php to 74 + +* Mon Apr 19 2021 Brian Read 0.2.3-3.sme +- Fix httpd syntax and expand it intially [SME: 11567] + +* Mon Apr 19 2021 Brian Read 0.2.3-2.sme +- Initial import to SME10 tree [SME: 11567] +- Add Update event to createlinks + +* Mon Apr 19 2021 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Sun Jan 21 2018 Daniel Berteaud 0.2.3-1 +- Use alt php binary when expiring tickets [SME: 10495] (daniel@firewall- + services.com) + +* Sun Nov 19 2017 Daniel Berteaud 0.2.2-1 +- Prepare spec file for tito (daniel@firewall-services.com) + +* Wed Jul 26 2017 Daniel Berteaud 0.2.1-1.sme +- Add /var/lib/php/dl to open_basedir for the fpm pool +- Assume MB if no unit is specified for max file size +- Remove hardcoded PHP version, replaced at build time + +* Thu Jul 13 2017 Daniel Berteaud 0.2.0-1.sme +- Support smeserver-php-fpm + +* Tue May 31 2016 Daniel Berteaud 0.1.4-1.sme +- Fix cron job output [SME: 9116] + +* Wed Apr 23 2014 Daniel Berteaud 0.1.3-1.sme +- Fix basic auth on SME9 + +* Tue Feb 4 2014 Daniel Berteaud 0.1.2-1.sme +- Grant admin privileges to the admin user + +* Sun Nov 24 2013 Daniel Berteaud 0.1.1-1.sme +- Automatically upgrade the database + +* Fri Nov 22 2013 Daniel Berteaud 0.1.0-1.sme +- First release + +%prep +%setup -q + +%build +perl ./createlinks +find root/ -type f | xargs grep -l __PHP_VERSION__ | xargs sed -i -e "s/__PHP_VERSION__/%{phpversion}/g" +%{__mkdir_p} root/var/log/php/dl +%{__mkdir_p} root/var/lib/php/dl/{tmp,opcache,session} + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + --dir /var/log/php/dl 'attr(0770,root,www)' \ + --dir /var/lib/php/dl 'attr(0770,root,www)' \ + --dir /var/lib/php/dl/tmp 'attr(0770,root,www)' \ + --dir /var/lib/php/dl/opcache 'attr(0770,root,www)' \ + --dir /var/lib/php/dl/session 'attr(0770,root,www)' \ + > %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + +%postun