Tomas Janousek 915c4a
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 915c4a
--- cyrus-imapd-2.3.7.orig/doc/man/imapd.conf.5.html	2006-07-10 16:31:53.000000000 +0200
Tomas Janousek 915c4a
+++ cyrus-imapd-2.3.7/doc/man/imapd.conf.5.html	2006-07-14 10:27:29.000000000 +0200
Tomas Janousek 915c4a
@@ -3130,6 +3130,24 @@
cf58a5
 
cf58a5
 
cf58a5
 
cf58a5
+

sendsms: /usr/bin/sendsms

cf58a5
+

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

The pathname of the sendsms executable. Sieve invokes

cf58a5
+sendsms for sending SMS notifications.

cf58a5
+
cf58a5
+
cf58a5
+
cf58a5
+

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

servername: <none>

Tomas Janousek 915c4a
 
cf58a5
 
Tomas Janousek 915c4a
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 915c4a
--- cyrus-imapd-2.3.7.orig/doc/man/notifyd.8.html	2006-07-10 16:31:54.000000000 +0200
Tomas Janousek 915c4a
+++ cyrus-imapd-2.3.7/doc/man/notifyd.8.html	2006-07-14 10:27:29.000000000 +0200
cf58a5
@@ -181,6 +181,18 @@
cf58a5
 
cf58a5
 
cf58a5
 
cf58a5
+

sms

cf58a5
+
cf58a5
+
cf58a5
+
cf58a5
+

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

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

cf58a5
+
cf58a5
+
cf58a5
+
cf58a5
+
cf58a5
+
cf58a5
 

zephyr

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