--- vpopmail-5.4.28/config.h.in.orig	2009-03-10 22:14:55.000000000 +0100
+++ vpopmail-5.4.28/config.h.in	2009-03-13 21:33:56.000000000 +0100
@@ -217,6 +217,9 @@
 #undef ONCHANGE_SCRIPT
 
 /* "" */
+#undef SKELETON
+
+/* "" */
 #undef OPEN_SMTP_CUR_FILE
 
 /* "" */
--- vpopmail-5.4.28/configure.orig	2009-03-10 22:14:55.000000000 +0100
+++ vpopmail-5.4.28/configure	2009-03-14 11:55:25.000000000 +0100
@@ -1324,6 +1324,7 @@
   --enable-qmail-ext         Enable qmail email address extension support.
   --enable-ip-alias-domains  Enable mapping of default domain via reverse ip lookup table.
   --enable-onchange-script   Enable onchange script. See README.onchange for more info.
+  --enable-skeleton          Enable skeleton directory. See README.skel for more info.
   --enable-spamassassin      Enable spamassassin. See  README.spamassassin for more info.
   --enable-spamc-prog=PATH   Full path to spamc program /usr/{local/}bin/spamc.
   --enable-maildrop          Enable maildrop. See  README.maildrop for more info.
@@ -7069,6 +7070,35 @@
 
 #----------------------------------------------------------------------
 
+echo "$as_me:$LINENO: checking whether skeleton directory is enabled" >&5
+echo $ECHO_N "checking whether skeleton directory is enabled... $ECHO_C" >&6
+# Check whether --enable-skeleton or --disable-skeleton was given.
+if test "${enable_skeleton+set}" = set; then
+  enableval="$enable_skeleton"
+  ENABLE_SKELETON=$enableval
+else
+
+                        ENABLE_SKELETON=0
+
+
+fi;
+
+case $ENABLE_SKELETON in
+  1*|y*|Y*)
+      echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+      ENABLE_SKELETON=1
+
+cat >>confdefs.h <<_ACEOF
+#define SKELETON $ENABLE_SKEL
+_ACEOF
+
+      ;;
+  *)
+      echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+      ;;
+esac
 
 #----------------------------------------------------------------------
 
@@ -9821,6 +9851,16 @@
 esac
 
 
+case $ENABLE_SKELETON in
+  1*|y*|Y*)
+    echo "skeleton directory = ON  --enable-skeleton"
+    ;;
+  *)
+    echo "skeleton directory = OFF --disable-skeleton (default)"
+    ;;
+esac
+
+
 case $AUTH_MODULE in
   cd*|Cd*|CD*)
     echo "       auth module = cdb --enable-auth-module=cdb (default)"
--- vpopmail-5.4.28/configure.in.orig	2009-03-10 22:14:55.000000000 +0100
+++ vpopmail-5.4.28/configure.in	2009-03-14 11:56:58.000000000 +0100
@@ -851,6 +851,25 @@
 
 #----------------------------------------------------------------------
 
+AC_MSG_CHECKING(whether skeleton directory is enabled)
+AC_ARG_ENABLE(skeleton,
+        [  --enable-skeleton          Enable skeleton directory. See README.skel for more info.],
+        ENABLE_SKELETON=$enableval,
+                [
+                        ENABLE_SKELETON=0
+                ]
+)
+
+case $ENABLE_SKELETON in
+  1*|y*|Y*)
+      AC_MSG_RESULT(yes)
+      ENABLE_SKELETON=1
+      AC_DEFINE_UNQUOTED(SKELETON,$ENABLE_SKEL,"")
+      ;;
+  *)
+      AC_MSG_RESULT(no)
+      ;;
+esac
 
 #----------------------------------------------------------------------
 
@@ -1682,6 +1701,16 @@
 esac
 
 
+case $ENABLE_SKELETON in
+  1*|y*|Y*)
+    echo "skeleton directory = ON  --enable-skeleton"
+    ;;
+  *)
+    echo "skeleton directory = OFF --disable-skeleton (default)"
+    ;;
+esac
+
+
 case $AUTH_MODULE in
   cd*|Cd*|CD*)
     echo "       auth module = cdb --enable-auth-module=cdb (default)"
--- vpopmail-5.4.28/vpopmail.c.orig	2009-03-10 22:14:55.000000000 +0100
+++ vpopmail-5.4.28/vpopmail.c	2009-03-13 21:34:03.000000000 +0100
@@ -59,6 +59,10 @@
 static char relay_tempfile[MAX_BUFF];
 #endif
 
+#ifdef SKELETON
+#include "copydir.h"
+#endif
+
 int verrori = 0;
 
 extern int cdb_seek();
@@ -1345,7 +1349,8 @@
   while((mydirent=readdir(mydir))!=NULL){
     if ( strncmp(mydirent->d_name,".", 2)!=0 && 
          strncmp(mydirent->d_name,"..", 3)!=0 ) {
-      stat( mydirent->d_name, &statbuf);
+      lstat( mydirent->d_name, &statbuf);
+      if ( S_ISLNK(statbuf.st_mode) ) continue;
       if ( S_ISDIR(statbuf.st_mode) ) {
         r_chown( mydirent->d_name, owner, group);
       } else {
@@ -2400,8 +2405,24 @@
     return(NULL);
   }
 
+#ifdef SKELETON
+  /* copy the skeleton into place */
+  struct stat s;
+  if ( stat ( VPOPMAILDIR "/skel" , &s ) ) {
+    if ( ENOENT != errno )
+      fprintf(stderr,"make_user_dir: stat(%s): %s\n",
+        VPOPMAILDIR "/skel" , strerror(errno) );
+  } else {
+    if ( S_ISDIR ( s.st_mode ) )
+      copydir ( VPOPMAILDIR "/skel" , "." , uid , gid ) ;
+    else
+      fprintf(stderr,"make_user_dir: %s is not a directory\n",
+        VPOPMAILDIR "/skel" );
+  }
+#endif
+
   for (i = 0; i < (int)(sizeof(dirnames)/sizeof(dirnames[0])); i++) {
-    if (mkdir(dirnames[i],VPOPMAIL_DIR_MODE) == -1){ 
+    if ((mkdir(dirnames[i],VPOPMAIL_DIR_MODE) == -1) && (EEXIST != errno)){ 
       fprintf(stderr, "make_user_dir: failed on %s\n", dirnames[i]);
       /* back out of changes made above */
       chdir("..");
@@ -3108,12 +3129,32 @@
   /* we should now be able to cd into the user's dir */
   if ( chdir(dir) != 0 ) { chdir(calling_dir); return(-1); }
 
+#ifdef SKELETON
+  /* copy the skeleton into place */
+  struct stat s;
+  if ( stat ( VPOPMAILDIR "/skel" , &s ) ) {
+    if ( ENOENT != errno )  
+      fprintf(stderr,"make_user_dir: stat(%s): %s\n",
+        VPOPMAILDIR "/skel" , strerror(errno) );
+  } else {
+    if ( S_ISDIR ( s.st_mode ) )
+      copydir ( VPOPMAILDIR "/skel" , "." , uid , gid ) ;
+    else
+      fprintf(stderr,"make_user_dir: %s is not a directory\n",
+        VPOPMAILDIR "/skel" );
+  }
+#endif
+
   /* now create the Maildir */
-  if (mkdir("Maildir",VPOPMAIL_DIR_MODE) == -1) { chdir(calling_dir); return(-1); }
+  if ((mkdir("Maildir",VPOPMAIL_DIR_MODE) == -1) && (EEXIST != errno)) {
+    chdir(calling_dir); return(-1); }
   if (chdir("Maildir") == -1) { chdir(calling_dir); return(-1); }
-  if (mkdir("cur",VPOPMAIL_DIR_MODE) == -1) { chdir(calling_dir); return(-1); }
-  if (mkdir("new",VPOPMAIL_DIR_MODE) == -1) { chdir(calling_dir); return(-1); }
-  if (mkdir("tmp",VPOPMAIL_DIR_MODE) == -1) { chdir(calling_dir); return(-1); }
+  if ((mkdir("cur",VPOPMAIL_DIR_MODE) == -1) && (EEXIST != errno)) {
+    chdir(calling_dir); return(-1); }
+  if ((mkdir("new",VPOPMAIL_DIR_MODE) == -1) && (EEXIST != errno)) {
+    chdir(calling_dir); return(-1); }
+  if ((mkdir("tmp",VPOPMAIL_DIR_MODE) == -1) && (EEXIST != errno)) {
+    chdir(calling_dir); return(-1); }
 
   /* set permissions on the user's dir */
   chdir(dir);
--- vpopmail-5.4.28/Makefile.in.orig	2009-08-24 17:01:33.000000000 +0200
+++ vpopmail-5.4.28/Makefile.in	2009-09-25 22:00:14.000000000 +0200
@@ -73,6 +73,7 @@
 	libvpopmail_a-vlimits.$(OBJEXT) \
 	libvpopmail_a-maildirquota.$(OBJEXT) \
 	libvpopmail_a-vutil.$(OBJEXT) libvpopmail_a-vlistlib.$(OBJEXT) \
+	libvpopmail_a-copydir.$(OBJEXT) \
 	libvpopmail_a-backfill.$(OBJEXT) \
 	libvpopmail_a-client.$(OBJEXT) libvpopmail_a-conf.$(OBJEXT) \
 	libvpopmail_a-ippp.$(OBJEXT)
@@ -323,8 +324,8 @@
 vpopuser = @vpopuser@
 SUBDIRS = cdb
 EXTRA_DIST = README.* cdb/* vcdb.c vldap.c vmysql.c voracle.pc vpgsql.c vsybase.c
-noinst_HEADERS = md5.h vpopmail.h file_lock.h vauth.h vlimits.h maildirquota.h vcdb.h vldap.h vmysql.h voracle.h vpgsql.h vsybase.h vlog.h global.h hmac_md5.h seek.h vutil.h
-COMMONSOURCES = vpopmail.c md5.c bigdir.c vauth.c file_lock.c vpalias.c seek.c vlimits.c maildirquota.c vutil.c vlistlib.c backfill.c client.c conf.c ippp.c
+noinst_HEADERS = md5.h vpopmail.h file_lock.h vauth.h vlimits.h maildirquota.h vcdb.h vldap.h vmysql.h voracle.h vpgsql.h vsybase.h vlog.h global.h hmac_md5.h seek.h vutil.h copydir.h
+COMMONSOURCES = vpopmail.c md5.c bigdir.c vauth.c file_lock.c vpalias.c seek.c vlimits.c maildirquota.c vutil.c vlistlib.c backfill.c client.c conf.c ippp.c copydir.c
 CONFIG_CLEAN_FILES = vauth.c cdb/conf-cc cdb/conf-ld cdb/compile cdb/load
 MYSQLCONF = $(DESTDIR)@vpopmaildir@/etc/vpopmail.mysql
 VLIMITS = $(DESTDIR)@vpopmaildir@/etc/vlimits.default
@@ -657,6 +658,12 @@
 libvpopmail_a-ippp.obj: ippp.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvpopmail_a_CFLAGS) $(CFLAGS) -c -o libvpopmail_a-ippp.obj `if test -f 'ippp.c'; then $(CYGPATH_W) 'ippp.c'; else $(CYGPATH_W) '$(srcdir)/ippp.c'; fi`
 
+libvpopmail_a-copydir.o: copydir.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvpopmail_a_CFLAGS) $(CFLAGS) -c -o libvpopmail_a-copydir.o `test -f 'copydir.c' || echo '$(srcdir)/'`copydir.c
+
+libvpopmail_a-copydir.obj: copydir.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvpopmail_a_CFLAGS) $(CFLAGS) -c -o libvpopmail_a-copydir.obj `if test -f 'copydir.c'; then $(CYGPATH_W) 'copydir.c'; else $(CYGPATH_W) '$(srcdir)/copydir.c'; fi`
+
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
 # To change the values of `make' variables: instead of editing Makefiles,
