From 26d83ef9c2ea43a77d76294281639441398318a7 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sat, 7 Sep 2024 20:42:45 +1000 Subject: [PATCH] initial commit of file from CVS for smeserver-mod_maxminddb on Sat Sep 7 20:42:45 AEST 2024 --- .gitignore | 4 + Makefile | 21 +++++ README.md | 16 +++- contriborbase | 1 + createlinks | 7 ++ .../configuration/defaults/modMaxminddb/Path | 1 + .../defaults/modMaxminddb/status | 1 + .../configuration/defaults/modMaxminddb/type | 1 + .../httpd.conf/20LoadModule80mod_maxminddb | 32 ++++++++ .../httpd.conf/79externalSSLAccessStringGeoip | 17 ++++ .../conf/httpd.conf/VirtualHosts/98geoipallow | 23 ++++++ smeserver-mod_maxminddb.spec | 80 +++++++++++++++++++ 12 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 contriborbase create mode 100644 createlinks create mode 100644 root/etc/e-smith/db/configuration/defaults/modMaxminddb/Path create mode 100644 root/etc/e-smith/db/configuration/defaults/modMaxminddb/status create mode 100644 root/etc/e-smith/db/configuration/defaults/modMaxminddb/type create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule80mod_maxminddb create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/79externalSSLAccessStringGeoip create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/98geoipallow create mode 100644 smeserver-mod_maxminddb.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..7b7d739 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: smeserver-mod_maxminddb +# $Id: Makefile,v 1.1 2021/04/02 19:22:44 jpp Exp $ +NAME := smeserver-mod_maxminddb +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 35ad15e..f55d4a5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ -# smeserver-mod_maxminddb +# smeserver-mod_maxminddb -SMEServer Koozali developed git repo for smeserver-mod_maxminddb smecontribs \ No newline at end of file +SMEServer Koozali developed git repo for smeserver-mod_maxminddb smecontribs + +## Wiki +
https://wiki.koozali.org/ + +## Bugzilla +Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-mod_maxminddb&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/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..9e985c4 --- /dev/null +++ b/createlinks @@ -0,0 +1,7 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); +my $event ="smeserver-mod_maxminddb-update"; +safe_symlink("reload-or-restart", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); +templates2events("/etc/httpd-e-smith/conf/httpd.conf", $event); + diff --git a/root/etc/e-smith/db/configuration/defaults/modMaxminddb/Path b/root/etc/e-smith/db/configuration/defaults/modMaxminddb/Path new file mode 100644 index 0000000..3afa1e7 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/modMaxminddb/Path @@ -0,0 +1 @@ +/usr/share/GeoIP diff --git a/root/etc/e-smith/db/configuration/defaults/modMaxminddb/status b/root/etc/e-smith/db/configuration/defaults/modMaxminddb/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/modMaxminddb/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/modMaxminddb/type b/root/etc/e-smith/db/configuration/defaults/modMaxminddb/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/modMaxminddb/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule80mod_maxminddb b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule80mod_maxminddb new file mode 100644 index 0000000..c820a1b --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule80mod_maxminddb @@ -0,0 +1,32 @@ +{ + # vim: ft=perl: + my $status = $modMaxminddb{status} || 'disabled'; + my $path = $modMaxminddb{Path} || '/usr/share/GeoIP'; + if ( $status eq "enabled" ) + { + $OUT .= "LoadModule maxminddb_module modules/mod_maxminddb.so\n"; + $OUT .= "\n"; + $OUT .= " MaxMindDBEnable On\n"; + $OUT .= " MaxMindDBFile COUNTRY_DB $path/GeoLite2-Country.mmdb\n"; + $OUT .= " MaxMindDBFile CITY_DB $path/GeoLite2-City.mmdb\n"; + $OUT .= " MaxMindDBEnv COUNTRY_CODE COUNTRY_DB/country/iso_code\n"; + $OUT .= " MaxMindDBEnv REGION_CODE CITY_DB/subdivisions/0/iso_code\n"; + $OUT .= " MaxMindDBEnv MM_COUNTRY_CODE CITY_DB/country/iso_code\n"; + $OUT .= " MaxMindDBEnv MM_COUNTRY_NAME CITY_DB/country/names/en\n"; + $OUT .= " MaxMindDBEnv MM_CITY_NAME CITY_DB/city/names/en\n"; + $OUT .= " MaxMindDBEnv MM_LONGITUDE CITY_DB/location/longitude\n"; + $OUT .= " MaxMindDBEnv MM_LATITUDE CITY_DB/location/latitude\n"; + $OUT .= " MaxMindDBEnv MM_CONTINENT_CODE CITY_DB/continent/code\n"; + $OUT .= " MaxMindDBEnv MM_CONTINENT_NAME CITY_DB/continent/names/en\n"; + $OUT .= " MaxMindDBEnv MM_REGION_CODE CITY_DB/subdivisions/0/iso_code\n"; + $OUT .= " MaxMindDBEnv MM_REGION_NAME CITY_DB/continent/names/en\n"; + $OUT .= " MaxMindDBEnv MM_POSTAL_CODE CITY_DB/postal/code\n"; + $OUT .= " MaxMindDBEnv MM_LOCATION_TIME_ZONE CITY_DB/location/time_zone\n"; + + $OUT .= "\n"; + } + else + { + $OUT .= "# mod_maxminddb disabled\n"; + } +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/79externalSSLAccessStringGeoip b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/79externalSSLAccessStringGeoip new file mode 100644 index 0000000..1152e01 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/79externalSSLAccessStringGeoip @@ -0,0 +1,17 @@ + +{ + #--------------------------------------------------------------------- + # Grab ValidFromGeoIP access list property of httpd-admin + # SSL enabled virtual hosts should only allow access from IP's in + # this list, as well as local networks. + #--------------------------------------------------------------------- + + $OUT = '# Mod_maxminddb variable definition'; + + my $validFromGeoIP = ${'httpd-admin'}{'ValidFromGeoIP'}; + return "#disabled\n" unless (defined $validFromGeoIP && ($modMaxminddb{'status'}||'disabled') eq 'enabled' ); + $validFromGeoIP =~ s/,/|/g; + $OUT .= "\nSetEnvIf MM_COUNTRY_CODE ^($validFromGeoIP) AllowCountries\n"; + # prior apache 2.4 you could combine ip and env by doing $externalSSLAccess .= ' env=AllowCountries'; + # now you should add "Require env AllowCountries" in Files, Directory or Location section + } diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/98geoipallow b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/98geoipallow new file mode 100644 index 0000000..c0e030f --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/98geoipallow @@ -0,0 +1,23 @@ +{ + $OUT =" # Mod_maxminddb\n"; + return " #disabled\n" unless ( ($modMaxminddb{'status'}||'disabled') eq 'enabled' || defined (${'httpd-admin'}{'ValidFromGeoIP'}) ); + $haveSSL = (exists ${modSSL}{status} and ${modSSL}{status} eq "enabled") ? 'yes' : 'no'; + if (($haveSSL eq 'yes') && ($port eq $httpsPort) ) { + $OUT .=" + Require ip $localAccess $externalSSLAccess + Require env AllowCountries + \n" if (-d "/etc/e-smith/web/panels/manager/" && (${'httpd-admin'}{'GeoIPManager'} || 'enabled' ) eq 'enabled' ); + $OUT .=" + Require ip $localAccess $externalSSLAccess + Require env AllowCountries + \n" if ( (${'httpd-admin'}{'GeoIPManager'} || 'enabled' ) eq 'enabled' || (${'httpd-admin'}{'GeoIPUser'} || 'enabled' ) eq 'enabled' || (${'httpd-admin'}{'GeoIPPassword'} || 'enabled' ) eq 'enabled') ; + $OUT .=" + Require ip $localAccess $externalSSLAccess + Require env AllowCountries + \n" if (-d "/etc/e-smith/web/panels/user/" && (${'httpd-admin'}{'GeoIPUser'} || 'enabled' ) eq 'enabled' ); + $OUT .=" + Require ip $localAccess $externalSSLAccess + Require env AllowCountries + \n" if (-d "/etc/e-smith/web/panels/password/" && (${'httpd-admin'}{'GeoIPPassword'} || 'enabled' ) eq 'enabled' ); + } +} diff --git a/smeserver-mod_maxminddb.spec b/smeserver-mod_maxminddb.spec new file mode 100644 index 0000000..7d05666 --- /dev/null +++ b/smeserver-mod_maxminddb.spec @@ -0,0 +1,80 @@ + +%define name smeserver-mod_maxminddb +%define version 1.1.0 +%define release 15 + +Summary: SME Server mod_dav implementation +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GPL +Group: Applications/Internet +Source: %{name}-%{version}.tar.xz + +BuildArchitectures: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +Requires: smeserver-release >= 10 +Requires: e-smith-apache >= 2.6.0-19 +Requires: httpd >= 2 +Requires: mod_maxminddb +Requires: libmaxminddb-devel +Requires: geolite2-city +Requires: geolite2-country +BuildRequires: e-smith-devtools >= 1.13.1-03 + +%description +Implementation of mod_dav for SME Server 7. + +%changelog +* Sat Sep 07 2024 cvs2git.sh aka Brian Read 1.1.0-15.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. + +* Mon Jul 25 2022 Jean-Philippe Pialasse 1.1.0-14.sme +- make compatible with httpd24 access [SME: 12052] + +* Fri Apr 02 2021 Jean-Philippe Pialasse 1.1.0-11.sme +- add option to allow countries to external access to manager [SME: 10768] + ValidFromGeoIP will add access to listed countries to managers and all + ressources using the usual list from httpd-admin Validfrom (local ibays, contribs...) + +* Fri Apr 02 2021 Jean-Philippe Pialasse 1.1.0-10.sme +- initial import to SME 10 [SME: 11521] +- update event created + +* Thu Apr 11 2019 Jean-Philipe Pialasse 1.1.0-7.sme +- fix missing db on installation [SME: 10770] + +* Thu Mar 14 2019 Jean-Philipe Pialasse 1.1.0-6.sme +- configure necessary variables [SME: 10759] + +* Wed Mar 13 2019 Jean-Philipe Pialasse 1.1.0-4.sme +- fix typo [SME: 10759] +- add requires mod_maxminddb +- rename template + +* Tue Mar 12 2019 Jean-Philipe Pialasse 1.1.0-1.sme +- Initial version [SME: 10759] + +%prep +%setup + +%build +perl createlinks + +%install +rm -rf %buildroot +(cd root ; find . -depth -print | cpio -dump %buildroot) +rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist %buildroot \ + --dir /var/run/davLocks 'attr(0755,www,www)' \ + > %{name}-%{version}-filelist + +%clean +rm -rf %buildroot + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root)