--- Begin Message ---
Package: papercut
Severity: wishlist
Tags: patch
Hi,
The dpatch patch management system has been deprecated for some time. The
Lintian currently flags use of dpatch packages as an error. The new 3.0
packaging format is an improved version which, among other things, contains
patch management built-in. For more information, see:
http://wiki.debian.org/Projects/DebSrc3.0
I had some free time; see attached patch to migrate to new package
format. Note that all files in debian/patches/* are canocalized to
*.patch.
Note:
Original sources were restores for following files; these in-line local
changes were moved to patch 10 (packaging format 3.0 requiredment):
TODO
auth/__init__.py
auth/mysql.py
auth/phorum_mysql_users.py
auth/phorum_pgsql_users.py
auth/phpbb_mysql_users.py
auth/phpnuke_phpbb_mysql_users.py
auth/postnuke_phpbb_mysql_users.py
default_settings.py
papercut.py
papercut_cache.py
portable_locker.py
settings.py
storage/__init__.py
storage/forwarding_proxy.py
storage/maildir.py
storage/mbox.py
storage/mime.py
storage/mysql.py
storage/p2p.py
storage/phorum_mysql.py
storage/phorum_pgsql.py
storage/phpbb_mysql.py
storage/phpnuke_phpbb_mysql.py
storage/strutil.py
Let me know if there is anything that needs adjusting or if it is ok
to upload this version in a NMU in case you are working on other
issues needing attention.
Thanks,
Jari
>From 5c7473c8067a09994b1b24b0b9046c1ad97b7b90 Mon Sep 17 00:00:00 2001
From: Jari Aalto <[email protected]>
Date: Sun, 8 Apr 2012 18:10:52 +0300
Subject: [PATCH] format-3.0
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Signed-off-by: Jari Aalto <[email protected]>
---
TODO | 4 +-
auth/__init__.py | 1 +
auth/mysql.py | 1 +
auth/phorum_mysql_users.py | 1 +
auth/phorum_pgsql_users.py | 1 +
auth/phpbb_mysql_users.py | 1 +
auth/phpnuke_phpbb_mysql_users.py | 1 +
auth/postnuke_phpbb_mysql_users.py | 1 +
debian/changelog | 10 ++
debian/compat | 2 +-
debian/control | 6 +-
debian/patches/00list | 1 -
....dpatch => 20-papercut.py-rewrite-daemon.patch} | 7 +-
debian/patches/series | 2 +
debian/rules | 19 +--
debian/source/format | 1 +
default_settings.py | 143 --------------------
papercut.py | 112 +---------------
papercut_cache.py | 5 +-
portable_locker.py | 3 +-
settings.py | 140 ++++++++++++++++++--
storage/__init__.py | 1 +
storage/forwarding_proxy.py | 1 +
storage/maildir.py | 1 +
storage/mbox.py | 4 +-
storage/mime.py | 9 +-
storage/mysql.py | 11 +-
storage/p2p.py | 1 +
storage/phorum_mysql.py | 8 +-
storage/phorum_pgsql.py | 8 +-
storage/phpbb_mysql.py | 87 ++++++------
storage/phpnuke_phpbb_mysql.py | 5 +-
storage/strutil.py | 1 +
33 files changed, 238 insertions(+), 361 deletions(-)
delete mode 100644 debian/patches/00list
rename debian/patches/{01_papercut.py_rewrite_daemon.dpatch => 20-papercut.py-rewrite-daemon.patch} (88%)
create mode 100644 debian/patches/series
create mode 100644 debian/source/format
delete mode 100644 default_settings.py
diff --git a/TODO b/TODO
index e3941e2..6887fd7 100644
--- a/TODO
+++ b/TODO
@@ -4,4 +4,6 @@ TODO list:
- 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
-- Add a --verbose flag to replace the current __DEBUG__ flag
+- 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
diff --git a/auth/__init__.py b/auth/__init__.py
index a6efaca..113681d 100644
--- a/auth/__init__.py
+++ b/auth/__init__.py
@@ -1,2 +1,3 @@
+#!/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 $
diff --git a/auth/mysql.py b/auth/mysql.py
index 139794c..945c2b2 100644
--- a/auth/mysql.py
+++ b/auth/mysql.py
@@ -1,3 +1,4 @@
+#!/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
diff --git a/auth/phorum_mysql_users.py b/auth/phorum_mysql_users.py
index 48faf02..f06493a 100644
--- a/auth/phorum_mysql_users.py
+++ b/auth/phorum_mysql_users.py
@@ -1,3 +1,4 @@
+#!/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
diff --git a/auth/phorum_pgsql_users.py b/auth/phorum_pgsql_users.py
index 4a69e0b..cc5afb9 100644
--- a/auth/phorum_pgsql_users.py
+++ b/auth/phorum_pgsql_users.py
@@ -1,3 +1,4 @@
+#!/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
diff --git a/auth/phpbb_mysql_users.py b/auth/phpbb_mysql_users.py
index bb109ba..effc365 100644
--- a/auth/phpbb_mysql_users.py
+++ b/auth/phpbb_mysql_users.py
@@ -1,3 +1,4 @@
+#!/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
diff --git a/auth/phpnuke_phpbb_mysql_users.py b/auth/phpnuke_phpbb_mysql_users.py
index e803f9b..3e28de2 100644
--- a/auth/phpnuke_phpbb_mysql_users.py
+++ b/auth/phpnuke_phpbb_mysql_users.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# Copyright (c) 2002 Joao Prado Maia. See the LICENSE file for more information.
import MySQLdb
import settings
diff --git a/auth/postnuke_phpbb_mysql_users.py b/auth/postnuke_phpbb_mysql_users.py
index 3902ff6..ca81176 100644
--- a/auth/postnuke_phpbb_mysql_users.py
+++ b/auth/postnuke_phpbb_mysql_users.py
@@ -1,3 +1,4 @@
+#!/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
diff --git a/debian/changelog b/debian/changelog
index 83daec8..dc5f5fc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+papercut (0.9.13-7.1) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Remove deprecated dpatch and upgrade to packaging format "3.0 quilt".
+ * Update to Standards-Version to 3.9.3.1 and debhelper to 9.
+ * Add build-arch and build-indep targets; use dh_prep in rules file.
+ * Note: all in-line local changes to upstream code were moved to patch 10.
+
+ -- Jari Aalto <[email protected]> Sun, 08 Apr 2012 18:09:22 +0300
+
papercut (0.9.13-7) unstable; urgency=low
* Fixed mysql and postgresql init dependencies (Closes: #486857)
diff --git a/debian/compat b/debian/compat
index 1e8b314..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-6
+9
diff --git a/debian/control b/debian/control
index f4ccf8e..fe57ce4 100644
--- a/debian/control
+++ b/debian/control
@@ -2,15 +2,15 @@ Source: papercut
Section: news
Priority: optional
Maintainer: César Gómez Martín <[email protected]>
-Build-Depends: debhelper (>= 6), dpatch
+Build-Depends: debhelper (>= 9)
Build-Depends-Indep: python, python-support (>= 0.3), xsltproc, docbook-xsl
-Standards-Version: 3.7.3
+Standards-Version: 3.9.3.1
HomePage: http://pessoal.org/papercut/
XS-Python-Version: current
Package: papercut
Architecture: all
-Depends: ${python:Depends}, adduser
+Depends: ${misc:Depends}, ${python:Depends}, adduser
XB-Python-Version: ${python:Versions}
Recommends: python-mysqldb, python-pgsql
Suggests: phpbb2, mysql-server
diff --git a/debian/patches/00list b/debian/patches/00list
deleted file mode 100644
index 062704c..0000000
--- a/debian/patches/00list
+++ /dev/null
@@ -1 +0,0 @@
-01_papercut.py_rewrite_daemon.dpatch
diff --git a/debian/patches/01_papercut.py_rewrite_daemon.dpatch b/debian/patches/20-papercut.py-rewrite-daemon.patch
similarity index 88%
rename from debian/patches/01_papercut.py_rewrite_daemon.dpatch
rename to debian/patches/20-papercut.py-rewrite-daemon.patch
index 35dc95e..caef199 100644
--- a/debian/patches/01_papercut.py_rewrite_daemon.dpatch
+++ b/debian/patches/20-papercut.py-rewrite-daemon.patch
@@ -1,9 +1,6 @@
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 01_papercut.py_rewrite_daemon.dpatch by Juan Angulo Moreno <[email protected]>
-##
-## DP: Rewrite funtions papercut daemon
+From: Juan Angulo Moreno <[email protected]>
+Subject: 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
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..28d73b4
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+10-local-changes.patch
+20-papercut.py-rewrite-daemon.patch
diff --git a/debian/rules b/debian/rules
index 620d5e9..0d87091 100755
--- a/debian/rules
+++ b/debian/rules
@@ -3,38 +3,29 @@
# 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:
+clean:
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-arch: build
+build-indep: build
-build: patch
+build:
install: build
dh_testdir
dh_testroot
- dh_clean -k
+ dh_prep
dh_installdirs
install -m 0755 papercut.py \
$(CURDIR)/debian/papercut/usr/bin/papercut
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/default_settings.py b/default_settings.py
deleted file mode 100644
index 3b2b439..0000000
--- a/default_settings.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# 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
diff --git a/papercut.py b/papercut.py
index 7a54fc2..b0c72ba 100644
--- a/papercut.py
+++ b/papercut.py
@@ -1,9 +1,6 @@
#!/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
@@ -12,9 +9,6 @@ import time
import re
import traceback
import StringIO
-from optparse import OptionParser
-
-sys.path = ['/usr/share/papercut'] + sys.path
# papercut based modules
import settings
@@ -778,7 +772,7 @@ class NNTPRequestHandler(SocketServer.StreamRequestHandler):
440 posting not allowed
441 posting failed
"""
- lines = "".join(self.article_lines)
+ lines = "\r\n".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):
@@ -876,47 +870,6 @@ if __name__ == '__main__':
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':
@@ -926,69 +879,10 @@ if __name__ == '__main__':
# 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)
- signal.signal(signal.SIGQUIT, sighandler)
- # register cleanup function
- atexit.register(exit_cleanup)
-
- server = NNTPServer((ip_address, settings.nntp_port),
- NNTPRequestHandler)
+ print 'Papercut %s (%s storage module) - starting up' % (__VERSION__, settings.storage_backend)
+ server = NNTPServer((settings.nntp_hostname, settings.nntp_port), NNTPRequestHandler)
server.serve_forever()
diff --git a/papercut_cache.py b/papercut_cache.py
index 56de643..289233d 100644
--- a/papercut_cache.py
+++ b/papercut_cache.py
@@ -1,3 +1,4 @@
+#!/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 $
@@ -5,7 +6,6 @@ import binascii
import md5
import time
import os
-import os.path
import cPickle
import portable_locker
# papercut settings file
@@ -72,8 +72,7 @@ class CallableWrapper:
def _get_filename(self, *args, **kwds):
arguments = '%s%s%s' % (self.name, args, kwds)
- return os.path.join(settings.nntp_cache_path,
- binascii.hexlify(md5.new(arguments).digest()))
+ return '%s%s' % (settings.nntp_cache_path, binascii.hexlify(md5.new(arguments).digest()))
class Cache:
diff --git a/portable_locker.py b/portable_locker.py
index fd3973f..69ff5b0 100644
--- a/portable_locker.py
+++ b/portable_locker.py
@@ -1,3 +1,4 @@
+#!/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
@@ -7,7 +8,6 @@ import os
# 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,7 +21,6 @@ if os.name == 'nt':
def unlock(fd):
hfile = win32file._get_osfhandle(fd.fileno( ))
win32file.UnlockFileEx(hfile, 0, 0xffff0000, __overlapped)
- """
elif os.name == 'posix':
import fcntl
diff --git a/settings.py b/settings.py
index 5047cca..17766c9 100644
--- a/settings.py
+++ b/settings.py
@@ -1,13 +1,135 @@
+#!/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
-DEFAULT_SETTINGS_FILE = '/usr/share/papercut/default_settings.py'
-LOCAL_SETTINGS_FILE = '/etc/papercut/papercut_cfg.py'
+#
+# 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.
+#
-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)
-# vim: et sw=4
+# 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()
diff --git a/storage/__init__.py b/storage/__init__.py
index 49589bf..56c543d 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -1,3 +1,4 @@
+#!/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 $
diff --git a/storage/forwarding_proxy.py b/storage/forwarding_proxy.py
index b98d048..c2c34bd 100644
--- a/storage/forwarding_proxy.py
+++ b/storage/forwarding_proxy.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
import nntplib
import re
import time
diff --git a/storage/maildir.py b/storage/maildir.py
index 4934d16..f8dc46f 100644
--- a/storage/maildir.py
+++ b/storage/maildir.py
@@ -1,3 +1,4 @@
+#!/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 $
diff --git a/storage/mbox.py b/storage/mbox.py
index d0365e6..ef95861 100644
--- a/storage/mbox.py
+++ b/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 @@ class Papercut_Storage:
self.mbox_dir = settings.mbox_path
def get_mailbox(self, filename):
- return mailbox.PortableUnixMailbox(open(os.path.join(self.mbox_dir, filename)))
+ return mailbox.PortableUnixMailbox(open(self.mbox_dir + filename))
def get_file_list(self):
return os.listdir(self.mbox_dir)
diff --git a/storage/mime.py b/storage/mime.py
index db63848..5af2f4c 100644
--- a/storage/mime.py
+++ b/storage/mime.py
@@ -1,3 +1,4 @@
+#!/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
@@ -21,7 +22,7 @@ def get_text_message(msg_string):
cnt_type = msg.get_main_type()
if cnt_type == 'text':
# a simple mime based text/plain message (is this even possible?)
- body = msg.get_payload(decode=True)
+ body = get_body(msg_string)
elif cnt_type == 'multipart':
# needs to loop thru all parts and get the text version
#print 'several parts here'
@@ -30,11 +31,7 @@ def get_text_message(msg_string):
if part.get_main_type() == 'text':
#print 'text based part'
#print 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))
+ text_parts[part.get_params()[0][0]] = get_body(part.as_string())
if 'text/plain' in text_parts:
return text_parts['text/plain']
elif 'text/html' in text_parts:
diff --git a/storage/mysql.py b/storage/mysql.py
index 0d300cb..957ca37 100644
--- a/storage/mysql.py
+++ b/storage/mysql.py
@@ -1,3 +1,4 @@
+#!/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
@@ -9,9 +10,9 @@ import mime
# we don't need to compile the regexps everytime..
singleline_regexp = re.compile("^\.", 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)
+from_regexp = re.compile("^From:(.*)", re.M)
+subject_regexp = re.compile("^Subject:(.*)", re.M)
+references_regexp = re.compile("^References:(.*)<(.*)>", re.M)
class Papercut_Storage:
"""
@@ -37,7 +38,7 @@ class Papercut_Storage:
def group_exists(self, group_name):
stmt = """
SELECT
- COUNT(*) AS checking
+ COUNT(*) AS check
FROM
papercut_groups
WHERE
@@ -49,7 +50,7 @@ class Papercut_Storage:
table_name = self.get_table_name(group_name)
stmt = """
SELECT
- COUNT(*) AS checking
+ COUNT(*) AS check
FROM
%s
WHERE
diff --git a/storage/p2p.py b/storage/p2p.py
index 6d5af4d..b85143f 100644
--- a/storage/p2p.py
+++ b/storage/p2p.py
@@ -1,3 +1,4 @@
+#!/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
diff --git a/storage/phorum_mysql.py b/storage/phorum_mysql.py
index 5b15959..6c458d1 100644
--- a/storage/phorum_mysql.py
+++ b/storage/phorum_mysql.py
@@ -1,3 +1,4 @@
+#!/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
@@ -9,7 +10,6 @@ import mime
import strutil
import smtplib
import md5
-import os.path
# patch by Andreas Wegmann <[email protected]> to fix the handling of unusual encodings of messages
q_quote_multiline = re.compile("=\?(.*?)\?[qQ]\?(.*?)\?=.*?=\?\\1\?[qQ]\?(.*?)\?=", re.M | re.S)
@@ -126,8 +126,7 @@ class Papercut_Storage:
def get_notification_emails(self, forum_id):
# open the configuration file
- fp = open("%s.php" % os.path.join(settings.phorum_settings_path,
- forum_id), "r")
+ fp = open("%s%s.php" % (settings.phorum_settings_path, forum_id), "r")
content = fp.read()
fp.close()
# get the value of the configuration variable
@@ -180,8 +179,7 @@ To edit this message use this URL:
self.cursor.execute(stmt)
forum_id, forum_name = self.cursor.fetchone()
# open the main configuration file
- fp = open("%s.php" % os.path.join(settings.phorum_settings_path,
- 'forums'), "r")
+ fp = open("%sforums.php" % (settings.phorum_settings_path), "r")
content = fp.read()
fp.close()
# regexps to get the content from the phorum configuration files
diff --git a/storage/phorum_pgsql.py b/storage/phorum_pgsql.py
index aca0973..a41a93d 100644
--- a/storage/phorum_pgsql.py
+++ b/storage/phorum_pgsql.py
@@ -1,3 +1,4 @@
+#!/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
@@ -9,7 +10,6 @@ import mime
import strutil
import smtplib
import md5
-import os.path
# patch by Andreas Wegmann <[email protected]> to fix the handling of unusual encodings of messages
q_quote_multiline = re.compile("=\?(.*?)\?[qQ]\?(.*?)\?=.*?=\?\\1\?[qQ]\?(.*?)\?=", re.M | re.S)
@@ -132,8 +132,7 @@ class Papercut_Storage:
def get_notification_emails(self, forum_id):
# open the configuration file
- fp = open("%s.php" % os.path.join(settings.phorum_settings_path,
- forum_id), "r")
+ fp = open("%s%s.php" % (settings.phorum_settings_path, forum_id), "r")
content = fp.read()
fp.close()
# get the value of the configuration variable
@@ -187,8 +186,7 @@ To edit this message use this URL:
forum_id, forum_name = self.cursor.fetchone()
forum_name.strip()
# open the main configuration file
- fp = open("%s.php" % os.path.join(settings.phorum_settings_path,
- 'forums'), "r")
+ fp = open("%sforums.php" % (settings.phorum_settings_path), "r")
content = fp.read()
fp.close()
# regexps to get the content from the phorum configuration files
diff --git a/storage/phpbb_mysql.py b/storage/phpbb_mysql.py
index c0f85a7..3c2b2b2 100644
--- a/storage/phpbb_mysql.py
+++ b/storage/phpbb_mysql.py
@@ -1,3 +1,4 @@
+#!/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
@@ -23,9 +24,9 @@ lines_regexp = re.compile("^Lines:(.*)", re.M)
class Papercut_Storage:
"""
- Storage Backend interface for the phpBB web message board software (http://phorum.org)
+ Storage Backend interface for the Phorum web message board software (http://phorum.org)
- This is the interface for phpBB running on a MySQL database. For more information
+ This is the interface for Phorum 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.
"""
@@ -168,45 +169,44 @@ class Papercut_Storage:
result = self.get_forum_stats(forum_id)
return (result[0], result[2], result[1])
- 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)
+ 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)
self.cursor.execute(stmt)
- result.extend(self.cursor.fetchall())
+ result = list(self.cursor.fetchall())
if len(result) == 0:
return ""
else:
@@ -217,7 +217,6 @@ class Papercut_Storage:
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):
@@ -285,8 +284,6 @@ class Papercut_Storage:
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]))
@@ -681,7 +678,7 @@ class Papercut_Storage:
0
)""" % (prefix, forum_id, self.quote_string(subject), poster_id)
self.cursor.execute(stmt)
- thread_id = self.conn.insert_id()
+ thread_id = self.cursor.insert_id()
stmt = """
INSERT INTO
%sposts
@@ -709,7 +706,7 @@ class Papercut_Storage:
0
)""" % (prefix, thread_id, forum_id, poster_id, self.encode_ip(ip_address), post_username)
self.cursor.execute(stmt)
- new_id = self.conn.insert_id()
+ new_id = self.cursor.insert_id()
if not new_id:
return None
else:
diff --git a/storage/phpnuke_phpbb_mysql.py b/storage/phpnuke_phpbb_mysql.py
index c9bcec9..e40cae2 100644
--- a/storage/phpnuke_phpbb_mysql.py
+++ b/storage/phpnuke_phpbb_mysql.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# Copyright (c) 2002, 2003, 2004 Joao Prado Maia. See the LICENSE file for more information.
import MySQLdb
import time
@@ -657,7 +658,7 @@ class Papercut_Storage:
0
)""" % (prefix, forum_id, self.quote_string(subject), poster_id)
self.cursor.execute(stmt)
- thread_id = self.conn.insert_id()
+ thread_id = self.cursor.insert_id()
stmt = """
INSERT INTO
%sposts
@@ -685,7 +686,7 @@ class Papercut_Storage:
0
)""" % (prefix, thread_id, forum_id, poster_id, self.encode_ip(ip_address), post_username)
self.cursor.execute(stmt)
- new_id = self.conn.insert_id()
+ new_id = self.cursor.insert_id()
if not new_id:
return None
else:
diff --git a/storage/strutil.py b/storage/strutil.py
index 466be8a..f1b4667 100644
--- a/storage/strutil.py
+++ b/storage/strutil.py
@@ -1,3 +1,4 @@
+#!/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
--
1.7.9.1
--- End Message ---