]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Always send LOGIN_DIR environment to login processes.
authorTimo Sirainen <tss@iki.fi>
Tue, 13 Jan 2009 18:12:21 +0000 (13:12 -0500)
committerTimo Sirainen <tss@iki.fi>
Tue, 13 Jan 2009 18:12:21 +0000 (13:12 -0500)
--HG--
branch : HEAD

src/login-common/main.c
src/master/login-process.c

index 7ef360567ccc6095cd33aff1a83fb3c33b86696b..62ae015046e9b99f796ca44231183802da8ea2f0 100644 (file)
@@ -264,10 +264,10 @@ static void drop_privileges(void)
 
                /* if we don't chroot, we must chdir */
                value = getenv("LOGIN_DIR");
-               if (value != NULL) {
-                       if (chdir(value) < 0)
-                               i_error("chdir(%s) failed: %m", value);
-               }
+               if (value == NULL)
+                       i_fatal("LOGIN_DIR environment missing");
+               if (chdir(value) < 0)
+                       i_error("chdir(%s) failed: %m", value);
        }
 
        /* Initialize SSL proxy so it can read certificate and private
index b8751a1025f354897e6d5fcaaeec1abb9b5fc935..8971d127511eee10ce1b1455ba16e2a8d0575e66 100644 (file)
@@ -617,6 +617,7 @@ static void login_process_init_env(struct login_group *group, pid_t pid)
                env_put(t_strconcat("TRUSTED_NETWORKS=",
                                    set->login_trusted_networks, NULL));
        }
+       env_put(t_strconcat("LOGIN_DIR=", set->login_dir, NULL));
 }
 
 static pid_t create_login_process(struct login_group *group)
@@ -714,14 +715,6 @@ static pid_t create_login_process(struct login_group *group)
        env_put(t_strdup_printf("LISTEN_FDS=%u", listen_count));
        env_put(t_strdup_printf("SSL_LISTEN_FDS=%u", ssl_listen_count));
 
-       if (!group->set->login_chroot) {
-               /* no chrooting, but still change to the directory */
-               if (chdir(group->set->login_dir) < 0) {
-                       i_fatal("chdir(%s) failed: %m",
-                               group->set->login_dir);
-               }
-       }
-
        restrict_process_size(group->set->login_process_size, (unsigned int)-1);
 
        /* make sure we don't leak syslog fd, but do it last so that
@@ -892,16 +885,6 @@ static int login_process_send_env(struct login_process *p)
                }
        }
 
-       if (!p->group->set->login_chroot) {
-               /* if we're not chrooting, we need to tell login process
-                  where its base directory is */
-               const char *str = t_strdup_printf("LOGIN_DIR=%s\n",
-                                                 p->group->set->login_dir);
-               len = strlen(str);
-               if (o_stream_send(p->output, str, len) != len)
-                       ret = -1;
-       }
-
        if (ret == 0 && o_stream_send(p->output, "\n", 1) != 1)
                ret = -1;