On Monday, March 17, 2003, at 01:22 PM, Brian Kolaci wrote to the qmailadmin list:
vmoduser needs to be updated to write a properly formatted
data to the field.  Currently, it just writes the information
verbatim from the command line.

Note: I was unable to find any versions of vpopmail newer than 5.3.16. Where can I get 5.3.19? I also saw mention of a 5.3.21 in another email...


Anyway, here's a patch for vmoduser to properly format the quota. It understands the following formats for the -q option, and will convert all sizes to #####S format:

10M (10,485,760 bytes)
500K (512,000 bytes)
10.5M (11,010,048 bytes)
1000000 (1,000,000 bytes)
NOQUOTA (no quota)
1000000S,1000C (1,000,000 bytes or 1000 messages)
100C (100 messages)

Note that I'm not sure whether 100C is a valid quota. I know that qmailadmin can't handle it.

--- vpopmail-5.3.16/vmoduser.c  Fri May 17 21:16:28 2002
+++ vpopmail-5.3.16-tc/vmoduser.c       Mon Mar 17 14:31:24 2003
@@ -153,6 +153,8 @@
  int errflag;
  extern char *optarg;
  extern int optind;
+ double q;
+ int i;

     memset(User, 0, MAX_BUFF);
     memset(Email, 0, MAX_BUFF);
@@ -188,7 +190,24 @@
                 break;
             case 'q':
                 QuotaFlag = 1;
+               /* properly handle the following formats:
+                * "1M", "1024K", "1048576" (set 1 MB quota)
+                * "NOQUOTA" (no quota)
+                * "1048576S,1000C" (1 MB size, 1000 message limit)
+                */
                 strncpy( Quota, optarg, MAX_BUFF-1);
+               i = strlen (Quota);
+               q = atof(Quota);
+               if ((Quota[i-1] == 'M') || (Quota[i-1] == 'm')) {
+                   sprintf (Quota, "%.0fS", q * 1024 * 1024);
+               } else if ((Quota[i-1] == 'K') || (Quota[i-1] == 'k')) {
+                   sprintf (Quota, "%.0fS", q * 1024);
+               } else if ((Quota[i-1] == 'S') || (Quota[i-1] == 's') ||
+                   (Quota[i-1] == 'C') || (Quota[i-1] == 'c')) {
+                   /* don't make any changes */
+               } else if (q > 0) {
+                   sprintf (Quota, "%.0fS", q);
+               } /* else don't make any changes */
                 break;
             case 'd':
                 GidFlag |= NO_PASSWD_CHNG;

--
Tom Collins
[EMAIL PROTECTED]




Reply via email to