From 01c17aaa1d7783b450cca277668aa556868614c0 Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 10:59:36 +0200 Subject: [PATCH 1/7] Move file in src directory * Follow Filesystem Hierarchy Standard followed by AlternC --- {lib => src/usr/lib/alternc}/httpperm_cron.php | 0 {logger => src/usr/lib/alternc/logger}/http-dns.php | 0 {logger => src/usr/lib/alternc/logger}/http-ulog.php | 0 {logger => src/usr/lib/alternc/logger}/http-ulog.sh | 0 dump.sql => src/usr/share/alternc/install/httpperm.sql | 0 {panel => src/usr/share/alternc/panel}/admin/httpperm_del.php | 0 {panel => src/usr/share/alternc/panel}/admin/httpperm_doedit.php | 0 {panel => src/usr/share/alternc/panel}/admin/httpperm_edit.php | 0 {panel => src/usr/share/alternc/panel}/admin/httpperm_list.php | 0 {panel => src/usr/share/alternc/panel}/admin/httpperm_log.php | 0 {panel => src/usr/share/alternc/panel}/class/m_httpperm.php | 0 canonicalize_test.php => test/canonicalize_test.php | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename {lib => src/usr/lib/alternc}/httpperm_cron.php (100%) rename {logger => src/usr/lib/alternc/logger}/http-dns.php (100%) rename {logger => src/usr/lib/alternc/logger}/http-ulog.php (100%) rename {logger => src/usr/lib/alternc/logger}/http-ulog.sh (100%) rename dump.sql => src/usr/share/alternc/install/httpperm.sql (100%) rename {panel => src/usr/share/alternc/panel}/admin/httpperm_del.php (100%) rename {panel => src/usr/share/alternc/panel}/admin/httpperm_doedit.php (100%) rename {panel => src/usr/share/alternc/panel}/admin/httpperm_edit.php (100%) rename {panel => src/usr/share/alternc/panel}/admin/httpperm_list.php (100%) rename {panel => src/usr/share/alternc/panel}/admin/httpperm_log.php (100%) rename {panel => src/usr/share/alternc/panel}/class/m_httpperm.php (100%) rename canonicalize_test.php => test/canonicalize_test.php (100%) diff --git a/lib/httpperm_cron.php b/src/usr/lib/alternc/httpperm_cron.php similarity index 100% rename from lib/httpperm_cron.php rename to src/usr/lib/alternc/httpperm_cron.php diff --git a/logger/http-dns.php b/src/usr/lib/alternc/logger/http-dns.php similarity index 100% rename from logger/http-dns.php rename to src/usr/lib/alternc/logger/http-dns.php diff --git a/logger/http-ulog.php b/src/usr/lib/alternc/logger/http-ulog.php similarity index 100% rename from logger/http-ulog.php rename to src/usr/lib/alternc/logger/http-ulog.php diff --git a/logger/http-ulog.sh b/src/usr/lib/alternc/logger/http-ulog.sh similarity index 100% rename from logger/http-ulog.sh rename to src/usr/lib/alternc/logger/http-ulog.sh diff --git a/dump.sql b/src/usr/share/alternc/install/httpperm.sql similarity index 100% rename from dump.sql rename to src/usr/share/alternc/install/httpperm.sql diff --git a/panel/admin/httpperm_del.php b/src/usr/share/alternc/panel/admin/httpperm_del.php similarity index 100% rename from panel/admin/httpperm_del.php rename to src/usr/share/alternc/panel/admin/httpperm_del.php diff --git a/panel/admin/httpperm_doedit.php b/src/usr/share/alternc/panel/admin/httpperm_doedit.php similarity index 100% rename from panel/admin/httpperm_doedit.php rename to src/usr/share/alternc/panel/admin/httpperm_doedit.php diff --git a/panel/admin/httpperm_edit.php b/src/usr/share/alternc/panel/admin/httpperm_edit.php similarity index 100% rename from panel/admin/httpperm_edit.php rename to src/usr/share/alternc/panel/admin/httpperm_edit.php diff --git a/panel/admin/httpperm_list.php b/src/usr/share/alternc/panel/admin/httpperm_list.php similarity index 100% rename from panel/admin/httpperm_list.php rename to src/usr/share/alternc/panel/admin/httpperm_list.php diff --git a/panel/admin/httpperm_log.php b/src/usr/share/alternc/panel/admin/httpperm_log.php similarity index 100% rename from panel/admin/httpperm_log.php rename to src/usr/share/alternc/panel/admin/httpperm_log.php diff --git a/panel/class/m_httpperm.php b/src/usr/share/alternc/panel/class/m_httpperm.php similarity index 100% rename from panel/class/m_httpperm.php rename to src/usr/share/alternc/panel/class/m_httpperm.php diff --git a/canonicalize_test.php b/test/canonicalize_test.php similarity index 100% rename from canonicalize_test.php rename to test/canonicalize_test.php From a4f9a7fb329abca85e534bd7ac0b47d1b4b6f4cc Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 11:09:40 +0200 Subject: [PATCH 2/7] Provide a standard packaging files * Set default packaging content to allow a build * As codebase is old we consider an old AlternC compatibility --- debian/changelog | 7 +++++++ debian/compat | 1 + debian/control | 20 ++++++++++++++++++++ debian/copyright | 17 +++++++++++++++++ debian/cron.d | 4 ++++ debian/install | 1 + debian/postinst | 15 +++++++++++++++ debian/rules | 5 +++++ 8 files changed, 70 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/cron.d create mode 100644 debian/install create mode 100644 debian/postinst create mode 100755 debian/rules diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..7ba5f83 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,7 @@ +alternc-httpperm (0.0.1) stretch buster; urgency=medium + + * False package version + * Version created only to follow git history + * Start nightly build from a stable version + + -- Benjamin Sonntag Thu, 10 Aug 2017 10:36:00 +0200 \ No newline at end of file diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b42da69 --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: alternc-httpperm +Section: admin +Priority: optional +Maintainer: AlternC Team +Build-Depends: debhelper (>= 8) +Standards-Version: 3.9.8 + +Package: alternc-httpperm +Priority: optional +Section: admin +Architecture: all +Depends: alternc (>= 3.1), alternc (< 3.5), apache2 (>= 2.4), iptables, ipset +Description: PHP-httpperm for AlternC + AlternC is a mutualized hosting software manager for Linux. + It allows you to manage your websites, domains, ftp, emails, aliases, + web statistics, mailing-lists, etc. + . + This package is an optional module to manage OUTGOING http/https filtering/logging + . + More information on https://www.alternc.com/ diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c3d591d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,17 @@ +Copyright: + + LICENSE + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License (GPL) + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + On Debian systems, the complete text of the GNU General Public + License can be found in /usr/share/common-licenses/GPL file. + diff --git a/debian/cron.d b/debian/cron.d new file mode 100644 index 0000000..e534969 --- /dev/null +++ b/debian/cron.d @@ -0,0 +1,4 @@ +SHELL=/bin/bash +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +* * * * * root cd /usr/lib/alternc && php httpperm_cron.php &>/dev/null \ No newline at end of file diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..b961d05 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +src/* . diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..68c50de --- /dev/null +++ b/debian/postinst @@ -0,0 +1,15 @@ +#!/bin/bash -e + +case "$1" in + configure) + printf "\tDon't forget to apply httpperm iptables rules as explained on Readme\n" + ;; + + triggered) + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. +#DEBHELPER# + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..ed58acc --- /dev/null +++ b/debian/rules @@ -0,0 +1,5 @@ +#!/usr/bin/make -f +#export DH_VERBOSE = 1 + +%: + dh $@ From c16c92367b24297a587e17184345fd77beb7e9bf Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 11:14:08 +0200 Subject: [PATCH 3/7] Add building information in readme * Prefer markdown --- README | 9 --------- README.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 97faba0..0000000 --- a/README +++ /dev/null @@ -1,9 +0,0 @@ -HTTPPERM -======== - -an OUTGOING http/https filtering/logging interface - -for AlternC hosting control panel - - - diff --git a/README.md b/README.md new file mode 100644 index 0000000..348652a --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# HTTPPERM + +an OUTGOING http/https filtering/logging interface +for AlternC hosting control panel + + +## Get the package + +### Build own package + +You can compile this package with: + +``` + apt install build-essential debhelper git + git clone https://github.com/AlternC/alternc-httperm/ + cd alternc-httperm + dpkg-buildpackage -us -uc +``` + +### From GitHub + +You can obtain nightly and last stable package from the dedicated page : [releases page](https://github.com/AlternC/alternc-httperm/releases) + +### From our repository + +You can get package from our official repository : [debian.alternc.org](https://debian.alternc.org/) + +## Dependency + +You need an AlternC 3.3.* (only). + +## How to use + +This package supports only AlternC 3.3. +Original code was set to AlternC 3.3 and could be deployed manually + From 9b458e4f85ef9bbca732549a4cd256dfb895a19a Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 11:21:49 +0200 Subject: [PATCH 4/7] Cron must be executable --- src/usr/lib/alternc/httpperm_cron.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/usr/lib/alternc/httpperm_cron.php diff --git a/src/usr/lib/alternc/httpperm_cron.php b/src/usr/lib/alternc/httpperm_cron.php old mode 100644 new mode 100755 From 5a31e474878430cf16b6f098278dbcbfcdf678b4 Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 11:22:51 +0200 Subject: [PATCH 5/7] Ignore internal debian packaging files --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb1a68e --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +debian/.debhelper/ +debian/debhelper-build-stamp +debian/files +debian/alternc*.log +debian/alternc*.substvars +debian/alternc*/ +*.gpg From 6ca6e37b54860c2b895c1c4ed433497909d01e2d Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 11:33:07 +0200 Subject: [PATCH 6/7] Update AlternC database schema * Inject in AlternC database table required to manage httpperm behavior --- debian/postinst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/debian/postinst b/debian/postinst index 68c50de..f507ec9 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,7 +1,19 @@ #!/bin/bash -e +ALTERNC_FUNCTIONS_FILE="/usr/lib/alternc/functions.sh" +HTTPPERM_SQL_FILE="/usr/share/alternc/install/httpperm.sql" + +if [ ! -r "${ALTERNC_FUNCTIONS_FILE}" ]; then + echo "Can't access ${ALTERNC_FUNCTIONS_FILE}" + exit 1 +fi + +# shellcheck source=/dev/null +. "${ALTERNC_FUNCTIONS_FILE}" + case "$1" in configure) + mysql_query "$(cat ${HTTPPERM_SQL_FILE})" printf "\tDon't forget to apply httpperm iptables rules as explained on Readme\n" ;; @@ -11,5 +23,4 @@ esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. -#DEBHELPER# - +#DEBHELPER# \ No newline at end of file From 1d5d24f33249b9ab164531b42e0b7706b5c5298a Mon Sep 17 00:00:00 2001 From: Camille Lafitte Date: Thu, 4 Jul 2024 17:18:46 +0200 Subject: [PATCH 7/7] Add precision about iptables rules to deploy * As we can't be sure how server iptables is set, we don't deploy any default rule * Adminsys must follow suggestion script and adapt it to its use case --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 348652a..12beb4e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ an OUTGOING http/https filtering/logging interface for AlternC hosting control panel +## Configuration + +Once pacakge retrieved and installed, you need to enable iptables rules +* Check [httpperm-iptables-script.sh](httpperm-iptables-script.sh) script +* Adapt it +* Deploy it +* Enjoy + ## Get the package ### Build own package