From: Timo Sirainen Date: Fri, 20 Jan 2012 22:27:52 +0000 (+0200) Subject: lmtp: Make core dumping work also after the first mail delivery. X-Git-Tag: 2.1.rc4~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffaa309c211897ab875bbe0b093bc7e709bb1e5d;p=thirdparty%2Fdovecot%2Fcore.git lmtp: Make core dumping work also after the first mail delivery. --- diff --git a/src/lmtp/commands.c b/src/lmtp/commands.c index 9a22841b49..7d073d2f79 100644 --- a/src/lmtp/commands.c +++ b/src/lmtp/commands.c @@ -11,6 +11,7 @@ #include "ostream.h" #include "istream-dot.h" #include "safe-mkstemp.h" +#include "restrict-access.h" #include "master-service.h" #include "rfc822-parser.h" #include "message-date.h" @@ -706,6 +707,10 @@ client_input_data_write_local(struct client *client, struct istream *input) lose e.g. config connection and need to reconnect to it. */ if (seteuid(0) < 0) i_fatal("seteuid(0) failed: %m"); + /* enable core dumping again. we need to chdir also to + root-owned directory to get core dumps. */ + restrict_access_allow_coredumps(TRUE); + (void)chdir(base_dir); } } diff --git a/src/lmtp/main.c b/src/lmtp/main.c index b375a88711..305e90a6a5 100644 --- a/src/lmtp/main.c +++ b/src/lmtp/main.c @@ -25,7 +25,7 @@ #define IS_STANDALONE() \ (getenv(MASTER_IS_PARENT_ENV) == NULL) -const char *dns_client_socket_path; +const char *dns_client_socket_path, *base_dir; struct mail_storage_service_ctx *storage_service; static void client_connected(struct master_service_connection *conn) @@ -107,6 +107,8 @@ int main(int argc, char *argv[]) } } + if (t_get_current_dir(&base_dir) < 0) + i_fatal("getcwd() failed: %m"); drop_privileges(); master_service_init_finish(master_service); master_service_init_log(master_service, diff --git a/src/lmtp/main.h b/src/lmtp/main.h index 9aae739ce9..8547032466 100644 --- a/src/lmtp/main.h +++ b/src/lmtp/main.h @@ -1,7 +1,7 @@ #ifndef MAIN_H #define MAIN_H -extern const char *dns_client_socket_path; +extern const char *dns_client_socket_path, *base_dir; extern struct mail_storage_service_ctx *storage_service; void listener_client_destroyed(void);