From 8e9a55abd88256de03185a737fc25d6045533ace Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 30 Jun 2009 13:23:39 -0400
Subject: [PATCH] Add SASL password wrapper program + update SASL instructions in README

---
 plugins/password/README                  |    6 +++---
 plugins/password/drivers/chgsaslpasswd.c |   27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/plugins/password/README b/plugins/password/README
index 920d3a3..a7e386e 100644
--- a/plugins/password/README
+++ b/plugins/password/README
@@ -123,13 +123,13 @@
 
  Installation:
 
- Edit the chgsaslpasswd.c and chgsaslpasswd.sh files as is documented
- within them.
+ Change into the drivers directory. Edit the chgsaslpasswd.c file as is
+ documented within it.
 
  Compile the wrapper program:
 	gcc -o chgsaslpasswd chgsaslpasswd.c
 
- Chown the chgsaslpasswd and chgsaslpasswd.sh to the cyrus user and group
+ Chown the compiled chgsaslpasswd binary to the cyrus user and group
  that your browser runs as, then chmod them to 4550.
 
  For example, if your cyrus user is 'cyrus' and the apache server group is
diff --git a/plugins/password/drivers/chgsaslpasswd.c b/plugins/password/drivers/chgsaslpasswd.c
new file mode 100644
index 0000000..17e20c6
--- /dev/null
+++ b/plugins/password/drivers/chgsaslpasswd.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <unistd.h>
+
+// set the UID this script will run as (cyrus user)
+#define UID 96
+// set the path to saslpasswd or saslpasswd2
+#define CMD "/usr/sbin/saslpasswd2"
+
+/* INSTALLING:
+  gcc -o chgsaslpasswd chgsaslpasswd.c
+  chown root.apache chgsaslpasswd
+  strip chgsaslpasswd
+  chmod 4550 chgsaslpasswd
+*/
+
+main(int argc, char *argv[])
+{
+  int rc,cc;
+
+  cc = setuid(UID);
+  rc = execvp(CMD, argv);
+  if ((rc != 0) || (cc != 0))
+  {
+    fprintf(stderr,"__ %s:  failed %d  %d\n",argv[0],rc,cc);
+    exit(1);
+  }
+}

--
Gitblit v1.9.1