From fdde529e91398a0819c5223a6f33253b95e22563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Sun, 26 Feb 2017 11:11:41 +0000 Subject: [PATCH] configuration added and updated --- AUTHORS | 2 +- COPYING | 1 + ChangeLog | 18 ++++++++++++++++++ INSTALL | 1 + README | 18 ++++++++++++++++++ ax_init_standard_project.m4 | 37 +++++++++++++++++++++++++++++++++++-- bootstrap.sh | 27 ++++++++++++++++++++++----- configure.ac | 5 ++++- etc/authentication.php | 24 ++++++++++++++++++++++++ etc/makefile.am | 13 +++++++++++++ etc/settings.php | 5 +++++ html/configuration.php.in | 6 ++++++ html/index.php | 13 +++++-------- resolve-debbuilddeps.sh | 11 +++++++---- 14 files changed, 160 insertions(+), 21 deletions(-) create mode 120000 COPYING create mode 120000 INSTALL create mode 100644 etc/authentication.php create mode 100644 etc/makefile.am create mode 100644 etc/settings.php create mode 100644 html/configuration.php.in diff --git a/AUTHORS b/AUTHORS index bd79912..86ccdef 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1 @@ -Marc Wäckerlin (http://marc.waeckerlin.org) +Marc Wäckerlin (https://marc.wäckerlin.ch) diff --git a/COPYING b/COPYING new file mode 120000 index 0000000..88798ab --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +/usr/share/automake-1.15/COPYING \ No newline at end of file diff --git a/ChangeLog b/ChangeLog index b616acc..bcf4889 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2017-02-17 11:04 + + * [r13] debian/control.in: + backup + +2017-01-14 10:26 + + * [r12] debian/control.in: + build system updated + +2017-01-12 13:22 + + * [r11] ChangeLog, autogen.sh, ax_init_standard_project.m4, + bootstrap.sh, build-in-docker.conf, build-in-docker.sh, + debian/changelog.in, debian/control.in, resolve-debbuilddeps.sh, + resolve-rpmbuilddeps.sh: + update build system + 2016-09-30 21:55 * [r10] ChangeLog[ADD], autogen.sh[ADD], diff --git a/INSTALL b/INSTALL new file mode 120000 index 0000000..ddcdb76 --- /dev/null +++ b/INSTALL @@ -0,0 +1 @@ +/usr/share/automake-1.15/INSTALL \ No newline at end of file diff --git a/README b/README index 04c36c4..edd9e82 100644 --- a/README +++ b/README @@ -3,3 +3,21 @@ Browse Fotos in Internet and Share with Friends Expose your personal foto folder to the internet, limit users by Apache or LDAP configuration and allow users to share fotos with friends. See: https://dev.marc.waeckerlin.org/redmine/projects/sharing-gallery/wiki + +Configuration: + +/etc/gallery/password: + +Contains only a server password that is used as part of any ancryption. Keep it secret. Only the web server process should be able to read this file. + +You can generate it e.g. using: `pwgen 20 1` > /etc/gallery/password + +/etc/gallery/settings.php + +Provide path to images as `$path`, path to thumbnails as `$thumbs`. Set maximum of days a link is valid in `$max_validity_days`. + +/etc/gallery/authentication.php + +Check and verify the user, then provide `$username` if login is successful. + +/etc/gallery/usersettings.php diff --git a/ax_init_standard_project.m4 b/ax_init_standard_project.m4 index 9b78951..686c800 100644 --- a/ax_init_standard_project.m4 +++ b/ax_init_standard_project.m4 @@ -137,6 +137,8 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [ AX_SUBST(PREFIX) SYSCONFDIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${sysconfdir}") AX_SUBST(SYSCONFDIR) + PKGSYSCONFDIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${SYSCONFDIR}/${PACKAGE_NAME}") + AX_SUBST(PKGSYSCONFDIR) DATADIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${datadir}") AX_SUBST(DATADIR) PKGDATADIR=$(test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${DATADIR}/${PACKAGE_NAME}") @@ -968,9 +970,40 @@ AC_DEFUN([AX_CHECK_VALID_LD_FLAG], [ # - parameter: # $1 = package name AC_DEFUN([AX_DEB_DEPEND_IFEXISTS], [ - pkg=$1 + pkg="$1" if test -n "$(apt-cache policy -q ${pkg} 2> /dev/null)"; then - DEB_DEPEND_IFEXISTS+=", ${pkg}" + DEB_DEPEND_IFEXISTS="${DEB_DEPEND_IFEXISTS}, ${pkg}" fi +]) + +# require package in debian/control.in append @DEB_BUILD_DEPEND@ to Build-Depends +# - parameter: +# $1 = package name +AC_DEFUN([AX_DEB_BUILD_DEPEND], [ + pkg="$1" + DEB_BUILD_DEPEND="${DEB_BUILD_DEPEND}, ${pkg}" +]) + +# require package in debian/control.in append @DEB_DEPEND@ to Depends +# - parameter: +# $1 = package name +AC_DEFUN([AX_DEB_DEPEND], [ + pkg="$1" + DEB_DEPEND="${DEB_DEPEND}, ${pkg}" +]) + +# require package in debian/control.in append @DEB_DEPEND@ to Depends +# - parameter: +# $1 = package name +AC_DEFUN([AX_DEB_SECTION], [ + pkg="$1" + DEB_SECTION="${pkg}" +]) + +# call after setting debian dependencies +AC_DEFUN([AX_DEB_RESOLVE], [ + AC_SUBST(DEB_BUILD_DEPEND) + AC_SUBST(DEB_DEPEND) + AC_SUBST(DEB_SECTION) AC_SUBST(DEB_DEPEND_IFEXISTS) ]) diff --git a/bootstrap.sh b/bootstrap.sh index 1a9fb58..48b0865 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -147,6 +147,7 @@ GENERATED FILES * src/makefile.am - if you enabled AX_USE_CXX * src/version.hxx - if you enabled AX_USE_CXX * src/version.cxx - if you enabled AX_USE_CXX + * etc/makefile.am - if you enable AX_USE_ETC * html/makefile.am - if you enabled AX_BUILD_HTML * scripts/makefile.am - if you enabled AX_USE_SCRIPTS * nodejs/makefile.am - if you add AX_USE_NODEJS @@ -256,6 +257,7 @@ FILES number. In git, git rev-list --all --count is used. The following macros are supported in configure.ac: * Enable C++: AX_USE_CXX + * Enable system config files in /etc: AX_USE_ETC * Enable LibTool library creation: AX_USE_LIBTOOL * Enable Scripts: AX_USE_SCRIPTS * Enable NodeJS project: AX_USE_NODEJS @@ -569,6 +571,7 @@ AX_INIT_STANDARD_PROJECT # requirements, uncomment, what you need: #AX_USE_CXX +#AX_USE_ETC #AX_USE_LIBTOOL #AX_USE_SCRIPTS #AX_USE_NODEJS @@ -690,9 +693,13 @@ ${CHEADER}#include <${PACKAGE_NAME}.hxx> #include #include #include +#include int main(int argc, char *argv[]) try { QApplication a(argc, argv); + a.setApplicationDisplayName(a.tr("${PACKAGE_NAME}")); + a.setApplicationName(${PACKAGE_NAME}::package_name().c_str()); + a.setApplicationVersion(${PACKAGE_NAME}::version().c_str()); QCommandLineParser parser; parser.addHelpOption(); parser.process(a); @@ -725,6 +732,7 @@ class ${PackageName}: public QMainWindow, protected Ui::${PackageName} { Q_OBJECT; public: explicit ${PackageName}(QWidget *parent = 0): QMainWindow(parent) { + setTitle(tr("${PACKAGE_NAME}[*]")); setupUi(this); } virtual ~${PackageName}() {} @@ -854,6 +862,11 @@ namespace NAMESPACE { const std::string IDENT("\$Id: " PACKAGE_STRING); } EOF +to --condition AX_USE_ETC etc/makefile.am < \ No newline at end of file diff --git a/etc/makefile.am b/etc/makefile.am new file mode 100644 index 0000000..220a35f --- /dev/null +++ b/etc/makefile.am @@ -0,0 +1,13 @@ +## @id $Id$ +## +## This file has been added: +## - by bootstrap.sh +## - on Sun, 26 February 2017 11:29:20 +0100 +## Feel free to change it or even remove and rebuild it, up to your needs +## +## 1 2 3 4 5 6 7 8 +## 45678901234567890123456789012345678901234567890123456789012345678901234567890 + +pkgsysconfdir = ${sysconfdir}/@PACKAGE_NAME@ + +dist_pkgsysconf_DATA = settings.php authentication.php diff --git a/etc/settings.php b/etc/settings.php new file mode 100644 index 0000000..e0b3666 --- /dev/null +++ b/etc/settings.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/html/configuration.php.in b/html/configuration.php.in new file mode 100644 index 0000000..99259f1 --- /dev/null +++ b/html/configuration.php.in @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/html/index.php b/html/index.php index 825fa77..dabff58 100644 --- a/html/index.php +++ b/html/index.php @@ -2,6 +2,7 @@ mb_internal_encoding("utf8"); $subpath=""; $file=""; + $username=""; function error_die($reason, $status='500 Internal Server Error') { header("Expires: Tue, 01 Jan 2000 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); @@ -11,6 +12,7 @@ header('HTTP/1.0 '.$status); die('

Error: '.$status.'

'.$reason.'

'); } + require('configuration.php'); function alt(&$p1 = NULL, &$p2 = NULL, &$p3 = NULL) { if (isset($p1)) return $p1; if (isset($p2)) return $p2; @@ -57,9 +59,10 @@ } function checkPath($pathToCheck) { global $path, $subpath; - if (ereg('^[-_a-zA-Z0-9äöüÄÖÜ/]*$', $pathToCheck) && is_dir($path.'/'.$pathToCheck)) { + $fullpath = $path.'/'.$pathToCheck + if ($fullpath==realpath($fullpath) && is_dir($fullpath)) { $subpath=$pathToCheck; - $path .= '/'.$pathToCheck; + $path = $fullpath; } else { error_die('path not allowed: '.htmlentities($pathToCheck)); } @@ -153,13 +156,7 @@ makelink($link, $img, $filename); } } - $server_password=file_get_contents('/etc/gallery/password'); - require('/etc/gallery/settings.php'); - if (!$server_password) $server_password=str_shuffle(sha1(rand().time()."ashu87as")); - $username=""; if (!isset($_REQUEST['secret'])) { - require('/etc/gallery/authentication.php'); - require('/etc/gallery/usersettings.php'); if ($username=="") error_die('not authorized', '403 Forbidden'); if (isset($_REQUEST['path'])) checkPath($_REQUEST['path']); if (isset($_REQUEST['folder']) && !ereg('/', $_REQUEST['folder'])) { diff --git a/resolve-debbuilddeps.sh b/resolve-debbuilddeps.sh index 94c1ba1..30b0a5d 100755 --- a/resolve-debbuilddeps.sh +++ b/resolve-debbuilddeps.sh @@ -32,21 +32,24 @@ function install() { } TO_INSTALL= +DEPS= if test -e debian/control.in -a ! -e debian/control; then for f in $(sed -n 's, *AX_DEB_DEPEND_IFEXISTS(\([^)]*\)).*,\1,p' configure.ac); do if test -n "$(${DO} apt-cache policy -q ${f})" && ((! $(${DO} apt-cache policy ${f} 2>&1 | grep -q 'N: Unable to locate package')) && (! ${DO} dpkg -l "${f}")); then - TO_INSTALL+=" ${f}" + DEPS+=" ${f}" fi done + for f in $(sed -n 's, *AX_DEB_BUILD_DEPEND(\([^)]*\)).*,\1,p' configure.ac); do + DEPS+=" ${f}" + done trap "rm debian/control" INT TERM EXIT - sed 's,@DEB_DEPEND_IFEXISTS@,,g' debian/control.in | \ + sed 's,@\(DEB_DEPEND_IFEXISTS\|DEB_BUILD_DEPEND\|DEB_DEPEND\)@,,g' debian/control.in | \ sed 's,@[^@]*@, dummytext,g' > debian/control fi install dpkg-dev -DEPS=$(LANG= ${DO} dpkg-checkbuilddeps 2>&1 || true) -DEPS=$(echo "$DEPS" | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}') +DEPS+=" $(LANG= ${DO} dpkg-checkbuilddeps 2>&1 | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')" for pa in ${DEPS}; do if test ${pa//|/} = ${pa}; then