Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/doc/man/imapd.conf.5.html cyrus-imapd-2.3.7/doc/man/imapd.conf.5.html
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/doc/man/imapd.conf.5.html	2006-07-10 16:31:53.000000000 +0200
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/doc/man/imapd.conf.5.html	2006-07-14 10:27:29.000000000 +0200
Tomas Janousek 915c4a4
@@ -3130,6 +3130,24 @@
cf58a5c
 
cf58a5c
 
cf58a5c
 
cf58a5c
+

sendsms: /usr/bin/sendsms

cf58a5c
+

cf58a5c
+
cf58a5c
+
cf58a5c
+       cols="2" cellspacing="0" cellpadding="0">
cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
+

The pathname of the sendsms executable. Sieve invokes

cf58a5c
+sendsms for sending SMS notifications.

cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
+

cf58a5c
+       cols="2" cellspacing="0" cellpadding="0">
cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
 

servername: <none>

Tomas Janousek 915c4a4
 
cf58a5c
 
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/doc/man/notifyd.8.html cyrus-imapd-2.3.7/doc/man/notifyd.8.html
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/doc/man/notifyd.8.html	2006-07-10 16:31:54.000000000 +0200
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/doc/man/notifyd.8.html	2006-07-14 10:27:29.000000000 +0200
cf58a5c
@@ -181,6 +181,18 @@
cf58a5c
 
cf58a5c
 
cf58a5c
 
cf58a5c
+

sms

cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
+

Send the notification as SMS. This method can ONLY be used in

cf58a5c
+a Sieve ’notify’ action as it requires a
cf58a5c
+sms: URL to be specified as an :option.

cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
+
cf58a5c
 

zephyr

cf58a5c
 
cf58a5c
 
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/lib/imapoptions cyrus-imapd-2.3.7/lib/imapoptions
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/lib/imapoptions	2006-06-27 17:58:42.000000000 +0200
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/lib/imapoptions	2006-07-14 10:27:29.000000000 +0200
Tomas Janousek 915c4a4
@@ -829,6 +829,10 @@
cf58a5c
 /* The pathname of the sendmail executable.  Sieve invokes sendmail
cf58a5c
    for sending rejections, redirects and vacation responses. */
cf58a5c
 
cf58a5c
+{ "sendsms", "/usr/bin/sendsms", STRING }
cf58a5c
+/* The pathname of the sendsms executable.  Sieve invokes sendsms
cf58a5c
+   for sending SMS notifications. */
cf58a5c
+
cf58a5c
 { "servername", NULL, STRING }
cf58a5c
 /* This is the hostname visible in the greeting messages of the POP,
cf58a5c
    IMAP and LMTP daemons. If it is unset, then the result returned
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/man/imapd.conf.5 cyrus-imapd-2.3.7/man/imapd.conf.5
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/man/imapd.conf.5	2006-07-10 16:31:52.000000000 +0200
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/man/imapd.conf.5	2006-07-14 10:27:29.000000000 +0200
Tomas Janousek 915c4a4
@@ -691,6 +691,9 @@
cf58a5c
 .IP "\fBsendmail:\fR /usr/lib/sendmail" 5
cf58a5c
 The pathname of the sendmail executable.  Sieve invokes sendmail
cf58a5c
 for sending rejections, redirects and vacation responses. 
cf58a5c
+.IP "\fBsendsms:\fR /usr/bin/sendsms" 5
cf58a5c
+The pathname of the sendsms executable.  Sieve invokes sendsms
cf58a5c
+for sending SMS notifications. 
cf58a5c
 .IP "\fBservername:\fR <none>" 5
cf58a5c
 This is the hostname visible in the greeting messages of the POP,
cf58a5c
 IMAP and LMTP daemons. If it is unset, then the result returned
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/man/notifyd.8 cyrus-imapd-2.3.7/man/notifyd.8
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/man/notifyd.8	2003-08-10 01:43:14.000000000 +0200
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/man/notifyd.8	2006-07-14 10:27:29.000000000 +0200
cf58a5c
@@ -110,6 +110,11 @@
cf58a5c
 Sieve 'notify' action as it requires a \fImailto:\fR URL to be
cf58a5c
 specified as an \fI:option\fR.
cf58a5c
 .TP
cf58a5c
+.B sms
cf58a5c
+Send the notification as SMS.  This method can ONLY be used in a
cf58a5c
+Sieve 'notify' action as it requires a \fIsms:\fR URL to be
cf58a5c
+specified as an \fI:option\fR.
cf58a5c
+.TP
cf58a5c
 .B zephyr
cf58a5c
 Send the notification as a zephyrgram.  If used in a Sieve 'notify'
cf58a5c
 action, additional recipients can be specified as \fI:options\fR.
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/notifyd/Makefile.in cyrus-imapd-2.3.7/notifyd/Makefile.in
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/notifyd/Makefile.in	2004-05-31 20:22:59.000000000 +0200
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/notifyd/Makefile.in	2006-07-14 10:27:29.000000000 +0200
cf58a5c
@@ -82,7 +82,7 @@
cf58a5c
 install:
cf58a5c
 	$(INSTALL) -m 755 notifyd $(DESTDIR)$(service_path)
cf58a5c
 
cf58a5c
-OBJS= notifyd.o notify_null.o notify_log.o notify_mailto.o notify_zephyr.o
cf58a5c
+OBJS= notifyd.o notify_null.o notify_log.o notify_mailto.o notify_sms.o notify_zephyr.o
cf58a5c
 
cf58a5c
 notifytest: notifytest.o
cf58a5c
 	$(CC) $(LDFLAGS) -o notifytest \
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/notifyd/notifyd.h cyrus-imapd-2.3.7/notifyd/notifyd.h
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/notifyd/notifyd.h	2003-02-13 21:15:48.000000000 +0100
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/notifyd/notifyd.h	2006-07-14 10:27:29.000000000 +0200
cf58a5c
@@ -48,6 +48,7 @@
cf58a5c
 #include "notify_null.h"
cf58a5c
 #include "notify_log.h"
cf58a5c
 #include "notify_mailto.h"
cf58a5c
+#include "notify_sms.h"
cf58a5c
 #include "notify_zephyr.h"
cf58a5c
 
cf58a5c
 /* Notify method dispatch table definition */
cf58a5c
@@ -64,6 +65,7 @@
cf58a5c
     { "null",	notify_null },		/* do nothing */
cf58a5c
     { "log",	notify_log },		/* use syslog (for testing) */
cf58a5c
     { "mailto",	notify_mailto },	/* send an email */
cf58a5c
+    { "sms",	notify_sms },		/* send an sms */
cf58a5c
 #ifdef HAVE_ZEPHYR
cf58a5c
     { "zephyr",	notify_zephyr },	/* send a zephyrgram */
cf58a5c
 #endif
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/notifyd/notify_sms.c cyrus-imapd-2.3.7/notifyd/notify_sms.c
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/notifyd/notify_sms.c	1970-01-01 01:00:00.000000000 +0100
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/notifyd/notify_sms.c	2006-07-14 10:29:10.000000000 +0200
Tomas Janousek 915c4a4
@@ -0,0 +1,116 @@
cf58a5c
+/* notify_sms.c -- SMS notification method
cf58a5c
+ * Simon Matter
cf58a5c
+ */
cf58a5c
+/*
cf58a5c
+ * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
cf58a5c
+ *
cf58a5c
+ * Redistribution and use in source and binary forms, with or without
cf58a5c
+ * modification, are permitted provided that the following conditions
cf58a5c
+ * are met:
cf58a5c
+ *
cf58a5c
+ * 1. Redistributions of source code must retain the above copyright
cf58a5c
+ *    notice, this list of conditions and the following disclaimer. 
cf58a5c
+ *
cf58a5c
+ * 2. Redistributions in binary form must reproduce the above copyright
cf58a5c
+ *    notice, this list of conditions and the following disclaimer in
cf58a5c
+ *    the documentation and/or other materials provided with the
cf58a5c
+ *    distribution.
cf58a5c
+ *
cf58a5c
+ * 3. The name "Carnegie Mellon University" must not be used to
cf58a5c
+ *    endorse or promote products derived from this software without
cf58a5c
+ *    prior written permission. For permission or any other legal
cf58a5c
+ *    details, please contact  
cf58a5c
+ *      Office of Technology Transfer
cf58a5c
+ *      Carnegie Mellon University
cf58a5c
+ *      5000 Forbes Avenue
cf58a5c
+ *      Pittsburgh, PA  15213-3890
cf58a5c
+ *      (412) 268-4387, fax: (412) 268-7395
cf58a5c
+ *      tech-transfer@andrew.cmu.edu
cf58a5c
+ *
cf58a5c
+ * 4. Redistributions of any form whatsoever must retain the following
cf58a5c
+ *    acknowledgment:
cf58a5c
+ *    "This product includes software developed by Computing Services
cf58a5c
+ *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
cf58a5c
+ *
cf58a5c
+ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
cf58a5c
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
cf58a5c
+ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
cf58a5c
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
cf58a5c
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
cf58a5c
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
cf58a5c
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
cf58a5c
+ *
cf58a5c
+ * notify_sms is based on code from notify_mailto by Ken Murchison.
Tomas Janousek 915c4a4
+ * Copyright (c) 2005-2006 Simon Matter, Invoca Systems.
Tomas Janousek 915c4a4
+ * Release 2006071300/2.3.7
cf58a5c
+*/
cf58a5c
+
cf58a5c
+#include <config.h>
cf58a5c
+
cf58a5c
+#include "notify_sms.h"
cf58a5c
+
cf58a5c
+#include <stdio.h>
cf58a5c
+#include <string.h>
cf58a5c
+#include <unistd.h>
cf58a5c
+#include <sys/types.h>
cf58a5c
+#include <sys/wait.h>
cf58a5c
+
cf58a5c
+#include "global.h"
cf58a5c
+#include "libconfig.h"
cf58a5c
+#include "sieve_interface.h"
cf58a5c
+
cf58a5c
+static int global_outgoing_count = 0;
cf58a5c
+
cf58a5c
+char* notify_sms(const char *class __attribute__((unused)),
Tomas Janousek 915c4a4
+		    const char *priority,
Tomas Janousek 915c4a4
+		    const char *user,
cf58a5c
+		    const char *mailbox __attribute__((unused)),
cf58a5c
+		    int nopt, char **options,
cf58a5c
+		    const char *message)
cf58a5c
+{
cf58a5c
+    FILE *sm;
cf58a5c
+    const char *smbuf[10];
cf58a5c
+    int sm_stat;
cf58a5c
+    pid_t sm_pid;
cf58a5c
+    int fds[2];
cf58a5c
+
cf58a5c
+    /* XXX check/parse options (sms URI) */
cf58a5c
+    if (nopt < 1)
cf58a5c
+	return strdup("NO sms URI not specified");
cf58a5c
+
cf58a5c
+    smbuf[0] = "sendsms";
Tomas Janousek 915c4a4
+    smbuf[1] = "-u";
Tomas Janousek 915c4a4
+    smbuf[2] = user;
Tomas Janousek 915c4a4
+    smbuf[3] = "-p";
Tomas Janousek 915c4a4
+    smbuf[4] = priority;
Tomas Janousek 915c4a4
+    smbuf[5] = "-o";
Tomas Janousek 915c4a4
+    smbuf[6] = options[0];
Tomas Janousek 915c4a4
+    smbuf[7] = NULL;
cf58a5c
+
cf58a5c
+    pipe(fds);
cf58a5c
+    if ((sm_pid = fork()) == 0) {
cf58a5c
+	/* i'm the child! run sendsms! */
cf58a5c
+	close(fds[1]);
cf58a5c
+	/* make the pipe be stdin */
cf58a5c
+	dup2(fds[0], 0);
cf58a5c
+	execv(config_getstring(IMAPOPT_SENDSMS), (char **) smbuf);
cf58a5c
+
cf58a5c
+	/* if we're here we suck */
cf58a5c
+	return strdup("NO sms couldn't exec");
cf58a5c
+    }
cf58a5c
+    /* i'm the parent */
cf58a5c
+    close(fds[0]);
cf58a5c
+    sm = fdopen(fds[1], "w");
cf58a5c
+
cf58a5c
+    if (!sm)
cf58a5c
+	return strdup("NO sms could not spawn sendsms process");
cf58a5c
+
cf58a5c
+    fprintf(sm, message);
cf58a5c
+
cf58a5c
+    fclose(sm);
cf58a5c
+    while (waitpid(sm_pid, &sm_stat, 0) < 0);
cf58a5c
+
cf58a5c
+    /* XXX check for sendsms exit code */
cf58a5c
+
cf58a5c
+    return strdup("OK sms notification successful");
cf58a5c
+}
Tomas Janousek 915c4a4
diff -Naur cyrus-imapd-2.3.7.orig/notifyd/notify_sms.h cyrus-imapd-2.3.7/notifyd/notify_sms.h
Tomas Janousek 915c4a4
--- cyrus-imapd-2.3.7.orig/notifyd/notify_sms.h	1970-01-01 01:00:00.000000000 +0100
Tomas Janousek 915c4a4
+++ cyrus-imapd-2.3.7/notifyd/notify_sms.h	2006-07-14 10:29:10.000000000 +0200
Tomas Janousek 915c4a4
@@ -0,0 +1,61 @@
cf58a5c
+/* notify_sms.h -- SMS notification method
cf58a5c
+ * Simon Matter
cf58a5c
+ */
cf58a5c
+/*
cf58a5c
+ * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
cf58a5c
+ *
cf58a5c
+ * Redistribution and use in source and binary forms, with or without
cf58a5c
+ * modification, are permitted provided that the following conditions
cf58a5c
+ * are met:
cf58a5c
+ *
cf58a5c
+ * 1. Redistributions of source code must retain the above copyright
cf58a5c
+ *    notice, this list of conditions and the following disclaimer. 
cf58a5c
+ *
cf58a5c
+ * 2. Redistributions in binary form must reproduce the above copyright
cf58a5c
+ *    notice, this list of conditions and the following disclaimer in
cf58a5c
+ *    the documentation and/or other materials provided with the
cf58a5c
+ *    distribution.
cf58a5c
+ *
cf58a5c
+ * 3. The name "Carnegie Mellon University" must not be used to
cf58a5c
+ *    endorse or promote products derived from this software without
cf58a5c
+ *    prior written permission. For permission or any other legal
cf58a5c
+ *    details, please contact  
cf58a5c
+ *      Office of Technology Transfer
cf58a5c
+ *      Carnegie Mellon University
cf58a5c
+ *      5000 Forbes Avenue
cf58a5c
+ *      Pittsburgh, PA  15213-3890
cf58a5c
+ *      (412) 268-4387, fax: (412) 268-7395
cf58a5c
+ *      tech-transfer@andrew.cmu.edu
cf58a5c
+ *
cf58a5c
+ * 4. Redistributions of any form whatsoever must retain the following
cf58a5c
+ *    acknowledgment:
cf58a5c
+ *    "This product includes software developed by Computing Services
cf58a5c
+ *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
cf58a5c
+ *
cf58a5c
+ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
cf58a5c
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
cf58a5c
+ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
cf58a5c
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
cf58a5c
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
cf58a5c
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
cf58a5c
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
cf58a5c
+ *
cf58a5c
+ * notify_sms is based on code from notify_mailto by Ken Murchison.
Tomas Janousek 915c4a4
+ * Copyright (c) 2005-2006 Simon Matter, Invoca Systems.
Tomas Janousek 915c4a4
+ * Release 2006071300/2.3.7
cf58a5c
+ *
cf58a5c
+ */
cf58a5c
+
cf58a5c
+#ifndef _NOTIFY_SMS_H_
cf58a5c
+#define _NOTIFY_SMS_H_
cf58a5c
+
cf58a5c
+#include <config.h>
cf58a5c
+
cf58a5c
+char* notify_sms(const char *class __attribute__((unused)),
Tomas Janousek 915c4a4
+		    const char *priority,
Tomas Janousek 915c4a4
+		    const char *user,
cf58a5c
+		    const char *mailbox __attribute__((unused)),
cf58a5c
+		    int nopt, char **options,
cf58a5c
+		    const char *message);
cf58a5c
+
cf58a5c
+#endif /* _NOTIFY_SMS_H_ */