cyrus-imapd/cyrus-imapd-2.2.12-notify_sms.patch

305 lines
12 KiB
Diff
Raw Normal View History

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