

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
14 messages in net.sourceforge.lists.courier-maildrop[maildropl] PATCH "unknown user" if c...| From | Sent On | Attachments |
|---|---|---|
| Chris Masters | Oct 14, 2003 8:02 am | |
| Chris Masters | Oct 14, 2003 9:06 am | |
| John Locke | Oct 14, 2003 9:35 am | |
| Martin List-Petersen | Oct 15, 2003 2:37 am | |
| Chris Masters | Oct 15, 2003 3:52 am | |
| John Locke | Oct 15, 2003 10:34 am | |
| Rob Hutton | Oct 15, 2003 11:02 am | |
| Chris Masters | Oct 16, 2003 5:03 am | |
| Arnaud Pignard | Jan 28, 2004 9:07 pm | |
| Chris Masters | Jan 30, 2004 10:48 am | |
| Arnaud Pignard | Jan 30, 2004 3:26 pm | |
| Robbie Scott | Jan 31, 2004 9:58 pm | |
| Devin Rubia | Feb 2, 2004 7:06 am | |
| Chris Masters | Feb 3, 2004 1:31 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [maildropl] PATCH "unknown user" if cannot connect to mysql | Actions... |
|---|---|---|
| From: | Chris Masters (roti...@yahoo.com) | |
| Date: | Oct 15, 2003 3:52:42 am | |
| List: | net.sourceforge.lists.courier-maildrop | |
OK,
This patch will EX_TEMPFAIL if there is any failure in ldap or mysql and will only EX_NOUSER if it has connected to the data sources and has found NO entries.
Please pull me up on any errors or coding practices.
This is an extension to the other patches that I have posted on the mailing list(it includes them but not all the files affected by them). So, in addition to the attached diffs, my diffs to maildir.C, mdldapconfig.* mdmysqlconfig.* are needed.
Is it possble to submit this to the maildrop development team? We don't want those mails boucing!
Enjoy!
Chris
--- Chris Masters <roti...@yahoo.com> wrote:
OK, oops. I'm relying to my own mail here.
It seems that the function get_user_mysql in mdmysql.c only ever returns NULL if any problems are encountered.
Would it not be better to return an exit code if there is a:
1) database connection error - so that main.C can return EX_TEMPFAIL
2) general database error - that main.C can return EX_TEMPFAIL
3) connot find user error - so that main.C can return EX_NOUSER
If there is any uncertainty about the database (ldap or mysql) being up and correct tempfail rather than bounce!
Anyone?
Do I feel a patch coming on?
--- Chris Masters <roti...@yahoo.com> wrote:
Hi All,
I use maildrop to deliver mails to virtual users located in MySQL.(from Postfix).
If maildrop cannot connect to the database it returns "unknown user" instead of a 451 (tempfail) error code:
Oct 14 14:35:48 lon-quar-01 postfix/pipe[2044]: [ID 197553 mail.info] A79E2D7388: to=<roti...@wardrobes.co.uk>, relay=maildrop, delay=55, status=bounced (user unknown. Command output: Could not connect to database 192.168.0.30 Could not connect to database 192.168.0.31 Invalid user specified. )
Has anyone got a fix?
Is this a known problem?
Thanks, Chris
__________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php
_______________________________________________ Courier-maildrop mailing list Cour...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/courier-maildrop
__________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php
_______________________________________________ Courier-maildrop mailing list Cour...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/courier-maildrop
__________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
# diff main.C.old main.C 97a98,103
static void dberror() { errexit=EX_TEMPFAIL; throw "Data source error. Please try again later."; }
334c340 < mdmysqlrec *mrec = NULL;
---
mdmysqlrec *mrec = NULL;
338,339c344,356 < setgroupid(mrec->gidnumber); < setuid(mrec->uidnumber);
---
if(mrec->error == 1) { free_mysql_rec(&mrec); return -1; } else if(mrec->error == 2) { free_mysql_rec(&mrec); return 0; }
setgroupid(mrec->gidnumber); setuid(mrec->uidnumber); 385a403,413 if(rec->error == 1) { free_ldap_rec(&rec); return -1; } else if(rec->error == 2) { free_ldap_rec(&rec); return 0; }
554a583,587
if(found == -1) { dberror(); } 761a795,800 #if USEMYSQL char *tempname, *slash; struct stat stat_buf2; #endif
763a803,844
#if USEMYSQL
//create home directory if it does not exist
if (VerboseLevel() > 1)
merr << "maildrop: Creating directory " << h <<
"\n";
tempname = strdup(h); slash=tempname; while(*slash == '/') slash++;
while((slash = strchr(slash, '/'))) { *slash = '\0';
if(stat( (const char *)tempname, &stat_buf2 ) ||
!
S_ISDIR(stat_buf2.st_mode))
if(mkdir(tempname, 0755))
{
if (VerboseLevel() > 1)
merr << "maildrop: Error
making directory " << tempname << "\n";
errexit=EX_TEMPFAIL;
throw "Could not make directory.";
}
else
{
if (VerboseLevel() > 1)
merr << "maildrop: Made
directory " << tempname << "\n";
}
*slash++ = '/'; while(*slash == '/') slash++; } free(tempname); if (chdir(h) < 0) { errexit=EX_TEMPFAIL; throw "Could not change to directory."; }
#else
765c846,847 < throw "Unable to change to home directory.";
---
throw "Could not change to directory."; #endif 766a849
# diff mdmysql.c.old mdmysql.c 2a3
#include <signal.h> 14a16,17 void timed_out(){}
16a20
struct sigaction action; 24a29,31 char *tempname = NULL; char temphn2[64]; int pos1 = 0,pos2 = 0,i,timeout = 5; 25a33,37 //alarm timeout initialisation for databse connect bzero(&action, sizeof(action)); action.sa_handler = timed_out; action.sa_flags = 0; sigaction(SIGALRM, &action, 0); 26a39,59 tempname = (char*)strdup(cfg->hostname);
rec = (mdmysqlrec*)malloc(sizeof(mdmysqlrec)+1); rec->uid = NULL; rec->homedir = NULL; rec->maildir = NULL; rec->quota = NULL; rec->mailstatus = NULL; rec->error = 0;
for(i=0;i<strlen(tempname)+1;i++) { if(tempname[i] == ',' || tempname[i] == '\0') { pos2 = i; memset(temphn2,'\0',64); strncpy(temphn2,tempname+pos1,pos2-pos1); pos1 = pos2+1;
alarm(timeout);
28,29c61,63 < mysql_init(&mysql_buf); < mysql=mysql_real_connect(&mysql_buf, cfg->hostname, cfg->dbuser, cfg->dbpw,
---
mysql_init(&mysql_buf);
mysql=mysql_real_connect(&mysql_buf, temphn2, cfg->dbuser,
cfg->dbpw,
32c66 < mysql=mysql_connect(&mysql_buf, server, userid, password);
---
mysql=mysql_connect(&mysql_buf, server, userid, password); 33a68 alarm(0); 34a70,77 if(mysql) break;
fprintf(stderr, "Could not connect to database %s\n", temphn2); } } free(tempname);
36c79,82 < return NULL;
---
{ rec->error = 1; return rec; }
39,41c85,88 < mysql_close(mysql); < mysql=0; < return NULL;
---
mysql_close(mysql); mysql=0; rec->error = 1; return rec;
55,56c102,104 < mysql_close(mysql); < return NULL;
---
mysql_close(mysql); rec->error = 1; return rec;
67,69c115,118 < mysql_close(mysql); < free(querybuf); < return NULL;
---
mysql_close(mysql); free(querybuf); rec->error = 1; return rec;
75,77c124,128 < if (! result) { < mysql_close(mysql); < return NULL;
---
if (! result) { mysql_close(mysql); rec->error = 1; return rec;
80,81d130 < rec = (mdmysqlrec*)malloc(sizeof(mdmysqlrec)+1); < 84,86c133,136 < mysql_free_result(result); < mysql_close(mysql); < return NULL;
---
mysql_free_result(result); mysql_close(mysql); rec->error = 2; return rec;
95,96c145,157 < rec->homedir=strdup(row[3]); < rec->maildir=strdup(row[4]);
---
//following lines added my cmasters 27-09-2003 for virtual base capability
rec->homedir=malloc(sizeof(char) * (strlen(row[3]) + strlen(cfg->maildir_base)
+ 1));
memset(rec->homedir,'\0',(strlen(row[3]) + strlen(cfg->maildir_base) + 1));
strcpy(rec->homedir,cfg->maildir_base);
strcat(rec->homedir,row[3]);
//rec->homedir=strdup(row[3]);
rec->maildir=malloc(sizeof(char) * (strlen(row[3]) + strlen(cfg->maildir_base)
+ 1));
memset(rec->maildir,'\0',(strlen(row[4]) + strlen(cfg->maildir_base) + 1));
strcpy(rec->maildir,cfg->maildir_base);
strcat(rec->maildir,row[4]);
//rec->maildir=strdup(row[4]);
104c165,168 < return NULL;
---
{ rec->error = 2; return rec; }
# diff mdmysql.h.old mdmysql.h 17a18
int error;
#
# diff mdldap.c.old mdldap.c 2a3
#include <signal.h> 11a13,14 void ldap_timed_out(){}
14c17,18 < LDAP *ldap;
---
struct sigaction action; LDAP *ldap = NULL; 24a29,31 char *tempname = NULL; char temphn2[64]; int pos1 = 0,pos2 = 0,i,timeout = 5,bind_result = 0;
26,28c33,37 < ldap = ldap_init(cfg->hostname,cfg->port); < if ( !ldap ) < return NULL;
---
//alarm timeout initialisation for databse connect bzero(&action, sizeof(action)); action.sa_handler = ldap_timed_out; action.sa_flags = 0; sigaction(SIGALRM, &action, 0);
30,35c39,46 < if ( cfg->binddn && cfg->bindpw ) < { < needbind = 1; < if ( ldap_simple_bind_s(ldap,cfg->binddn,cfg->bindpw) != 0 ) < return NULL; < }
---
tempname = (char*)strdup(cfg->hostname); rec = (mdldaprec*)malloc(sizeof(mdldaprec)+1); rec->dn = NULL; rec->maildir = NULL; rec->mail = NULL; rec->homedirectory = NULL; rec->quota = NULL; rec->error = 0; 36a48,84 for(i=0;i<strlen(tempname)+1;i++) { if(tempname[i] == ',' || tempname[i] == '\0') { pos2 = i; memset(temphn2,'\0',64); strncpy(temphn2,tempname+pos1,pos2-pos1); pos1 = pos2+1;
alarm(timeout);
ldap = ldap_init(temphn2,cfg->port); if ( !ldap ) return NULL;
if ( cfg->binddn && cfg->bindpw )
{
needbind = 1;
bind_result =
ldap_simple_bind_s(ldap,cfg->binddn,cfg->bindpw);
}
alarm(0);
if(bind_result == 0) break;
fprintf(stderr, "Could not connect to ldap %s\n", temphn2); } } free(tempname);
if (bind_result != 0) { rec->error = 1; return rec; }
65,69c113,118 < if ( needbind ) < ldap_unbind(ldap); < free(mail_filter); < free(filter); < return NULL;
---
if ( needbind ) ldap_unbind(ldap); free(mail_filter); free(filter); rec->error = 1; return rec;
76,80c125,130 < if ( needbind ) < ldap_unbind(ldap); < free(mail_filter); < free(filter); < return NULL;
---
if ( needbind ) ldap_unbind(ldap); free(mail_filter); free(filter); rec->error = 2; return rec;
83,84d132 < rec = (mdldaprec*)malloc(sizeof(mdldaprec)+1); < 97c145,149 < rec->maildir = strdup(values[0]);
---
rec->maildir= malloc(sizeof(char) * (strlen(values[0]) +
strlen(cfg->maildir_base_ldap) + 1));
strcpy(rec->maildir,cfg->maildir_base_ldap);
strcat(rec->maildir,values[0]);
//rec->maildir = strdup(values[0]);
132c184,187 < rec->homedirectory = strdup(values[0]);
---
rec->homedirectory = malloc(sizeof(char) * (strlen(values[0]) +
strlen(cfg->maildir_base_ldap) + 1));
strcpy(rec->homedirectory,cfg->maildir_base_ldap);
strcat(rec->homedirectory,values[0]);
//rec->homedirectory = strdup(values[0]);
#
# diff mdldap.h.old mdldap.h 15a16
int error;
#







