]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Allow one parameter for mail_executable.
authorTimo Sirainen <tss@iki.fi>
Wed, 20 Aug 2003 22:12:44 +0000 (01:12 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 20 Aug 2003 22:12:44 +0000 (01:12 +0300)
--HG--
branch : HEAD

src/master/mail-process.c
src/master/master-settings.c

index 6e6a6144c4682be9ed7e4dbe34b0245761038526..7fc9267cac1518d9ec1078b2f2e17c2666856b86 100644 (file)
@@ -135,9 +135,10 @@ int create_mail_process(struct login_group *group, int socket,
                        struct ip_addr *ip,
                        struct auth_master_reply *reply, const char *data)
 {
-       static const char *argv[] = { NULL, NULL, NULL };
+       const char *argv[4];
        struct settings *set = group->set;
        const char *addr, *mail, *user, *chroot_dir, *home_dir, *full_home_dir;
+       const char *executable, *p;
        char title[1024];
        pid_t pid;
        int i, err, ret;
@@ -285,13 +286,14 @@ int create_mail_process(struct login_group *group, int socket,
        addr = net_ip2addr(ip);
        env_put(t_strconcat("IP=", addr, NULL));
 
-       if (set->verbose_proctitle) {
+       if (!set->verbose_proctitle)
+               title[0] = '\0';
+       else {
                if (addr == NULL)
                        addr = "??";
 
                i_snprintf(title, sizeof(title), "[%s %s]",
                           data + reply->virtual_user_idx, addr);
-               argv[1] = title;
        }
 
        /* make sure we don't leak syslog fd, but do it last so that
@@ -301,14 +303,23 @@ int create_mail_process(struct login_group *group, int socket,
        if (set->mail_drop_priv_before_exec)
                restrict_access_by_env(TRUE);
 
+       /* very simple argument splitting. */
+       i = 0;
+       argv[i++] = executable = t_strcut(group->set->mail_executable, ' ');
+       argv[i] = strchr(group->set->mail_executable, ' ');
+       if (argv[i] != NULL) {
+               argv[i]++;
+               i++;
+       }
+       if (title[0] != '\0')
+               argv[i++] = title;
+       argv[i] = NULL;
+
        /* hide the path, it's ugly */
-       argv[0] = strrchr(group->set->mail_executable, '/');
-       if (argv[0] == NULL)
-               argv[0] = group->set->mail_executable;
-       else
-               argv[0]++;
+       p = strrchr(argv[0], '/');
+       if (p != NULL) argv[0] = p+1;
 
-       execv(group->set->mail_executable, (char **) argv);
+       execv(executable, (char **) argv);
        err = errno;
 
        for (i = 0; i < 3; i++)
index 827e58b53a081badcb4297308c567c69d08a3113..4942f2c6abb4948f1b35cac5083b82648aeeaa6e 100644 (file)
@@ -359,9 +359,9 @@ static int settings_verify(struct settings *set)
        if (!get_login_uid(set))
                return FALSE;
 
-       if (access(set->mail_executable, X_OK) < 0) {
+       if (access(t_strcut(set->mail_executable, ' '), X_OK) < 0) {
                i_error("Can't use mail executable %s: %m",
-                       set->mail_executable);
+                       t_strcut(set->mail_executable, ' '));
                return FALSE;
        }