Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2886:634cf6aa34d1 HEAD
Allow running all executables with parameters.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 24 Nov 2004 18:44:11 +0200 |
parents | 1880f191278a |
children | 70ce8c45e86b |
files | src/master/auth-process.c src/master/common.h src/master/login-process.c src/master/mail-process.c src/master/main.c src/master/master-settings.c |
diffstat | 6 files changed, 29 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/master/auth-process.c Sun Nov 14 03:23:21 2004 +0200 +++ b/src/master/auth-process.c Wed Nov 24 18:44:11 2004 +0200 @@ -349,7 +349,6 @@ static int create_auth_process(struct auth_process_group *group) { - static char *argv[] = { NULL, NULL }; struct auth_socket_settings *as; const char *prefix, *str; struct log_io *log; @@ -468,15 +467,7 @@ any errors above will be logged */ closelog(); - /* hide the path, it's ugly */ - argv[0] = strrchr(group->set->executable, '/'); - if (argv[0] == NULL) - argv[0] = i_strdup(group->set->executable); - else - argv[0]++; - - execv(group->set->executable, argv); - + client_process_exec(group->set->executable, ""); i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", group->set->executable); return -1;
--- a/src/master/common.h Sun Nov 14 03:23:21 2004 +0200 +++ b/src/master/common.h Wed Nov 24 18:44:11 2004 +0200 @@ -38,6 +38,7 @@ hash_remove(pids, POINTER_CAST(pid)) void child_process_init_env(void); +void client_process_exec(const char *cmd, const char *title); /* misc */ #define VALIDATE_STR(str) \
--- a/src/master/login-process.c Sun Nov 14 03:23:21 2004 +0200 +++ b/src/master/login-process.c Wed Nov 24 18:44:11 2004 +0200 @@ -445,7 +445,6 @@ static pid_t create_login_process(struct login_group *group) { - static const char *argv[] = { NULL, NULL }; struct log_io *log; const char *prefix; pid_t pid; @@ -539,15 +538,7 @@ any errors above will be logged */ closelog(); - /* hide the path, it's ugly */ - argv[0] = strrchr(group->set->login_executable, '/'); - if (argv[0] == NULL) - argv[0] = group->set->login_executable; - else - argv[0]++; - - execv(group->set->login_executable, (char **) argv); - + client_process_exec(group->set->login_executable, ""); i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", group->set->login_executable); return -1;
--- a/src/master/mail-process.c Sun Nov 14 03:23:21 2004 +0200 +++ b/src/master/mail-process.c Wed Nov 24 18:44:11 2004 +0200 @@ -251,30 +251,6 @@ } } -static void mail_process_exec_set(struct settings *set, const char *title) -{ - const char *executable, *p, *argv[4]; - int i; - - /* very simple argument splitting. */ - i = 0; - argv[i++] = executable = t_strcut(set->mail_executable, ' '); - argv[i] = strchr(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 */ - p = strrchr(argv[0], '/'); - if (p != NULL) argv[0] = p+1; - - execv(executable, (char **) argv); -} - void mail_process_exec(const char *protocol, const char *section) { struct server_settings *server = settings_root; @@ -303,7 +279,7 @@ getenv("TCPREMOTEIP"), getpid()); mail_process_set_environment(set, getenv("MAIL"), var_expand_table); - mail_process_exec_set(set, ""); + client_process_exec(set->mail_executable, ""); i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", set->mail_executable); @@ -469,7 +445,7 @@ if (set->mail_drop_priv_before_exec) restrict_access_by_env(TRUE); - mail_process_exec_set(set, title); + client_process_exec(set->mail_executable, title); err = errno; for (i = 0; i < 3; i++)
--- a/src/master/main.c Sun Nov 14 03:23:21 2004 +0200 +++ b/src/master/main.c Wed Nov 24 18:44:11 2004 +0200 @@ -72,6 +72,25 @@ #endif } +void client_process_exec(const char *cmd, const char *title) +{ + const char *executable, *p, **argv; + + /* very simple argument splitting. */ + if (*title == '\0') + argv = t_strsplit(cmd, " "); + else + argv = t_strsplit(t_strconcat(cmd, " ", title), " "); + + executable = argv[0]; + + /* hide the path, it's ugly */ + p = strrchr(argv[0], '/'); + if (p != NULL) argv[0] = p+1; + + execv(executable, (char **)argv); +} + static void sig_quit(int signo __attr_unused__) { io_loop_stop(ioloop);
--- a/src/master/master-settings.c Sun Nov 14 03:23:21 2004 +0200 +++ b/src/master/master-settings.c Wed Nov 24 18:44:11 2004 +0200 @@ -385,8 +385,9 @@ auth->uid = pw->pw_uid; auth->gid = pw->pw_gid; - if (access(auth->executable, X_OK) < 0) { - i_error("Can't use auth executable %s: %m", auth->executable); + if (access(t_strcut(auth->executable, ' '), X_OK) < 0) { + i_error("Can't use auth executable %s: %m", + t_strcut(auth->executable, ' ')); return FALSE; } @@ -579,9 +580,9 @@ return FALSE; } - if (access(set->login_executable, X_OK) < 0) { + if (access(t_strcut(set->login_executable, ' '), X_OK) < 0) { i_error("Can't use login executable %s: %m", - set->login_executable); + t_strcut(set->login_executable, ' ')); return FALSE; }