

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
1 message in net.sourceforge.lists.courier-users[courier-users] home directory creati...| From | Sent On | Attachments |
|---|---|---|
| Jérôme Bolliet | Apr 17, 2002 5:12 am | .diff |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [courier-users] home directory creation & patch maildrop | Actions... |
|---|---|---|
| From: | Jérôme Bolliet (jbol...@noos.fr) | |
| Date: | Apr 17, 2002 5:12:38 am | |
| List: | net.sourceforge.lists.courier-users | |
| Attachments: | ||
Hello,
In my new mail server, i want to use maildrop with postfix as local delivery agent. All work's fine except that i need to automatically create home directory for my user when i doesn't exist.
It exist a patch pour courier-mta but not for maildrop.
I have made a patch (based on the works of Carlo, http://www.commedia.it/ccontavalli/#courier).
This patch add the option '-c <path to the script>' which define a path to a script which create home directory.
I'm using a script like this :
---- #!/bin/sh
logger -p mail.notice -i -t "maildrop/homedirmake" "Create maildir $1" mkdir -p $1 cd $1 maildirmake Maildir
----
Best regards.
-- _.' Jérôme Bolliet - DRS/Dpt Ingenierie Internet //\ Noos - 20, place des vins de france 75614 Paris Cedex 12 V_/_ Tél.: 01.44.87.52.84 Email: jbol...@noos.fr (s'il n'y a pas de solution, c'est qui n'y avait pas de problème...)
diff -ru maildrop-1.3.8.ori/maildrop/main.C maildrop-1.3.8/maildrop/main.C --- maildrop-1.3.8.ori/maildrop/main.C Fri Feb 15 14:37:15 2002 +++ maildrop-1.3.8/maildrop/main.C Wed Apr 17 13:54:39 2002 @@ -44,6 +44,10 @@ #include "mdmysql.h" #endif
+#include <stdarg.h> +#include <sys/wait.h> + + static const char rcsid[]="$Id: main.C,v 1.39 2002/02/15 13:37:15 mrsam Exp $"; #if HAS_GETHOSTNAME #else @@ -230,6 +234,54 @@ mout.flush(); }
+/* Carlo */ +/****/ +static int sysex(char *exe, ...) +{ + va_list ap; + char ** argv=NULL; + char *ptr=exe; + int size=0; + int i=0; + int pid; + + pid=fork(); + if(pid == -1 ) { + errexit=EX_TEMPFAIL; + throw "Unable to fork process"; + } + + if(pid==0) { + va_start(ap, exe); + do { + if(size <= i) { + size+=(size != 0) ? size : 16; + argv=(char **)(realloc(argv, size*sizeof(char *))); + if(argv == NULL) { + errexit=EX_TEMPFAIL; + throw "Unable to realloc memory"; + } + } + argv[i]=ptr; + ptr=va_arg(ap, char *); + } while(argv[i++] != NULL); + va_end(ap); + + execve(exe, argv, environ); + exit(127); + } + + while(1) { + if(waitpid(pid, &i, 0) == -1 && errno != EINTR) { + errexit=EX_TEMPFAIL; + throw "Waitpid error"; + } + else + return i; + } +} +/******/ + void Maildrop::reset_vars() { int i; @@ -266,6 +318,7 @@ { int argn; const char *deliverymode=0; +const char *create_home=0; char *embedded_filter=0; const char *from=0; Buffer recipe; @@ -315,6 +368,12 @@ if (!*optarg && argn < argc) optarg=argv[argn++]; deliverymode=optarg; break; +/*******/ + case 'c': + if (!*optarg && argn < argc) optarg=argv[argn++]; + create_home=optarg; + break; +/*******/ case 'V': if (!*optarg && argn < argc) optarg=argv[argn++]; maildrop.verbose_level=atoi(optarg); @@ -755,11 +814,21 @@ if (VerboseLevel() > 1) merr << "maildrop: Changing to " << h << "\n";
- if (chdir(h) < 0) - { - errexit=EX_TEMPFAIL; - throw "Unable to change to home directory."; - } +/****/ + if(chdir(h) != 0) { + if(!create_home) { + errexit=EX_TEMPFAIL; + throw "Unable to change to home directory."; + } + + sysex((char*)create_home, h, NULL); + if(chdir(h) != 0) { + errexit=EX_TEMPFAIL; + throw "Unable to change to home directory."; + } + } +/******/ + recipe=".mailfilter";
if ( stat(".", &buf) < 0 ||








.diff