From 092c3cc12a7092032c77ecfb75b7c6baec1da3cb Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 30 Apr 2020 16:35:44 +0200 Subject: Debian packaging --- LICENSE.txt | 26 ++++++++++ Makefile | 94 ++++++++++++++++++++++++++++++++++--- README.txt | 3 ++ debian/control | 4 +- debian/copyright | 30 ++++++++++-- debian/webserver.manpages | 1 + plugins/webbox/Makefile | 14 +++--- plugins/weblog/procmail/procmail.sh | 29 ++++++------ webserver.1 | 14 ++++++ webserver.cpp | 6 ++- 10 files changed, 186 insertions(+), 35 deletions(-) create mode 100644 LICENSE.txt create mode 100644 debian/webserver.manpages create mode 100644 webserver.1 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b868bb7 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,26 @@ +Copyright 2020 Roland Reichwein + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile index 4f0e435..02cb17c 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ endif # -fprofile-instr-generate -fcoverage-mapping # gcc:--coverage -CXXFLAGS+= -Wall -I. -DVERSION=\"$(VERSION)\" +CXXFLAGS+= -Wall -I. -DVERSION=\"$(VERSION)\" -fPIE CXXFLAGS+= -pthread ifeq ($(CXX),clang++-10) @@ -64,6 +64,8 @@ LIBS+= \ -lstdc++fs endif +LDFLAGS+=-pie + PROGSRC=\ auth.cpp \ base64.cpp \ @@ -95,10 +97,10 @@ all: build # testsuite ---------------------------------------------- test-$(PROJECTNAME): $(TESTSRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ + $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ $(PROJECTNAME): $(SRC:.cpp=.o) - $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@ + $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ dep: $(TESTSRC:.cpp=.d) @@ -148,10 +150,88 @@ clean: -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f for i in $(PLUGINS) ; do make -C plugins/$$i clean ; done -zip: clean - -rm -f ../$(PROJECTNAME).zip - zip -r ../$(PROJECTNAME).zip * - ls -l ../$(PROJECTNAME).zip +DISTFILES= \ + archive.h \ + auth.cpp \ + auth.h \ + base64.cpp \ + base64.h \ + config.cpp \ + config.h \ + file.cpp \ + file.h \ + http.cpp \ + http.h \ + https.cpp \ + https.h \ + os.cpp \ + os.h \ + plugin.cpp \ + plugin.h \ + plugin_interface.h \ + privileges.cpp \ + privileges.h \ + response.cpp \ + response.h \ + server.cpp \ + server.h \ + statistics.cpp \ + statistics.h \ + test-webserver.cpp \ + webserver.cpp \ + webserver.1 \ + README.txt \ + LICENSE.txt \ + Makefile \ + googletest \ + googlemock \ + debian/changelog \ + debian/compat \ + debian/control \ + debian/copyright \ + debian/README.Debian \ + debian/rules \ + debian/source/format \ + debian/webserver.conf \ + debian/webserver.dirs \ + debian/webserver.docs \ + debian/webserver.install \ + debian/webserver.service \ + plugins/cgi/cgi.h \ + plugins/cgi/Makefile \ + plugins/cgi/cgi.cpp \ + plugins/webbox/file.h \ + plugins/webbox/file.cpp \ + plugins/webbox/stringutil.cpp \ + plugins/webbox/stringutil.h \ + plugins/webbox/webbox.h \ + plugins/webbox/html/refresh-inverted.png \ + plugins/webbox/html/directory.png \ + plugins/webbox/html/file.png \ + plugins/webbox/html/menu.png \ + plugins/webbox/html/webbox.css \ + plugins/webbox/html/favicon.ico \ + plugins/webbox/html/index.html \ + plugins/webbox/html/webbox.js \ + plugins/webbox/Makefile \ + plugins/webbox/webbox.cpp \ + plugins/weblog/weblog.h \ + plugins/weblog/procmail/procmailrc \ + plugins/weblog/procmail/procmail.sh \ + plugins/weblog/stringutil.h \ + plugins/weblog/stringutil.cpp \ + plugins/weblog/Makefile \ + plugins/weblog/weblog.cpp \ + plugins/static-files/static-files.h \ + plugins/static-files/static-files.cpp \ + plugins/static-files/Makefile \ + plugins/statistics/statistics.h \ + plugins/statistics/Makefile \ + plugins/statistics/statistics.cpp + +dist: clean + tar cfJ ../$(PROJECTNAME)-$(VERSION).tar.xz $(DISTFILES) + ls -l ../$(PROJECTNAME)-$(VERSION).tar.xz .PHONY: clean all zip install deb deb-src debs all $(DISTROS) diff --git a/README.txt b/README.txt index 439faab..7748d0a 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,6 @@ +Reichwein.IT Webserver +====================== + Features -------- diff --git a/debian/control b/debian/control index a417c81..acd8ae5 100644 --- a/debian/control +++ b/debian/control @@ -1,8 +1,8 @@ Source: webserver Section: httpd -Priority: extra +Priority: optional Maintainer: Roland Reichwein -Build-Depends: debhelper (>= 12), libssl-dev, libboost-all-dev | libboost1.71-all-dev, clang | g++-9, node-uglify, htmlmin | tidy, cleancss +Build-Depends: debhelper (>= 12), libssl-dev, libboost-all-dev | libboost1.71-all-dev, clang | g++-9, node-uglify, python3-pkg-resources, htmlmin, cleancss Standards-Version: 4.1.3 Homepage: http://www.reichwein.it/webserver/ diff --git a/debian/copyright b/debian/copyright index 71cab6b..4b3a1b3 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,29 @@ -This package is Copyright 2020 by Reichwein.IT -Roland Reichwein +This package is Copyright 2020 by Roland Reichwein -Commercial licensing is available. +Both upstream source code and Debian packaging is licensed under the BSD +license: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/webserver.manpages b/debian/webserver.manpages new file mode 100644 index 0000000..0bf93db --- /dev/null +++ b/debian/webserver.manpages @@ -0,0 +1 @@ +webserver.1 diff --git a/plugins/webbox/Makefile b/plugins/webbox/Makefile index 54c954c..5ff22f7 100644 --- a/plugins/webbox/Makefile +++ b/plugins/webbox/Makefile @@ -97,14 +97,12 @@ install: mkdir -p $(DESTDIR)/usr/lib/webserver/plugins cp $(PROJECTNAME).so $(DESTDIR)/usr/lib/webserver/plugins - mkdir -p $(DESTDIR)/var/www/webbox - cp -r html/* $(DESTDIR)/var/www/webbox/ - - # Minify, conditionally - command -v uglifyjs && uglifyjs html/webbox.js -m -c > $(DESTDIR)/var/www/webbox/webbox.js || true - command -v htmlmin && \ - htmlmin html/index.html $(DESTDIR)/var/www/webbox/index.html || true - command -v cleancss && cleancss -o $(DESTDIR)/var/www/webbox/webbox.css html/webbox.css || true + mkdir -p $(DESTDIR)/usr/lib/webbox/html + cp -r html/* $(DESTDIR)/usr/lib/webbox/html/ + + uglifyjs html/webbox.js -m -c > $(DESTDIR)/usr/lib/webbox/html/webbox.js + htmlmin html/index.html $(DESTDIR)/usr/lib/webbox/html/index.html + cleancss -o $(DESTDIR)/usr/lib/webbox/html/webbox.css html/webbox.css # misc --------------------------------------------------- diff --git a/plugins/weblog/procmail/procmail.sh b/plugins/weblog/procmail/procmail.sh index bafe889..44fa68f 100755 --- a/plugins/weblog/procmail/procmail.sh +++ b/plugins/weblog/procmail/procmail.sh @@ -46,18 +46,6 @@ if echo "$ADDR" | grep -q "weblog-bloginput" ; then exit 1 fi -#if grep -q "^pitch " inmail ; then -# PITCH=`grep "^pitch " inmail|head -n1|sed -e 's/^pitch \([+-]\?[0-9]\+\(\.[0-9]\+\)\?\).*/\1/'` -# if echo "$PITCH" | grep -q "^pitch " ; then -# # no pitch match -# ERRORMSG="Bad pitch syntax." -# exit 1 -# fi -# USERLOG="pitch $PITCH" -#else -# PITCH=0 -#fi - ALLLINES=`wc -l inmail | cut -f1 -d" "` HEADERLINES=`cat inmail | (n=0; while read i ; do @@ -77,12 +65,25 @@ echo "$BODY" > /home/weblog-bloginput/body.txt SUBJECT=`echo "$HEADER" | mimedecode` SUBJECT_PATH=`echo "$SUBJECT" | sed -e 's/[^a-zA-Z0-9]/_/g'` -ARTICLEDIR="$BLOGDIR/`date +%Y/%Y%m%d_%H%M`_$SUBJECT_PATH" +ARTICLEDIR="$BLOGDIR/`date +%Y/%Y%m%d`_$SUBJECT_PATH" mkdir -p $ARTICLEDIR echo "Subject: $SUBJECT" >> $ARTICLEDIR/article.data echo "" >> $ARTICLEDIR/article.data -echo "$BODY" >> $ARTICLEDIR/article.data + +# get attachments +munpack -C $ARTICLEDIR `pwd`/inmail >/dev/null || true + +DATANAME="`ls $ARTICLEDIR/*.desc || true`" 2>/dev/null +if [ "$DATANAME" = "" ] ; then + echo "$BODY" >> $ARTICLEDIR/article.data +else + cat "$DATANAME" >> $ARTICLEDIR/article.data + rm "$DATANAME" +fi + +chmod -R a+r $ARTICLEDIR +chmod a+x $ARTICLEDIR echo "Processed successfully." | mutt -s "Bloginput: $SUBJECT_PATH" -- "$ADDR" >> ~/log 2>&1 diff --git a/webserver.1 b/webserver.1 new file mode 100644 index 0000000..39da1eb --- /dev/null +++ b/webserver.1 @@ -0,0 +1,14 @@ +.TH webserver 1 "30 April 2020" "Version 1.3" "Webserver Manual" + +.SH NAME +webserver \- A small webserver + +.SH SYNOPSIS +webserver + +.SH DESCRIPTION +.B webserver +is a HTTP and HTTPS server supporting a C++ plugin interface. + +.SH AUTHOR +Roland Reichwein diff --git a/webserver.cpp b/webserver.cpp index 98fedc3..c832ec8 100644 --- a/webserver.cpp +++ b/webserver.cpp @@ -11,7 +11,11 @@ using namespace std::string_literals; void usage() { - std::cout << "usage: webserver [-c ]" << std::endl; + std::cout << "usage: webserver [-c | -p ] " << std::endl; + std::cout << " webserver [-c ] - start server with specified configuration\n" + " file or default /etc/webserver.conf" << std::endl; + std::cout << " webserver -p - encrypt password for basic HTTP AUTH,\n" + " suitable for config file" << std::endl; } void initlocale() { -- cgit v1.2.3