Hi, 

On Mon, 8 Mar 2004 16:13:18 -0600
Ken Nonaka <[EMAIL PROTECTED]> wrote:
> If you use postgresql as an auth module. see 
> http://www.mail-archive.com/[EMAIL PROTECTED]/msg16766.html

msg16766's patch may annoys you as it rebuilds cdb every pop3 auth.

The (possible) patch below for vpopmail 5.4.2 (vpgsql.c 1.20) 
rebuilds cdb only when inserting.

And do clearopensmtp once before using vpopmail. 
clearopensmtp will create relay table if you don't have relay table yet. 
Without this, you will get pop3 auth error at first time like..

> [21:19:38] POP3< +OK <[EMAIL PROTECTED]>
> [21:19:38] POP3> APOP test 2866a59704a31bcc505f5a6fe47xxxxx
> [21:19:39] POP3< NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 
> "relay_pkey" for table "relay"

Ummm.


Thanks,

Ken

--- vpgsql.c.ver.1.20   2004-02-26 19:44:58.000000000 +0900
+++ vpgsql.c.ver.1.20.kn2       2004-03-09 12:39:11.000000000 +0900
@@ -1,4 +1,5 @@
 /*
+ * vpgsql.c.ver.1.20.kn2 2004/03/09 k.n
  * $Id: vpgsql.c,v 1.20 2004/02/11 15:40:17 tomcollins Exp $
  * Copyright (C) 1999-2003 Inter7 Internet Technologies, Inc.
  *
@@ -626,44 +627,50 @@
 
   if ( (err=vauth_open()) != 0 ) return 0;
 
+  /* updating... */
+
   snprintf(SqlBufUpdate, SQL_BUF_SIZE, 
     "UPDATE relay SET ip_addr='%s', timestamp=%d WHERE ip_addr='%s'",
     ipaddr, (int)mytime, ipaddr);
 
   pgres=PQexec(pgc, SqlBufUpdate);
-  if (PQresultStatus(pgres) == PGRES_COMMAND_OK && atoi(PQcmdTuples(pgres)) == 0) {
-    if( pgres ) PQclear(pgres);
 
-    snprintf( SqlBufUpdate, SQL_BUF_SIZE,
-      "INSERT INTO relay (ip_addr, timestamp) VALUES ('%s', %lu)",
-      ipaddr, time(NULL)); 
+  /* ...got error, ignored some exceptions ;-P */
 
-    pgres=PQexec(pgc, SqlBufUpdate);
+  if (PQresultStatus(pgres) != PGRES_COMMAND_OK) {
+    if (pgres) {
+      PQclear(pgres);
     }
-
-/* UPDATE returned 0 rows and/or INSERT failed.  Try creating the table */
-  if(!pgres || PQresultStatus(pgres) != PGRES_COMMAND_OK) {
-    if( pgres ) PQclear(pgres);
-
     vcreate_relay_table();
+  }

-/* and try INSERTing now... */
-    snprintf( SqlBufUpdate, SQL_BUF_SIZE,
-      "INSERT INTO relay (ip_addr, timestamp) VALUES ('%s', %lu)",
-      ipaddr, time(NULL)); 
+  /* ...updated */
 
-    pgres=PQexec(pgc, SqlBufUpdate);
+  else if (atoi(PQcmdTuples(pgres)) != 0) {
+    if (pgres) {
+      PQclear(pgres);
     }
+    return 0;
+  }
 
-  if(!pgres || PQresultStatus(pgres)!= PGRES_COMMAND_OK ) {
-    /* need to return non-zero value if value inserted */
-    if( pgres ) PQclear(pgres);
-    return 1;
+  /* inserting... */
+
+  snprintf( SqlBufUpdate, SQL_BUF_SIZE,
+    "INSERT INTO relay (ip_addr, timestamp) VALUES ('%s', %lu)",
+    ipaddr, time(NULL)); 
+
+  pgres=PQexec(pgc, SqlBufUpdate);
+
+  /* ...ignored some exceptions ;-P */
+
+  /* ...inserted */
+
+  if (pgres) {
+    PQclear(pgres);
   }
+  return 1;
 
-  if( pgres ) PQclear(pgres);
-  return 0;
-}
+} /* end vopen_smtp_relay() */



---
Ken Nonaka
nonaka at imasy or jp

Reply via email to