Hi,

Duly noting the near absolute lack of interest in my previous email (Only 
Devendra Singh  responded indicating he had the same problem),  I decided to 
go and figure out things my way.

At first, I wrote a small script that would look for the "Delivered-To" line 
emails found in the "catch-all" account and would redirect them 
appropriately.

But that was too much of a hack, so I did look at the problem itself.

And now, the end is near and so I face the final problem. My Friends, I'll say 
it clear, I'll state my case, I'm almost certain. I've looked the source in 
full, I've followed each and every pathway. But more, I found the bug and 
killed it my way.

In "vmysql.c", the function "vauth_open_update" works like this

        If (NOT OK(Connect to given Host/Database) {
           If( OK (Connect to given Host)
                Create the Database;
            } else Complain
       } else Use it.

The initial test is done using the 
                mysql_real_connect function

When given both a Host and a Database (+ user name, password and so on) It 
sometimes fails. The reason stated being "Lost connection to MySQL server 
during query". The subsequent connect, without a DB name, succeeding, the 
system tries to create the (already existing) database... and it's all 
downhill from there.

The change I made was to to change the logic to

        If(Not OK(Connect to given host)
                Complain and return

        If(Not OK (Select given Database)
                Created it and select it

        Use it.


And, in my case at leat, it solved the problem.

I do not know why the problem occurred with the apparently correct original 
code, all I can say is that I now longer have the problem I described before.

I attache a "patch" in case someone is foolhardy enough to try it.


Cheers,
        François

> Hi,
>
> I am new to this list.
>
> I recently installed on a Gentoo linux
>
>               qmail  1.03 (r13)
>               vpopmail 5.4.0
>               maildrop 1.5.3
>               qmail-scanner 1.16  ( With some modifs)
>
>
> Everything was working well until today.
>
> Today, I took my local domain and made it a "virtual" domain on my hosts.
>
> Things are mostly working, but every now and then I get the following error
> message
>
> @4000000040b3436602b4f094 delivery 2035: success:
> vmysql:_sql_error[1]:_Can't_create_database_'vpopmail'._Database_exists/vmy
>sql:_sql_error[3]:
> _No_Database_Selected/could_not_create_limits_table_CREATE_TABLE_limits_(_d
> .... The whole SQL query......
> _No_Database_Selected/user_does_not_exist,but_will_deliver_to_/var/vpopmail
>/domains/mydomain/mycatchall/
>
>
> Because I have a "catchall" account, the emails get delivered there instead
> of the correct mailbox. I can see that the "Delivered-To" header is set to
> the correct user.   I can't seem to find a pattern in the occurrence of the
> problem  The only thing is that I get the feeling it is related to the use
> of aliases  ( .qmaol-myalias)  but I am not sure.
>
> Has anyone experienced the same problem? Has anyone found a solution?
>
> Thanks
>       François Wautier
diff -ru vpopmail-5.4.0/vmysql.c vpopmail-5.4.0-fw1/vmysql.c
--- vpopmail-5.4.0/vmysql.c	2004-01-14 06:56:41.000000000 +0700
+++ vpopmail-5.4.0-fw1/vmysql.c	2004-06-06 16:10:54.848660760 +0700
@@ -203,41 +203,36 @@
     mysql_init(&mysql_update);
     mysql_options(&mysql_update, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout);
 
-    /* Try to connect to the mysql update server with the specified database. */
+    /* Try to connect to the mysql update server */
     if (!(mysql_real_connect(&mysql_update, MYSQL_UPDATE_SERVER,
-            MYSQL_UPDATE_USER, MYSQL_UPDATE_PASSWD,
-            MYSQL_UPDATE_DATABASE, MYSQL_UPDATE_PORT, NULL, 0))) {
-
-        /* Could not connect to the update mysql server with the database
-         * so try to connect with no database specified
-         */
-        if (!(mysql_real_connect(&mysql_update, MYSQL_UPDATE_SERVER,
-                MYSQL_UPDATE_USER, MYSQL_UPDATE_PASSWD, NULL, MYSQL_UPDATE_PORT,
-                NULL, 0))) {
-
-            /* if we can not connect, report a error and return */
-            verrori = VA_NO_AUTH_CONNECTION;
-            return(VA_NO_AUTH_CONNECTION);
-        }
-
-        /* we were able to connect, so create the database */ 
-        snprintf( SqlBufUpdate, SQL_BUF_SIZE, 
-            "create database %s", MYSQL_UPDATE_DATABASE );
-        if (mysql_query(&mysql_update,SqlBufUpdate)) {
-
-            /* we could not create the database
-             * so report the error and return 
-             */
-            fprintf(stderr, "vmysql: sql error[1]: %s\n", mysql_error(&mysql_update));
-            return(-1);
-        } 
-
-        /* set the database */ 
-        if (mysql_select_db(&mysql_update, MYSQL_UPDATE_DATABASE)) {
-            fprintf(stderr, "could not enter %s database\n", MYSQL_UPDATE_DATABASE);
-            return(-1);
-        }    
+			     MYSQL_UPDATE_USER, MYSQL_UPDATE_PASSWD, NULL, MYSQL_UPDATE_PORT,
+			     NULL, 0))) {
+      
+      /* if we can not connect, report a error and return */
+      verrori = VA_NO_AUTH_CONNECTION;
+      return(VA_NO_AUTH_CONNECTION);
+    }
+
+    /* set the database we use */
+    if (mysql_select_db(&mysql_update, MYSQL_UPDATE_DATABASE)) {
+      /* we were able to connect, so create the database */ 
+      snprintf( SqlBufUpdate, SQL_BUF_SIZE, 
+		"create database %s", MYSQL_UPDATE_DATABASE );
+      if (mysql_query(&mysql_update,SqlBufUpdate)) {
+	
+	/* we could not create the database
+	 * so report the error and return 
+	 */
+	fprintf(stderr, "vmysql: sql error[1]: %s\n", mysql_error(&mysql_update));
+	return(-1);
+      } 
+      /* set the database (we just created)*/ 
+      if (mysql_select_db(&mysql_update, MYSQL_UPDATE_DATABASE)) {
+	fprintf(stderr, "could not enter (just created) %s database\n", MYSQL_UPDATE_DATABASE);
+	return(-1);
+      }    
     }
+
     return(0);
 }
 

Reply via email to