--- didiwiki-0.5.orig/debian/didiwiki.1 +++ didiwiki-0.5/debian/didiwiki.1 @@ -0,0 +1,76 @@ +.\" didiwiki.1 +.\" Copyright 2005 Hanna M. Wallach +.TH DIDIWIKI 1 "January 15, 2005" "" +.SH NAME +didiwiki \- simple wiki implementation with built-in webserver +.SH SYNOPSIS +.B didiwiki +.RI [ options ] +.SH DESCRIPTION +.B didiwiki +is aimed at those who need a quick and lightweight wiki for personal +use, such as notes, "to do" lists, etc. It is written in C, and has +very low system requirements (binary size of ~25k stripped). This +makes it particularly useful for handhelds. +.B didiwiki +does not require installation of a separate webserver, scripting +language, or database. + +The appearance of the wiki pages may be altered by placing a +styles.css in \fI~/.didiwiki\fR or in the directory specified using +the \fB--home\fR option. +.SH OPTIONS +.TP +\fB\-d\fR, \fB\--debug\fR +Start in debug mode. In this case, +.B didiwiki +will not bind to any IP address or port: it will only read the requests from standard input (stdin) +.TP +\fB\-h\fR \fIdirectory\fR, \fB\--home\fR=\fIdirectory\fR +By default +.B didiwiki +stores its pages in \fI~/.didiwiki\fR. You can override this by +specifying an alternative directory +.TP +\fB\-l\fR \fIipaddr\fR, \fB\--listen\fR=\fIipaddr\fR +By default +.B didiwiki +binds to "0.0.0.0". You can override this by specifying an alternative IP address +.TP +\fB\-p\fR \fIport\fR, \fB\--port\fR=\fIport\fR +By default +.B didiwiki +will listen on port \fI8000\fR. You can override this by specifying an +alternative port +.TP +\fB\--help\fR +Display the help message + +.SH EXAMPLES +.TP +\fBdidiwiki\fR uses syslog to log when it is launched or stopped, and when a page is accessed or modified. Here is an example configuration of rsyslog: +.RS +.ft 3 +.nf +.sp +$ cat /etc/rsyslog.d/didiwiki.conf +local0.* /var/log/didiwiki.log +.ft +.LP +.RE +.fi + +In order to launch \fBdidiwiki\fR on a specific IP and port: +.RS +.ft 3 +.nf +.sp +$ didiwiki \-l 127.0.0.1 \-p 8080 +.ft +.LP +.RE +.fi + +.SH AUTHOR +.B didiwiki +was written by Matthew Allum . --- didiwiki-0.5.orig/debian/README.Debian +++ didiwiki-0.5/debian/README.Debian @@ -0,0 +1,16 @@ +didiwiki for Debian +------------------- + +By default a single central copy of didiwiki is started. If instead +you'd prefer to have individual users run their own copies of +didiwiki, comment out ENABLE_DAEMON=yes in /etc/default/didiwiki. This +may be preferable on a multiuser system. + +If using a single central copy of didiwiki, the appearance of the wiki +pages can be altered by editing the stylesheet +/etc/didiwiki/styles.css. + +When run, didiwiki will listen on localhost:8000 by default. Connect +to it by pointing your web browser at http://localhost:8000. + + -- Hanna Wallach Wed, 12 Jan 2005 23:13:30 -0500 --- didiwiki-0.5.orig/debian/compat +++ didiwiki-0.5/debian/compat @@ -0,0 +1 @@ +7 --- didiwiki-0.5.orig/debian/watch +++ didiwiki-0.5/debian/watch @@ -0,0 +1,2 @@ +version=3 +# upstream URL (http://didiwiki.org/) is currently unavailable. --- didiwiki-0.5.orig/debian/didiwiki.postrm +++ didiwiki-0.5/debian/didiwiki.postrm @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e + +case "$1" in + purge) + userdel didiwiki || true + rm -f /var/run/didiwiki.pid + + if [ "`readlink /var/lib/didiwiki/styles.css`" = "/etc/didiwiki/styles.css" ] + then + rm /var/lib/didiwiki/styles.css + fi + + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- didiwiki-0.5.orig/debian/didiwiki.docs +++ didiwiki-0.5/debian/didiwiki.docs @@ -0,0 +1,2 @@ +README +TODO --- didiwiki-0.5.orig/debian/changelog +++ didiwiki-0.5/debian/changelog @@ -0,0 +1,143 @@ +didiwiki (0.5-9+deb6u1build0.12.04.1) precise-security; urgency=medium + + * fake sync from Debian + + -- Tyler Hicks Tue, 01 Mar 2016 16:41:15 -0600 + +didiwiki (0.5-9+deb6u1) squeeze-lts; urgency=high + + * Non-maintainer upload by the Squeeze LTS Team. + * thanks to Ignace Mouzannar and + Alexander Izmailov for + providing the patch for CVE-2013-7448, correcting a major security + issue allowing didiwiki to display any file on the + filesystem. (Closes: #815111) + + -- Thorsten Alteholz Mon, 22 Feb 2016 18:03:02 +0100 + +didiwiki (0.5-9) unstable; urgency=low + + * Added debian/README.source pointing to the dpatch documentation. + * Added debian/patches/90_search_engine.dpatch: + - Makes search case insensitive. + - Removes redirection to page when the search terms are identical to + a page name. + - Adds a new behaviour: if the search returns only one page, then it + redirects the user there. + Patch based on initial work provided by Carlo Mandelli + (Closes: #536484) + * Modified debian/patches/40_spelling.dpatch: + - Corrects a minor typo in src/wiki.c + * Standards-Version bumped to 3.8.3. + + -- Ignace Mouzannar Tue, 06 Oct 2009 21:08:17 +0200 + +didiwiki (0.5-8) unstable; urgency=low + + * New maintainer (Closes: #531177) + * Added access log support using syslog. + Patch provided by Carlo Mandelli (Closes: #486285) + * Added the possibility to bind to an IP address other than the default + "0.0.0.0" using the -l or --listen flags. + Patch based on initial work provided by Carlo Mandelli + (Closes: #536787) + * Completed the usage() function to print a user friendly help message + * Added the --help flag that displays the usage() message + * Added SIGINT and SIGTERM handlers in order to stop didiwiki cleanly and + log the events + * Updated the man page including the new features listed above + * Corrected a compilation warning: "pointer targets in passing argument + 3 of ‘...’ differ in signedness" (http.c:228 and http.c:510) + + -- Ignace Mouzannar Mon, 20 Jul 2009 19:19:25 +0200 + +didiwiki (0.5-7) unstable; urgency=low + + * QA upload. + * Added the '-R' option to dh_installinit in order to restart the didiwiki + service after an upgrade. And removed overlapping functions from the + didiwiki.postinst file to prevent the service from being started twice. + (Closes: #533862) + * Standards-Version bumped to 3.8.2. + * Added a patch to fix some spelling errors reported by lintian. + * Service would not start if default home (/var/lib/didiwiki) did not exist. + Added var/lib/didiwiki in the didiwiki.dirs file to fix this issue. + * Corrected ownership of /var/lib/didiwiki to didiwiki:didiwiki + * Added a commented watch file, and removed the lintian override + (debian-watch-file-is-missing) + + -- Ignace Mouzannar Sun, 21 Jun 2009 19:52:12 +0200 + +didiwiki (0.5-6) unstable; urgency=low + + * QA upload. + * Maintainer changed to QA Group. + * Add Build-depends on dpatch and patchutils. + * Rewrited didiwiki.postinst to use invoke-rc.d to comply with + the version 3.7.0 of the Policy. + * Standards-Version bumped to 3.8.1. + * Since the src/ directory had modified files without using patches, I + replaced these modified-files with the original ones and added a patch + to re-introduce these changes to keep the compatibility backwards. + This patch can be found in debian/patches/10_modified_code.dpatch. + * Removed the non-existant '-m 644' option of dh_install from + debian/rules. (Closes: #518861) + * Added a patch to fix the mangling on (unicode) wiki pages' names. + Patch provided by Alexey Khudyakov + (Closes: #420696) + * Added a patch to remove the double newline on preformatted text. + Patch provided by Neil Stockbridge (Closes: #376457) + * Added Lintian override and removed the watch file since upstream URL is + not working anymore. (Closes: #449902) + * Added a note on the copyright file regarding the "dead" upstream's URL. + (Closes: #477049) + + -- Mauro Lizaur Mon, 01 Jun 2009 00:11:31 -0300 + +didiwiki (0.5-5.1) unstable; urgency=low + + * Non-maintainer upload. + * Added LSB formatted dependency info in init.d script (closes: #468458) + * Fixed bashism in postrm (closes: #472227) + + -- Peter Eisentraut Wed, 02 Apr 2008 00:54:30 +0200 + +didiwiki (0.5-5) unstable; urgency=low + + * debian/didiwiki.postrm: Remove /var/lib/didiwiki/styles.css if it + is still a symlink to /etc/didiwiki/styles.css when the package is + purged. Closes #340121. + * Remove old FSF address from debian/copyright. Fixes + old-fsf-address-in-copyright-file Lintian warning. + + -- Hanna Wallach Fri, 24 Mar 2006 19:48:15 -0500 + +didiwiki (0.5-4) unstable; urgency=low + + * Add adduser to Depends. Fixes + maintainer-script-needs-depends-on-adduser Lintian warning. + * src/didi.c: Make didiwiki's port configurable. + * Change Standards-Version to 3.6.2. Fixes out-of-date-standards-version + Lintian warning. + + -- Hanna Wallach Sun, 28 Aug 2005 12:39:37 -0400 + +didiwiki (0.5-3) unstable; urgency=low + + * src/wiki.c: Use user-defined data as parameters to fixed format + string rather than as the format string itself (closes #302273). + + -- Hanna Wallach Wed, 30 Mar 2005 21:41:49 -0500 + +didiwiki (0.5-2) unstable; urgency=low + + * Use dh_install rather than install to install styles.css. + + -- Hanna Wallach Wed, 2 Feb 2005 00:44:19 +0000 + +didiwiki (0.5-1) unstable; urgency=low + + * Initial Release (closes #289973). + + -- Hanna Wallach Wed, 12 Jan 2005 23:13:30 -0500 + --- didiwiki-0.5.orig/debian/rules +++ didiwiki-0.5/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f + +DEB_DH_INSTALLINIT_ARGS := -R + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/autotools.mk +include /usr/share/cdbs/1/rules/dpatch.mk + +install/didiwiki:: + dh_install debian/styles.css etc/didiwiki/ --- didiwiki-0.5.orig/debian/README.source +++ didiwiki-0.5/debian/README.source @@ -0,0 +1,3 @@ +This package uses the dpatch patch management solution. +For more information about how to use it, please refer to: +/usr/share/doc/dpatch/README.source.gz --- didiwiki-0.5.orig/debian/didiwiki.dirs +++ didiwiki-0.5/debian/didiwiki.dirs @@ -0,0 +1 @@ +var/lib/didiwiki --- didiwiki-0.5.orig/debian/copyright +++ didiwiki-0.5/debian/copyright @@ -0,0 +1,28 @@ +This package was debianised by Hanna Wallach on Wed, +12 Jan 2005 23:13:30 -0500. + +It was downloaded from http://didiwiki.org/ + +Note: The upstream URL is not availabe anymore, now it's a spam-site. +This software can be downloaded from: + http://svn.o-hand.com/repos/didiwiki/trunk/ + +Upstream Authors: Matthew Allum + Carsten Graeser + +Copyright: + + Copyright (C) 2004 Matthew Allum + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License 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 GNU/Linux systems, the complete text of the GNU General +Public License can be found in '/usr/share/common-licenses/GPL-2'. --- didiwiki-0.5.orig/debian/didiwiki.postinst +++ didiwiki-0.5/debian/didiwiki.postinst @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +umask 0022 + +do_didiwiki_adduser () { + if ! getent passwd didiwiki >/dev/null; then + adduser --quiet --system --no-create-home --home /var/lib/didiwiki \ + --gecos "DidiWiki" --group didiwiki + fi + chown -R didiwiki:didiwiki /var/lib/didiwiki +} + +do_didiwiki_css () { + ln -s /etc/didiwiki/styles.css /var/lib/didiwiki/styles.css \ + 2>/dev/null || true +} + +case "$1" in + configure) + do_didiwiki_adduser + do_didiwiki_css + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- didiwiki-0.5.orig/debian/styles.css +++ didiwiki-0.5/debian/styles.css @@ -0,0 +1,88 @@ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 90%; + color: #333333; + margin: 2px; + padding: 2px; +} + +#header { + font-size: 90%; + background-color: #eef; + border: 1px solid #aaa; + font-family: Verdana, Arial, Helvetica, sans-serif; + padding: 5px; + margin-bottom:20px; +} +#header input { + margin:0px; + padding: 0; + background-color: White; + border: 1px solid #aaaaaa; + font-size: 90%; +} + +#footer { + font-size: 10px; + color: #ddd; + margin-top:40px; + width: 100%; + text-align: center; +} +table.wikitable { background-color: #fff; border: 1px solid #aaa; } +table.wikitable td { background-color: #fff; border: 1px solid #aaa; } + +pre { + font-family: monospace; + background-color: #eee; + padding: 2px; + padding-left: 10px; + margin-left: 20px; + margin-right: 20px; +} + +hr { + height: 1px; + color: #aaaaaa; + background-color: #aaaaaa; + border: 0; + margin: 0.2em 5px 0.2em 5px; +} + +form { + border: none; + margin: 0; +} + +textarea { + border: 1px solid #aaaaaa; + color: Black; + background-color: white; + width: 100%; + padding: 0.1em; + overflow: auto; +} + +input { + margin-top:1px; + padding: 0 0.4em !important; + background-color: White; + border: 1px solid #aaaaaa; +} + +a, ulink{ + color: #333; + text-decoration:none; + border-bottom: 1px #333 dotted; + display: inline; + } + +a:hover { + color: #333; + text-decoration: None; + border-bottom: 1px #000 solid; + } + +a:visited { + color: #333; +} --- didiwiki-0.5.orig/debian/didiwiki.manpages +++ didiwiki-0.5/debian/didiwiki.manpages @@ -0,0 +1 @@ +debian/didiwiki.1 --- didiwiki-0.5.orig/debian/didiwiki.default +++ didiwiki-0.5/debian/didiwiki.default @@ -0,0 +1,11 @@ +# Defaults for didiwiki initscript +# sourced by /etc/init.d/didiwiki +# installed at /etc/default/didiwiki by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# run central copy of didiwiki? +ENABLE_DAEMON=yes + --- didiwiki-0.5.orig/debian/control +++ didiwiki-0.5/debian/control @@ -0,0 +1,17 @@ +Source: didiwiki +Section: web +Priority: optional +Maintainer: Ignace Mouzannar +Build-Depends: debhelper (>= 7), cdbs, dpatch +Standards-Version: 3.8.3 + +Package: didiwiki +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, adduser +Description: simple wiki implementation with built-in webserver + DidiWiki is aimed at those who need a quick and lightweight wiki for + personal use, such as notes, "to do" lists, etc. It is written in C, + and has very low system requirements (binary size of ~25k + stripped). This makes it particularly useful for handhelds. DidiWiki + does not require installation of a separate webserver, scripting + language, or database. --- didiwiki-0.5.orig/debian/didiwiki.init +++ didiwiki-0.5/debian/didiwiki.init @@ -0,0 +1,78 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: didiwiki +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start, restart and stop Didiwiki's daemon +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/bin/didiwiki +NAME=didiwiki +DESC=didiwiki + +test -x $DAEMON || exit 0 + +# Include didiwiki defaults if available +if [ -f /etc/default/didiwiki ] ; then + . /etc/default/didiwiki +fi + +set -e + +check_enable_daemon_option() { + if [ ! "$ENABLE_DAEMON" = "yes" ]; then + echo "Not starting didiwiki, disabled via /etc/default/didiwiki" + return 1 + else + return 0 + fi +} + +case "$1" in + start) + if check_enable_daemon_option; then + echo -n "Starting $DESC: " + start-stop-daemon --start -b -m -c didiwiki --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON -- --home=/var/lib/didiwiki + echo "$NAME." + else + RET=1 + fi + ;; + stop) + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet -m -o --pidfile /var/run/$NAME.pid \ + --exec $DAEMON + echo "$NAME." + ;; + restart|force-reload) + # + # If the "reload" option is implemented, move the "force-reload" + # option to the "reload" entry above. If not, "force-reload" is + # just the same as "restart". + # + echo -n "Restarting $DESC: " + start-stop-daemon --stop -m -o --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON + sleep 1 + if check_enable_daemon_option; then + start-stop-daemon --start -b -m -c didiwiki --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON -- \ + --home=/var/lib/didiwiki + echo "$NAME." + else + RET=1 + fi + ;; + *) + N=/etc/init.d/$NAME + # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 --- didiwiki-0.5.orig/debian/patches/80_sigint_sigterm.dpatch +++ didiwiki-0.5/debian/patches/80_sigint_sigterm.dpatch @@ -0,0 +1,78 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 80_sigint.dpatch by Ignace Mouzannar +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Implementation of a SIGINT handler in order to stop didiwiki cleanly + +@DPATCH@ +diff -urNad didiwiki-0.5~/src/http.c didiwiki-0.5/src/http.c +--- didiwiki-0.5~/src/http.c 2009-07-24 17:19:53.000000000 +0200 ++++ didiwiki-0.5/src/http.c 2009-07-24 17:20:29.000000000 +0200 +@@ -442,6 +442,40 @@ + } + + /* ++** SIGINT handler. ++*/ ++ ++void ++sigint(int sig) ++{ ++ printf("\nDidiwiki stopped.\n"); ++ syslog(LOG_LOCAL0|LOG_INFO, "Didiwiki stopped.\n"); ++ ++ (void)signal(SIGINT, SIG_DFL); ++ (void)kill(getpid(), SIGINT); ++ ++ /* NOTREACHED */ ++ exit(1); ++} ++ ++/* ++** SIGTERM handler ++*/ ++void ++sigterm(int sig) ++{ ++ printf("\nDidiwiki stopped.\n"); ++ syslog(LOG_LOCAL0|LOG_INFO, "Didiwiki stopped.\n"); ++ ++ (void)signal(SIGTERM, SIG_DFL); ++ (void)kill(getpid(), SIGTERM); ++ ++ /* NOTREACHED */ ++ exit(1); ++ ++} ++ ++/* + ** Maximum number of child processes that we can have running + ** at one time before we start slowing things down. + */ +@@ -463,6 +497,12 @@ + struct sockaddr_in inaddr; /* The socket address */ + int reuse = 1; + ++ /* catch SIGINT */ ++ (void) signal(SIGINT, sigint); ++ ++ /* catch SIGTERM */ ++ (void) signal(SIGTERM, sigterm); ++ + memset(&inaddr, 0, sizeof(inaddr)); + inaddr.sin_family = AF_INET; + inaddr.sin_addr.s_addr = address.s_addr; +diff -urNad didiwiki-0.5~/src/http.h didiwiki-0.5/src/http.h +--- didiwiki-0.5~/src/http.h 2009-07-24 17:19:53.000000000 +0200 ++++ didiwiki-0.5/src/http.h 2009-07-24 17:20:53.000000000 +0200 +@@ -55,5 +55,10 @@ + void + http_response_send(HttpResponse *res); + ++void ++sigint(int sig); ++ ++void ++sigterm(int sig); + + #endif --- didiwiki-0.5.orig/debian/patches/10_modified_code.dpatch +++ didiwiki-0.5/debian/patches/10_modified_code.dpatch @@ -0,0 +1,238 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 10_modified_code.dpatch by Mauro Lizaur +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Modifies the modified code. (?) +## DP: The src/ dir had modified files directly instead of using patches, +## DP: so this (mega-)patch modifies the original (pristine) code +## DP: to keep these modifications made before. + +@DPATCH@ + +diff -Naur src-orig/didi.c src/didi.c +--- didiwiki-0.5/src-orig/didi.c 2004-07-29 10:33:47.000000000 -0300 ++++ didiwiki-0.5/src/didi.c 2009-06-01 15:47:47.000000000 -0300 +@@ -1,5 +1,7 @@ + #include "didi.h" + ++static int debug; ++ + void + usage(char *progname) + { +@@ -11,13 +13,61 @@ + { + HttpRequest *req = NULL; + int port = 8000; ++ int c; ++ char *didiwiki_home = NULL; + +- wiki_init(); ++ debug = 0; + +- if(argc > 1 && !strcmp(argv[1],"debug")) +- req = http_request_new(); /* reads request from stdin */ +- else ++ while (1) ++ { ++ static struct option long_options[] = ++ { ++ {"debug", no_argument, 0, 'd'}, ++ {"port", required_argument, 0, 'p'}, ++ {"home", required_argument, 0, 'h'}, ++ {0, 0, 0, 0} ++ }; ++ ++ /* getopt_long stores the option index here */ ++ int option_index = 0; ++ ++ c = getopt_long (argc, argv, "dp:h:", long_options, &option_index); ++ ++ /* detect the end of the options */ ++ if (c == -1) ++ break; ++ ++ switch (c) ++ { ++ case 0: ++ break; ++ ++ case 'd': ++ debug = 1; ++ break; ++ ++ case 'p': ++ port = atoi(optarg); ++ break; ++ ++ case 'h': ++ didiwiki_home = optarg; ++ break; ++ ++ default: ++ abort (); ++ } ++ } ++ ++ wiki_init(didiwiki_home); ++ ++ if (debug) ++ { ++ req = http_request_new(); /* reads request from stdin */ ++ } ++ else { + req = http_server(port); /* forks here */ ++ } + + wiki_handle_http_request(req); + +diff -Naur didiwiki-0.5/src-orig/didi.h didiwiki-0.5/src/didi.h +--- didiwiki-0.5/src-orig/didi.h 2004-09-17 07:07:12.000000000 -0300 ++++ didiwiki-0.5/src/didi.h 2009-06-01 15:47:47.000000000 -0300 +@@ -75,6 +75,7 @@ + #include + #include + #include ++#include + + #endif + +diff -Naur didiwiki-0.5/src-orig/http.c didiwiki-0.5/src/http.c +--- didiwiki-0.5/src-orig/http.c 2004-09-17 06:10:00.000000000 -0300 ++++ didiwiki-0.5/src/http.c 2009-06-01 15:47:47.000000000 -0300 +@@ -454,7 +454,6 @@ + struct timeval delay; /* How long to wait inside select() */ + struct sockaddr_in inaddr; /* The socket address */ + int reuse = 1; +- int n = 0; + + memset(&inaddr, 0, sizeof(inaddr)); + inaddr.sin_family = AF_INET; +@@ -474,33 +473,24 @@ + setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); + #endif + +- while (n < 10) ++ fprintf(stderr,"Attempting to use port %d .. ", iPort); ++ ++ inaddr.sin_port = htons(iPort); ++ ++ if( bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr)) < 0 ) + { +- fprintf(stderr,"Attempting to use port %d .. ", iPort+n); +- +- inaddr.sin_port = htons(iPort + n); +- +- if( bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr)) < 0 ) +- { +- fprintf(stderr,"Failed! \n"); +- n++; +- continue; +- } ++ fprintf(stderr,"Failed! \n"); + +- fprintf(stderr,"Success! \n"); +- break; +- } +- +- if (n == 10) +- { +- fprintf(stderr,"Can't bind to any ports, giving up.\n"); ++ fprintf(stderr,"Can't bind to port. You can specify an alternative port using the -p option.\n"); + exit(1); + } +- +- fprintf(stderr,"DidiWiki Started. Please point your browser at http://localhost:%i\n", iPort+n); +- ++ ++ fprintf(stderr,"Success! \n"); ++ ++ fprintf(stderr,"DidiWiki Started. Please point your browser at http://localhost:%i\n", iPort); ++ + listen(listener,10); +- ++ + while( 1 ) + { + if( nchildren>MAX_PARALLEL ) +diff -Naur didiwiki-0.5/src-orig/wiki.c didiwiki-0.5/src/wiki.c +--- didiwiki-0.5/src-orig/wiki.c 2004-09-30 12:15:00.000000000 -0300 ++++ didiwiki-0.5/src/wiki.c 2009-06-01 15:48:16.000000000 -0300 +@@ -1032,26 +1032,33 @@ + } + + int +-wiki_init(void) ++wiki_init(char *didiwiki_home) + { + char datadir[512] = { 0 }; +- struct stat st; ++ struct stat st; + +- if (getenv("DIDIWIKIHOME")) ++ if (didiwiki_home) + { +- snprintf(datadir, 512, getenv("DIDIWIKIHOME")); ++ snprintf(datadir, 512, "%s", didiwiki_home); + } +- else ++ else + { +- if (getenv("HOME") == NULL) ++ if (getenv("DIDIWIKIHOME")) + { +- fprintf(stderr, "Unable to get home directory, is HOME set?\n"); +- exit(1); ++ snprintf(datadir, 512, "%s", getenv("DIDIWIKIHOME")); + } +- +- snprintf(datadir, 512, "%s/.didiwiki", getenv("HOME")); +- } +- ++ else ++ { ++ if (getenv("HOME") == NULL) ++ { ++ fprintf(stderr, "Unable to get home directory, is HOME set?\n"); ++ exit(1); ++ } ++ ++ snprintf(datadir, 512, "%s/.didiwiki", getenv("HOME")); ++ } ++ } ++ + /* Check if ~/.didiwiki exists and create if not */ + if (stat(datadir, &st) != 0 ) + { +diff -Naur didiwiki-0.5/src-orig/wiki.h didiwiki-0.5/src/wiki.h +--- didiwiki-0.5/src-orig/wiki.h 2004-09-22 19:05:17.000000000 -0300 ++++ didiwiki-0.5/src/wiki.h 2009-06-01 15:47:47.000000000 -0300 +@@ -22,7 +22,7 @@ + wiki_print_data_as_html(HttpResponse *res, char *raw_page_data); + + int +-wiki_init(void); ++wiki_init(char *didiwiki_home); + + + #endif +diff -Naur didiwiki-0.5/src-orig/wikitext.h didiwiki-0.5/src/wikitext.h +--- didiwiki-0.5/src-orig/wikitext.h 2004-09-10 14:06:30.000000000 -0300 ++++ didiwiki-0.5/src/wikitext.h 2009-06-01 15:47:47.000000000 -0300 +@@ -70,13 +70,13 @@ + \ + "==Welcome to !DidiWiki\n" \ + "/!DidiWiki / is a small and simple [http://en.wikipedia.org/wiki/Wiki WikiWikiWeb]\n" \ +-"Implementaion. Its intended for personal note taking, Todo lists and any other uses you can think of.\n" \ ++"implementation. It's intended for personal note-taking, \"to do\" lists, and any other uses you can think of.\n" \ + "\n" \ + "To learn more about what a [http://www.c2.com/cgi/wiki?WikiWikiWeb WikiWikiWeb] is, read about [http://www.c2.com/cgi/wiki?WhyWikiWorks WhyWikiWorks] and the [http://www.c2.com/cgi/wiki?WikiNature WikiNature]. Also, consult the [http://www.c2.com/cgi/wiki?WikiWikiWebFaq WikiWikiWebFaq].\n" \ + "\n" \ +-"For an example how a !WikiWiki entry looks in text form you can [?edit edit] this page. Also see WikiHelp for infomation on usage and formatting rules. Use The WikiSandbox to experiment.\n" \ ++"For an example of how a !DidiWiki entry looks in text form you can [?edit edit] this page. Also see WikiHelp for infomation on usage and formatting rules. Use The WikiSandbox to experiment.\n" \ + "\n" \ +-"/!DidiWiki / is written by [mailto://mallum@o-hand.com Matthew Allum] in C and is free software, released under the [http://www.gnu.org GNU] [http://www.gnu.org/copyleft/gpl.html GPL]. It uses a formatting style similar to that of [http://www.kwiki.org kwiki] and some webserver code from [http://www.cvstrac.org cvstrac]\n" ++"/!DidiWiki / is written by [mailto://mallum@o-hand.com Matthew Allum] in C and is free software, released under the [http://www.gnu.org GNU] [http://www.gnu.org/copyleft/gpl.html GPL]. It uses a formatting style similar to that of [http://www.kwiki.org kwiki] and some webserver code from [http://www.cvstrac.org cvstrac].\n" + + + #define HELPTEXT "" \ --- didiwiki-0.5.orig/debian/patches/40_spelling.dpatch +++ didiwiki-0.5/debian/patches/40_spelling.dpatch @@ -0,0 +1,44 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 40_spelling.dpatch by Ignace Mouzannar +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Corrects spelling errors (seperated -> separated) in README file +## DP: Corrects minor typo in src/wiki.c + +@DPATCH@ +diff -urNad didiwiki-0.5~/README didiwiki-0.5/README +--- didiwiki-0.5~/README 2009-10-06 23:12:56.000000000 +0200 ++++ didiwiki-0.5/README 2009-10-06 23:14:06.000000000 +0200 +@@ -45,7 +45,7 @@ + + http://didiwiki/api/pages + +- Returns a seperated list ( one entry per line containing page ++ Returns a separated list ( one entry per line containing page + title,TAB,modified date) of wiki pages with the most recently modified + first. + +diff -urNad didiwiki-0.5~/src/wiki.c didiwiki-0.5/src/wiki.c +--- didiwiki-0.5~/src/wiki.c 2009-10-06 23:14:06.000000000 +0200 ++++ didiwiki-0.5/src/wiki.c 2009-10-06 23:15:58.000000000 +0200 +@@ -730,7 +730,7 @@ + if (expr == NULL || strlen(expr) == 0) + { + wiki_show_header(res, "Search", FALSE); +- http_response_printf(res, "No Search Terms supplied"); ++ http_response_printf(res, "No search terms supplied."); + wiki_show_footer(res); + http_response_send(res); + exit(0); +diff -urNad didiwiki-0.5~/src/wikitext.h didiwiki-0.5/src/wikitext.h +--- didiwiki-0.5~/src/wikitext.h 2009-10-06 23:14:06.000000000 +0200 ++++ didiwiki-0.5/src/wikitext.h 2009-10-06 23:14:06.000000000 +0200 +@@ -108,7 +108,7 @@ + " ---- Horizonal line\n" \ + "----\n" \ + "\n" \ +-"Paragraphs are seperated by an empty line\n" \ ++"Paragraphs are separated by an empty line\n" \ + "\n" \ + "Like this. Another paragraph.\n" \ + "\n" \ --- didiwiki-0.5.orig/debian/patches/60_bind_address.dpatch +++ didiwiki-0.5/debian/patches/60_bind_address.dpatch @@ -0,0 +1,136 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 60_bind_address.dpatch by Carlo Mandelli and Ignace Mouzannar +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Implementation of the -l|--listen option that lets you bind to a +## DP: address other than the default "0.0.0.0" + +@DPATCH@ +diff -urNad didiwiki-0.5~/src/didi.c didiwiki-0.5/src/didi.c +--- didiwiki-0.5~/src/didi.c 2009-07-23 14:33:33.000000000 +0200 ++++ didiwiki-0.5/src/didi.c 2009-07-23 14:33:33.000000000 +0200 +@@ -11,27 +11,33 @@ + int + main(int argc, char **argv) + { +- HttpRequest *req = NULL; +- int port = 8000; +- int c; +- char *didiwiki_home = NULL; ++ HttpRequest *req = NULL; ++ int port = 8000; ++ int c; ++ char *didiwiki_home = NULL; ++ struct in_addr address; ++ + + debug = 0; + ++ /* by default bind server to "0.0.0.0" */ ++ address.s_addr = inet_addr("0.0.0.0"); ++ + while (1) + { + static struct option long_options[] = + { +- {"debug", no_argument, 0, 'd'}, +- {"port", required_argument, 0, 'p'}, +- {"home", required_argument, 0, 'h'}, ++ {"debug", no_argument, 0, 'd'}, ++ {"listen", required_argument, 0, 'l'}, ++ {"port", required_argument, 0, 'p'}, ++ {"home", required_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + + /* getopt_long stores the option index here */ + int option_index = 0; + +- c = getopt_long (argc, argv, "dp:h:", long_options, &option_index); ++ c = getopt_long (argc, argv, "dl:p:h:", long_options, &option_index); + + /* detect the end of the options */ + if (c == -1) +@@ -54,6 +60,14 @@ + didiwiki_home = optarg; + break; + ++ case 'l': ++ if(inet_aton(optarg,&address) == 0) { ++ fprintf(stderr, "didiwiki: invalid ip address \"%s\"\n", optarg); ++ exit(1); ++ } else ++ address.s_addr = inet_addr(optarg); ++ break; ++ + default: + abort (); + } +@@ -66,7 +80,7 @@ + req = http_request_new(); /* reads request from stdin */ + } + else { +- req = http_server(port); /* forks here */ ++ req = http_server(address, port); /* forks here */ + } + + wiki_handle_http_request(req); +diff -urNad didiwiki-0.5~/src/http.c didiwiki-0.5/src/http.c +--- didiwiki-0.5~/src/http.c 2009-07-23 14:33:33.000000000 +0200 ++++ didiwiki-0.5/src/http.c 2009-07-23 14:34:19.000000000 +0200 +@@ -451,7 +451,7 @@ + ** Implement an HTTP server daemon. + */ + HttpRequest* +-http_server(int iPort) ++http_server(struct in_addr address, int iPort) + { + int listener; /* The server socket */ + int connection; /* A socket for each connection */ +@@ -465,7 +465,7 @@ + + memset(&inaddr, 0, sizeof(inaddr)); + inaddr.sin_family = AF_INET; +- inaddr.sin_addr.s_addr = INADDR_ANY; ++ inaddr.sin_addr.s_addr = address.s_addr; + inaddr.sin_port = htons(iPort); + listener = socket(AF_INET, SOCK_STREAM, 0); + +@@ -481,21 +481,21 @@ + setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); + #endif + +- fprintf(stderr,"Attempting to use port %d .. ", iPort); +- ++ fprintf(stderr,"Attempting to bind to %s:%i .. ", inet_ntoa(address), iPort); ++ + inaddr.sin_port = htons(iPort); + + if( bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr)) < 0 ) + { + fprintf(stderr,"Failed! \n"); + +- fprintf(stderr,"Can't bind to port. You can specify an alternative port using the -p option.\n"); ++ fprintf(stderr,"Can't bind to IP and/or port.\n"); + exit(1); + } + + fprintf(stderr,"Success! \n"); + +- fprintf(stderr,"DidiWiki Started. Please point your browser at http://localhost:%i\n", iPort); ++ fprintf(stderr,"DidiWiki Started.\n"); + + /* log starting information */ + openlog("didiwiki", 0, 0); +diff -urNad didiwiki-0.5~/src/http.h didiwiki-0.5/src/http.h +--- didiwiki-0.5~/src/http.h 2009-07-23 14:33:33.000000000 +0200 ++++ didiwiki-0.5/src/http.h 2009-07-23 14:33:33.000000000 +0200 +@@ -6,7 +6,7 @@ + typedef struct HttpRequestParam HttpRequestParam; + + HttpRequest* +-http_server(int iPort); ++http_server(struct in_addr address, int iPort); + + HttpRequest* + http_request_new(void); --- didiwiki-0.5.orig/debian/patches/00list +++ didiwiki-0.5/debian/patches/00list @@ -0,0 +1,10 @@ +10_modified_code.dpatch +20_redirect.dpatch +30_preformatted.dpatch +40_spelling.dpatch +50_accesslog.dpatch +60_bind_address.dpatch +70_usage.dpatch +80_sigint_sigterm.dpatch +90_search_engine.dpatch +91_check_page_path.dpatch --- didiwiki-0.5.orig/debian/patches/30_preformatted.dpatch +++ didiwiki-0.5/debian/patches/30_preformatted.dpatch @@ -0,0 +1,19 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 20_preformatted.dpatch by Neil Stockbridge +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Removes the double newlines in preformatted text + +@DPATCH@ + +--- didiwiki-orig/didiwiki-0.5/src/wiki.c 2009-06-01 16:16:50.000000000 -0300 ++++ didiwiki-0.5/src/wiki.c 2009-06-01 15:48:16.000000000 -0300 +@@ -249,7 +249,7 @@ + if (pre_on && !isspace(*line) && *line != '\0') + { + /* close any preformatting if already on*/ +- http_response_printf(res, "\n\n") ; ++ http_response_printf(res, "\n") ; + pre_on = 0; + } + --- didiwiki-0.5.orig/debian/patches/90_search_engine.dpatch +++ didiwiki-0.5/debian/patches/90_search_engine.dpatch @@ -0,0 +1,41 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 90_search_engine.dpatch by Carlo Mandelli and +## Ignace Mouzannar +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: - Make search case insensitive +## DP: - Removes redirection to page when search terms are identical to +## DP; a page name +## DP: - If the search returns only one page, then it redirects the user there +## DP: - This patch closes #536484 + +@DPATCH@ +diff -urNad didiwiki-0.5~/src/wiki.c didiwiki-0.5/src/wiki.c +--- didiwiki-0.5~/src/wiki.c 2009-10-06 22:47:59.000000000 +0200 ++++ didiwiki-0.5/src/wiki.c 2009-10-06 22:49:07.000000000 +0200 +@@ -662,7 +662,7 @@ + { /* Super Simple Search */ + char *data = NULL; + if ((data = file_read(namelist[n]->d_name)) != NULL) +- if (strstr(data, expr) == NULL) ++ if (strcasestr(data, expr) == NULL) + if (strcmp(namelist[n]->d_name, expr) != 0) + goto cleanup; + } +@@ -740,12 +740,12 @@ + + if (pages) + { +- for (i=0; iname, expr)) /* redirect on page name match */ +- wiki_redirect(res, pages[i]->name); +- + wiki_show_header(res, "Search", FALSE); + ++ /* if only one page is found, redirect to it */ ++ if (n_pages == 1) ++ wiki_redirect(res, pages[0]->name); ++ + for (i=0; i%s
\n", --- didiwiki-0.5.orig/debian/patches/91_check_page_path.dpatch +++ didiwiki-0.5/debian/patches/91_check_page_path.dpatch @@ -0,0 +1,89 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 91_check_page_path.dpatch by Alexander Izmailov +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Correct a major security issue allowing didiwiki to +## DP: display any file on the filesystem + +@DPATCH@ +diff -urNad didiwiki-0.5~/src/wiki.c didiwiki-0.5/src/wiki.c +--- didiwiki-0.5~/src/wiki.c 2009-07-24 17:19:53.000000000 +0200 ++++ didiwiki-0.5/src/wiki.c 2009-07-24 17:20:29.000000000 +0200 +@@ -812,6 +812,25 @@ wiki_show_footer(HttpResponse *res) + ); + } + ++int page_name_is_good(char* page_name) ++{ ++/* We should give access only to subdirs of didiwiki root. ++ I guess that check for absense of '/' is enough. ++ ++ TODO: Use realpath() ++*/ ++ if (!page_name) ++ return FALSE; ++ ++ if (!isalnum(page_name[0])) ++ return FALSE; ++ ++ if (strstr(page_name, "..")) ++ return FALSE; ++ ++ return TRUE; ++} ++ + void + wiki_handle_rest_call(HttpRequest *req, + HttpResponse *res, +@@ -827,7 +846,7 @@ wiki_handle_rest_call(HttpRequest *req, + if (page == NULL) + page = http_request_get_query_string(req); + +- if (page && (access(page, R_OK) == 0)) ++ if (page && page_name_is_good(page) && (access(page, R_OK) == 0)) + { + http_response_printf(res, "%s", file_read(page)); + http_response_send(res); +@@ -840,11 +859,14 @@ wiki_handle_rest_call(HttpRequest *req, + if( ( (wikitext = http_request_param_get(req, "text")) != NULL) + && ( (page = http_request_param_get(req, "page")) != NULL)) + { +- file_write(page, wikitext); ++ if (page_name_is_good(page)) ++ { ++ file_write(page, wikitext); + http_response_printf(res, "success"); + http_response_send(res); + return; + } ++ } + } + else if (!strcmp(func, "page/delete")) + { +@@ -853,7 +875,7 @@ wiki_handle_rest_call(HttpRequest *req, + if (page == NULL) + page = http_request_get_query_string(req); + +- if (page && (unlink(page) > 0)) ++ if (page && page_name_is_good(page) && (unlink(page) > 0)) + { + http_response_printf(res, "success"); + http_response_send(res); +@@ -867,7 +889,7 @@ wiki_handle_rest_call(HttpRequest *req, + if (page == NULL) + page = http_request_get_query_string(req); + +- if (page && (access(page, R_OK) == 0)) ++ if (page && page_name_is_good(page) && (access(page, R_OK) == 0)) + { + http_response_printf(res, "success"); + http_response_send(res); +@@ -966,7 +988,7 @@ wiki_handle_http_request(HttpRequest *re + /* A little safety. issue a malformed request for any paths, + * There shouldn't need to be any.. + */ +- if (strchr(page, '/')) ++ if (!page_name_is_good(page)) + { + http_response_set_status(res, 404, "Not Found"); + http_response_printf(res, "404 Not Found\n"); --- didiwiki-0.5.orig/debian/patches/70_usage.dpatch +++ didiwiki-0.5/debian/patches/70_usage.dpatch @@ -0,0 +1,55 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 70_usage.dpatch by Ignace Mouzannar +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Usage() function implementation + +@DPATCH@ +diff -urNad didiwiki-0.5~/src/didi.c didiwiki-0.5/src/didi.c +--- didiwiki-0.5~/src/didi.c 2009-07-23 17:38:44.000000000 +0200 ++++ didiwiki-0.5/src/didi.c 2009-07-23 17:39:32.000000000 +0200 +@@ -2,10 +2,16 @@ + + static int debug; + +-void +-usage(char *progname) +-{ +- fprintf(stderr, "usage..\n"); ++int ++usage() ++{ ++ fprintf(stderr, "Usage: didiwiki [options]\n"); ++ fprintf(stderr, " -d, --debug : debug mode, listens to requests from stdin\n"); ++ fprintf(stderr, " -h, --home : specify didiwiki's home directory\n"); ++ fprintf(stderr, " -l, --listen : specify IP address\n"); ++ fprintf(stderr, " -p, --port : specify port number \n"); ++ fprintf(stderr, " --help : display this help message\n"); ++ exit(1); + } + + int +@@ -31,6 +37,7 @@ + {"listen", required_argument, 0, 'l'}, + {"port", required_argument, 0, 'p'}, + {"home", required_argument, 0, 'h'}, ++ {"help", no_argument, 0, 10 }, + {0, 0, 0, 0} + }; + +@@ -67,9 +74,13 @@ + } else + address.s_addr = inet_addr(optarg); + break; +- ++ ++ case 10: ++ usage(); ++ break; ++ + default: +- abort (); ++ usage(); + } + } + --- didiwiki-0.5.orig/debian/patches/20_redirect.dpatch +++ didiwiki-0.5/debian/patches/20_redirect.dpatch @@ -0,0 +1,103 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 10_redirect.dpatch by Alexey Khudyakov +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Fixes unicode chars on page names + +@DPATCH@ + +diff -Naur didiwiki-0.5-deb/src/util.c didiwiki-0.5-patch/src/util.c +--- didiwiki-0.5-deb/src/util.c 2007-04-21 15:56:13.000000000 +0400 ++++ didiwiki-0.5-patch/src/util.c 2007-04-21 15:57:27.000000000 +0400 +@@ -189,3 +189,47 @@ + out[i] = 0; + return out; + } ++ ++ ++int validURIchar(char c) ++{ ++ return ++ (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || ++ c == '.' || c == '-' || c == '_' || c == '~' || c == '?'; ++ /* question mark isn't allowed character, but I'm not going ++ to encode it */ ++} ++ ++/* ++ * Encodes character which aren't allowed in URIs ++ * like %D0 ++ */ ++char urienc[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; ++char * util_httpize(const char* url) ++{ ++ /* Find length of result string */ ++ int i; ++ int len = 0; ++ for(i = 0; url[i]; ++i) { ++ if( validURIchar(url[i]) ) ++ len++; ++ else ++ len += 3; ++ } ++ char * out = malloc(sizeof(char)*(len + 1)); ++ if( out == 0 ) return 0; ++ ++ out[len]=0; ++ int j = 0; ++ for( i = 0; url[i]; ++i ) { ++ if( validURIchar(url[i]) ) ++ out[j++] = url[i]; ++ else { ++ out[j++] = '%'; ++ out[j++] = urienc[ (url[i]&0xF0) >> 4 ]; ++ out[j++] = urienc[ url[i]&0x0F ]; ++ } ++ } ++ return out; ++} ++ +diff -Naur didiwiki-0.5-deb/src/util.h didiwiki-0.5-patch/src/util.h +--- didiwiki-0.5-deb/src/util.h 2007-04-21 15:56:13.000000000 +0400 ++++ didiwiki-0.5-patch/src/util.h 2007-04-21 15:57:27.000000000 +0400 +@@ -16,5 +16,6 @@ + char * + util_htmlize(const char *in, int n); + +- ++char * ++util_httpize(const char* url); + #endif +diff -Naur didiwiki-0.5-deb/src/wiki.c didiwiki-0.5-patch/src/wiki.c +--- didiwiki-0.5-deb/src/wiki.c 2007-04-21 15:56:13.000000000 +0400 ++++ didiwiki-0.5-patch/src/wiki.c 2007-04-21 15:57:27.000000000 +0400 +@@ -555,14 +555,17 @@ + + } + +-int ++int + wiki_redirect(HttpResponse *res, char *location) + { +- int header_len = strlen(location) + 14; ++ char *location_enc = util_httpize(location); ++ ++ int header_len = strlen(location_enc) + 14; + char *header = alloca(sizeof(char)*header_len); + +- snprintf(header, header_len, "Location: %s\r\n", location); +- ++ snprintf(header, header_len, "Location: %s\r\n", location_enc); ++ free(location_enc); ++ + http_response_append_header(res, header); + http_response_printf(res, "\n

Redirect to %s

\n\n", + location); +@@ -573,6 +576,7 @@ + } + + ++ + void + wiki_show_page(HttpResponse *res, char *wikitext, char *page) + { --- didiwiki-0.5.orig/debian/patches/50_accesslog.dpatch +++ didiwiki-0.5/debian/patches/50_accesslog.dpatch @@ -0,0 +1,119 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 50_accesslog.dpatch by Carlo Mandelli +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Adds access log to didiwiki using syslog + +@DPATCH@ +diff -urNad didiwiki-0.5~/src/didi.h didiwiki-0.5/src/didi.h +--- didiwiki-0.5~/src/didi.h 2009-07-23 14:34:34.000000000 +0200 ++++ didiwiki-0.5/src/didi.h 2009-07-23 14:34:34.000000000 +0200 +@@ -76,6 +76,7 @@ + #include + #include + #include ++#include + + #endif + +diff -urNad didiwiki-0.5~/src/http.c didiwiki-0.5/src/http.c +--- didiwiki-0.5~/src/http.c 2009-07-23 14:34:34.000000000 +0200 ++++ didiwiki-0.5/src/http.c 2009-07-23 14:35:15.000000000 +0200 +@@ -30,6 +30,7 @@ + char *uri; + char *path_info; + char *query_string; ++ char *ip_src; + }; + + struct HttpResponse +@@ -170,6 +171,11 @@ + return req->query_string; + } + ++char* ++http_request_get_ip_src(HttpRequest *req) ++{ ++ return req->ip_src; ++} + + /* + * This routine handles a single HTTP request which is coming in on +@@ -182,7 +188,7 @@ + char *token, *content_type, *post_data, *z; + int i, len; + struct sockaddr_in remoteName; +- int size = sizeof(struct sockaddr_in); ++ socklen_t size = sizeof(struct sockaddr_in); + char request_line[2048]; /* A single line of input. */ + HttpRequest *req = NULL; + +@@ -225,8 +231,10 @@ + if (&token[i]) + req->query_string = strdup(&token[i]); + +- if( getpeername(fileno(stdin), (struct sockaddr*)&remoteName, &size) >=0 ) ++ if( getpeername(fileno(stdin), (struct sockaddr*)&remoteName, &size) >=0 ) { + putenv(util_mprintf("REMOTE_ADDR=%s", inet_ntoa(remoteName.sin_addr))); ++ req->ip_src = inet_ntoa(remoteName.sin_addr); ++ } + + /* Get all the optional fields that follow the first line. + */ +@@ -448,7 +456,7 @@ + int listener; /* The server socket */ + int connection; /* A socket for each connection */ + fd_set readfds; /* Set of file descriptors for select() */ +- int lenaddr; /* Length of the inaddr structure */ ++ socklen_t lenaddr; /* Length of the inaddr structure */ + int child; /* PID of the child process */ + int nchildren = 0; /* Number of child processes */ + struct timeval delay; /* How long to wait inside select() */ +@@ -488,6 +496,10 @@ + fprintf(stderr,"Success! \n"); + + fprintf(stderr,"DidiWiki Started. Please point your browser at http://localhost:%i\n", iPort); ++ ++ /* log starting information */ ++ openlog("didiwiki", 0, 0); ++ syslog(LOG_LOCAL0|LOG_INFO, "started with PID %d", getpid()); + + listen(listener,10); + +diff -urNad didiwiki-0.5~/src/http.h didiwiki-0.5/src/http.h +--- didiwiki-0.5~/src/http.h 2009-07-23 14:26:34.000000000 +0200 ++++ didiwiki-0.5/src/http.h 2009-07-23 14:34:34.000000000 +0200 +@@ -23,6 +23,8 @@ + char* + http_request_get_query_string(HttpRequest *req); + ++char* ++http_request_get_ip_src(HttpRequest *req); + + HttpResponse* + http_response_new(HttpRequest *req); +diff -urNad didiwiki-0.5~/src/wiki.c didiwiki-0.5/src/wiki.c +--- didiwiki-0.5~/src/wiki.c 2009-07-23 14:34:34.000000000 +0200 ++++ didiwiki-0.5/src/wiki.c 2009-07-23 14:34:34.000000000 +0200 +@@ -1001,13 +1001,19 @@ + /* TODO: dont blindly write wikitext data to disk */ + if ( (wikitext = http_request_param_get(req, "wikitext")) != NULL) + { +- file_write(page, wikitext); ++ file_write(page, wikitext); ++ ++ /* log modified page name and IP address */ ++ syslog(LOG_LOCAL0|LOG_INFO, "page %s modified from %s", page ,http_request_get_ip_src(req)); + } + + if (access(page, R_OK) == 0) /* page exists */ + { + wikitext = file_read(page); +- ++ ++ /* log read page name and IP address */ ++ syslog(LOG_LOCAL0|LOG_INFO, "page %s viewed from %s", page, http_request_get_ip_src(req)); ++ + if (!strcmp(command, "edit")) + { + /* print edit page */