[vchkpw] Transition from pop-before-smtp

2006-03-14 Thread Michael Krieger
I've got a much older mail system running vpopmail/qmail that was  created some time ago.  We have been encouraging new settings on  users for some time, including using their full e-mail address instead  of just the username to authenticate, as well as enabling smtp  authentication.As with any transition, it's a slow process that nobody seems to care much about until it stops working.The vipmap situation (default domains) was easy, as I document below  incase it helps anyone.  The SMTP authentication I seem to be  having a bit more trouble with.  Of course many users don't use  our smtp servers at all and instead use their ISPs.  Yet vpopmail  opens POP for everyone.  What I want to know is to have a log  entry (probably the from address) every time a user:   - is allowed to relay through our mail server (so has RELAYCLIENT set)   - did not authenticate (so TCPREMOTEINFO does not have their username)   -
 sends to an e-mail address not in rcpthosts (so relays)Any ideas how we'd implement that?  Are any existing contributions useful here?To find people who are using vipmap and not specifying their domain  (with a % or @), we implemented the following code in vpopmail.c's  parse_email() function instead of just vset_default_domain().       FILE *;  and    if ( (domain == NULL) || (strlen(domain)<1) ) {     vset_default_domain(domain);      = fopen("/tmp/legacyipalias", "a");     fprintf(,"[EMAIL PROTECTED]", user, domain, get_remote_ip());     fclose();      = NULL;    } else {    // not needed since it'll just return, but just in case     vset_default_domain(domain);    }    

[vchkpw] Per user .qmail files patch for 5.4.15

2006-03-14 Thread drew-vpopmail
Just in case anyone was using them attached are the patches for 5.4.15 to 
enable per-user .qmail files.  I use per user .qmail files in a live 
environment so have to do these patch files anyway.
diff -uPr vpopmail-5.4.15.orig/vdelivermail.c vpopmail-5.4.15/vdelivermail.c
--- vpopmail-5.4.15.orig/vdelivermail.c 2005-11-19 16:24:22.0 +
+++ vpopmail-5.4.15/vdelivermail.c  2006-03-14 15:51:31.0 +
@@ -62,6 +62,7 @@
 #ifdef QMAIL_EXT
 /* the User with '-' and following chars out if any */
 char TheUserExt[AUTH_SIZE]; 
+char TheExt[AUTH_SIZE];
 #endif
 
 #define FILE_SIZE 156
@@ -217,6 +218,11 @@
 vexit(EXIT_BOUNCE);
 }
 
+strncpy(TheExt, &TheUser[i+1], AUTH_SIZE);
+for (i = 0; (TheExt[i] != 0); i++) {
+   if (TheExt[i] == '.') TheExt[i] = ':';
+}
+
 #endif
 
 vget_assign(TheDomain, TheDomainDir, sizeof(TheDomainDir), &TheDomainUid, 
&TheDomainGid);
@@ -698,14 +704,34 @@
 chdir(dir);
 
 /* format the file name */
-if ( (fs = fopen(".qmail","r")) == NULL ) {
-
-/* no file, so just return */
-return(-1);
+#ifdef QMAIL_EXT
+if (strlen(TheExt)) {
+   strcpy(tmpbuf,".qmail-");
+   strcat(tmpbuf,TheExt);
+   if ( (fs = fopen(tmpbuf,"r")) == NULL ) {
+   for (i = strlen(TheExt);i>=0;i--) {
+   if (!i || TheExt[i-1]=='-') {
+   strcpy(tmpbuf,".qmail-");
+   strncat(tmpbuf,TheExt,i);
+   strcat(tmpbuf,"default");
+   if ( (fs = fopen(tmpbuf,"r")) != NULL ) {
+   break;
+   }
+   }
+   }
+   }
+} else {
+   fs = fopen(".qmail","r");
 }
+#else
+fs = fopen(".qmail","r");
+#endif
 
-/* format a simple loop checker name */
-snprintf(tmpbuf, sizeof(tmpbuf), "[EMAIL PROTECTED]", TheUser, TheDomain);
+/* no .qmail file at all */
+if (fs == NULL) {
+   /* no file, so just return */
+   return(-1);
+}
 
 /* read the file, line by line */
 while ( fgets(qmail_line, sizeof(qmail_line), fs ) != NULL ) {
@@ -719,14 +745,6 @@
 if (qmail_line[i] == '\n') qmail_line[i] = 0;
 }
 
-/* simple loop check, if they are sending it to themselves
- * then skip this line
- */
-if ( strcmp( qmail_line, tmpbuf) == 0 ) continue;
-/* check for &[EMAIL PROTECTED] as well */
-if ((*qmail_line == '&') && (strcmp (qmail_line + 1, tmpbuf) == 0))
-continue;
-
 deliver_mail(qmail_line, "");
 
 return_value = 1;
diff -uPr vpopmail-5.4.15.orig/vdelivermail.c vpopmail-5.4.15/vdelivermail.c
--- vpopmail-5.4.15.orig/vdelivermail.c 2006-03-14 15:51:31.0 +
+++ vpopmail-5.4.15/vdelivermail.c  2006-03-14 15:59:07.0 +
@@ -505,6 +505,7 @@
  FILE *fs;
  char tmp_file[256];
  char maildirquota[80];
+ char *email;
 
 /* This is a comment, ignore it */
 if ( *address == '#' ) return;
@@ -603,15 +604,19 @@
 }
 #endif
 
+   /* Get the email address from the maildir */
+   email = maildir_to_email(address);
+
 /* Set the Delivered-To: header */
-if ( strcmp( address, bounce) == 0 ) {
+if ( strcmp( address, bounce ) == 0 ||
+strcmp( email, "" ) == 0 ) {
 snprintf(DeliveredTo, sizeof(DeliveredTo), 
 "%sDelivered-To: [EMAIL PROTECTED]", getenv("RPLINE"), 
  TheUser, TheDomain);
 } else {
 snprintf(DeliveredTo, sizeof(DeliveredTo), 
 "%sDelivered-To: %s\n", getenv("RPLINE"), 
-maildir_to_email(address));
+email);
 }
 
 switch (deliver_to_maildir (address, DeliveredTo, 0, message_size)) {


Re: [vchkpw] Domain Quota Features

2006-03-14 Thread Ken Jones

kengheng wrote:

Hi, when will the domain quota feature back to vpopmail?


Thanks.


Probably never. It is too resource intensive.
I recommend using operating system user quotas.
Place each domain under a different user and let
the file system handle the quota.

This is also helpful if you host the web site
and email. Then you can impose an overall
disk space quota per account.

Ken Jones