(1) In vdeliver mail, the orginal run_command did not have
proper exit code. This version conforms with qmail-local: 

/* open a pipe to a command
* return the child exit code of command or -1 if error
*/
int qmail_run_command(char *prog)
{
 pid_t child;
 char *(args[4]);
 int wstat,r,child_exitcode;

 while (*prog==' ') ++prog;
 while (*prog=='|') ++prog;

 if ( lseek(0, 0L, SEEK_SET) < 0 ) {
   printf("MyRunCmd: lseek errno=%d\n", errno);
   vexit(111);
 }

 switch(child = fork())
   {
   case -1:
     printf("unable to fork: errno=%d \n", errno);
     vexit(111);
   case 0:
     args[0] = "/bin/sh"; args[1] = "-c"; args[2] = prog; args[3] = 0;
     sig_catch(SIGPIPE,SIG_DFL);
     execv(*args,args);
     printf("Unable to run /bin/sh: errno=%d \n", errno);
     _exit(111); /* child should call _exit */
   }

 /* copied from qmail-local */
 /* wait_pid(&wstat,child); */
 do
   r = waitpid(child,&wstat,0);
 while ((r == -1) && (errno == EINTR)); 

 if (WCOREDUMP(wstat)) /* temp_childcrashed(); */
  {
     printf("Process %s crashed!\n", prog);
     vexit(111);
  } 

 child_exitcode = WEXITSTATUS(wstat);
 /* printf("Process %s ExitCode=%d\n", prog, child_exitcode); */
 r = strlen(prog)-15; if (r<0) r = 0;
 printf("%s=%d\n", prog+r, child_exitcode);

 switch(child_exitcode)
  {
   case 100:
   case 64: case 65: case 70: case 76:
   case 77: case 78: case 112: vexit(100); /* hard error */
   case 0: break;  /* successful */
   case 99: vexit(99); /* successful, let qmail ignore further processing */
   default: vexit(111); /* soft error: faild but should retry */
  }
 /* maildrop's EX_TEMPFAIL is 75, which causes _exit(111) here */
 return  child_exitcode;
} 

(2) The easiest way to get quota to work between vpopmail and sqwebmail is 
to add a few lines in vdelivermail.c, so that it writes the current vpopmail 
quota limit in .current_size (and let vpopmail only handle the quota 
checking): 

void update_quota(off_t new_size, ssize_t size_limit)
{
char tmpbuf[100]; 

        snprintf(tmpbuf, 100, "%d\n", (int)new_size);
        lseek(CurrentQuotaSizeFd, 0L, SEEK_SET);
        write(CurrentQuotaSizeFd, tmpbuf, strlen(tmpbuf));
        snprintf(tmpbuf, 100, "%d\n", size_limit);
        write(CurrentQuotaSizeFd, tmpbuf, strlen(tmpbuf));
        close(CurrentQuotaSizeFd);
} 

Then in folder.c of sqwebmail, add some code to read .current_size 

void folder_showquota()
{
const char      *quotamsg;
/* char    quotabuf[QUOTABUFSIZE]; */
/* int  nquota; */
long    mlimit,msize;
FILE    *f;
struct stat stat_buf;
char    blimit[40], bsize[40]; 

        quotamsg=getarg("QUOTAUSAGE");
        f=fopen("./.current_size","r");
       if (!f) return;
       if ((fstat(fileno(f), &stat_buf) != 0) ||
            (!fgets(bsize, sizeof(bsize), f)) || (!fgets(blimit, sizeof(blimit), 
f)))
       {
               fclose(f);
               return;
       } else {
               fclose(f);
                blimit[sizeof(blimit)-1]=0; blimit[sizeof(bsize)-1]=0;
                mlimit=atol(blimit); msize=atol(bsize);
                if ((mlimit>0)&&(msize>0)) printf(quotamsg, mlimit/1024, 
msize/1024);
        } 

 

================================================
>>>>>>>> Visit http://www.acosmo.com  <<<<<<<<<

Reply via email to