--- papercut-0.9.13.orig/TODO +++ papercut-0.9.13/TODO @@ -4,6 +4,4 @@ - Set the self.commands and self.extensions on the storage extensions, as some storages do not support all commands - MODE STREAM (it means several commands at the same time without waiting for responses) - Check more the patterns of searching (wildmat) -> backend.format_wildcards() -> Work in progress -- Fork the server to the background automatically (using fork()?) -- Make a command line option to make the server actually run on the foreground (-f option?) -- Add a --verbose flag to replace the current __DEBUG__ flag \ No newline at end of file +- Add a --verbose flag to replace the current __DEBUG__ flag --- papercut-0.9.13.orig/auth/__init__.py +++ papercut-0.9.13/auth/__init__.py @@ -1,3 +1,2 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: __init__.py,v 1.1 2002/04/04 23:10:20 jpm Exp $ --- papercut-0.9.13.orig/auth/mysql.py +++ papercut-0.9.13/auth/mysql.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: mysql.py,v 1.3 2003/04/26 00:24:55 jpm Exp $ import MySQLdb --- papercut-0.9.13.orig/auth/phorum_mysql_users.py +++ papercut-0.9.13/auth/phorum_mysql_users.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: phorum_mysql_users.py,v 1.5 2004/01/14 22:26:40 jpm Exp $ import MySQLdb --- papercut-0.9.13.orig/auth/phorum_pgsql_users.py +++ papercut-0.9.13/auth/phorum_pgsql_users.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: phorum_pgsql_users.py,v 1.3 2004/01/14 22:26:40 jpm Exp $ from pyPgSQL import PgSQL --- papercut-0.9.13.orig/auth/phpbb_mysql_users.py +++ papercut-0.9.13/auth/phpbb_mysql_users.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: phpbb_mysql_users.py,v 1.4 2003/09/19 03:11:51 jpm Exp $ import MySQLdb --- papercut-0.9.13.orig/auth/phpnuke_phpbb_mysql_users.py +++ papercut-0.9.13/auth/phpnuke_phpbb_mysql_users.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. import MySQLdb import settings --- papercut-0.9.13.orig/auth/postnuke_phpbb_mysql_users.py +++ papercut-0.9.13/auth/postnuke_phpbb_mysql_users.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: postnuke_phpbb_mysql_users.py,v 1.1 2004/08/01 01:51:48 jpm Exp $ import MySQLdb --- papercut-0.9.13.orig/debian/README.Debian +++ papercut-0.9.13/debian/README.Debian @@ -0,0 +1,11 @@ +Papercut for Debian +------------------- + + * This package ships with Papercut configured to use the Maildir storage + module. To add a newsgroup, just use something like: + mkdir -p /var/lib/papercut/maildirs/my.new.group/{new,cur,tmp} + + * To use modules interacting with MySQL, please install the python-mysqldb + package. For PostgreSQL, install python-pgsql. + + -- Jérémy Bobbio Wed, 19 Oct 2005 00:45:55 +0200 --- papercut-0.9.13.orig/debian/TODO +++ papercut-0.9.13/debian/TODO @@ -0,0 +1,34 @@ +To-do list for papercut Debian package +====================================== + +* Sort out where should custom auth and storage modules should be put. + + Original plan: + - ship an n empty directory: /usr/local/share/papercut + Problem: + - the modules must be in auth.* or storage.* + - so we need to have + /usr/local/share/papercut/{auth,storage}/__init__.py + - but this is forbidden by the policy + Test case: + echo import foo.bar > test.py + echo 'foo.bar.f()' >> test.py + mkdir foo + echo 'def f(): print "Hello"' > foo/bar.py + python test.py # fails + touch foo/__init__.py + python test.py # succeed + + Ideas: + perhaps you can create them in the postinst and remove in + postrm? or is that not allowed either? + +* Fix the manpage accordingly. +* Add how to add new modules to README.Debian. + +* Support running the daemon as an unprivilegied user. + +* Add purge of /var/lib/papercut after confirmation (with debconf) + +* Change storages to print a message asking to install the correct Debian + package if database modules fails to import. --- papercut-0.9.13.orig/debian/changelog +++ papercut-0.9.13/debian/changelog @@ -0,0 +1,103 @@ +papercut (0.9.13-7.1ubuntu1) xenial; urgency=medium + + * Merge with Debian unstable. Remaining changes: + + Suggest phpbb3 instead of phpbb2. + + -- Graham Inggs Sun, 17 Jan 2016 18:39:30 +0200 + +papercut (0.9.13-7.1) unstable; urgency=medium + + * Non-maintainer upload. + * Port from python-support to dh-python (Closes: #786011). + * Drop unnecessary XB-Python-Versions. + + -- Andrey Rahmatullin Sun, 23 Aug 2015 23:18:20 +0500 + +papercut (0.9.13-7ubuntu1) jaunty; urgency=low + + * Suggest phpbb3 instead of phpbb2. + + -- Luca Falavigna Mon, 29 Dec 2008 18:41:01 +0100 + +papercut (0.9.13-7) unstable; urgency=low + + * Fixed mysql and postgresql init dependencies (Closes: #486857) + * Fixed postinst rules. addgroup was not using --system switch (Closes: #490850) + + -- César Gómez Martín Sat, 26 Jul 2008 17:12:43 +0200 + +papercut (0.9.13-6) unstable; urgency=low + + * New maintainer (Closes: #433308) + * Bashism fixed in /etc/init.d/papercut (Closes: #468693) + * python-support moved from Build-Depends to Build-Depends-Indep + (the package is arch: all) + * Fixed debian/copyright. storage/maildir.py has an additional copyright + * Added some missing directories to papercut.dirs + + -- César Gómez Martín Wed, 13 Mar 2008 12:43:28 +0100 + +papercut (0.9.13-5) unstable; urgency=low + + * QA Group upload. + * Added debian/papercut.postinst with user/group creation. (Closes: #462864) + * Fixed debian/papercut.postrm with delete user support. + * Fixed debian/papercut.init (with user daemon support). + * Added debian/pyDaemon.py library. + * Fixed papercut script with pyDaemon.py. + * Fixed .pid file (Its uses the default directory /var/run/papercut). + * Fixed debian/README.Debian: little error typo. (Closes: #445407) + * Update Debhelper 6. + * Update Standards Version to 3.7.3. + + -- Juan Angulo Moreno Wed, 20 Feb 2008 03:29:33 -0430 + +papercut (0.9.13-4) unstable; urgency=low + + * Switch to the new Python Policy. (Closes: #380886) + + -- Jérémy Bobbio Tue, 1 Aug 2006 16:14:53 +0200 + +papercut (0.9.13-3) unstable; urgency=low + + * Fix missing import of errno in papercut module. + * Fix Build-Depends and Build-Depends-Indep wrt. policy section 7.6. + * Add missing build target in debian/rules. + * Update to dehelper 5. + * Bump Standards-Version to 3.7.2 (no changes required). + + -- Jérémy Bobbio Fri, 16 Jun 2006 04:29:49 +0200 + +papercut (0.9.13-2) unstable; urgency=low + + * Fix plain MySQL storage: CHECK is a reserved word in MySQL 4. + * Make regexps in plain MySQL storage case insensitive: this bug was + triggered by Mailman posts. + * Fix insert_id() usage in phpBB and phpNuke storage. (Closes: #338962) + * Don't mention SSL port in papercut_cfg.py. (Closes: #338959) + * Fix startup failure when enabling auth_backends, patch by Jonas + Smedegaard. (Closes: #338958) + * Improve comments on the phpBB backend. + * Overhaul of the init script and daemonization process. (Closes: #338963) + * Improve quoted-printable and other encoding support. (Closes: #340723) + * Fix newsgroup listing for the phpBB storage: it now list public forum + as well as private forums when authentication is enabled. + + -- Jérémy Bobbio Sun, 9 Apr 2006 22:22:29 +0200 + +papercut (0.9.13-1) unstable; urgency=low + + * Initial release. (Closes: #235941) + * Changes made to upstream during the packaging process: + - Remove she-bang from module source files. + - Use os.path.join more extensively avoiding potential configuation + errors for missing trailling slash. + - Add support to run in background. + - Add support for command-line options, mostly for the --foreground + option which returns papercut to original behaviour. + - Add automatic hostname detection. + - Settings now have default values overriden by local definitions. + - Fix a bug in article receiving which posted articles have multiple + line separators. + + -- Jérémy Bobbio Wed, 26 Oct 2005 01:18:46 +0200 --- papercut-0.9.13.orig/debian/compat +++ papercut-0.9.13/debian/compat @@ -0,0 +1 @@ +6 --- papercut-0.9.13.orig/debian/control +++ papercut-0.9.13/debian/control @@ -0,0 +1,35 @@ +Source: papercut +Section: news +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: César Gómez Martín +Build-Depends: debhelper (>= 6), dpatch +Build-Depends-Indep: python, dh-python, xsltproc, docbook-xsl +Standards-Version: 3.7.3 +HomePage: http://pessoal.org/papercut/ +XS-Python-Version: current + +Package: papercut +Architecture: all +Depends: ${python:Depends}, adduser +Recommends: python-mysqldb, python-pgsql +Suggests: phpbb3, mysql-server +Description: simple and extensible NNTP server + Papercut is a simple NNTP server. Its main objective is to integrate existing + web based message board software with an Usenet front-end. + . + However, using Python, new article containers can be added to store and + retrieve messages from various source and formats. + . + This package contains the following storage classes: + - Phorum web bulletin board (on MySQL or PostgreSQL), + - phpBB web bulletin board, + - PHPNuke/NukeBB web bulletin board, + - proxying another NNTP server, + - simple MySQL database, + - maildirs, + - mboxes. + . + Please note that Papercut is only a NNTP server, not a full-featured news + transport system. It does not handle newsfeeding or other usual news + software features. --- papercut-0.9.13.orig/debian/copyright +++ papercut-0.9.13/debian/copyright @@ -0,0 +1,81 @@ +This package was written by Jérémy Bobbio on +Sun, 16 Oct 2005 12:02:42 +0200. + +It was downloaded from: + + http://pessoal.org/papercut/ + +Changes: + + The docs/ directory and its content was removed: IETF RFCs are non-free + in the DFSG sense. + +Files: * +Copyright: (c) 2002-2005 Joao Prado Maia +License: public domain + + (c) 2002-2005 Joao Prado Maia + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +File: pyDaemon.py +Copyright: (C) 2005 Chad J. Schroeder +License: public domain + + (C) 2005 Chad J. Schroeder + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +File: maildir.py +Copyright: (C) 2004 Scott Parish, Joao Prado Maia +License: public domain + + (C) 2004 Scott Parish, Joao Prado Maia + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- papercut-0.9.13.orig/debian/papercut.1.xml +++ papercut-0.9.13/debian/papercut.1.xml @@ -0,0 +1,130 @@ + +Jeremy"> + Bobbio"> + October 16, 2005"> + 1"> + jeremy.bobbio@etu.upmc.fr"> + + papercut"> + + + + + GNU"> + GPL"> +]> + + + +
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2005 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + simple and extensible NNTP server + + + + &dhpackage; + + + -f + --foreground + + + + + DESCRIPTION + + This manual page documents briefly the + &dhpackage; command. + + This manual page was written for the &debian; distribution + because the original program does not have a manual page. + + &dhpackage; is a simple NNTP server. Its main + objective is to integrate existing web based message board software with + an Usenet front-end. + + However, using Python, new article containers can be added to store + and retrieve messages from various source and formats. + + Please note that Papercut is only a NNTP server, not a full-featured + news transport system. It does not handle newsfeeding or other usual + news software features. + + + + + OPTIONS + + These programs follow the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below. + + + + + + + + Show summary of options. + + + + + + + + Show version of program. + + + + + + + + Do not fork and run the process in background. + + + + + + + AUTHOR + + This manual page was written by &dhusername; &dhemail; for + the &debian; system (but may be used by others). Permission is + granted to copy, distribute and/or modify this document under + the terms of the &gnu; General Public License, Version 2 any + later version published by the Free Software Foundation. + + On Debian systems, the complete text of the GNU General Public + License can be found in /usr/share/common-licenses/GPL. + + +
+ + --- papercut-0.9.13.orig/debian/papercut.dirs +++ papercut-0.9.13/debian/papercut.dirs @@ -0,0 +1,14 @@ +/etc/papercut +/usr/bin +/usr/share/papercut +/usr/share/papercut/auth +/usr/share/papercut/storage +/var/cache/papercut +/var/lib/papercut +/var/lib/papercut/maildirs +/var/lib/papercut/maildirs/test +/var/lib/papercut/maildirs/test/tmp +/var/lib/papercut/maildirs/test/cur +/var/lib/papercut/maildirs/test/new +/var/lib/papercut/mboxes +/var/log --- papercut-0.9.13.orig/debian/papercut.docs +++ papercut-0.9.13/debian/papercut.docs @@ -0,0 +1,6 @@ +README +TODO +storage/mysql_storage.sql +storage/phorum_pgsql_fix.sql +storage/phorum_mysql_fix.sql +storage/phpbb_mysql_fix.sql --- papercut-0.9.13.orig/debian/papercut.init +++ papercut-0.9.13/debian/papercut.init @@ -0,0 +1,78 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: papercut +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Should-Start: mysql postgresql +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Papercut NNTP server +# Description: Papercut is a simple and extensible NNTP server, meant +# to provide news access to existing content, e.g. web based +# bulletin board systems. +### END INIT INFO +# +# Author: Jérémy Bobbio . +# Rewrite by: Juan Angulo Moreno and César Gómez Martín +# + + +NAME=papercut +PATH=/bin:/usr/bin:/sbin:/usr/sbin +DAEMON=/usr/bin/papercut +PIDFILE=/var/run/$NAME/$NAME.pid + + +trap "" 1 +export LANG=C +export PATH + +test -f $DAEMON || exit 0 + + +case "$1" in + start) + echo "Starting papercut detection : $NAME" + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --exec $DAEMON --chuid papercut || true && + echo "." || + echo " failed!" + ;; + + stop) + echo "Stopping papercut detection : $NAME" + start-stop-daemon --stop --quiet --pidfile $PIDFILE && + rm -f /var/run/papercut/papercut.pid + echo "." || + echo " not running." + ;; + + reload-config) + echo "Reloading $NAME configuration" + start-stop-daemon --stop --signal HUP --exec $DAEMON + ;; + + restart-papercut) + echo "Restarting $NAME" + $0 stop + $0 start + ;; + + restart|force-reload) + $0 restart-papercut + exit $? + ;; + + *) + echo "Usage: /etc/init.d/$NAME {start|stop|reload-config|restart|force-reload}" + exit 1 + ;; +esac + +if [ $? = 0 ]; then + echo . + exit 0 +else + echo failed + exit 1 +fi --- papercut-0.9.13.orig/debian/papercut.logrotate +++ papercut-0.9.13/debian/papercut.logrotate @@ -0,0 +1,9 @@ +/var/log/papercut.log { + daily + missingok + rotate 7 + compress + copytruncate + notifempty + create 640 root adm +} --- papercut-0.9.13.orig/debian/papercut.manpages +++ papercut-0.9.13/debian/papercut.manpages @@ -0,0 +1 @@ +papercut.1 --- papercut-0.9.13.orig/debian/papercut.postinst +++ papercut-0.9.13/debian/papercut.postinst @@ -0,0 +1,65 @@ +#!/bin/sh + +set -e + +DATA_DIR="/var/lib/papercut" +MAILDIR_STORAGE_DIR="$DATA_DIR/maildirs" + +case "$1" in + configure) + # Create a default test group for the mbox storage + if [ ! -e "$DATA_DIR/.test_created" ]; then + mkdir -p "$MAILDIR_STORAGE_DIR/test/tmp" + mkdir -p "$MAILDIR_STORAGE_DIR/test/cur" + mkdir -p "$MAILDIR_STORAGE_DIR/test/new" + touch "$DATA_DIR/.test_created" + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + + +add_group_if_missing() { + if [ -x /usr/sbin/addgroup ]; then + if ! id -g papercut >/dev/null 2>&1; then + addgroup --system --force-badname papercut || true + fi + fi +} + +add_user_if_missing() { + if [ -x /usr/sbin/adduser ]; then + if ! id -u papercut > /dev/null 2>&1; then + adduser --system --no-create-home \ + --disabled-password \ + --force-badname papercut \ + --ingroup papercut + fi + fi +} + +create_pid_file(){ + if ! [ -d /var/run/papercut ]; then + mkdir /var/run/papercut + touch /var/run/papercut/papercut.pid + fi + chown papercut:papercut -R /var/run/papercut +} + +add_group_if_missing +add_user_if_missing +create_pid_file + + +#DEBHELPER# + +exit 0 + +# vim: set et sw=4 --- papercut-0.9.13.orig/debian/papercut.postrm +++ papercut-0.9.13/debian/papercut.postrm @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +case "$1" in + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + purge) + rm -rf /var/cache/papercut + rm -rf /var/run/papercut + rm -rf /var/lib/papercut + userdel papercut || true + ;; + + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 0 + +esac + +#DEBHELPER# + +exit 0 + +# vim: et sw=4 --- papercut-0.9.13.orig/debian/papercut_cfg.py +++ papercut-0.9.13/debian/papercut_cfg.py @@ -0,0 +1,170 @@ +# Configuration file for Papercut. +# +# Settings in this file override those in +# /usr/share/papercut/default_settings.py. + +# +# SERVER CONFIGURATION +# + +# hostname that Papercut will bind against +# (by default, this is automacally detected) +#nntp_hostname = 'news.example.com' +# usually 119 +#nntp_port = 119 + +# what is the maximum number of concurrent connections that should be allowed +#max_connections = 20 + +# type of server ('read-only' or 'read-write') +#server_type = 'read-write' + + +# +# CACHE SYSTEM +# + +# the cache system may need a lot of diskspace +#nntp_cache = 'yes' +# cache expire (in seconds) +#nntp_cache_expire = 60 * 60 * 3 + + +# +# MAILDIR STORAGE +# +# To add a new group: +# mkdir -p /var/lib/papercut/maildirs/my.new.group/{new,cur,tmp} + +storage_backend = 'maildir' + +# the full path for where the mbox files are stored in +# (default path was created by the Debian package) +maildir_path = "/var/lib/papercut/maildirs" + +# +# FORWARDING PROXY +# + +#storage_backend = "forwarding_proxy" + +# remote nntp server +#forward_host = 'news.example.com' + + +# +# PHORUM +# +# Please note that you have to change your database schema by doing: +# mysql [-h ] -u -p \ +# < /usr/share/doc/papercut/phorum_mysql_fix.sql +# or +# psql [-h -U \ +# -f /usr/share/doc/papercut/phorum_pgsql_fix.sql +# +# Also don't forget to install python-mysqldb or python-pgsql packages. + +# use of of them, depending on your database +#storage_backend = "phorum_mysql" +#storage_backend = "phorum_pgsql" + +# enable authentication +#nntp_auth = 'yes' +#auth_backend = 'phorum_mysql_users.py' +#auth_backend = 'phorum_pgsql_users.py' + +# full path to the directory where the Phorum configuration files are stored +#phorum_settings_path = "/var/www/phorum/phorum_settings" +# the version for the installed copy of Phorum +#phorum_version = "3.3.2a" + +# database connection variables +#dbhost = "localhost" +#dbname = "phorum" +#dbuser = "root" +#dbpass = "" + + +# +# PHPBB +# +# To use this storage backend, you first need to update your database schema +# by doing: +# mysql [-h ] -u -p \ +# < /usr/share/doc/papercut/phpbb_mysql_fix.sql +# +# Then, edit the nntp_group_name field for each forums in the forums +# table. +# +# Also, don't forget to install the python-mysqldb package. + +#storage_backend = "phpbb_mysql" + +# enable authentication +#nntp_auth = 'yes' +#auth_backend = 'phpbb_mysql_users' + +# database connection variables +#dbhost = "localhost" +#dbname = "phpbb2" +#dbuser = "root" +#dbpass = "" + +# the prefix for the phpBB tables +#phpbb_table_prefix = "phpbb_" + + +# +# PHPNUKE PHPBB +# + +#storage_backend = 'phpnuke_phpbb_mysql' + +# enable authentication +#nntp_auth = 'yes' +#auth_backend = 'phpnuke_phpbb_mysql_users' +#auth_backend = 'postnuke_phpbb_mysql_users' + +# database connection variables +#dbhost = "localhost" +#dbname = "phpnuke" +#dbuser = "root" +#dbpass = "" + +# prefix for the nuke tables +#nuke_table_prefix = "nuke_" + +# prefix for the phpBB tables +#phpbb_table_prefix = "nuke_bb" + + +# +# STANDALONE MYSQL STORAGE +# +# Please create the database schema with: +# mysql [-h ] -u -p \ +# < /usr/share/doc/papercut/mysql_storage.sql +# Don't forget to install python-mysqldb. + +# storage_backend = 'mysql' + +# database connection variables +#dbhost = "localhost" +#dbname = "phpnuke" +#dbuser = "root" +#dbpass = "" + + +# +# MBOX STORAGE +# +# This storage is currently read-only. To create a new group, just link or +# copy the required mbox in the path set below. + +#storage_backend = 'mbox' + +# the full path for where the mbox files are stored in +# (default path was created by the Debian package) +#mbox_path = "/var/lib/papercut/mboxes" + + --- papercut-0.9.13.orig/debian/patches/00list +++ papercut-0.9.13/debian/patches/00list @@ -0,0 +1 @@ +01_papercut.py_rewrite_daemon.dpatch --- papercut-0.9.13.orig/debian/patches/01_papercut.py_rewrite_daemon.dpatch +++ papercut-0.9.13/debian/patches/01_papercut.py_rewrite_daemon.dpatch @@ -0,0 +1,57 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 01_papercut.py_rewrite_daemon.dpatch by Juan Angulo Moreno +## +## DP: Rewrite funtions papercut daemon + +@DPATCH@ +diff -urNad papercut-0.9.13~/papercut.py papercut-0.9.13/papercut.py +--- papercut-0.9.13~/papercut.py 2008-02-21 18:27:30.000000000 -0430 ++++ papercut-0.9.13/papercut.py 2008-02-21 18:29:20.000000000 -0430 +@@ -19,6 +19,7 @@ + # papercut based modules + import settings + import papercut_cache ++import pyDaemon + + __VERSION__ = '0.9.13' + # set this to 0 (zero) for real world use +@@ -887,7 +888,7 @@ + + def is_process_running(pid): + try: +- os.kill(pid, 0) ++ #os.kill(pid, 0) + return True + except OSError, e: + if e.errno != errno.ESRCH: +@@ -953,27 +954,10 @@ + ip_address = "127.0.0.1" + + if options.background: +- try: +- pid = os.fork() +- if pid > 0: +- # Exit first parent +- sys.exit(0) +- except OSError, e: +- print >>sys.stderr, "fork failed: %d (%s)" % (e.errno, e.strerror) +- sys.exit(1) +- +- # write PID ++ pyDaemon.createDaemon() + write_pid(os.getpid()) +- +- # unlink parent environment +- fp = open('/dev/null', 'rw') +- sys.stdin = sys.__stdin__ = fp +- sys.stdout = sys.__stdout__ = fp +- sys.stderr = sys.__stderr__ = fp +- del fp +- os.chdir('/') +- os.setsid() +- os.umask(0) ++ while 1: ++ time.sleep(5) + + else: # foreground + write_pid(os.getpid()) --- papercut-0.9.13.orig/debian/pyDaemon.py +++ papercut-0.9.13/debian/pyDaemon.py @@ -0,0 +1,208 @@ +"""Disk And Execution MONitor (Daemon) +http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 + +Configurable daemon behaviors: + + 1.) The current working directory set to the "/" directory. + 2.) The current file creation mode mask set to 0. + 3.) Close all open files (1024). + 4.) Redirect standard I/O streams to "/dev/null". + +A failed call to fork() now raises an exception. + +References: + 1) Advanced Programming in the Unix Environment: W. Richard Stevens + 2) Unix Programming Frequently Asked Questions: + http://www.erlenstar.demon.co.uk/unix/faq_toc.html +""" + +__author__ = "Chad J. Schroeder" +__copyright__ = "Copyright (C) 2005 Chad J. Schroeder" + +__revision__ = "$Id$" +__version__ = "0.2" + +# Standard Python modules. +import os # Miscellaneous OS interfaces. +import sys # System-specific parameters and functions. + +# Default daemon parameters. +# File mode creation mask of the daemon. +UMASK = 0 + +# Default working directory for the daemon. +WORKDIR = "/" + +# Default maximum for the number of available file descriptors. +MAXFD = 1024 + +# The standard I/O file descriptors are redirected to /dev/null by default. +if (hasattr(os, "devnull")): + REDIRECT_TO = os.devnull +else: + REDIRECT_TO = "/dev/null" + +def createDaemon(): + """Detach a process from the controlling terminal and run it in the + background as a daemon. + """ + + try: + # Fork a child process so the parent can exit. This returns control to + # the command-line or shell. It also guarantees that the child will not + # be a process group leader, since the child receives a new process ID + # and inherits the parent's process group ID. This step is required + # to insure that the next call to os.setsid is successful. + pid = os.fork() + except OSError, e: + raise Exception, "%s [%d]" % (e.strerror, e.errno) + + if (pid == 0): # The first child. + # To become the session leader of this new session and the process group + # leader of the new process group, we call os.setsid(). The process is + # also guaranteed not to have a controlling terminal. + os.setsid() + + # Is ignoring SIGHUP necessary? + # + # It's often suggested that the SIGHUP signal should be ignored before + # the second fork to avoid premature termination of the process. The + # reason is that when the first child terminates, all processes, e.g. + # the second child, in the orphaned group will be sent a SIGHUP. + # + # "However, as part of the session management system, there are exactly + # two cases where SIGHUP is sent on the death of a process: + # + # 1) When the process that dies is the session leader of a session that + # is attached to a terminal device, SIGHUP is sent to all processes + # in the foreground process group of that terminal device. + # 2) When the death of a process causes a process group to become + # orphaned, and one or more processes in the orphaned group are + # stopped, then SIGHUP and SIGCONT are sent to all members of the + # orphaned group." [2] + # + # The first case can be ignored since the child is guaranteed not to have + # a controlling terminal. The second case isn't so easy to dismiss. + # The process group is orphaned when the first child terminates and + # POSIX.1 requires that every STOPPED process in an orphaned process + # group be sent a SIGHUP signal followed by a SIGCONT signal. Since the + # second child is not STOPPED though, we can safely forego ignoring the + # SIGHUP signal. In any case, there are no ill-effects if it is ignored. + # + # import signal # Set handlers for asynchronous events. + # signal.signal(signal.SIGHUP, signal.SIG_IGN) + + try: + # Fork a second child and exit immediately to prevent zombies. This + # causes the second child process to be orphaned, making the init + # process responsible for its cleanup. And, since the first child is + # a session leader without a controlling terminal, it's possible for + # it to acquire one by opening a terminal in the future (System V- + # based systems). This second fork guarantees that the child is no + # longer a session leader, preventing the daemon from ever acquiring + # a controlling terminal. + pid = os.fork() # Fork a second child. + except OSError, e: + raise Exception, "%s [%d]" % (e.strerror, e.errno) + + if (pid == 0): # The second child. + # Since the current working directory may be a mounted filesystem, we + # avoid the issue of not being able to unmount the filesystem at + # shutdown time by changing it to the root directory. + os.chdir(WORKDIR) + # We probably don't want the file mode creation mask inherited from + # the parent, so we give the child complete control over permissions. + os.umask(UMASK) + else: + # exit() or _exit()? See below. + os._exit(0) # Exit parent (the first child) of the second child. + else: + # exit() or _exit()? + # _exit is like exit(), but it doesn't call any functions registered + # with atexit (and on_exit) or any registered signal handlers. It also + # closes any open file descriptors. Using exit() may cause all stdio + # streams to be flushed twice and any temporary files may be unexpectedly + # removed. It's therefore recommended that child branches of a fork() + # and the parent branch(es) of a daemon use _exit(). + os._exit(0) # Exit parent of the first child. + + # Close all open file descriptors. This prevents the child from keeping + # open any file descriptors inherited from the parent. There is a variety + # of methods to accomplish this task. Three are listed below. + # + # Try the system configuration variable, SC_OPEN_MAX, to obtain the maximum + # number of open file descriptors to close. If it doesn't exists, use + # the default value (configurable). + # + # try: + # maxfd = os.sysconf("SC_OPEN_MAX") + # except (AttributeError, ValueError): + # maxfd = MAXFD + # + # OR + # + # if (os.sysconf_names.has_key("SC_OPEN_MAX")): + # maxfd = os.sysconf("SC_OPEN_MAX") + # else: + # maxfd = MAXFD + # + # OR + # + # Use the getrlimit method to retrieve the maximum file descriptor number + # that can be opened by this process. If there is not limit on the + # resource, use the default value. + # + import resource # Resource usage information. + maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] + if (maxfd == resource.RLIM_INFINITY): + maxfd = MAXFD + + # Iterate through and close all file descriptors. + for fd in range(0, maxfd): + try: + os.close(fd) + except OSError: # ERROR, fd wasn't open to begin with (ignored) + pass + + # Redirect the standard I/O file descriptors to the specified file. Since + # the daemon has no controlling terminal, most daemons redirect stdin, + # stdout, and stderr to /dev/null. This is done to prevent side-effects + # from reads and writes to the standard I/O file descriptors. + + # This call to open is guaranteed to return the lowest file descriptor, + # which will be 0 (stdin), since it was closed above. + os.open(REDIRECT_TO, os.O_RDWR) # standard input (0) + + # Duplicate standard input to standard output and standard error. + os.dup2(0, 1) # standard output (1) + os.dup2(0, 2) # standard error (2) + + return(0) + +if __name__ == "__main__": + + retCode = createDaemon() + + # The code, as is, will create a new file in the root directory, when + # executed with superuser privileges. The file will contain the following + # daemon related process parameters: return code, process ID, parent + # process group ID, session ID, user ID, effective user ID, real group ID, + # and the effective group ID. Notice the relationship between the daemon's + # process ID, process group ID, and its parent's process ID. + + procParams = """ + return code = %s + process ID = %s + parent process ID = %s + process group ID = %s + session ID = %s + user ID = %s + effective user ID = %s + real group ID = %s + effective group ID = %s + """ % (retCode, os.getpid(), os.getppid(), os.getpgrp(), os.getsid(0), + os.getuid(), os.geteuid(), os.getgid(), os.getegid()) + + open("createDaemon.log", "w").write(procParams + "\n") + + sys.exit(retCode) --- papercut-0.9.13.orig/debian/rules +++ papercut-0.9.13/debian/rules @@ -0,0 +1,78 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This package uses dpatch. +#include /usr/share/dpatch/dpatch.make + +DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl +XP=xsltproc -''-nonet + +papercut.1: debian/papercut.1.xml + $(XP) -o $@ $(DB2MAN) $< + +clean: clean-patched unpatch +clean-patched: + dh_testdir + dh_testroot + rm -rf *.py[co] auth/*.py[co] storage/*.py[co] + rm -f papercut.1 + dh_clean + +patch: patch-stamp +patch-stamp: + dpatch apply-all +#dpatch call-all -a=pkg-info >patch-stamp + +unpatch: + dpatch deapply-all + rm -rf patch-stamp debian/patched + +build: patch + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + install -m 0755 papercut.py \ + $(CURDIR)/debian/papercut/usr/bin/papercut + install -m 0644 papercut_cache.py portable_locker.py settings.py \ + $(CURDIR)/debian/papercut/usr/share/papercut + install -m 0644 default_settings.py \ + $(CURDIR)/debian/papercut/usr/share/papercut + install -m 0644 auth/*.py \ + $(CURDIR)/debian/papercut/usr/share/papercut/auth + install -m 0644 storage/*.py \ + $(CURDIR)/debian/papercut/usr/share/papercut/storage + install -m 0644 debian/papercut_cfg.py \ + $(CURDIR)/debian/papercut/etc/papercut + install -m 0644 debian/pyDaemon.py \ + $(CURDIR)/debian/papercut/usr/share/papercut + sed -i -e 's~/var/run/papercut.pid~/var/run/papercut/papercut.pid~g' \ + $(CURDIR)/debian/papercut/usr/share/papercut/default_settings.py + +binary-indep: build install papercut.1 + dh_testdir + dh_testroot + dh_python2 /usr/share/papercut /usr/share/papercut/auth \ + /usr/share/papercut/storage + dh_installchangelogs + dh_installdocs + dh_installlogrotate + dh_installinit + dh_installman + dh_compress + dh_fixperms + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: build install + +binary: binary-indep binary-arch + +.PHONY: build clean binary-indep binary-arch binary install + --- papercut-0.9.13.orig/debian/watch +++ papercut-0.9.13/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://pessoal.org/papercut/papercut-(.*).tar.gz --- papercut-0.9.13.orig/default_settings.py +++ papercut-0.9.13/default_settings.py @@ -0,0 +1,143 @@ +# Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. +# $Id: settings.py,v 1.18 2004/08/01 01:03:22 jpm Exp $ +import time +import sys +import os +import os.path + +# +# The following configuration settings should be pretty self-explanatory, but +# please let me know if this is not complete or if more information / examples +# are needed. +# + + +# what is the maximum number of concurrent connections that should be allowed +max_connections = 20 + + +# +# GENERAL PATH INFORMATION +# + +# full path for where Papercut will store the log file +log_path = "/var/log" +# the actual log filename +log_file = os.path.join(log_path, "papercut.log") + +# full path for pid file +pid_file = "/var/run/papercut.pid" + +# +# HOSTNAME / PORT OF THE SERVER +# + +# hostname that Papercut will bind against - unset in order to trigger +# autodetection during start up +nntp_hostname = None +# usually 119, but use 563 for an SSL server +nntp_port = 119 + +# type of server ('read-only' or 'read-write') +server_type = 'read-write' + + +# +# NNTP AUTHENTICATION SUPPORT +# + +# does the server need authentication ? ('yes' or 'no') +nntp_auth = 'no' +# backend that Papercut will use to authenticate the users +auth_backend = '' +# ONLY needed for phorum_mysql_users auth module +PHP_CRYPT_SALT_LENGTH = 2 + + +# +# CACHE SYSTEM +# + +# the cache system may need a lot of diskspace ('yes' or 'no') +nntp_cache = 'no' +# cache expire (in seconds) +nntp_cache_expire = 60 * 60 * 3 +# path to where the cached files should be kept +nntp_cache_path = '/var/cache/papercut' + + +# +# STORAGE MODULE +# + +# backend that Papercut will use to get (and store) the actual articles content +#storage_backend = "mbox" + +# +# FORWARDING_PROXY STORAGE MODULE OPTIONS +# + +# remote nntp server +forward_host = 'news' + + +# +# PHORUM STORAGE MODULE OPTIONS +# + +# full path to the directory where the Phorum configuration files are stored +phorum_settings_path = "/var/www/phorum/phorum_settings" +# the version for the installed copy of Phorum +phorum_version = "3.3.2a" + +# database connection variables +dbhost = "localhost" +dbname = "phorum" +dbuser = "root" +dbpass = "" + + +# +# PHPBB STORAGE MODULE OPTIONS +# + +# the prefix for the phpBB tables +phpbb_table_prefix = "phpbb_" + + +# +# PHPNUKE PHPBB STORAGE MODULE OPTIONS +# + +# if you're running PHPNuke, set this for the nuke tables and phpbb_table_prefix +# for the bb tables. +nuke_table_prefix = "nuke_" + +# the prefix for the phpBB tables +phpbb_table_prefix = "nuke_bb" + + +# +# MBOX STORAGE MODULE OPTIONS +# + +# the full path for where the mbox files are stored in +mbox_path = "/var/lib/papercut/mboxes" + + +# +# MAILDIR STORAGE MODULE OPTIONS +# + +# the full path for where the mbox files are stored in +maildir_path = "/var/lib/papercut/maildirs" + + +# helper function to log information +def logEvent(msg): + f = open(log_file, "a") + f.write("[%s] %s\n" % (time.strftime("%a %b %d %H:%M:%S %Y", + time.gmtime()), msg)) + f.close() + +# vim: et sw=4 --- papercut-0.9.13.orig/papercut.py +++ papercut-0.9.13/papercut.py @@ -1,6 +1,9 @@ #!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: papercut.py,v 1.93 2005/03/05 04:06:54 jpm Exp $ +import atexit +import errno +import socket import SocketServer import sys import os @@ -9,6 +12,9 @@ import re import traceback import StringIO +from optparse import OptionParser + +sys.path = ['/usr/share/papercut'] + sys.path # papercut based modules import settings @@ -772,7 +778,7 @@ 440 posting not allowed 441 posting failed """ - lines = "\r\n".join(self.article_lines) + lines = "".join(self.article_lines) # check the 'Newsgroups' header group_name = newsgroups_regexp.search(lines, 0).groups()[0].strip() if not backend.group_exists(group_name): @@ -870,6 +876,47 @@ time.sleep(1) sys.exit(0) + def exit_cleanup(): + if os.path.exists(settings.pid_file): + os.unlink(settings.pid_file) + + def write_pid(pid): + fp = open(settings.pid_file, 'w') + fp.write("%d\n" % pid) + fp.close() + + def is_process_running(pid): + try: + os.kill(pid, 0) + return True + except OSError, e: + if e.errno != errno.ESRCH: + raise + else: + return False + + parser = OptionParser(version="%%prog %s" % __VERSION__) + parser.add_option("-f", "--foreground", action="store_false", + dest="background", default=True, + help="don't run in background") + (options, args) = parser.parse_args() + + if len(args) > 0: + parser.print_help() + sys.exit(1) + + # check for another papercut running + if os.path.exists(settings.pid_file): + try: + old_pid = int(open(settings.pid_file).read().strip()) + if is_process_running(old_pid): + print >>sys.stderr, "\npapercut seems to be already running." + sys.exit(1) + except ValueError, e: + pass + os.unlink(settings.pid_file) + print >>sys.stderr, "\nWarning: stale pid file removed." + # dynamic loading of the appropriate storage backend module temp = __import__('storage.%s' % (settings.storage_backend), globals(), locals(), ['Papercut_Storage']) if settings.nntp_cache == 'yes': @@ -879,10 +926,69 @@ # now for the authentication module, if needed if settings.nntp_auth == 'yes': + # check for the appropriate configuration + if settings.auth_backend == '': + sys.exit("Please configure the 'nntp_auth' and 'auth_backend' " + + "options correctly and restart Papercut.") temp = __import__('auth.%s' % (settings.auth_backend), globals(), locals(), ['Papercut_Auth']) auth = temp.Papercut_Auth() + if not settings.nntp_hostname: + try: + settings.nntp_hostname = socket.gethostname() + except: + print >>sys.stderr, ( + "Unable to determine hostname. Using 127.0.0.1 as a " + + "fallback. Please set nntp_hostname in " + + "/etc/papercut/settings.py.") + settings.nntp_hostname = "127.0.0.1" + + try: + ip_address = socket.gethostbyname(settings.nntp_hostname) + except: + print >>sys.stderr, ( + "Unable to lookup %s. Using 127.0.0.1 as a " + + "fallback. Please check nntp_hostname in " + + "/etc/papercut/settings.py." % settings.nntp_hostname) + ip_address = "127.0.0.1" + + if options.background: + try: + pid = os.fork() + if pid > 0: + # Exit first parent + sys.exit(0) + except OSError, e: + print >>sys.stderr, "fork failed: %d (%s)" % (e.errno, e.strerror) + sys.exit(1) + + # write PID + write_pid(os.getpid()) + + # unlink parent environment + fp = open('/dev/null', 'rw') + sys.stdin = sys.__stdin__ = fp + sys.stdout = sys.__stdout__ = fp + sys.stderr = sys.__stderr__ = fp + del fp + os.chdir('/') + os.setsid() + os.umask(0) + + else: # foreground + write_pid(os.getpid()) + + settings.logEvent( + 'Papercut %s (%s storage module) - starting up (PID: %d)' + % (__VERSION__, settings.storage_backend, os.getpid())) + + # register signal handler + signal.signal(signal.SIGTERM, sighandler) signal.signal(signal.SIGINT, sighandler) - print 'Papercut %s (%s storage module) - starting up' % (__VERSION__, settings.storage_backend) - server = NNTPServer((settings.nntp_hostname, settings.nntp_port), NNTPRequestHandler) + signal.signal(signal.SIGQUIT, sighandler) + # register cleanup function + atexit.register(exit_cleanup) + + server = NNTPServer((ip_address, settings.nntp_port), + NNTPRequestHandler) server.serve_forever() --- papercut-0.9.13.orig/papercut_cache.py +++ papercut-0.9.13/papercut_cache.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: papercut_cache.py,v 1.7 2002/10/04 03:14:38 jpm Exp $ @@ -6,6 +5,7 @@ import md5 import time import os +import os.path import cPickle import portable_locker # papercut settings file @@ -72,7 +72,8 @@ def _get_filename(self, *args, **kwds): arguments = '%s%s%s' % (self.name, args, kwds) - return '%s%s' % (settings.nntp_cache_path, binascii.hexlify(md5.new(arguments).digest())) + return os.path.join(settings.nntp_cache_path, + binascii.hexlify(md5.new(arguments).digest())) class Cache: --- papercut-0.9.13.orig/portable_locker.py +++ papercut-0.9.13/portable_locker.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # $Id: portable_locker.py,v 1.2 2002/10/03 01:05:24 jpm Exp $ # Note: this was originally from Python Cookbook, which was @@ -8,6 +7,7 @@ # needs win32all to work on Windows if os.name == 'nt': + """ import win32con, win32file, pywintypes LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK LOCK_SH = 0 # the default @@ -21,6 +21,7 @@ def unlock(fd): hfile = win32file._get_osfhandle(fd.fileno( )) win32file.UnlockFileEx(hfile, 0, 0xffff0000, __overlapped) + """ elif os.name == 'posix': import fcntl --- papercut-0.9.13.orig/settings.py +++ papercut-0.9.13/settings.py @@ -1,135 +1,13 @@ -#!/usr/bin/env python -# Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. -# $Id: settings.py,v 1.18 2004/08/01 01:03:22 jpm Exp $ -import time import sys -import os -# -# The following configuration settings should be pretty self-explanatory, but -# please let me know if this is not complete or if more information / examples -# are needed. -# +DEFAULT_SETTINGS_FILE = '/usr/share/papercut/default_settings.py' +LOCAL_SETTINGS_FILE = '/etc/papercut/papercut_cfg.py' +execfile(DEFAULT_SETTINGS_FILE, globals(), locals()) +try: + execfile(LOCAL_SETTINGS_FILE, globals(), locals()) +except: + print >>sys.stderr, "Error in %s: %s %s" % ( + LOCAL_SETTINGS_FILE, sys.exc_type, sys.exc_value) -# what is the maximum number of concurrent connections that should be allowed -max_connections = 20 - - -# -# GENERAL PATH INFORMATION -# - -# full path for where Papercut will store the log file -log_path = "/home/papercut/logs/" -# the actual log filename -log_file = log_path + "papercut.log" - - -# -# HOSTNAME / PORT OF THE SERVER -# - -# hostname that Papercut will bind against -nntp_hostname = 'nntp.domain.com' -# usually 119, but use 563 for an SSL server -nntp_port = 119 - -# type of server ('read-only' or 'read-write') -server_type = 'read-write' - - -# -# NNTP AUTHENTICATION SUPPORT -# - -# does the server need authentication ? ('yes' or 'no') -nntp_auth = 'no' -# backend that Papercut will use to authenticate the users -auth_backend = '' -# ONLY needed for phorum_mysql_users auth module -PHP_CRYPT_SALT_LENGTH = 2 - - -# -# CACHE SYSTEM -# - -# the cache system may need a lot of diskspace ('yes' or 'no') -nntp_cache = 'no' -# cache expire (in seconds) -nntp_cache_expire = 60 * 60 * 3 -# path to where the cached files should be kept -nntp_cache_path = '/home/papercut/cache/' - - -# -# STORAGE MODULE -# - -# backend that Papercut will use to get (and store) the actual articles content -storage_backend = "phorum_mysql" - -# for the forwarding_proxy backend, set the next option to the remote nntp server -forward_host = 'news.remotedomain.com' - - -# -# PHORUM STORAGE MODULE OPTIONS -# - -# full path to the directory where the Phorum configuration files are stored -phorum_settings_path = "/home/papercut/www/domain.com/phorum_settings/" -# the version for the installed copy of Phorum -phorum_version = "3.3.2a" - -# configuration values for 'storage/phorum_mysql.py' -# database connection variables -dbhost = "localhost" -dbname = "phorum" -dbuser = "anonymous" -dbpass = "anonymous" - - -# -# PHPBB STORAGE MODULE OPTIONS -# - -# the prefix for the phpBB tables -phpbb_table_prefix = "phpbb_" - - -# -# PHPNUKE PHPBB STORAGE MODULE OPTIONS -# - -# if you're running PHPNuke, set this for the nuke tables and phpbb_table_prefix -# for the bb tables. -nuke_table_prefix = "nuke_" - -# the prefix for the phpBB tables -phpbb_table_prefix = "nuke_bb" - - -# -# MBOX STORAGE MODULE OPTIONS -# - -# the full path for where the mbox files are stored in -mbox_path = "/home/papercut/mboxes/" - - -# check for the appropriate options -if nntp_auth == 'yes' and auth_backend == '': - sys.exit("Please configure the 'nntp_auth' and 'auth_backend' options correctly") - -# check for the trailing slash -if phorum_settings_path[-1] != '/': - phorum_settings_path = phorum_settings_path + '/' - - -# helper function to log information -def logEvent(msg): - f = open(log_file, "a") - f.write("[%s] %s\n" % (time.strftime("%a %b %d %H:%M:%S %Y", time.gmtime()), msg)) - f.close() +# vim: et sw=4 --- papercut-0.9.13.orig/storage/__init__.py +++ papercut-0.9.13/storage/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: __init__.py,v 1.4 2002/03/26 22:55:00 jpm Exp $ --- papercut-0.9.13.orig/storage/forwarding_proxy.py +++ papercut-0.9.13/storage/forwarding_proxy.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python import nntplib import re import time --- papercut-0.9.13.orig/storage/maildir.py +++ papercut-0.9.13/storage/maildir.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2004 Scott Parish, Joao Prado Maia # See the LICENSE file for more information. # $Id: maildir.py,v 1.2 2004/08/01 01:51:48 jpm Exp $ --- papercut-0.9.13.orig/storage/mbox.py +++ papercut-0.9.13/storage/mbox.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: mbox.py,v 1.7 2004/08/01 01:51:48 jpm Exp $ import os +import os.path import mailbox import settings import strutil @@ -19,7 +19,7 @@ self.mbox_dir = settings.mbox_path def get_mailbox(self, filename): - return mailbox.PortableUnixMailbox(open(self.mbox_dir + filename)) + return mailbox.PortableUnixMailbox(open(os.path.join(self.mbox_dir, filename))) def get_file_list(self): return os.listdir(self.mbox_dir) --- papercut-0.9.13.orig/storage/mime.py +++ papercut-0.9.13/storage/mime.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: mime.py,v 1.1 2002/02/03 06:15:25 jpm Exp $ import re @@ -22,7 +21,7 @@ cnt_type = msg.get_main_type() if cnt_type == 'text': # a simple mime based text/plain message (is this even possible?) - body = get_body(msg_string) + body = msg.get_payload(decode=True) elif cnt_type == 'multipart': # needs to loop thru all parts and get the text version #print 'several parts here' @@ -31,7 +30,11 @@ if part.get_main_type() == 'text': #print 'text based part' #print part.as_string() - text_parts[part.get_params()[0][0]] = get_body(part.as_string()) + mimetype = part.get_params()[0][0] + if not text_parts.has_key(mimetype): + text_parts[mimetype] = '' + text_parts[mimetype] = (text_parts[mimetype] + + part.get_payload(decode=True)) if 'text/plain' in text_parts: return text_parts['text/plain'] elif 'text/html' in text_parts: --- papercut-0.9.13.orig/storage/mysql.py +++ papercut-0.9.13/storage/mysql.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: mysql.py,v 1.44 2004/08/01 01:51:48 jpm Exp $ import MySQLdb @@ -10,9 +9,9 @@ # we don't need to compile the regexps everytime.. singleline_regexp = re.compile("^\.", re.M) -from_regexp = re.compile("^From:(.*)", re.M) -subject_regexp = re.compile("^Subject:(.*)", re.M) -references_regexp = re.compile("^References:(.*)<(.*)>", re.M) +from_regexp = re.compile("^From:(.*)", re.M | re.I) +subject_regexp = re.compile("^Subject:(.*)", re.M | re.I) +references_regexp = re.compile("^References:(.*)<(.*)>", re.M | re.I) class Papercut_Storage: """ @@ -38,7 +37,7 @@ def group_exists(self, group_name): stmt = """ SELECT - COUNT(*) AS check + COUNT(*) AS checking FROM papercut_groups WHERE @@ -50,7 +49,7 @@ table_name = self.get_table_name(group_name) stmt = """ SELECT - COUNT(*) AS check + COUNT(*) AS checking FROM %s WHERE --- papercut-0.9.13.orig/storage/p2p.py +++ papercut-0.9.13/storage/p2p.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: p2p.py,v 1.2 2002/04/03 23:07:22 jpm Exp $ import settings --- papercut-0.9.13.orig/storage/phorum_mysql.py +++ papercut-0.9.13/storage/phorum_mysql.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: phorum_mysql.py,v 1.47 2004/08/01 01:51:48 jpm Exp $ import MySQLdb @@ -10,6 +9,7 @@ import strutil import smtplib import md5 +import os.path # patch by Andreas Wegmann to fix the handling of unusual encodings of messages q_quote_multiline = re.compile("=\?(.*?)\?[qQ]\?(.*?)\?=.*?=\?\\1\?[qQ]\?(.*?)\?=", re.M | re.S) @@ -126,7 +126,8 @@ def get_notification_emails(self, forum_id): # open the configuration file - fp = open("%s%s.php" % (settings.phorum_settings_path, forum_id), "r") + fp = open("%s.php" % os.path.join(settings.phorum_settings_path, + forum_id), "r") content = fp.read() fp.close() # get the value of the configuration variable @@ -179,7 +180,8 @@ self.cursor.execute(stmt) forum_id, forum_name = self.cursor.fetchone() # open the main configuration file - fp = open("%sforums.php" % (settings.phorum_settings_path), "r") + fp = open("%s.php" % os.path.join(settings.phorum_settings_path, + 'forums'), "r") content = fp.read() fp.close() # regexps to get the content from the phorum configuration files --- papercut-0.9.13.orig/storage/phorum_pgsql.py +++ papercut-0.9.13/storage/phorum_pgsql.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: phorum_pgsql.py,v 1.13 2004/08/01 01:51:48 jpm Exp $ from pyPgSQL import PgSQL @@ -10,6 +9,7 @@ import strutil import smtplib import md5 +import os.path # patch by Andreas Wegmann to fix the handling of unusual encodings of messages q_quote_multiline = re.compile("=\?(.*?)\?[qQ]\?(.*?)\?=.*?=\?\\1\?[qQ]\?(.*?)\?=", re.M | re.S) @@ -132,7 +132,8 @@ def get_notification_emails(self, forum_id): # open the configuration file - fp = open("%s%s.php" % (settings.phorum_settings_path, forum_id), "r") + fp = open("%s.php" % os.path.join(settings.phorum_settings_path, + forum_id), "r") content = fp.read() fp.close() # get the value of the configuration variable @@ -186,7 +187,8 @@ forum_id, forum_name = self.cursor.fetchone() forum_name.strip() # open the main configuration file - fp = open("%sforums.php" % (settings.phorum_settings_path), "r") + fp = open("%s.php" % os.path.join(settings.phorum_settings_path, + 'forums'), "r") content = fp.read() fp.close() # regexps to get the content from the phorum configuration files --- papercut-0.9.13.orig/storage/phpbb_mysql.py +++ papercut-0.9.13/storage/phpbb_mysql.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002, 2003, 2004 Joao Prado Maia. See the LICENSE file for more information. # $Id: phpbb_mysql.py,v 1.20 2004/08/01 01:51:48 jpm Exp $ import MySQLdb @@ -24,9 +23,9 @@ class Papercut_Storage: """ - Storage Backend interface for the Phorum web message board software (http://phorum.org) + Storage Backend interface for the phpBB web message board software (http://phorum.org) - This is the interface for Phorum running on a MySQL database. For more information + This is the interface for phpBB running on a MySQL database. For more information on the structure of the 'storage' package, please refer to the __init__.py available on the 'storage' sub-directory. """ @@ -169,44 +168,45 @@ result = self.get_forum_stats(forum_id) return (result[0], result[2], result[1]) - def get_LIST(self, username=""): - # If the username is supplied, then find what he is allowed to see - if len(username) > 0: - stmt = """ - SELECT - DISTINCT f.nntp_group_name, - f.forum_id - FROM - %sforums AS f - INNER JOIN - %sauth_access AS aa - ON - f.forum_id=aa.forum_id - INNER JOIN - %suser_group AS ug - ON - aa.group_id=ug.group_id - INNER JOIN - %susers AS u - ON - ug.user_id=u.user_id - WHERE - u.username='%s' AND - LENGTH(f.nntp_group_name) > 0 OR - f.auth_view = 0""" % (settings.phpbb_table_prefix, settings.phpbb_table_prefix, settings.phpbb_table_prefix, settings.phpbb_table_prefix, username) - else: - stmt = """ - SELECT - nntp_group_name, - forum_id - FROM - %sforums - WHERE - LENGTH(nntp_group_name) > 0 AND auth_view=0 - ORDER BY - nntp_group_name ASC""" % (settings.phpbb_table_prefix) + def get_LIST(self, username=""): + result = [] + # If the username is supplied, then find what he is allowed to see + if len(username) > 0: + stmt = """ + SELECT + DISTINCT f.nntp_group_name, + f.forum_id + FROM + %sforums AS f + INNER JOIN + %sauth_access AS aa + ON + f.forum_id=aa.forum_id + INNER JOIN + %suser_group AS ug + ON + aa.group_id=ug.group_id + INNER JOIN + %susers AS u + ON + ug.user_id=u.user_id + WHERE + u.username='%s' AND + LENGTH(f.nntp_group_name) > 0 AND + f.auth_view != 0""" % (settings.phpbb_table_prefix, settings.phpbb_table_prefix, settings.phpbb_table_prefix, settings.phpbb_table_prefix, username) + self.cursor.execute(stmt) + result.extend(self.cursor.fetchall()) + # Fetch public forums + stmt = """ + SELECT + nntp_group_name, + forum_id + FROM + %sforums + WHERE + LENGTH(nntp_group_name) > 0 AND auth_view=0""" % (settings.phpbb_table_prefix) self.cursor.execute(stmt) - result = list(self.cursor.fetchall()) + result.extend(self.cursor.fetchall()) if len(result) == 0: return "" else: @@ -217,6 +217,7 @@ lists.append("%s %s %s n" % (group_name, maximum, minimum)) else: lists.append("%s %s %s y" % (group_name, maximum, minimum)) + lists.sort() return "\r\n".join(lists) def get_STAT(self, group_name, id): @@ -284,6 +285,8 @@ headers.append("From: %s" % (author)) headers.append("Newsgroups: %s" % (group_name)) headers.append("Date: %s" % (formatted_time)) + headers.append("Content-Type: text/plain; charset=iso-8859-1; format=flowed") + headers.append("Content-Transfer-Encoding: 8Bit") headers.append("Subject: %s" % (result[3])) headers.append("Message-ID: <%s@%s>" % (result[0], group_name)) headers.append("Xref: %s %s:%s" % (settings.nntp_hostname, group_name, result[0])) @@ -678,7 +681,7 @@ 0 )""" % (prefix, forum_id, self.quote_string(subject), poster_id) self.cursor.execute(stmt) - thread_id = self.cursor.insert_id() + thread_id = self.conn.insert_id() stmt = """ INSERT INTO %sposts @@ -706,7 +709,7 @@ 0 )""" % (prefix, thread_id, forum_id, poster_id, self.encode_ip(ip_address), post_username) self.cursor.execute(stmt) - new_id = self.cursor.insert_id() + new_id = self.conn.insert_id() if not new_id: return None else: --- papercut-0.9.13.orig/storage/phpnuke_phpbb_mysql.py +++ papercut-0.9.13/storage/phpnuke_phpbb_mysql.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002, 2003, 2004 Joao Prado Maia. See the LICENSE file for more information. import MySQLdb import time @@ -658,7 +657,7 @@ 0 )""" % (prefix, forum_id, self.quote_string(subject), poster_id) self.cursor.execute(stmt) - thread_id = self.cursor.insert_id() + thread_id = self.conn.insert_id() stmt = """ INSERT INTO %sposts @@ -686,7 +685,7 @@ 0 )""" % (prefix, thread_id, forum_id, poster_id, self.encode_ip(ip_address), post_username) self.cursor.execute(stmt) - new_id = self.cursor.insert_id() + new_id = self.conn.insert_id() if not new_id: return None else: --- papercut-0.9.13.orig/storage/strutil.py +++ papercut-0.9.13/storage/strutil.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information. # $Id: strutil.py,v 1.3 2003/02/22 00:46:18 jpm Exp $ import time