Re: [Exim] $home for virtual users

Top Page
Delete this message
Reply to this message
Author: Nico Erfurth
Date:  
To: exim-users@exim.org
CC: Philip Hazel
Subject: Re: [Exim] $home for virtual users
On Fri, 25 Oct 2002, Nico Erfurth wrote:

> I know, guess who wanted this item ;)))
> I was tricking this with the readfile+sg "fake", but i don't liked it.


Replying to my self, i send a updated version of the patch, that removes a
uneeded temporary variable and a useless string_copy, shame on me for
wasting ressources in the first version ;)


diff -uNr exim-snapshot/src/globals.c exim-snapshot.new/src/globals.c
--- exim-snapshot/src/globals.c    Thu Aug 29 11:26:02 2002
+++ exim-snapshot.new/src/globals.c    Fri Oct 25 15:12:53 2002
@@ -654,6 +654,7 @@
     NULL,                      /* extra_headers */
     NULL,                      /* fallback_hosts */
     NULL,                      /* home_directory */
+    NULL,                      /* router_home_directory */
     NULL,                      /* ignore_target_hosts */
     NULL,                      /* local_parts */
     NULL,                      /* pass_router_name */
diff -uNr exim-snapshot/src/route.c exim-snapshot.new/src/route.c
--- exim-snapshot/src/route.c    Thu Aug 29 11:26:04 2002
+++ exim-snapshot.new/src/route.c    Sat Oct 26 13:11:44 2002
@@ -56,6 +56,8 @@
                  (void *)offsetof(router_instance, extra_headers) },
   { "headers_remove",     opt_stringptr|opt_public,
                  (void *)offsetof(router_instance, remove_headers) },
+  { "home_directory", opt_stringptr|opt_public,
+                 (void *)offsetof(router_instance, router_home_directory) },
   { "ignore_target_hosts",opt_stringptr|opt_public,
                  (void *)offsetof(router_instance, ignore_target_hosts) },
   { "initgroups",         opt_bool | opt_public,
@@ -811,6 +813,20 @@
   deliver_home = string_copy(US (*pw)->pw_dir);
   }


+/* Without check_local_user we set the home directory from the routers
+optionsblock if home_directory is set */
+else if (r->router_home_directory)
+  {
+  deliver_home = expand_string(r->router_home_directory);
+
+  if (deliver_home == NULL)
+    {
+    *perror = string_sprintf("failed to expand \"%s\" for home_directory: %s",
+      r->router_home_directory, expand_string_message);
+    return DEFER;
+    }
+  }
+
 /* This is the point at which we print out the router's debugging string if it
 is set. We wait till here so as to have $home available for local users (and
 anyway, we don't want too much stuff for skipped routers). */
diff -uNr exim-snapshot/src/routers/redirect.c exim-snapshot.new/src/routers/redirect.c
--- exim-snapshot/src/routers/redirect.c    Thu Aug 29 11:26:04 2002
+++ exim-snapshot.new/src/routers/redirect.c    Fri Oct 25 16:38:59 2002
@@ -337,6 +337,8 @@
       next->home_dir = rblock->home_directory;
     else if (rblock->check_local_user)
       next->home_dir = string_sprintf("\\N%s\\N", pw->pw_dir);
+    else if (rblock->router_home_directory != NULL)
+      next->home_dir = rblock->router_home_directory;


     next->current_dir = rblock->current_directory;


diff -uNr exim-snapshot/src/structs.h exim-snapshot.new/src/structs.h
--- exim-snapshot/src/structs.h    Thu Aug 29 11:26:05 2002
+++ exim-snapshot.new/src/structs.h    Fri Oct 25 15:05:14 2002
@@ -220,6 +220,7 @@
   uschar *extra_headers;          /* Additional headers */
   uschar *fallback_hosts;         /* For remote transports (text list) */
   uschar *home_directory;         /* For use during delivery */
+  uschar *router_home_directory;  /* For use during routing (emulate check_local_user) */
   uschar *ignore_target_hosts;    /* Target hosts to ignore */
   uschar *local_parts;            /* Specific local parts */
   uschar *pass_router_name;       /* Router for passed address */