[qmailadmin] patch to make qmailadmin 1.0.8 POSIX compatible
I've updated alias.c and util.c to remove the fts_* functions and put in a new get_du() function. Also, I've implemented the scandir() function and called it bkscandir(). I also fixed an obvious memory leak in the alias functions that used scandir(). Going through the code it appears there's lots of memory leaks in there... This should allow all POSIX compatible systems to run the latest version. Finally... I can add the vlimits() stuff in. Thanks, Brian Only in qmailadmin-1.0.8: Makefile diff -c qmailadmin-1.0.8.orig/alias.c qmailadmin-1.0.8/alias.c *** qmailadmin-1.0.8.orig/alias.c Wed Jan 22 00:46:04 2003 --- qmailadmin-1.0.8/alias.cThu Jan 23 23:10:11 2003 *** *** 31,36 --- 31,40 #include qmailadminx.h char* dotqmail_alias_command(char* command); + int bkscandir(const char *dirname, + struct dirent ***namelist, + int (*select)(struct dirent *), + int (*compar)(const void *, const void *)); int show_aliases(void) { *** *** 83,89 return(0); } ! n = scandir(., namelist, 0, qa_sort); for (m=0; mn; m++) { mydirent=namelist[m]; --- 87,93 return(0); } ! n = bkscandir(., namelist, 0, qa_sort); for (m=0; mn; m++) { mydirent=namelist[m]; *** *** 172,181 fclose(fs); k++; } - free(namelist[m]); } - closedir(mydir); free(namelist); if (AdminType == DOMAIN_ADMIN) { --- 176,186 fclose(fs); k++; } } closedir(mydir); + /* bk: fix memory leak */ + for (m=0; mn; m++) + free(namelist[m]); free(namelist); if (AdminType == DOMAIN_ADMIN) { *** *** 673,676 --- 678,738 /* otherwise just report nothing */ return(NULL); } + } + + /* + * Brian Kolaci + * quick implementation of the scandir() BSD function + */ + int bkscandir(const char *dirname, + struct dirent ***namelist, + int (*select)(struct dirent *), + int (*compar)(const void *, const void *)) + { + int i; + int entries; + int esize; + struct dirent* dp; + struct dirent* dent; + DIR * dirp; + + *namelist = NULL; + entries = esize = 0; + + /* load the names */ + if ((dirp = opendir(dirname)) == NULL) + return -1; + + while ((dp = readdir(dirp)) != NULL) { + if (select == NULL || (*select)(dp)) { + if (entries = esize) { + void* mem; + esize += 10; + if ((mem = realloc(*namelist, esize * sizeof(struct dirent*))) == NULL) { + for (i = 0; i entries; i++) + free((*namelist)[i]); + free(*namelist); + closedir(dirp); + return -1; + } + *namelist = (struct dirent**)mem; + } + if ((dent = (struct dirent*)malloc(sizeof(struct dirent)+MAX_FILE_NAME)) == +NULL) { + for (i = 0; i entries; i++) + free((*namelist)[i]); + free(*namelist); + closedir(dirp); + return -1; + } + memcpy(dent, dp, sizeof(*dp)+MAX_FILE_NAME); + (*namelist)[entries] = dent; + entries++; + } + } + closedir(dirp); + + /* sort them */ + if (compar) + qsort((void*)*namelist, entries, sizeof(struct dirent*), compar); + return entries; } Common subdirectories: qmailadmin-1.0.8.orig/autom4te.cache and qmailadmin-1.0.8/autom4te.cache diff -c qmailadmin-1.0.8.orig/cgi.c qmailadmin-1.0.8/cgi.c *** qmailadmin-1.0.8.orig/cgi.c Tue Aug 6 18:04:59 2002 --- qmailadmin-1.0.8/cgi.c Thu Jan 23 23:29:27 2003 *** *** 27,33 #include config.h #include qmailadmin.h #include qmailadminx.h - #include syslog.h get_cgi() { --- 27,32 Only in qmailadmin-1.0.8: config.h Only in qmailadmin-1.0.8: config.log Only in qmailadmin-1.0.8: config.status Only in qmailadmin-1.0.8: doconfig Common subdirectories: qmailadmin-1.0.8.orig/html and qmailadmin-1.0.8/html Common subdirectories: qmailadmin-1.0.8.orig/images and qmailadmin-1.0.8/images diff -c qmailadmin-1.0.8.orig/qmailadmin.h qmailadmin-1.0.8/qmailadmin.h *** qmailadmin-1.0.8.orig/qmailadmin.h Fri Oct 25 04:33:42 2002 --- qmailadmin-1.0.8/qmailadmin.h Thu Jan 23 21:31:45 2003 *** *** 51,54 char *get_quota_used(char*); //jhopper prototype int quota_to_bytes(char[], char*); //jhopper prototype int quota_to_megabytes(char[], char*); //jhopper prototype ! double get_du(char*); //jhopper prototype --- 51,54 char *get_quota_used(char*); //jhopper prototype int quota_to_bytes(char[], char*); //jhopper prototype int quota_to_megabytes(char[], char*); //jhopper prototype ! off_t get_du(const char*); //bk prototype Only in qmailadmin-1.0.8: stamp-h1 diff -c qmailadmin-1.0.8.orig/user.c qmailadmin-1.0.8/user.c *** qmailadmin-1.0.8.orig/user.cFri Jan 17
Re: [qmailadmin] patch to make qmailadmin 1.0.8 POSIX compatible
Did you leave the function qa_sort() there or remove it? It should have stayed exactly as it was before. All I did was write a function called bkscandir() that implements what's written on the linux scandir() man page. I took 10 minutes looking for the BSD sources, then said forget it and wrote it in the next 20 minutes. Didn't want to waste too much time with something that looked simple... I've attached copies of my util.c and alias.c that you can just drop into 1.0.8. You will need to manually update the prototype for get_du() (in qmailadmin.h) to be the following: off_t get_du(const char*); Thanks, Brian At 23:36 23/01/2003 -0500, you wrote: Hi Brian, quick follow up .. I forgot one change when I manually edited the alias.c file (didn't change scandir to bkscandir), but the compile still fails when it gets to the qa_sort. -- Steve Content-Type: TEXT/plain; charset=us-ascii Content-MD5: qWmg8rE8CezbPN2qsIWDBQ== I've updated alias.c and util.c to remove the fts_* functions and put in a new get_du() function. Also, I've implemented the scandir() function and called it bkscandir(). I also fixed an obvious memory leak in the alias functions that used scandir(). Going through the code it appears there's lots of memory leaks in there... This should allow all POSIX compatible systems to run the latest version. Finally... I can add the vlimits() stuff in. Thanks, Brian Content-Type: TEXT/plain; name=qdiff; charset=us-ascii; x-unix-mode=0644 Content-Description: qdiff Content-MD5: tw7QdOEV8Vqw7P+FoUbA7Q== Only in qmailadmin-1.0.8: Makefile diff -c qmailadmin-1.0.8.orig/alias.c qmailadmin-1.0.8/alias.c *** qmailadmin-1.0.8.orig/alias.c Wed Jan 22 00:46:04 2003 --- qmailadmin-1.0.8/alias.cThu Jan 23 23:10:11 2003 *** *** 31,36 --- 31,40 #include qmailadminx.h char* dotqmail_alias_command(char* command); + int bkscandir(const char *dirname, + struct dirent ***namelist, + int (*select)(struct dirent *), + int (*compar)(const void *, const void *)); int show_aliases(void) { *** *** 83,89 return(0); } ! n = scandir(., namelist, 0, qa_sort); for (m=0; mn; m++) { mydirent=namelist[m]; --- 87,93 return(0); } ! n = bkscandir(., namelist, 0, qa_sort); for (m=0; mn; m++) { mydirent=namelist[m]; *** *** 172,181 fclose(fs); k++; } - free(namelist[m]); } - closedir(mydir); free(namelist); if (AdminType == DOMAIN_ADMIN) { --- 176,186 fclose(fs); k++; } } closedir(mydir); + /* bk: fix memory leak */ + for (m=0; mn; m++) + free(namelist[m]); free(namelist); if (AdminType == DOMAIN_ADMIN) { *** *** 673,676 --- 678,738 /* otherwise just report nothing */ return(NULL); } + } + + /* + * Brian Kolaci + * quick implementation of the scandir() BSD function + */ + int bkscandir(const char *dirname, + struct dirent ***namelist, + int (*select)(struct dirent *), + int (*compar)(const void *, const void *)) + { + int i; + int entries; + int esize; + struct dirent* dp; + struct dirent* dent; + DIR * dirp; + + *namelist = NULL; + entries = esize = 0; + + /* load the names */ + if ((dirp = opendir(dirname)) == NULL) + return -1; + + while ((dp = readdir(dirp)) != NULL) { + if (select == NULL || (*select)(dp)) { + if (entries = esize) { + void* mem; + esize += 10; + if ((mem = realloc(*namelist, esize * sizeof(struct dirent*))) == NULL) { + for (i = 0; i entries; i++) + free((*namelist)[i]); + free(*namelist); + closedir(dirp); + return -1; + } + *namelist = (struct dirent**)mem; + } + if ((dent = (struct dirent*)malloc(sizeof(struct dirent)+MAX_FILE_NAME)) == NULL) { + for (i = 0; i entries; i++) + free((*namelist)[i]); + free(*namelist); + closedir(dirp); + return -1; + } + memcpy(dent, dp, sizeof(*dp)+MAX_FILE_NAME); + (*namelist)[entries] = dent; + entries++; + } + } + closedir(dirp); + + /* sort them */ + if (compar) + qsort((void*)*namelist, entries, sizeof(struct dirent*), compar); + return entries; } Common subdirectories: qmailadmin-1.0.8.orig/autom4te.cache
Re: [qmailadmin] patch to make qmailadmin 1.0.8 POSIX compatible
At 10:45 24/01/2003 -0500, Brian Kolaci wrote: Did you leave the function qa_sort() there or remove it? It should have stayed exactly as it was before. I eventually replaced it with qsort instead of qa_sort. It compiled and ran fine, though the alias/forwards menus did not work. I used your alias.c and util.c, recompiled and everything appears to be working file. -- Steve All I did was write a function called bkscandir() that implements what's written on the linux scandir() man page. I took 10 minutes looking for the BSD sources, then said forget it and wrote it in the next 20 minutes. Didn't want to waste too much time with something that looked simple... I've attached copies of my util.c and alias.c that you can just drop into 1.0.8. You will need to manually update the prototype for get_du() (in qmailadmin.h) to be the following: off_t get_du(const char*); Thanks, Brian At 23:36 23/01/2003 -0500, you wrote: Hi Brian, quick follow up .. I forgot one change when I manually edited the alias.c file (didn't change scandir to bkscandir), but the compile still fails when it gets to the qa_sort. -- Steve Content-Type: TEXT/plain; charset=us-ascii Content-MD5: qWmg8rE8CezbPN2qsIWDBQ== I've updated alias.c and util.c to remove the fts_* functions and put in a new get_du() function. Also, I've implemented the scandir() function and called it bkscandir(). I also fixed an obvious memory leak in the alias functions that used scandir(). Going through the code it appears there's lots of memory leaks in there... This should allow all POSIX compatible systems to run the latest version. Finally... I can add the vlimits() stuff in. Thanks, Brian Content-Type: TEXT/plain; name=qdiff; charset=us-ascii; x-unix-mode=0644 Content-Description: qdiff Content-MD5: tw7QdOEV8Vqw7P+FoUbA7Q== Only in qmailadmin-1.0.8: Makefile diff -c qmailadmin-1.0.8.orig/alias.c qmailadmin-1.0.8/alias.c *** qmailadmin-1.0.8.orig/alias.c Wed Jan 22 00:46:04 2003 --- qmailadmin-1.0.8/alias.cThu Jan 23 23:10:11 2003 *** *** 31,36 --- 31,40 #include qmailadminx.h char* dotqmail_alias_command(char* command); + int bkscandir(const char *dirname, + struct dirent ***namelist, + int (*select)(struct dirent *), + int (*compar)(const void *, const void *)); int show_aliases(void) { *** *** 83,89 return(0); } ! n = scandir(., namelist, 0, qa_sort); for (m=0; mn; m++) { mydirent=namelist[m]; --- 87,93 return(0); } ! n = bkscandir(., namelist, 0, qa_sort); for (m=0; mn; m++) { mydirent=namelist[m]; *** *** 172,181 fclose(fs); k++; } - free(namelist[m]); } - closedir(mydir); free(namelist); if (AdminType == DOMAIN_ADMIN) { --- 176,186 fclose(fs); k++; } } closedir(mydir); + /* bk: fix memory leak */ + for (m=0; mn; m++) + free(namelist[m]); free(namelist); if (AdminType == DOMAIN_ADMIN) { *** *** 673,676 --- 678,738 /* otherwise just report nothing */ return(NULL); } + } + + /* + * Brian Kolaci + * quick implementation of the scandir() BSD function + */ + int bkscandir(const char *dirname, + struct dirent ***namelist, + int (*select)(struct dirent *), + int (*compar)(const void *, const void *)) + { + int i; + int entries; + int esize; + struct dirent* dp; + struct dirent* dent; + DIR * dirp; + + *namelist = NULL; + entries = esize = 0; + + /* load the names */ + if ((dirp = opendir(dirname)) == NULL) + return -1; + + while ((dp = readdir(dirp)) != NULL) { + if (select == NULL || (*select)(dp)) { + if (entries = esize) { + void* mem; + esize += 10; + if ((mem = realloc(*namelist, esize * sizeof(struct dirent*))) == NULL) { + for (i = 0; i entries; i++) + free((*namelist)[i]); + free(*namelist); + closedir(dirp); + return -1; + } + *namelist = (struct dirent**)mem; + } + if ((dent = (struct dirent*)malloc(sizeof(struct dirent)+MAX_FILE_NAME)) == NULL) { + for (i = 0; i entries; i++) + free((*namelist)[i]); + free(*namelist); + closedir(dirp); + return -1; + } + memcpy(dent, dp, sizeof(*dp)+MAX_FILE_NAME); + (*namelist)[entries] = dent; +
Re: [qmailadmin] patch to make qmailadmin 1.0.8 POSIX compatible
qa_sort() is the comparison function that's fed into qsort. In any case, qsort is always called. Brian At 10:45 24/01/2003 -0500, Brian Kolaci wrote: Did you leave the function qa_sort() there or remove it? It should have stayed exactly as it was before. I eventually replaced it with qsort instead of qa_sort. It compiled and ran fine, though the alias/forwards menus did not work. I used your alias.c and util.c, recompiled and everything appears to be working file. -- Steve All I did was write a function called bkscandir() that implements what's written on the linux scandir() man page. I took 10 minutes looking for the BSD sources, then said forget it and wrote it in the next 20 minutes. Didn't want to waste too much time with something that looked simple... I've attached copies of my util.c and alias.c that you can just drop into 1.0.8. You will need to manually update the prototype for get_du() (in qmailadmin.h) to be the following: off_t get_du(const char*); Thanks, Brian
[qmailadmin] New 1.0.9 devel version
A new devel version is available for the changes from Brian Kolaci and Oden Erikson. I was able to compile on both RedHat 7.3 Linux and Solaris 5.8! Download URL: http://www.inter7.com/deve/qmailadmin-1.0.9.tar.gz 1.0.9 01/24/03 - Makefile.am had 8 spaces instead of a tab Brian Kolaci - make qmailadmin posix complient remove the fts_ functions implemented scandir() and bkscandir() functions fixed memory leak in alias functions that used scandir Oden Eriksson - Makefile.am: use DESTDIR variable -- - Ken Jones
Re: [qmailadmin] New 1.0.9 devel version
Ken, and all the others who work on qmailadmin. YOU ROCK! ;^) thanks for your efforts on this. i'll be downloading and compiling just as soon as i get 37 other tasks in my queue trimmed down At 01:16 PM 01-24-2003, Ken Jones wrote: Sorry, typo on link, it should be http://www.inter7.com/devel/qmailadmin-1.0.9.tar.gz On Friday 24 January 2003 15:15, Ken Jones wrote: A new devel version is available for the changes from Brian Kolaci and Oden Erikson. I was able to compile on both RedHat 7.3 Linux and Solaris 5.8! Download URL: http://www.inter7.com/deve/qmailadmin-1.0.9.tar.gz 1.0.9 01/24/03 - Makefile.am had 8 spaces instead of a tab Brian Kolaci - make qmailadmin posix complient remove the fts_ functions implemented scandir() and bkscandir() functions fixed memory leak in alias functions that used scandir Oden Eriksson - Makefile.am: use DESTDIR variable -- - Ken Jones Paul Theodoropoulos http://www.anastrophe.com http://folding.stanford.edu The Nicest Misanthrope on the Net
RE: [qmailadmin] New 1.0.9 devel version
-Original Message- From: Ken Jones [mailto:[EMAIL PROTECTED]] Sent: Saturday, 25 January 2003 8:16 AM To: [EMAIL PROTECTED] Subject: [qmailadmin] New 1.0.9 devel version A new devel version is available for the changes from Brian Kolaci and Oden Erikson. I was able to compile on both RedHat 7.3 Linux and Solaris 5.8! Just letting you know I installed qmailadmin-1.0.9 on my vpopmail-5.3.14 w/mysql server (redhat 7.2) and all looks good All the sorting stuff appears to be working fine! Michael.