Hello, There is a "qmailadmin-toaster" project which has created RPMS for creating a Qmailadmin toaster.
As part of their software, they have patched vmysql.h so that the database information is kept in a file called "sql" in the /var/qmail/control directory (actually, a more appropriate place would rpolly be ~vpopmail/etc, but that's another matter). Anyway, I much prefer this idea of being able to change MySQL server information via a single file, as opposed to recompiling vpopmail (and all the tools that uses it's libs, like Qmailadmin) whenever you wish to change the server that the vpopmail MySQL database is stored on. I have included the patch below (it's for 5.3.8), since it is open source, and hopefully this can make it into the mainstream branch? Please note: I am not the author of this patch, so please do not give me credit for it; I am just trying to bring good code to the masses :-) Thanks! Alan Murrell <[EMAIL PROTECTED]> diff -Naur ./vmysql.c ../vpopmail-5.3.8/vmysql.c --- ./vmysql.c Sat Apr 6 16:30:30 2002 +++ ../vpopmail-5.3.8/vmysql.c Thu Aug 1 01:40:08 2002 @@ -93,11 +93,50 @@ void vcreate_lastauth_table(); #endif +/* + * Qmail Toaster Patch + */ +void leggi_parametri_sql() { + + FILE *fp; + if(fp=fopen("/var/qmail/control/sql","r")) { + char line[256]; + char tag[256]; + char value[256]; + + while(fgets(line,256,fp)) { + char *comment; + if(comment=strchr(line,'#')) { + *comment='\0'; + } ++ if(sscanf(line,"%s\t%s\n", tag, value) != 2) continue; + + if(!strcasecmp(tag,"server")) { + sprintf( MYSQL_UPDATE_SERVER, "%s", value ) ; + sprintf( MYSQL_READ_SERVER, "%s", value ) ; + } else if(!strcasecmp(tag,"user")) { + sprintf( MYSQL_UPDATE_USER, "%s", value ) ; + sprintf( MYSQL_READ_USER, "%s", value ) ; + } else if(!strcasecmp(tag,"pass")) { + sprintf( MYSQL_UPDATE_PASSWD, "%s", value ) ; + sprintf( MYSQL_READ_PASSWD, "%s", value ) ; + } + + } + + } + +} + + /* * Open a connection to mysql for updates */ int vauth_open_update() { + leggi_parametri_sql() ; + if ( update_open != 0 ) return(0); update_open = 1; @@ -155,6 +194,8 @@ */ int vauth_open_read() { + leggi_parametri_sql() ; + /* if we are already connected, just return */ if ( read_open != 0 ) return(0); read_open = 1; @@ -186,6 +227,8 @@ */ int vauth_open_read_getall() { + leggi_parametri_sql() ; + /* if we are already connected, just return */ if ( read_getall_open != 0 ) return(0); diff -Naur ./vmysql.h ../vpopmail-5.3.8/vmysql.h --- ./vmysql.h Sat Apr 6 16:30:31 2002 +++ ../vpopmail-5.3.8/vmysql.h Thu Aug 1 01:38:31 2002 @@ -19,14 +19,26 @@ #define VPOPMAIL_MYSQL_H /* Edit to match your set up */ -#define MYSQL_UPDATE_SERVER "localhost" -#define MYSQL_UPDATE_USER "root" -#define MYSQL_UPDATE_PASSWD "secret" - -#define MYSQL_READ_SERVER "localhost" -#define MYSQL_READ_USER "root" -#define MYSQL_READ_PASSWD "secret" +//#define MYSQL_UPDATE_SERVER "localhost" +//#define MYSQL_UPDATE_USER "root" +//#define MYSQL_UPDATE_PASSWD "secret" +// +//#define MYSQL_READ_SERVER "localhost" +//#define MYSQL_READ_USER "root" +//#define MYSQL_READ_PASSWD "secret" /* End of setup section*/ + +/* QmailToaster patch */ +char db_host[256] ; +char db_user[256] ; +char db_password[256] ; +char MYSQL_UPDATE_SERVER[256] ; +char MYSQL_UPDATE_USER[256] ; +char MYSQL_UPDATE_PASSWD[256] ; +char MYSQL_READ_SERVER[256] ; +char MYSQL_READ_USER[256] ; +char MYSQL_READ_PASSWD[256] ; +void leggi_parametri_sql() ; /* defaults - no need to change */ #define MYSQL_VPORT 0 ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca