debian/0000755000000000000000000000000011773145134007174 5ustar debian/source/0000755000000000000000000000000011730002753010464 5ustar debian/source/format0000644000000000000000000000001411730002753011672 0ustar 3.0 (quilt) debian/didiwiki.postrm0000644000000000000000000000066711730002166012236 0ustar #!/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 debian/didiwiki.docs0000644000000000000000000000002411730031333011623 0ustar README TODO AUTHORS debian/compat0000644000000000000000000000000211730002341010353 0ustar 9 debian/didiwiki.default0000644000000000000000000000053611773144704012345 0ustar # 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 # set ip address on which the daemon will listen LISTEN=127.0.0.1 # set default didiwiki home directory HOME=/var/lib/didiwiki debian/didiwiki.dirs0000644000000000000000000000002111730002166011633 0ustar var/lib/didiwiki debian/didiwiki.postinst0000644000000000000000000000123111730002166012561 0ustar #!/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 debian/changelog0000644000000000000000000001543511773145130011052 0ustar didiwiki (0.5-11) unstable; urgency=low * debian/didiwiki.preinst: - Added new file to force the stop of didiwiki before an upgrade. (Closes: 677008) * debian/didiwiki.default: - Added the $HOME variable. * debian/didiwiki.init: - Corrected the --listen flag when restarting the service. (Closes: #677007) - Corrected the --home flag. -- Ignace Mouzannar Fri, 29 Jun 2012 01:10:56 +0400 didiwiki (0.5-10) unstable; urgency=low [ Ignace Mouzannar ] * debian/didiwiki.init: - The daemon now listens by default on localhost. Thank you José Sebrosa for the patch. (Closes: #601489) * debian/didiwiki.default: - Added the LISTEN variable to listen by default on localhost. * debian/didiwiki.init: - Added Description field. - Added the 'status' option. * debian/rule: - Replaced CDBS with dh7 features. * debian/control: - Removed dependency on cdbs. - Added DM-Upload-Allowed field. * debian/source/format: - New file set to '3.0 (quilt)'. * debian/didiwiki.docs: - Added AUTHORS file. * debian/copyright: - Removed second upstream URL. [ Jari Aalto ] * Remove deprecated dpatch and upgrade to packaging format "3.0 quilt". * debian/compat - Update to 9. * debian/control - Update to Standards-Version to 3.9.3 and debhelper to 9. * debian/rules: - Added hardening flags. * debian/patches - Remove deprecated dpatch and upgrade to packaging format "3.0 quilt". (Closes: #668005) -- Ignace Mouzannar Sun, 08 Apr 2012 19:18:40 +0400 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 debian/README.Debian0000644000000000000000000000116411730002166011225 0ustar 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 debian/rules0000755000000000000000000000030711740326115010246 0ustar #!/usr/bin/make -f # -*- makefile -*- export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed %: dh $@ debian/didiwiki.preinst0000644000000000000000000000077311773143051012402 0ustar #! /bin/sh # preinst script for didiwiki set -e case "$1" in install) ;; upgrade) if [ -x "/etc/init.d/didiwiki" ]; then if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then invoke-rc.d didiwiki stop || exit $? else /etc/init.d/didiwiki stop || exit $? fi fi ;; abort-upgrade) ;; *) echo "preinst called with unknown argument '$1'" >&2 exit 1 ;; esac #DEBHELPER# exit 0 debian/patches/0000755000000000000000000000000011730004277010616 5ustar debian/patches/40_spelling.patch0000644000000000000000000000361511730002341013752 0ustar From: Ignace Mouzannar Subject: Corrects spelling errors (seperated -> separated) in README file Corrects minor typo in src/wiki.c 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" \ debian/patches/series0000644000000000000000000000027011730004274012027 0ustar 10_modified_code.patch 20_redirect.patch 30_preformatted.patch 40_spelling.patch 50_accesslog.patch 60_bind_address.patch 70_usage.patch 80_sigint_sigterm.patch 90_search_engine.patch debian/patches/80_sigint_sigterm.patch0000644000000000000000000000316111730002341015164 0ustar From: Ignace Mouzannar Subject: Implementation of a SIGINT handler in order to stop didiwiki cleanly 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 debian/patches/60_bind_address.patch0000644000000000000000000000775311730002341014567 0ustar From: Carlo Mandelli and Ignace Mouzannar Subject: Implementation of the -l|--listen option that lets you bind to a address other than the default "0.0.0.0" 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); debian/patches/70_usage.patch0000644000000000000000000000242311730002341013240 0ustar From: Ignace Mouzannar Subject: Usage() function implementation 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(); } } debian/patches/10_modified_code.patch0000644000000000000000000001704411730002341014705 0ustar From: Mauro Lizaur Subject: Modifies the modified code. (?) The src/ dir had modified files directly instead of using patches, so this (mega-)patch modifies the original (pristine) code to keep these modifications made before. 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 "" \ debian/patches/20_redirect.patch0000644000000000000000000000514211730002341013731 0ustar From: Alexey Khudyakov Subject: Fixes unicode chars on page names 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) { debian/patches/50_accesslog.patch0000644000000000000000000000757511730002341014112 0ustar From: Carlo Mandelli Subject: Adds access log to didiwiki using syslog 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 */ debian/patches/30_preformatted.patch0000644000000000000000000000073611730002341014631 0ustar From: Neil Stockbridge Subject: Removes the double newlines in preformatted text --- 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; } debian/patches/90_search_engine.patch0000644000000000000000000000225511730002341014733 0ustar From: Carlo Mandelli and Subject: - Make search case insensitive - Removes redirection to page when search terms are identical to - If the search returns only one page, then it redirects the user there - This patch closes #536484 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", debian/control0000644000000000000000000000126511740236040010572 0ustar Source: didiwiki Section: web Priority: optional Maintainer: Ignace Mouzannar DM-Upload-Allowed: yes Build-Depends: debhelper (>= 9) Standards-Version: 3.9.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. debian/didiwiki.init0000644000000000000000000000403611773144445011665 0ustar #! /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 # Description: This script starts/stops the lightweight wiki # didiwiki 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 PIDFILE=/var/run/$NAME.pid HOME=/var/lib/didiwiki test -x $DAEMON || exit 0 . /lib/lsb/init-functions # 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 \ $PIDFILE --exec $DAEMON -- --home=$HOME \ --listen=$LISTEN echo "$NAME." else RET=1 fi ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet -m -o --pidfile $PIDFILE \ --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 \ $PIDFILE --exec $DAEMON sleep 1 if check_enable_daemon_option; then start-stop-daemon --start -b -m -c didiwiki --quiet --pidfile \ $PIDFILE --exec $DAEMON -- \ --home=$HOME --listen=$LISTEN echo "$NAME." else RET=1 fi ;; status) status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? ;; *) N=/etc/init.d/$NAME # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0 debian/didiwiki.10000644000000000000000000000363511730002166011050 0ustar .\" 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 . debian/styles.css0000644000000000000000000000275111730002166011224 0ustar 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; } debian/didiwiki.install0000644000000000000000000000004311730030770012346 0ustar debian/styles.css etc/didiwiki/ debian/didiwiki.manpages0000644000000000000000000000002211730002166012466 0ustar debian/didiwiki.1 debian/README.source0000644000000000000000000000023211730002166011336 0ustar 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 debian/copyright0000644000000000000000000000176711740312322011127 0ustar 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. 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'. debian/watch0000644000000000000000000000011211730002166010205 0ustar version=3 # upstream URL (http://didiwiki.org/) is currently unavailable.