Skip to content

Commit

Permalink
doveadm: Move getenv to correct place
Browse files Browse the repository at this point in the history
All getenv()s must be done after master_service_init() or the pointer will be
corrupted with Linux and other OSes without setproctitle().
  • Loading branch information
cmouse authored and sirainen committed Mar 29, 2016
1 parent 102279b commit 1cccb7f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/doveadm/doveadm.c
Expand Up @@ -291,7 +291,6 @@ int main(int argc, char *argv[])

memset(&cctx,0,sizeof(cctx));
cctx.cli = TRUE;
cctx.username = getenv("USER");

i_set_failure_exit_callback(failure_exit_callback);
doveadm_dsync_main(&argc, &argv);
Expand Down Expand Up @@ -369,6 +368,10 @@ int main(int argc, char *argv[])
i_set_debug_file("/dev/null");
}

/* this has to be done here because proctitle hack can break
the env pointer */
cctx.username = getenv("USER");

if (!doveadm_cmd_try_run_ver2(cmd_name, argc, (const char**)argv, &cctx) &&
!doveadm_try_run(cmd_name, argc, (const char **)argv) &&
!doveadm_mail_try_run(cmd_name, argc, argv)) {
Expand Down

0 comments on commit 1cccb7f

Please sign in to comment.