]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Replaced execv*() with execv*_const() wherever possible.
authorTimo Sirainen <tss@iki.fi>
Fri, 26 Mar 2010 23:34:23 +0000 (01:34 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 26 Mar 2010 23:34:23 +0000 (01:34 +0200)
--HG--
branch : HEAD

src/auth/mech-winbind.c
src/auth/passdb-checkpassword.c
src/auth/userdb-checkpassword.c
src/dsync/dsync.c
src/lib-lda/smtp-client.c
src/lib-master/master-service-settings.c
src/lib-settings/settings-parser.c
src/master/main.c
src/util/script.c

index 357080d9a0688b743a5e44abd604a9fa5890a76d..d653562394ba8914c5e5b3cb0ac238948ab0c6c1 100644 (file)
@@ -13,6 +13,7 @@
 #include "str.h"
 #include "buffer.h"
 #include "base64.h"
+#include "execv-const.h"
 #include "istream.h"
 #include "ostream.h"
 
@@ -136,8 +137,7 @@ winbind_helper_connect(const struct auth_settings *set,
                args[0] = set->winbind_helper_path;
                args[1] = winbind->param;
                args[2] = NULL;
-               execv(args[0], (void *)args);
-               i_fatal("execv(%s) failed: %m", args[0]);
+               execv_const(args[0], args);
        }
 
        /* parent */
index aa7f7aaf91483dd70c25d2d32b8865845ef1a53e..8af65e68e2b71a49c8eb3b781dea8d39664d8a04 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2004-2010 Dovecot authors, see the included COPYING file */
 
 #include "auth-common.h"
+#include "execv-const.h"
 #include "passdb.h"
 
 #ifdef PASSDB_CHECKPASSWORD 
@@ -142,9 +143,7 @@ checkpassword_verify_plain_child(struct auth_request *request,
                                       "execute: %s", cmd);
 
                args = t_strsplit(cmd, " ");
-               execv(args[0], (char **)args);
-               auth_request_log_error(request, "checkpassword",
-                                      "execv(%s) failed: %m", args[0]);
+               execv_const(args[0], args);
        }
        exit(2);
 }
index a48f1ac7dc41f4e29de53fee2b654ad83b11b78e..d6f044625d42e8637c311a158d83d13352355d09 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2004-2010 Dovecot authors, see the included COPYING file */
 
 #include "auth-common.h"
+#include "execv-const.h"
 #include "userdb.h"
 
 #ifdef USERDB_CHECKPASSWORD
@@ -127,9 +128,7 @@ checkpassword_lookup_child(struct auth_request *request,
                                       "execute: %s", cmd);
 
                args = t_strsplit(cmd, " ");
-               execv(args[0], (char **)args);
-               auth_request_log_error(request, "userdb-checkpassword",
-                                      "execv(%s) failed: %m", args[0]);
+               execv_const(args[0], args);
        }
        exit(2);
 }
index 37bcf8c0fa620be5474397959c5f550c22296102..ecb2e76045e0a74a0eeec0382367c411a9725452 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2009-2010 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
+#include "execv-const.h"
 #include "settings-parser.h"
 #include "master-service.h"
 #include "master-service-settings.h"
@@ -19,7 +20,7 @@ static struct dsync_proxy_server *server;
 
 static void run_cmd(const char *cmd, int *fd_in_r, int *fd_out_r)
 {
-       char **args;
+       const char *const *args;
        int fd_in[2], fd_out[2];
 
        if (pipe(fd_in) < 0 || pipe(fd_out) < 0)
@@ -41,9 +42,8 @@ static void run_cmd(const char *cmd, int *fd_in_r, int *fd_out_r)
                (void)close(fd_out[0]);
                (void)close(fd_out[1]);
 
-               args = p_strsplit(pool_datastack_create(), cmd, " ");
-               (void)execvp(args[0], args);
-               i_fatal("execve(%s) failed: %m", args[0]);
+               args = t_strsplit(cmd, " ");
+               execvp_const(args[0], args);
                break;
        default:
                /* parent */
index 937350a935a41f2f9fb7a9cc771103e4eb1f32c7..539aa9dcfe1c0fbab77e4bd7c21f8a07207d673f 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2006-2010 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
+#include "execv-const.h"
 #include "master-service.h"
 #include "lda-settings.h"
 #include "mail-deliver.h"
@@ -52,8 +53,7 @@ smtp_client_run_sendmail(const struct lda_settings *set,
 
        master_service_env_clean(TRUE);
 
-       (void)execv(sendmail_path, (void *)argv);
-       i_fatal("execv(%s) failed: %m", sendmail_path);
+       execv_const(sendmail_path, argv);
 }
 
 struct smtp_client *
index 6d2337e86c047553216d40f2adcb3c7aa5a170cb..40c1d07ccf49a3ca4ed6c84850d58604c39258ec 100644 (file)
@@ -6,6 +6,7 @@
 #include "istream.h"
 #include "write-full.h"
 #include "str.h"
+#include "execv-const.h"
 #include "settings-parser.h"
 #include "master-service-private.h"
 #include "master-service-settings.h"
@@ -101,8 +102,7 @@ master_service_exec_config(struct master_service *service,
        conf_argv[8] = binary_path;
        memcpy(conf_argv+9, service->argv + 1,
               (service->argc) * sizeof(conf_argv[0]));
-       execv(conf_argv[0], (char **)conf_argv);
-       i_fatal("execv(%s) failed: %m", conf_argv[0]);
+       execv_const(conf_argv[0], conf_argv);
 }
 
 static void
index 5341cd3728aa86aa0803ffca7a3173940b2f4d27..3ffd0c51a00963f9cbc5850328d4bd27d4bb7959 100644 (file)
@@ -5,6 +5,7 @@
 #include "hash.h"
 #include "network.h"
 #include "istream.h"
+#include "execv-const.h"
 #include "str.h"
 #include "strescape.h"
 #include "var-expand.h"
@@ -960,9 +961,7 @@ int settings_parse_exec(struct setting_parser_context *ctx,
                if (dup2(fd[1], STDOUT_FILENO) < 0)
                        i_fatal("dup2() failed: %m");
 
-               execv(argv[0], (void *)argv);
-               i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", bin_path);
-               return -1;
+               execv_const(argv[0], argv);
        }
        (void)close(fd[1]);
 
index ec717efba7ab70ffab3d366a12dec53ad78a9d70..d770e1afed088519f6179e6de46fc89eba221364 100644 (file)
@@ -9,6 +9,7 @@
 #include "env-util.h"
 #include "hostpid.h"
 #include "abspath.h"
+#include "execv-const.h"
 #include "restrict-process-size.h"
 #include "master-service.h"
 #include "master-service-settings.h"
@@ -80,10 +81,7 @@ void process_exec(const char *cmd, const char *extra_args[])
 
        /* prefix with dovecot/ */
        argv[0] = t_strconcat(PACKAGE"/", argv[0], NULL);
-
-       (void)execv(executable, (char **)argv);
-       i_fatal_status(errno == ENOMEM ? FATAL_OUTOFMEM : FATAL_EXEC,
-                      "execv(%s) failed: %m", executable);
+       (void)execv_const(executable, argv);
 }
 
 int get_uidgid(const char *user, uid_t *uid_r, gid_t *gid_r,
@@ -691,8 +689,7 @@ int main(int argc, char *argv[])
                args[2] = "-c";
                args[3] = master_service_get_config_path(master_service);
                args[4] = NULL;
-               execv(args[0], (char **)args);
-               i_fatal("execv(%s) failed: %m", args[0]);
+               execv_const(args[0], args);
        }
 
        while (optind < argc) {
index 1c10ae4374bbaced672cdc3cd71fd66196033a66..881c1a70d09060313f99472c6090c905430e7dba 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "env-util.h"
+#include "execv-const.h"
 #include "fdpass.h"
 #include "restrict-access.h"
 #include "str.h"
@@ -18,7 +19,7 @@
 #define ENV_USERDB_KEYS "USERDB_KEYS"
 #define SCRIPT_COMM_FD 3
 
-static char **exec_args;
+static const char **exec_args;
 static bool drop_privileges = FALSE;
 
 static void client_connected(const struct master_service_connection *conn)
@@ -119,8 +120,7 @@ static void client_connected(const struct master_service_connection *conn)
        if (close(MASTER_STATUS_FD) < 0)
                i_error("close(status) failed: %m");
 
-       (void)execvp(exec_args[0], exec_args);
-       i_fatal("execvp(%s) failed: %m", exec_args[0]);
+       execvp_const(exec_args[0], exec_args);
 }
 
 static void script_execute_finish(void)
@@ -160,7 +160,6 @@ static void script_execute_finish(void)
 int main(int argc, char *argv[])
 {
        enum master_service_flags flags = 0;
-       const char *path;
        int i, c;
 
        if (getenv(MASTER_UID_ENV) == NULL)
@@ -189,16 +188,15 @@ int main(int argc, char *argv[])
        else {
                if (argv[0] == NULL)
                        i_fatal("Missing script path");
-               exec_args = i_new(char *, argc + 2);
+               exec_args = i_new(const char *, argc + 2);
                for (i = 0; i < argc; i++)
                        exec_args[i] = argv[i];
                exec_args[i] = PKG_LIBEXECDIR"/script";
                exec_args[i+1] = NULL;
 
                if (exec_args[0][0] != '/') {
-                       path = t_strconcat(PKG_LIBEXECDIR"/",
-                                          exec_args[0], NULL);
-                       exec_args[0] = t_strdup_noconst(path);
+                       exec_args[0] = t_strconcat(PKG_LIBEXECDIR"/",
+                                                  exec_args[0], NULL);
                }
 
                master_service_run(master_service, client_connected);