Snapshot release 20030305-1531
Charles Cazabon <[email protected]> 5 Mar 2003 21:31:50 -0000
| Newsgroups | gmane.mail.bikini.devel |
|---|---|
| Message-ID | <[email protected]> |
Snapshot 20030305-1531 released and uploaded. From the CHANGELOG:
2003-03-05
Implemented SEND. It will now try to queue the message using
/var/qmail/bin/qmail-queue . Tested and works.
Add checkpassword and arg to example service-run.sh.
Diff follows.
diff -urN --exclude=bikini.html --exclude=bikini.txt --exclude=CHANGELOG bikini-20030305-1237/bikini/server.py bikini-20030305-1531/bikini/server.py
--- bikini-20030305-1237/bikini/server.py Wed Mar 5 12:37:52 2003
+++ bikini-20030305-1531/bikini/server.py Wed Mar 5 15:31:24 2003
@@ -421,7 +421,7 @@
or len (parts) < 3): # Not enough parts
raise bSyntaxError, 'bad envelope format'
- receipt = deliver_message (f, envelope) # ??? Currently a stub
+ receipt = deliver_message (f, envelope)
except KeyError, err:
raise PermanentCommandError, 'no such message %s' % path
diff -urN --exclude=bikini.html --exclude=bikini.txt --exclude=CHANGELOG bikini-20030305-1237/bikini/utilities.py bikini-20030305-1531/bikini/utilities.py
--- bikini-20030305-1237/bikini/utilities.py Wed Mar 5 12:37:52 2003
+++ bikini-20030305-1531/bikini/utilities.py Wed Mar 5 15:31:24 2003
@@ -1,7 +1,7 @@
#!/usr/bin/python2.2
import sys
-import os.path
+import os
import time
import signal
import glob
@@ -36,10 +36,56 @@
#######################################
def deliver_message (path, envelope):
- '''Ask the local MTA to deliver the message. Currently a stub that does nothing.
+ '''Ask the local MTA to deliver the message.
'''
log (TRACE, 'path %s envelope %s\n' % (path, envelope))
- return 'this is a receipt, should be a queue id or similar'
+ mail_command = '/var/qmail/bin/qmail-queue'
+ READ, WRITE = 0, 1
+ try:
+ messagepipe = os.pipe ()
+ envelopepipe = os.pipe ()
+ child_pid = os.fork ()
+ if child_pid == 0:
+ # child
+ os.close (messagepipe[WRITE])
+ os.close (envelopepipe[WRITE])
+ os.close (0)
+ os.close (1)
+ os.close (2)
+ os.dup2 (messagepipe[READ], 0)
+ os.dup2 (envelopepipe[READ], 1)
+ os.execl (mail_command, mail_command)
+ raise TemporaryCommandError, 'exec failed'
+ # Parent
+ log (DEBUG, 'forked pid %i\n' % child_pid)
+ os.close (messagepipe[READ])
+ os.close (envelopepipe[READ])
+ # Write message
+ os.write (messagepipe[WRITE], open (path, 'rb').read ())
+ os.close (messagepipe[WRITE])
+ # Write envelope
+ parts = envelope.split ('\0')
+ os.write (envelopepipe[WRITE], 'F%s\0' % parts[0])
+ for recip in parts[1:-1]:
+ os.write (envelopepipe[WRITE], 'T%s\0' % recip)
+ os.write (envelopepipe[WRITE], '\0')
+ os.close (envelopepipe[WRITE])
+ tries = 0
+ while tries < 10:
+ pid, rc = os.waitpid (child_pid, os.WNOHANG)
+ log (TRACE, 'os.waitpid returned %i, %s\n' % (pid, rc))
+ if pid == child_pid and os.WIFEXITED (rc):
+ if os.WEXITSTATUS (rc) == 0:
+ log (TRACE, 'message queued\n')
+ return 'this is a receipt, should be a queue id or similar' # ???
+ log (TRACE, 'message not queued (exited %i)\n' % os.WEXITSTATUS (rc))
+ raise TemporaryCommandError, '%s exited %i' % (mail_command, os.WEXITSTATUS (rc))
+ time.sleep (1)
+ log (ERROR, 'child never exited?\n')
+ raise TemporaryCommandError, '%s never exited' % mail_command
+
+ except UnhandledException, txt:
+ raise TemporaryCommandError, 'failure queuing message: %s' % txt
#######################################
def utcdate (timestamp):
@@ -190,6 +236,8 @@
for new files (modern delivery identifiers). See
http://cr.yp.to/proto/maildir.html for details.
'''
+ assert_maildir (maildirpath)
+
# Set a 24-hour alarm for this delivery
signal.signal (signal.SIGALRM, alarm_handler)
signal.alarm (24 * 60 * 60)
@@ -201,9 +249,6 @@
}
dir_tmp = os.path.join (maildirpath, 'tmp')
dir_new = os.path.join (maildirpath, 'new')
- if not assert_maildir (maildirpath):
- raise PermanentCommandError, 'not a Maildir (%s)' % maildirpath
-
got_file = 0
for unused in range (3):
t = time.time ()
diff -urN --exclude=bikini.html --exclude=bikini.txt --exclude=CHANGELOG bikini-20030305-1237/service-run.sh bikini-20030305-1531/service-run.sh
--- bikini-20030305-1237/service-run.sh Wed Mar 5 12:37:52 2003
+++ bikini-20030305-1531/service-run.sh Wed Mar 5 15:31:24 2003
@@ -8,6 +8,6 @@
exec tcpserver -c "$concurrency" -v -R \
127.0.0.1 5555 \
- /usr/bin/python2.2 \
- -c "import bikini.serverauth ; bikini.serverauth.main(\"$MAILPATH\", \"$INBOX\")" \
+ /usr/bin/python2.2 /usr/lib/python2.2/site-packages/bikini/serverauth.py \
+ "$MAILPATH" "$INBOX" /bin/checkpassword /bin/true \
2>&1