Search
j0ke.net Open Build Service
>
Projects
>
server:mail
>
vpopmail
> vpopmail-5.4.27-skel4.patch.tmp
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File vpopmail-5.4.27-skel4.patch.tmp of Package vpopmail (Revision 39)
Currently displaying revision
39
,
show latest
@@ -609,6 +610,12 @@ libvpopmail_a-vlistlib.obj: vlistlib.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvpopmail_a_CFLAGS) $(CFLAGS) -c -o libvpopmail_a-vlistlib.obj `if test -f 'vlistlib.c'; then $(CYGPATH_W) 'vlistlib.c'; else $(CYGPATH_W) '$(srcdir)/vlistlib.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, diff -ruN vpopmail-5.4.26-factory/README.skel vpopmail-5.4.26-patched/README.skel --- vpopmail-5.4.26-factory/README.skel 1969-12-31 19:00:00.000000000 -0500 +++ vpopmail-5.4.26-patched/README.skel 2008-02-12 17:35:33.000000000 -0500 @@ -0,0 +1,19 @@ +README for the --enable-skeleton configure option +John Simpson <jms1@jms1.net> 2007-09-19 +----------------------------------------------------------- + +When you use the --enable-skeleton option on your ./configure command +line, vpopmail will use ~vpopmail/skel as a template for creating new +mailboxes, much like how most *nix systems use the "/etc/skel" directory +as a template for new user accounts' home directories. + +Any files and/or directories within ~vpopmail/skel will be copied to the +new mailbox, with their structure and permissions preserved, and the +ownership of all new files and directories set to the uid/gid which owns +the mailbox (normally the vpopmail user, but it may be different if the +domain is controlled by a different system userid.) + +If the ~vpopmail/skel directory does not exist, or does not contain the +standard Maildir structure, it will be created regardless. This way the +required Maildir directory structure will exist regardless of what you +may be doing with the ~vpopmail/skel directory. diff -ruN vpopmail-5.4.26-factory/config.h.in vpopmail-5.4.26-patched/config.h.in --- vpopmail-5.4.26-factory/config.h.in 2007-11-15 04:42:32.000000000 -0500 +++ vpopmail-5.4.26-patched/config.h.in 2008-02-12 17:35:33.000000000 -0500 @@ -214,6 +214,9 @@ #undef ONCHANGE_SCRIPT /* "" */ +#undef SKELETON + +/* "" */ #undef OPEN_SMTP_CUR_FILE /* "" */ diff -ruN vpopmail-5.4.26-factory/configure vpopmail-5.4.26-patched/configure --- vpopmail-5.4.26-factory/configure 2007-11-15 04:41:27.000000000 -0500 +++ vpopmail-5.4.26-patched/configure 2008-02-12 17:35:33.000000000 -0500 @@ -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. @@ -7068,6 +7069,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 #---------------------------------------------------------------------- @@ -9799,6 +9829,16 @@ esac +case $ENABLE_SKELETON in + 1*|y*|Y*) + echo "skeleton directory = ON --enable-skeleton" + ;; + *) + echo "skeleton directory = OFF --disable-skeleton (default)" + ;; +esac + + #case $ENABLE_DOMAIN_QUOTAS in # 1*|y*|Y*) # echo " domain quotas = ON --enable-domainquotas" diff -ruN vpopmail-5.4.26-factory/configure.in vpopmail-5.4.26-patched/configure.in --- vpopmail-5.4.26-factory/configure.in 2007-10-19 03:32:26.000000000 -0400 +++ vpopmail-5.4.26-patched/configure.in 2008-02-12 17:35:33.000000000 -0500 @@ -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 #---------------------------------------------------------------------- @@ -1666,6 +1685,16 @@ esac +case $ENABLE_SKELETON in + 1*|y*|Y*) + echo "skeleton directory = ON --enable-skeleton" + ;; + *) + echo "skeleton directory = OFF --disable-skeleton (default)" + ;; +esac + + #case $ENABLE_DOMAIN_QUOTAS in # 1*|y*|Y*) # echo " domain quotas = ON --enable-domainquotas" diff -ruN vpopmail-5.4.26-factory/copydir.c vpopmail-5.4.26-patched/copydir.c --- vpopmail-5.4.26-factory/copydir.c 1969-12-31 19:00:00.000000000 -0500 +++ vpopmail-5.4.26-patched/copydir.c 2008-02-12 17:35:33.000000000 -0500 @@ -0,0 +1,309 @@ +/* copydir.c + * John Simpson <jms1@jms1.net> 2007-09-18 + * + * 2007-12-28 jms1 - using S_ISLNK() macro. i don't really remember why, + * but i do remember that when i first wrote this code years ago, i + * avoided using this particular macro for some reason. thanks to rance + * hall for pointing out the problem. + * + **************************************************************************** + * + * Copyright (C) 2001,2007 John Simpson. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + +#include "copydir.h" + +int makedir ( const char *dir , mode_t dmode , uid_t uid , gid_t gid ) +{ + struct stat s ; + + if ( mkdir ( dir , 0700 ) ) + { + if ( EEXIST == errno ) + { + stat ( dir , &s ) ; + if ( ! S_ISDIR ( s.st_mode ) ) + { + fprintf ( stderr , "makedir(): mkdir(%s): %s\n" , + dir , strerror ( errno ) ) ; + return -1 ; + } + } + else + { + fprintf ( stderr , "makedir(): mkdir(%s): %s\n" , + dir , strerror ( errno ) ) ; + return -1 ; + } + } + + if ( chown ( dir , uid , gid ) ) + { + fprintf ( stderr , "makedir(): chown(%s): %s\n" , + dir , strerror ( errno ) ) ; + return -1 ; + } + + if ( chmod ( dir , dmode ) ) + { + fprintf ( stderr , "makedir(): chmod(%s): %s\n" , + dir , strerror ( errno ) ) ; + return -1 ; + } + + return 0 ; +} + +#define COPY_BUF_SIZE 65536 +char copybuf[COPY_BUF_SIZE] ; + +int copyfile ( const char *src , const char *dst , uid_t uid , gid_t gid ) +{ + int ifd , ofd , count , x ; + struct stat s ; + + if ( stat ( src , &s ) ) + { + fprintf ( stderr , "copyfile(): stat(%s): %s\n" , + src , strerror ( errno ) ) ; + return -1 ; + } + + ifd = open ( src , O_RDONLY ) ; + if ( -1 == ifd ) + { + fprintf ( stderr , "copyfile(): open(%s) for read: %s\n" , + src , strerror ( errno ) ) ; + return -1 ; + } + + ofd = open ( dst , O_WRONLY | O_CREAT | O_TRUNC ) ; + if ( -1 == ofd ) + { + fprintf ( stderr , "copyfile(): open(%s) for write: %s\n" , + dst , strerror ( errno ) ) ; + close ( ifd ) ; + return -1 ; + } + + while ( 1 ) + { + count = read ( ifd , copybuf , COPY_BUF_SIZE ) ; + + if ( -1 == count ) + { + fprintf ( stderr , "copyfile(): read(%s): %s\n" , + src , strerror ( errno ) ) ; + close ( ifd ) ; + close ( ofd ) ; + unlink ( dst ) ; + return -1 ; + } + + if ( 0 == count ) + break ; + + while ( count ) + { + x = write ( ofd , copybuf , count ) ; + + if ( -1 == x ) + { + fprintf ( stderr , "copyfile(): write(%s): %s\n" , + dst , strerror ( errno ) ) ; + close ( ifd ) ; + close ( ofd ) ; + unlink ( dst ) ; + return -1 ; + } + + count -= x ; + } + } + + close ( ifd ) ; + close ( ofd ) ; + + if ( chown ( dst , uid , gid ) ) + { + fprintf ( stderr , "copyfile(): chown(%s): %s\n" , + dst , strerror ( errno ) ) ; + return -1 ; + } + + if ( chmod ( dst , s.st_mode ) ) + { + fprintf ( stderr , "copyfile(): chmod(%s): %s\n" , + dst , strerror ( errno ) ) ; + return -1 ; + } + + return 0 ; +} + +int copylink ( const char *src , const char *dst ) +{ + int x ; + + x = readlink ( src , copybuf , COPY_BUF_SIZE ) ; + if ( -1 == x ) + { + fprintf ( stderr , "copylink(): readlink(%s): %s\n" , + src , strerror ( errno ) ) ; + return -1 ; + } + + copybuf[x] = 0 ; /* readlink() doesn't do this, grrr */ + + if ( symlink ( copybuf , dst ) ) + { + fprintf ( stderr , "copylink(): symlink(%s): %s\n" , + dst , strerror ( errno ) ) ; + return -1 ; + } + + return 0 ; +} + +int copydir ( const char *src , const char *dst , uid_t uid , gid_t gid ) +{ + DIR *d ; + struct dirent *e ; + struct stat s; + char *srcf , *dstf , *srcfp , *dstfp ; + + if ( stat ( src , &s ) ) + { + fprintf ( stderr , "copydir(): stat(%s): %s\n" , + src , strerror ( errno ) ) ; + return -1 ; + } + + if ( ! S_ISDIR ( s.st_mode ) ) + { + fprintf ( stderr , "copydir(): %s is not a directory!\n" , + src ) ; + return -1 ; + } + + d = opendir ( src ) ; + if ( ! d ) + { + fprintf ( stderr , "copydir(): opendir(%s): %s\n" , + src , strerror ( errno ) ) ; + return -1 ; + } + + if ( makedir ( dst , s.st_mode , uid , gid ) ) + { + closedir ( d ) ; + return -1 ; + } + + srcf = malloc ( strlen(src) + NAME_MAX + 2 ) ; + if ( ! srcf ) + { + fprintf ( stderr , "copydir(): malloc(): %s\n" , + strerror ( errno ) ) ; + return -1 ; + } + + dstf = malloc ( strlen(dst) + NAME_MAX + 2 ) ; + if ( ! dstf ) + { + fprintf ( stderr , "copydir(): malloc(): %s\n" , + strerror ( errno ) ) ; + free ( srcf ) ; + return -1 ; + } + + strcpy ( srcf , src ) ; + strcat ( srcf , "/" ) ; + srcfp = srcf + strlen ( srcf ) ; + + strcpy ( dstf , dst ) ; + strcat ( dstf , "/" ) ; + dstfp = dstf + strlen ( dstf ) ; + + while ( ( e = readdir ( d ) ) ) + { + if ( (!strcmp(e->d_name,".")) || (!strcmp(e->d_name,"..")) ) + continue ; + + strcpy ( srcfp , e->d_name ) ; + strcpy ( dstfp , e->d_name ) ; + + lstat ( srcf , &s ) ; + + if ( S_ISLNK ( s.st_mode ) ) + { + if ( copylink ( srcf , dstf ) ) + { + closedir ( d ) ; + free ( dstf ) ; + free ( srcf ) ; + return -1 ; + } + + continue ; + } + + if ( S_ISDIR ( s.st_mode ) ) + { + if ( copydir ( srcf , dstf , uid , gid ) ) + { + closedir ( d ) ; + free ( dstf ) ; + free ( srcf ) ; + return -1 ; + } + + continue ; + } + + if ( ! S_ISREG ( s.st_mode ) ) + { + fprintf ( stderr , "copydir(): ignoring special %s\n" , + srcf ) ; + continue ; + } + + if ( copyfile ( srcf , dstf , uid , gid ) ) + { + closedir ( d ) ; + free ( dstf ) ; + free ( srcf ) ; + return -1 ; + } + } + + closedir ( d ) ; + free ( dstf ) ; + free ( srcf ) ; + return 0 ; +} diff -ruN vpopmail-5.4.26-factory/copydir.h vpopmail-5.4.26-patched/copydir.h --- vpopmail-5.4.26-factory/copydir.h 1969-12-31 19:00:00.000000000 -0500 +++ vpopmail-5.4.26-patched/copydir.h 2008-02-12 17:35:33.000000000 -0500 @@ -0,0 +1,31 @@ +/* copydir.h + * John Simpson <jms1@jms1.net> 2007-09-18 + * + * Copyright (C) 2001,2007 John Simpson. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef _copydir_h +#define _copydir_h + +#include <sys/types.h> + +int makedir ( const char *dir , mode_t dmode , uid_t uid , gid_t gid ) ; +int copyfile ( const char *src , const char *dst , uid_t uid , gid_t gid ) ; +int copylink ( const char *src , const char *dst ) ; +int copydir ( const char *src , const char *dst , uid_t uid , gid_t gid ) ; + +#endif diff -ruN vpopmail-5.4.26-factory/vpopmail.c vpopmail-5.4.26-patched/vpopmail.c --- vpopmail-5.4.26-factory/vpopmail.c 2007-10-31 03:55:39.000000000 -0400 +++ vpopmail-5.4.26-patched/vpopmail.c 2008-02-12 17:36:52.000000000 -0500 @@ -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 { @@ -2393,8 +2398,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(".."); @@ -3101,12 +3122,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);