dovecot-2.0: Replaced execv*() with execv*_const() wherever poss...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 27 01:34:38 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/43f2452b7dd8
changeset: 10996:43f2452b7dd8
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 27 01:34:23 2010 +0200
description:
Replaced execv*() with execv*_const() wherever possible.
diffstat:
src/auth/mech-winbind.c | 4 ++--
src/auth/passdb-checkpassword.c | 5 ++---
src/auth/userdb-checkpassword.c | 5 ++---
src/dsync/dsync.c | 8 ++++----
src/lib-lda/smtp-client.c | 4 ++--
src/lib-master/master-service-settings.c | 4 ++--
src/lib-settings/settings-parser.c | 5 ++---
src/master/main.c | 9 +++------
src/util/script.c | 14 ++++++--------
9 files changed, 25 insertions(+), 33 deletions(-)
diffs (252 lines):
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/auth/mech-winbind.c
--- a/src/auth/mech-winbind.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/auth/mech-winbind.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
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 */
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/auth/passdb-checkpassword.c
--- a/src/auth/passdb-checkpassword.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/auth/passdb-checkpassword.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
"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);
}
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/auth/userdb-checkpassword.c
--- a/src/auth/userdb-checkpassword.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/auth/userdb-checkpassword.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
"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);
}
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/dsync/dsync.c
--- a/src/dsync/dsync.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/dsync/dsync.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 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 @@
(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 */
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/lib-lda/smtp-client.c
--- a/src/lib-lda/smtp-client.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/lib-lda/smtp-client.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
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 *
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/lib-master/master-service-settings.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
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
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/lib-settings/settings-parser.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
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]);
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/master/main.c
--- a/src/master/main.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/master/main.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
/* 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 @@
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) {
diff -r ddbc6e8b2776 -r 43f2452b7dd8 src/util/script.c
--- a/src/util/script.c Sat Mar 27 01:33:33 2010 +0200
+++ b/src/util/script.c Sat Mar 27 01:34:23 2010 +0200
@@ -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 @@
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 @@
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 @@
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);
More information about the dovecot-cvs
mailing list