PATCH: alllow content directory to be specified adding a new domain
--------------------------
Attached is a diff against 5.3.21 which adds the ability to utilize any directory as the content directory, rather than simply as the domains directory. We use this for a hosting provider who wants to store users mail in their homedirectories. This aids backup (as one can backup their homedirectory with all of their users and IMAP-stored mail), security (as users own their own mail folders) and means that users who operate ezmlm mailing lists (for example) can access their archives (formerly, they are restricted by the ~vpopmail/domains folder with it's 700 permissions as well as the user folder.
It looks like a hack, however allowing a user to specify ~username/domain.com/mail as their domain folder is I'm sure a beneficial feature to many who use similar situations as myself. It could be easily integrated.
The only other thing that would need moficiation would be vqadmin, as I added a parameter to vadddomain. Simply defaulting to a 0 in this parrameter when called in vqadmin would suffice in the short run to keep things working. qmailadmin doesn't add domains, and no other functions in the source appear to call this.


Thoughts? Anyone else potentially find something like this useful to perfect and integrate?
-Michael


----- START DIFF -----
diff -r vpopmail-5.3.21/vadddomain.c vpopmail-5.3.21-orig/vadddomain.c
39d38
< char DirDom[MAX_BUFF];
68,69c67
<     if ( DirDom[0] == 0 ) {
<       if ( (err=vadddomain(Domain,Dir,Uid,Gid,0)) != VA_SUCCESS ) {
---
if ( (err=vadddomain(Domain,Dir,Uid,Gid)) != VA_SUCCESS ) {
72,77d69
<       }
<     } else {
<       if ( (err=vadddomain(Domain,DirDom,Uid,Gid,1)) != VA_SUCCESS ) {
<         printf("Error: %s\n", verror(err));
<         vexit(err);
<       }
125,126c117
<    printf("         -D dir (sets the dir to use for this domain)\n");
<    printf("         -d dir (sets the domains structure for this domain)\n");
---
printf(" -d dir (sets the dir to use for this domain)\n");
149d139
< memset(DirDom, 0, MAX_BUFF);
159c149
< while( !errflag && (c=getopt(argc,argv,"q:be:u:vi:g:D:d:Or")) != -1 ) {
---
while( !errflag && (c=getopt(argc,argv,"q:be:u:vi:g:d:Or")) != -1 ) {
167,169d156
<    case 'D':
<        strncpy(DirDom,optarg,MAX_BUFF);
<        break;

diff -r vpopmail-5.3.21/vpopmail.c vpopmail-5.3.21-orig/vpopmail.c
50d49
< static char content_dir[FILE_SIZE];
91c90
< int vadddomain( char *domain, char *dir, uid_t uid, gid_t gid, int dirtype )
---
int vadddomain( char *domain, char *dir, uid_t uid, gid_t gid )
151,159d149
<   /* change to the custom domain directory if
<    * specified with -D
<    */
<   if (dirtype == 1) {
<     if ( chdir(dir) != 0 ) {
<       return (VA_BAD_V_DIR);
<     }
<   }
<
170,188c160,161
<   if ( dirtype == 0 ) {
<     if ( strlen(domain_sub_dir) > 0 ) {
<       snprintf(DomainSubDir, FILE_SIZE, "%s/%s", domain_sub_dir, domain);
<     } else {
<       snprintf(DomainSubDir, FILE_SIZE, "%s", domain);
<     }
<
<     if ( r_mkdir(DomainSubDir, uid, gid ) != 0 ) {
<       chdir(TmpBuf1);
<       return(VA_COULD_NOT_MAKE_DOMAIN_DIR);
<     }
<
<     if ( chdir(DomainSubDir) != 0 ) {
<       chdir(TmpBuf1);
<       return(VA_BAD_D_DIR);
<     }
<
<     snprintf(content_dir, MAX_BUFF, "%s/%s/%s", dir, DOMAINS_DIR,
<       DomainSubDir);
---
  if ( strlen(domain_sub_dir) > 0 ) {
    snprintf(DomainSubDir, FILE_SIZE, "%s/%s", domain_sub_dir, domain);
190,199c163,173
<     /* Set directory to place users in */
<     snprintf(content_dir, MAX_BUFF, dir);
<     /* Close permissions to this directory which already
<      * exists.  Generally, an admin creating it would
<      * make it with a world-readable mask
<      */
<     if (chmod(content_dir, VPOPMAIL_DIR_MODE) != 0) {
<       /* Likely no permissions */
<       return(VA_COULD_NOT_MAKE_DOMAIN_DIR);
<     }
---
    snprintf(DomainSubDir, FILE_SIZE, "%s", domain);
  }
     if ( r_mkdir(DomainSubDir, uid, gid ) != 0 ) {
    chdir(TmpBuf1);
    return(VA_COULD_NOT_MAKE_DOMAIN_DIR);
  }
      if ( chdir(DomainSubDir) != 0 ) {
    chdir(TmpBuf1);
    return(VA_BAD_D_DIR);
202c176,177
<   snprintf(TmpBuf, MAX_BUFF, "%s/.qmail-default", content_dir);
---
snprintf(TmpBuf, MAX_BUFF, "%s/%s/%s/.qmail-default", dir, DOMAINS_DIR, DomainSubDir);
210c185
<   snprintf(TmpBuf, MAX_BUFF, "%s", content_dir);
---
snprintf(TmpBuf, MAX_BUFF, "%s/%s/%s", dir, DOMAINS_DIR, DomainSubDir);
215c190
<   snprintf(TmpBuf, MAX_BUFF, "%s", content_dir);
---
snprintf(TmpBuf, MAX_BUFF, "%s/%s/%s", dir, DOMAINS_DIR, DomainSubDir);

diff -r vpopmail-5.3.21/vpopmail.h vpopmail-5.3.21-orig/vpopmail.h
102c102
< int vadddomain( char *domain, char *dir, uid_t uid, gid_t gid, int dirtype);
---
int vadddomain( char *domain, char *dir, uid_t uid, gid_t gid);
----- END DIFF -----

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus





Reply via email to