Hi,

I am looking to upgrade to vqadmin 2.3.6, however this needs to be done on several hundred servers and so having the satabase details (which are randomly generated) compiled into the code is not an option.

What would be better would be to get vqadmin to read in the settings from /home/vpopmail/etc/vpopmail.mysql in order to do the authentication.

Now I am not a c coder by any stretch of the imagination ;) but I have managed to cobble together the following, which on its own runs fine and can pull the details and print them out to stdout.

Does anyone have any idea how this should be integrated into the dbowner.c file to allow the app to compile (again, this is using vanilla vqadmin-2.3.6 from sourceforge.net).

Thanks for your time.

Chris Sarginson


!DSPAM:4549d53a27412005420385!
#include <stdio.h>
int main(void){
FILE *fp;
char config[256];
char conn_info[256];
int eof;
char delimiters[] = "|\n";
char *conf_read, *host, *db_port, *user, *passwd, *db;

sprintf(config, "/home/vpopmail/etc/vpopmail.mysql");

fp=fopen(config, "r"); /* open read-only */


do {
        eof = (fgets (conn_info, sizeof(conn_info), fp) == NULL);
    } while (!eof && ((*conn_info == '#') || (*conn_info == '\n')));

    if (eof) {
        /* no valid data read, return error */
        fprintf(stderr, "vqadmin: no valid settings in %s\n", config);
    }

        conf_read = strdup(conn_info);
        host = strtok(conf_read, delimiters);
        db_port = strtok(NULL, delimiters);
        user = strtok(NULL, delimiters);
        passwd = strtok(NULL, delimiters);
        db = strtok(NULL, delimiters);

printf(host);
printf(db_port);
printf(user);
printf(passwd);
printf(db);

}



!DSPAM:4549d53a27412005420385!

Reply via email to