Hi all,

After struggling for sometime to get skeldir functionality to work, I've
given up for now.

The primary reason for wanting skeldirs was so that new accounts could
be created with IMAPdir support for use with bincimap.

The following patch modifies vpopmail to create an IMAPdir directory.

It also modifies r_chown to work correctly with symlinks (required since
IMAPdir contains a symlink IMAPdir/INBOX -> ../Maildir/)

R.

--- vpopmail-5.4.15/vpopmail.c  2006-01-17 11:30:52.000000000 -0800
+++ vpopmail-5.4.15-IMAPdir/vpopmail.c  2006-03-27 11:30:50.000000000 -0800
@@ -1298,11 +1298,16 @@
   while((mydirent=readdir(mydir))!=NULL){
     if ( strncmp(mydirent->d_name,".", 2)!=0 &&
          strncmp(mydirent->d_name,"..", 3)!=0 ) {
-      stat( mydirent->d_name, &statbuf);
-      if ( S_ISDIR(statbuf.st_mode) ) {
-        r_chown( mydirent->d_name, owner, group);
+      lstat( mydirent->d_name, &statbuf);
+      // don't recurse into symlinks - just chown symlink to owner:group
+      if ( S_ISLNK(statbuf.st_mode) ) {
+        lchown(mydirent->d_name,owner,group);
       } else {
-        chown(mydirent->d_name,owner,group);
+        if ( S_ISDIR(statbuf.st_mode) ) {
+          r_chown( mydirent->d_name, owner, group);
+        } else {
+          chown(mydirent->d_name,owner,group);
+        }
       }
     }
   }
@@ -2115,7 +2120,7 @@
  struct vqpasswd *mypw;
  char calling_dir[MAX_BUFF];
  char domain_dir[MAX_BUFF];
- const char *dirnames[] = {"Maildir", "Maildir/new", "Maildir/cur",
+ const char *dirnames[] = {"Maildir", "IMAPdir", "Maildir/new",
"Maildir/cur",
        "Maildir/tmp"};
  int i;

@@ -2175,6 +2180,16 @@
     }
   }

+  // Add the symlink IMAPdir/INBOX -> ../Maildir/
+  if (symlink("../Maildir/", "IMAPdir/INBOX") == -1) {
+    fprintf(stderr, "make_user_dir: failed to symlink %s\n",
"IMAPdir/INBOX");
+    /* back out of changes made above */
+    chdir("..");
+    vdelfiles(username);
+    chdir(calling_dir);
+    return(NULL);
+  }
+
   /* set permissions on the user's dir */
   r_chown(".", uid, gid);

Reply via email to