Re: mailfront imapfront-auth with dovecot 1.2.16 : SUCCESS
Bruce Guenter <[email protected]> Wed, 10 Nov 2010 14:07:02 -0600
| Newsgroups | gmane.comp.sysutils.bgware |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Nov 10, 2010 at 09:20:58AM +0800, Giam Teck Choon wrote: > This is just to share with the list members that upon couple hours of > researching, I have successfully run mailfront v1.17 imapfront-auth with > dovecot v1.2.16 which doesn't require dovecot service to be running. > > Below is the wrapper /usr/bin/mailfront-imapfront-auth-dovecot or name > whatever you like and chmod +x /usr/bin/mailfront-imapfront-auth-dovecot: > --------------------8<----------8<----------8<----------8<--------------------- > #!/bin/sh > > if [ -n "$MAIL" ] ; then > export MAIL=maildir:`echo $MAIL | sed 's@:@::@g'` > fi > exec "$@" Well, if that's all that's needed, I can add that right into imapfront-auth itself. Please try the appended patch. Simply set SETUP_DOVECOT=1 (or = anything) before running imapfront-auth, and it should set $MAIL to an appropriate string. I am working on testing it myself, but the test CVM I am currently using doesn't actually set a mail fact. -- Bruce Guenter <[email protected]> http://untroubled.org/ diff --git a/imapfront-auth.c b/imapfront-auth.c index 3f85d21..eecb658 100644 --- a/imapfront-auth.c +++ b/imapfront-auth.c @@ -245,15 +245,37 @@ void cmd_capability(void) respond(0, "OK CAPABILITY completed"); } +static int setup_env(void) +{ + const char* maildir; + const char* colon; + + if (cvm_fact_mailbox != 0 + && getenv("SETUP_DOVECOT")) { + /* Use cmd for temporary storage of the substituted mailbox name */ + if (!str_copys(&cmd, "maildir:")) + return 0; + maildir = cvm_fact_mailbox; + while ((colon = strchr(maildir, ':')) != 0) { + if (!str_catb(&cmd, maildir, colon-maildir) + || !str_catb(&cmd, "::", 2)) + return 0; + maildir = colon + 1; + } + if (!str_cats(&cmd, maildir)) + return 0; + cvm_fact_mailbox = cmd.s; + } + return cvm_setenv() + && setenv("IMAPLOGINTAG", tag.s, 1) == 0 + && setenv("AUTHENTICATED", cvm_fact_username, 1) == 0; +} + void do_exec(void) { if (!cvm_setugid()) respond(0, "NO Internal error: could not set UID/GID"); - else if (!cvm_setenv() || - (cvm_fact_mailbox != 0 && - setenv("MAILDIR", cvm_fact_mailbox, 1) == -1) || - setenv("IMAPLOGINTAG", tag.s, 1) == -1 || - setenv("AUTHENTICATED", cvm_fact_username, 1) == -1) + else if (!setup_env()) respond(0, "NO Internal error: could not set environment"); else { alarm(0);
signature.asc
(application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEARECAAYFAkza+2UACgkQ6W+y3GmZgOibgwCfar0491cCkM0TlGxb5WfNvOx/ iAcAn2UN5XWVIUiChQjUh4Q8hCqph8bY =l0dl -----END PGP SIGNATURE-----