From fe3e81a373f8018745d4473f0690ac9a7f015bb3 Mon Sep 17 00:00:00 2001 From: alec Date: Wed, 7 Mar 2012 10:18:08 +0000 Subject: - Added DBMail driver (#1488281) git-svn-id: https://svn.roundcube.net/trunk@5976 208e9e7b-5314-0410-a742-e7e81cd9613c --- plugins/password/drivers/chgdbmailusers.c | 48 +++++++++++++++++++++++++++++++ plugins/password/drivers/dbmail.php | 42 +++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 plugins/password/drivers/chgdbmailusers.c create mode 100644 plugins/password/drivers/dbmail.php (limited to 'plugins/password/drivers') diff --git a/plugins/password/drivers/chgdbmailusers.c b/plugins/password/drivers/chgdbmailusers.c new file mode 100644 index 000000000..28f79c100 --- /dev/null +++ b/plugins/password/drivers/chgdbmailusers.c @@ -0,0 +1,48 @@ +#include +#include +#include + +// set the UID this script will run as (root user) +#define UID 0 +#define CMD "/usr/sbin/dbmail-users" +#define RCOK 0x100 + +/* INSTALLING: + gcc -o chgdbmailusers chgdbmailusers.c + chown root.apache chgdbmailusers + strip chgdbmailusers + chmod 4550 chgdbmailusers +*/ + +main(int argc, char *argv[]) +{ + int cnt,rc,cc; + char cmnd[255]; + + strcpy(cmnd, CMD); + + if (argc > 1) + { + for (cnt = 1; cnt < argc; cnt++) + { + strcat(cmnd, " "); + strcat(cmnd, argv[cnt]); + } + } + else + { + fprintf(stderr, "__ %s: failed %d %d\n", argv[0], rc, cc); + return 255; + } + + cc = setuid(UID); + rc = system(cmnd); + + if ((rc != RCOK) || (cc != 0)) + { + fprintf(stderr, "__ %s: failed %d %d\n", argv[0], rc, cc); + return 1; + } + + return 0; +} diff --git a/plugins/password/drivers/dbmail.php b/plugins/password/drivers/dbmail.php new file mode 100644 index 000000000..a457fc27b --- /dev/null +++ b/plugins/password/drivers/dbmail.php @@ -0,0 +1,42 @@ +config->get('password_dbmail_args', ''); + + exec("$curdir/chgdbmailusers -c $username -w $newpass $args", $output, $returnvalue); + + if ($returnvalue == 0) { + return PASSWORD_SUCCESS; + } + else { + raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers" + ), true, false); + } + + return PASSWORD_ERROR; + } +} -- cgit v1.2.3