int main(int argc, char *argv[])
{
- master_service = master_service_init("anvil", 0, argc, argv, NULL);
+ master_service = master_service_init("anvil", 0, &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
return FATAL_DEFAULT;
{
int c;
- master_service = master_service_init("auth", 0, argc, argv, "w");
+ master_service = master_service_init("auth", 0, &argc, &argv, "w");
master_service_init_log(master_service, "auth: ");
while ((c = master_getopt(master_service)) > 0) {
memset(&filter, 0, sizeof(filter));
master_service = master_service_init("config",
MASTER_SERVICE_FLAG_STANDALONE,
- argc, argv, "af:m:nNe");
+ &argc, &argv, "af:m:nNe");
i_set_failure_prefix("doveconf: ");
while ((c = master_getopt(master_service)) > 0) {
if (c == 'e')
{
const char *path, *error;
- master_service = master_service_init("config", 0, argc, argv, NULL);
+ master_service = master_service_init("config", 0, &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
return FATAL_DEFAULT;
};
const char *error;
- master_service = master_service_init("dict", 0, argc, argv, NULL);
+ master_service = master_service_init("dict", 0, &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
return FATAL_DEFAULT;
master_service = master_service_init("doveadm",
MASTER_SERVICE_FLAG_STANDALONE,
- argc, argv, "+");
+ &argc, &argv, "+");
i_array_init(&doveadm_cmds, 32);
doveadm_mail_init();
doveadm_register_cmd(&doveadm_cmd_help);
master_service = master_service_init("dsync",
MASTER_SERVICE_FLAG_STANDALONE |
MASTER_SERVICE_FLAG_STD_CLIENT,
- argc, argv, "b:e:fu:v");
+ &argc, &argv, "b:e:fu:v");
username = getenv("USER");
while ((c = master_getopt(master_service)) > 0) {
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
-#include "process-title.h"
#include "safe-memset.h"
#include "str.h"
#include "strescape.h"
#include "base64.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
-#include "process-title.h"
#include "master-interface.h"
#include "master-service.h"
#include "master-login.h"
}
}
-int main(int argc, char *argv[], char *envp[])
+int main(int argc, char *argv[])
{
enum master_service_flags service_flags = 0;
}
master_service = master_service_init("imap", service_flags,
- argc, argv, NULL);
+ &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
exit(FATAL_DEFAULT);
- process_title_init(argv, envp);
master_service_init_finish(master_service);
/* plugins may want to add commands, so this needs to be called early */
master_service = master_service_init("lda",
MASTER_SERVICE_FLAG_STANDALONE |
MASTER_SERVICE_FLAG_DONT_LOG_TO_STDERR,
- argc, argv, "a:d:p:ekm:nsf:");
+ &argc, &argv, "a:d:p:ekm:nsf:");
memset(&ctx, 0, sizeof(ctx));
ctx.pool = pool_alloconly_create("mail deliver context", 256);
#include "array.h"
#include "env-util.h"
#include "home-expand.h"
+#include "process-title.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
#include "settings-parser.h"
struct master_service *
master_service_init(const char *name, enum master_service_flags flags,
- int argc, char *argv[], const char *getopt_str)
+ int *argc, char **argv[], const char *getopt_str)
{
+ extern char **environ;
struct master_service *service;
const char *str;
if (getenv(MASTER_UID_ENV) == NULL)
flags |= MASTER_SERVICE_FLAG_STANDALONE;
+ process_title_init(argv, environ);
+
service = i_new(struct master_service, 1);
- service->argc = argc;
- service->argv = argv;
+ service->argc = *argc;
+ service->argv = *argv;
service->name = i_strdup(name);
service->getopt_str =
i_strconcat(master_service_getopt_string(), getopt_str, NULL);
/* Start service initialization. */
struct master_service *
master_service_init(const char *name, enum master_service_flags flags,
- int argc, char *argv[], const char *getopt_str);
+ int *argc, char **argv[], const char *getopt_str);
/* Call getopt() and handle internal parameters. Return values are the same as
getopt()'s. */
int master_getopt(struct master_service *service);
process_title_len = (size_t) (envp[i-1] - argv[0]) + strlen(envp[i-1]);
}
+static char **argv_dup(char *old_argv[])
+{
+ char **new_argv;
+ unsigned int i, count;
+
+ for (count = 0; old_argv[count] != NULL; count++) ;
+
+ new_argv = malloc(sizeof(char *) * (count + 1));
+ for (i = 0; i < count; i++) {
+ new_argv[i] = strdup(old_argv[i]);
+ if (new_argv[i] == NULL)
+ i_fatal_status(FATAL_OUTOFMEM, "strdup() failed: %m");
+ }
+ new_argv[i] = NULL;
+ return new_argv;
+}
+
static void linux_proctitle_set(const char *title)
{
i_strocpy(process_title, title, process_title_len);
#endif
-void process_title_init(char *argv[], char *envp[] ATTR_UNUSED)
+void process_title_init(char **argv[], char *envp[] ATTR_UNUSED)
{
#ifdef LINUX_PROCTITLE_HACK
- linux_proctitle_init(argv, envp);
+ *argv = argv_dup(*argv);
+ linux_proctitle_init(*argv, envp);
#endif
- process_name = argv[0];
+ process_name = (*argv)[0];
}
void process_title_set(const char *title ATTR_UNUSED)
linux_proctitle_set(t_strconcat(process_name, " ", title, NULL));
#endif
}
-
#define PROCESS_TITLE_H
/* Initialize title changing. */
-void process_title_init(char *argv[], char *envp[]);
+void process_title_init(char **argv[], char *envp[]);
/* Change the process title if possible. */
void process_title_set(const char *title);
#include "ioloop.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
-#include "process-title.h"
#include "master-service.h"
#include "master-service-settings.h"
#include "master-interface.h"
clients_destroy();
}
-int main(int argc, char *argv[], char *envp[])
+int main(int argc, char *argv[])
{
const struct setting_parser_info *set_roots[] = {
&lda_setting_parser_info,
}
master_service = master_service_init("lmtp", service_flags,
- argc, argv, NULL);
+ &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
return FATAL_DEFAULT;
storage_service_flags);
restrict_access_allow_coredumps(TRUE);
- process_title_init(argv, envp);
-
main_init();
master_service_run(master_service, client_connected);
{
const char *error;
- master_service = master_service_init("log", 0, argc, argv, NULL);
+ master_service = master_service_init("log", 0, &argc, &argv, NULL);
/* use log prefix and log to stderr until we've configured the real
logging */
#include "randgen.h"
#include "restrict-access.h"
#include "restrict-process-size.h"
-#include "process-title.h"
#include "master-auth.h"
#include "master-service.h"
#include "master-interface.h"
}
}
-int main(int argc, char *argv[], char *envp[])
+int main(int argc, char *argv[])
{
enum master_service_flags service_flags =
MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN |
int c;
master_service = master_service_init(login_process_name, service_flags,
- argc, argv, "DS");
+ &argc, &argv, "DS");
master_service_init_log(master_service, t_strconcat(
login_process_name, ": ", NULL));
login_process_preinit();
- process_title_init(argv, envp);
set_pool = pool_alloconly_create("global login settings", 4096);
global_login_settings =
login_settings_read(master_service, set_pool, NULL, NULL,
master_service = master_service_init(MASTER_SERVICE_NAME,
MASTER_SERVICE_FLAG_STANDALONE |
MASTER_SERVICE_FLAG_DONT_LOG_TO_STDERR,
- argc, argv, "Fanp-");
+ &argc, &argv, "Fanp-");
i_set_failure_prefix("");
io_loop_set_time_moved_callback(current_ioloop, master_time_moved);
master_service = master_service_init("convert-tool",
MASTER_SERVICE_FLAG_STANDALONE,
- argc, argv, NULL);
+ &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
i_fatal(USAGE_STRING);
master_service = master_service_init("expire-tool",
MASTER_SERVICE_FLAG_STANDALONE,
- argc, argv, "t");
+ &argc, &argv, "t");
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
#include "ostream.h"
#include "base64.h"
#include "restrict-access.h"
-#include "process-title.h"
#include "master-service.h"
#include "master-login.h"
#include "master-interface.h"
}
}
-int main(int argc, char *argv[], char *envp[])
+int main(int argc, char *argv[])
{
enum master_service_flags service_flags = 0;
}
master_service = master_service_init("pop3", service_flags,
- argc, argv, NULL);
+ &argc, &argv, NULL);
if (master_getopt(master_service) > 0)
return FATAL_DEFAULT;
- process_title_init(argv, envp);
master_service_init_finish(master_service);
if (IS_STANDALONE()) {
{
const struct ssl_params_settings *set;
- master_service = master_service_init("ssl-params", 0, argc, argv, NULL);
+ master_service = master_service_init("ssl-params", 0,
+ &argc, &argv, NULL);
master_service_init_log(master_service, "ssl-params: ");
if (master_getopt(master_service) > 0)
lib_init();
i_set_failure_internal();
- process_title_init(argv, envp);
+ process_title_init(&argv, envp);
argc--;
argv++;