[courier-users] PATCH: webmail address from auth

This is a discussion on [courier-users] PATCH: webmail address from auth within the Courier-Imap forums, part of the Mail Servers and Related category; This is a multi-part message in MIME format. --------------010707010505020401090300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed ...


Go Back   Usenet Forums > Mail Servers and Related > Courier-Imap

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-23-2006
Alessandro Vesely
 
Posts: n/a
Default [courier-users] PATCH: webmail address from auth

This is a multi-part message in MIME format.
--------------010707010505020401090300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Webmail currently obtains the email address from the html form.
The patch I propose replaces that with the official address
obtained from authentication. Often they are equal. However,
using advanced configuration features of Courier-Authlib,
it is possible to obtain different results. (In such cases,
IME, webmail just fails to set the sender address correctly.)


--------------010707010505020401090300
Content-Type: text/plain;
name="webmail-address-from-auth.patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="webmail-address-from-auth.patch.txt"

--- webmail/auth.original.h 2004-11-21 04:49:57.000000000 +0100
+++ webmail/auth.h 2006-10-22 18:51:13.000000000 +0200
@@ -11,7 +11,7 @@
#define auth_h

extern int prelogin(const char *);
-extern const char *do_login(const char *, const char *, const char *);
+extern const char *do_login(char **, const char *, const char *);

extern const char *login_returnaddr();
extern const char *login_fromhdr();
--- webmail/sqwebmail.original.c 2006-07-25 03:21:17.000000000 +0200
+++ webmail/sqwebmail.c 2006-10-22 19:24:40.000000000 +0200
@@ -2900,13 +2900,14 @@
const char *u2=cgi("logindomain");
char *ubuf=malloc(strlen(u)+strlen(u2)+2);

+ if (ubuf == NULL) enomem();
strcpy(ubuf, u);
if (*u2)
strcat(strcat(ubuf, "@"), u2);

maildir_cache_start();

- if (*p && (mailboxid=do_login(ubuf, p, ip_addr))
+ if (*p && (mailboxid=do_login(&ubuf, p, ip_addr))
!= 0)
{
char *q;
--- webmail/auth.original.c 2006-05-28 17:29:52.000000000 +0200
+++ webmail/auth.c 2006-10-22 19:20:24.000000000 +0200
@@ -91,14 +91,15 @@
{
const char *p=auth_getoption(a->options ? a->options:"",
"disablewebmail");
- const char *c=(const char *)vp;
+ const char *c=a->address;

static char *authaddr=NULL;
static char *authfullname=NULL;
static char *authoptions=NULL;
const char *n;
- char *b;
+ char *b, **ubuf = (char **)vp;
int rc;
+ size_t len;


if (p && atoi(p))
@@ -117,7 +118,7 @@
return (-1);
}

- b=malloc(sizeof("AUTHADDR=")+strlen(c));
+ b=malloc(sizeof("AUTHADDR=") + (len = strlen(c)));

if (!b)
enomem();
@@ -126,6 +127,17 @@
if (authaddr)
free(authaddr);
authaddr=b;
+
+ if (ubuf)
+ {
+ if (strlen(*ubuf) < len)
+ {
+ free(*ubuf);
+ if ((*ubuf = malloc(len + 1)) == NULL)
+ enomem();
+ }
+ strcpy(*ubuf, c);
+ }


n=a->fullname;
@@ -156,17 +168,18 @@
return (0);
}

-const char *do_login(const char *u, const char *p, const char *ip)
+const char *do_login(char **ubuf, const char *p, const char *ip)
{
- if (auth_login("webmail", u, p, doauthlogin, (void *)u))
+ char *u = ubuf? *ubuf: NULL;
+ if (auth_login("webmail", u, p, doauthlogin, (void *)ubuf))
{
courier_safe_printf("INFO: LOGIN FAILED, user=%s, ip=[%s]",
u?u:"", ip);
return NULL;
}

- fprintf(stderr, "INFO: LOGIN, user=%s, ip=[%s]\n", u, ip);
- return u;
+ fprintf(stderr, "INFO: LOGIN, user=%s, ip=[%s]\n", *ubuf, ip);
+ return *ubuf;
}

int nochangepass()
@@ -205,7 +218,7 @@

int prelogin(const char *u)
{
- return auth_getuserinfo("webmail", u, doauthlogin, (void *)u);
+ return auth_getuserinfo("webmail", u, doauthlogin, NULL);
}

const char *login_returnaddr()

--------------010707010505020401090300
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=...057&dat=121642
--------------010707010505020401090300
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
courier-users mailing list
courier-users@lists.sourceforge.net
Unsubscribe: https://lists.sourceforge.net/lists/.../courier-users

--------------010707010505020401090300--

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0