Here's a patch for vpopmail 5.3.18.

This fixes a bug in the vmysql.c file to increase the
SQL buffer size to 2K rather than 600 bytes.

It also updates maildirquota.c to *only* set the following
functions as global:

int readdomainquota(const char *dir, long *sizep, int *cntp);
int readuserquota(const char* dir, long *sizep, int *cntp);
int domain_over_maildirquota(const char *userdir);
int user_over_maildirquota(const char *dir, const char *quota);
void add_warningsize_to_quota( const char *dir, const char *quota);
int vmaildir_readquota(const char *dir, const char *quota);

Note that the function maildir_readquota() was renamed to
vmaildir_readquota() so it won't clash with courier.  It was
also renamed in vdelivermail.c and vuserinfo.c.

All the rest of the functions in maildirquota.c were made static.
The object maildirquota.o was added to libvpopmail.a.

This way we can use the maildir quota functions in the library.
This will allow integration of the quota functions to qmailadmin,
vqsignup, vqadmin, etc.

Brian

diff -c vpopmail-5.3.18/Makefile.am vpopmail-5.3.18.new/Makefile.am
*** vpopmail-5.3.18/Makefile.am Mon Oct 21 14:59:13 2002
--- vpopmail-5.3.18.new/Makefile.am     Wed Feb 26 11:34:06 2003
***************
*** 4,10 ****
  
  noinst_LIBRARIES=libvpopmail.a
  
! COMMONSOURCES=vpopmail.c md5.c bigdir.c vauth.c file_lock.c vpalias.c seek.c 
vlimits.c
  CONFIG_CLEAN_FILES=vauth.c
  
  libvpopmail_a_SOURCES=$(COMMONSOURCES) 
--- 4,10 ----
  
  noinst_LIBRARIES=libvpopmail.a
  
! COMMONSOURCES=vpopmail.c md5.c bigdir.c vauth.c file_lock.c vpalias.c seek.c 
vlimits.c maildirquota.c
  CONFIG_CLEAN_FILES=vauth.c
  
  libvpopmail_a_SOURCES=$(COMMONSOURCES) 
diff -c vpopmail-5.3.18/Makefile.in vpopmail-5.3.18.new/Makefile.in
*** vpopmail-5.3.18/Makefile.in Thu Feb 20 16:17:24 2003
--- vpopmail-5.3.18.new/Makefile.in     Wed Feb 26 11:34:23 2003
***************
*** 76,82 ****
  
  noinst_LIBRARIES = libvpopmail.a
  
! COMMONSOURCES = vpopmail.c md5.c bigdir.c vauth.c file_lock.c vpalias.c seek.c 
vlimits.c
  CONFIG_CLEAN_FILES = vauth.c
  
  libvpopmail_a_SOURCES = $(COMMONSOURCES) 
--- 76,82 ----
  
  noinst_LIBRARIES = libvpopmail.a
  
! COMMONSOURCES = vpopmail.c md5.c bigdir.c vauth.c file_lock.c vpalias.c seek.c 
vlimits.c maildirquota.c
  CONFIG_CLEAN_FILES = vauth.c
  
  libvpopmail_a_SOURCES = $(COMMONSOURCES) 
***************
*** 162,168 ****
  LIBS = @LIBS@
  libvpopmail_a_DEPENDENCIES =  cdb/*.o
  libvpopmail_a_OBJECTS =  vpopmail.o md5.o bigdir.o vauth.o file_lock.o \
! vpalias.o seek.o vlimits.o
  AR = ar
  PROGRAMS =  $(vpopmailbin_PROGRAMS)
  
--- 162,168 ----
  LIBS = @LIBS@
  libvpopmail_a_DEPENDENCIES =  cdb/*.o
  libvpopmail_a_OBJECTS =  vpopmail.o md5.o bigdir.o vauth.o file_lock.o \
! vpalias.o seek.o vlimits.o maildirquota.o
  AR = ar
  PROGRAMS =  $(vpopmailbin_PROGRAMS)
  
Common subdirectories: vpopmail-5.3.18/attic and vpopmail-5.3.18.new/attic
Common subdirectories: vpopmail-5.3.18/cdb and vpopmail-5.3.18.new/cdb
Common subdirectories: vpopmail-5.3.18/contrib and vpopmail-5.3.18.new/contrib
Common subdirectories: vpopmail-5.3.18/convert and vpopmail-5.3.18.new/convert
Common subdirectories: vpopmail-5.3.18/doc and vpopmail-5.3.18.new/doc
Common subdirectories: vpopmail-5.3.18/ldap and vpopmail-5.3.18.new/ldap
diff -c vpopmail-5.3.18/maildirquota.c vpopmail-5.3.18.new/maildirquota.c
*** vpopmail-5.3.18/maildirquota.c      Thu Feb 20 16:43:07 2003
--- vpopmail-5.3.18.new/maildirquota.c  Wed Feb 26 12:28:30 2003
***************
*** 33,39 ****
  #include "maildirquota.h"
  #include "config.h"
  
! 
  static char *makenewmaildirsizename(const char *, int *);
  static int countcurnew(const char *, time_t *, off_t *, unsigned *);
  static int countsubdir(const char *, const char *,
--- 33,39 ----
  #include "maildirquota.h"
  #include "config.h"
  
! /* private functions - no name clashes with courier */
  static char *makenewmaildirsizename(const char *, int *);
  static int countcurnew(const char *, time_t *, off_t *, unsigned *);
  static int countsubdir(const char *, const char *,
***************
*** 40,56 ****
                time_t *, off_t *, unsigned *);
  static int statcurnew(const char *, time_t *);
  static int statsubdir(const char *, const char *, time_t *);
! static int    doaddquota(const char *, int, const char *, long, int, int);
! static int docheckquota(const char *dir,
!       int *maildirsize_fdptr,
!       const char *quota_type,
!       long xtra_size,
!       int xtra_cnt, int *percentage);
  static int docount(const char *, time_t *, off_t *, unsigned *);
! int readdomainquota(const char *dir, long *sizep, int *cntp);
! int readuserquota(const char* dir, long *sizep, int *cntp);
! int deliver_quota_warning(const char *dir);
  
  #define  NUMBUFSIZE      60
  #define       MDQUOTA_SIZE    'S'     /* Total size of all messages in maildir */
  #define       MDQUOTA_BLOCKS  'B'     /* Total # of blocks for all messages in
--- 40,59 ----
                time_t *, off_t *, unsigned *);
  static int statcurnew(const char *, time_t *);
  static int statsubdir(const char *, const char *, time_t *);
! static int doaddquota(const char *, int, const char *, long, int, int);
! static int docheckquota(const char *dir, int *maildirsize_fdptr,
!       const char *quota_type, long xtra_size, int xtra_cnt, int *percentage);
  static int docount(const char *, time_t *, off_t *, unsigned *);
! static int maildir_checkquota(const char *dir, int *maildirsize_fdptr,
!       const char *quota_type, long xtra_size, int xtra_cnt);
! static int maildir_addquota(const char *dir, int maildirsize_fd,
!       const char *quota_type, long maildirsize_size, int maildirsize_cnt);
! static int maildir_safeopen(const char *path, int mode, int perm);
! static char *str_pid_t(pid_t t, char *arg);
! static char *str_time_t(time_t t, char *arg);
! static int maildir_parsequota(const char *n, unsigned long *s);
  
+ 
  #define  NUMBUFSIZE      60
  #define       MDQUOTA_SIZE    'S'     /* Total size of all messages in maildir */
  #define       MDQUOTA_BLOCKS  'B'     /* Total # of blocks for all messages in
***************
*** 98,104 ****
                        free(domdir);
                        return 0;
                }
- 
                /* convert from MB to bytes */
                maxsize = limits.diskquota * 1024 * 1024;
                maxcnt = limits.maxmsgcount;
--- 101,106 ----
***************
*** 425,431 ****
  }
  
  
! int maildir_checkquota(const char *dir,
        int *maildirsize_fdptr,
        const char *quota_type,
        long xtra_size,
--- 427,433 ----
  }
  
  
! static int maildir_checkquota(const char *dir,
        int *maildirsize_fdptr,
        const char *quota_type,
        long xtra_size,
***************
*** 437,443 ****
                xtra_size, xtra_cnt, &dummy));
  }
  
! int maildir_readquota(const char *dir, const char *quota_type)
  {
  int   percentage=0;
  int   fd=-1;
--- 439,445 ----
                xtra_size, xtra_cnt, &dummy));
  }
  
! int vmaildir_readquota(const char *dir, const char *quota_type)
  {
  int   percentage=0;
  int   fd=-1;
diff -c vpopmail-5.3.18/maildirquota.h vpopmail-5.3.18.new/maildirquota.h
*** vpopmail-5.3.18/maildirquota.h      Sat Apr  6 09:30:35 2002
--- vpopmail-5.3.18.new/maildirquota.h  Wed Feb 26 12:23:56 2003
***************
*** 6,12 ****
--- 6,26 ----
  
  
  
+ /* I've removed pretty much the whole file execept for
+    some public functions so as to not conflict with courier.
+    I"ve made the courier functions static.
+    - Brian Kolaci
+ */
+ int readdomainquota(const char *dir, long *sizep, int *cntp);
+ int readuserquota(const char* dir, long *sizep, int *cntp);
+ int domain_over_maildirquota(const char *userdir);
+ int user_over_maildirquota(const char *dir, const char *quota);
+ void add_warningsize_to_quota( const char *dir, const char *quota);
+ int vmaildir_readquota(const char *dir,       const char *quota);
  
+ /* skip the rest... */
+ #if 0
+ 
  /* from maildirquota.h */
  
  #ifndef       maildirquota_h
***************
*** 247,249 ****
--- 261,264 ----
  }
  #endif
  #endif
+ #endif
Common subdirectories: vpopmail-5.3.18/oracle and vpopmail-5.3.18.new/oracle
diff -c vpopmail-5.3.18/vdelivermail.c vpopmail-5.3.18.new/vdelivermail.c
*** vpopmail-5.3.18/vdelivermail.c      Thu Feb 20 16:30:19 2003
--- vpopmail-5.3.18.new/vdelivermail.c  Wed Feb 26 12:24:48 2003
***************
*** 89,101 ****
  void checkuser(void);
  void usernotfound(void);
  int is_loop_match( char *dt, char *address);
- 
- /* functions in maildirquota.c */
  int deliver_quota_warning(const char *dir, const char *q);
- int user_over_maildirquota(char *address, char *quota);
- int domain_over_maildirquota(char *userdir);
- void add_warningsize_to_quota( const char *dir, const char *q);
- char *format_maildirquota(const char *q);
  
  static char local_file[156];
  static char local_file_new[156];
--- 89,95 ----
***************
*** 488,494 ****
                  return(-1);
              }
              if (QUOTA_WARN_PERCENT >= 0 &&
!                 maildir_readquota(address, format_maildirquota(quota))
                      >= QUOTA_WARN_PERCENT) {
                  deliver_quota_warning(address, format_maildirquota(quota));
              }
--- 482,488 ----
                  return(-1);
              }
              if (QUOTA_WARN_PERCENT >= 0 &&
!                 vmaildir_readquota(address, format_maildirquota(quota))
                      >= QUOTA_WARN_PERCENT) {
                  deliver_quota_warning(address, format_maildirquota(quota));
              }
diff -c vpopmail-5.3.18/vmysql.c vpopmail-5.3.18.new/vmysql.c
*** vpopmail-5.3.18/vmysql.c    Mon Jan 27 11:29:15 2003
--- vpopmail-5.3.18.new/vmysql.c        Wed Feb 26 09:54:55 2003
***************
*** 60,66 ****
  static MYSQL_ROW row;
  static MYSQL_ROW row_getall;
  
! #define SQL_BUF_SIZE 600
  static char SqlBufRead[SQL_BUF_SIZE];
  static char SqlBufUpdate[SQL_BUF_SIZE];
  static char SqlBufCreate[SQL_BUF_SIZE];
--- 60,66 ----
  static MYSQL_ROW row;
  static MYSQL_ROW row_getall;
  
! #define SQL_BUF_SIZE 2048
  static char SqlBufRead[SQL_BUF_SIZE];
  static char SqlBufUpdate[SQL_BUF_SIZE];
  static char SqlBufCreate[SQL_BUF_SIZE];
diff -c vpopmail-5.3.18/vuserinfo.c vpopmail-5.3.18.new/vuserinfo.c
*** vpopmail-5.3.18/vuserinfo.c Sat May 18 00:16:28 2002
--- vpopmail-5.3.18.new/vuserinfo.c     Wed Feb 26 12:24:54 2003
***************
*** 261,267 ****
          sprintf(maildir, "%s/Maildir", mypw->pw_dir);
          if((strcmp(mypw->pw_shell, "NOQUOTA"))) {
              printf("usage:     %d%%\n", 
!                 maildir_readquota(maildir, format_maildirquota(mypw->pw_shell)));
          } else {
              printf("usage:     %s\n", mypw->pw_shell);
          }
--- 261,267 ----
          sprintf(maildir, "%s/Maildir", mypw->pw_dir);
          if((strcmp(mypw->pw_shell, "NOQUOTA"))) {
              printf("usage:     %d%%\n", 
!                 vmaildir_readquota(maildir, format_maildirquota(mypw->pw_shell)));
          } else {
              printf("usage:     %s\n", mypw->pw_shell);
          }
***************
*** 329,335 ****
              sprintf(maildir, "%s/Maildir", mypw->pw_dir);
              if((strcmp(mypw->pw_shell, "NOQUOTA"))) {
                  printf("%d%%\n", 
!                     maildir_readquota(maildir, format_maildirquota(mypw->pw_shell)));
              } else {
                  printf("%s\n", mypw->pw_shell);
              }
--- 329,335 ----
              sprintf(maildir, "%s/Maildir", mypw->pw_dir);
              if((strcmp(mypw->pw_shell, "NOQUOTA"))) {
                  printf("%d%%\n", 
!                     vmaildir_readquota(maildir, 
format_maildirquota(mypw->pw_shell)));
              } else {
                  printf("%s\n", mypw->pw_shell);
              }

Reply via email to