dovecot-2.0: Use t_abspath() instead of duplicating code.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Dec 16 20:48:22 EET 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/28a14e2fe5d6
changeset: 10501:28a14e2fe5d6
user: Timo Sirainen <tss at iki.fi>
date: Wed Dec 16 13:42:45 2009 -0500
description:
Use t_abspath() instead of duplicating code.
diffstat:
2 files changed, 4 insertions(+), 12 deletions(-)
src/lda/main.c | 10 ++--------
src/master/main.c | 6 ++----
diffs (62 lines):
diff -r 28ff2944d4e9 -r 28a14e2fe5d6 src/lda/main.c
--- a/src/lda/main.c Wed Dec 16 13:31:12 2009 -0500
+++ b/src/lda/main.c Wed Dec 16 13:42:45 2009 -0500
@@ -7,6 +7,7 @@
#include "close-keep-errno.h"
#include "istream.h"
#include "istream-seekable.h"
+#include "abspath.h"
#include "safe-mkstemp.h"
#include "eacces-error.h"
#include "mkdir-parents.h"
@@ -256,7 +257,6 @@ int main(int argc, char *argv[])
struct istream *input;
struct mailbox_transaction_context *t;
struct mailbox_header_lookup_ctx *headers_ctx;
- char cwd[PATH_MAX];
void **sets;
uid_t process_euid;
bool stderr_rejection = FALSE;
@@ -328,13 +328,7 @@ int main(int argc, char *argv[])
break;
case 'p':
/* input path */
- path = optarg;
- if (*path != '/') {
- /* expand relative paths before we chdir */
- if (getcwd(cwd, sizeof(cwd)) == NULL)
- i_fatal("getcwd() failed: %m");
- path = t_strconcat(cwd, "/", path, NULL);
- }
+ path = t_abspath(optarg);
break;
default:
print_help();
diff -r 28ff2944d4e9 -r 28a14e2fe5d6 src/master/main.c
--- a/src/master/main.c Wed Dec 16 13:31:12 2009 -0500
+++ b/src/master/main.c Wed Dec 16 13:42:45 2009 -0500
@@ -8,6 +8,7 @@
#include "write-full.h"
#include "env-util.h"
#include "hostpid.h"
+#include "abspath.h"
#include "restrict-process-size.h"
#include "master-service.h"
#include "master-service-settings.h"
@@ -420,15 +421,12 @@ static const char *get_full_config_path(
static const char *get_full_config_path(struct service_list *list)
{
const char *path;
- char cwd[PATH_MAX];
path = master_service_get_config_path(master_service);
if (*path == '/')
return path;
- if (getcwd(cwd, sizeof(cwd)) == NULL)
- i_fatal("getcwd() failed: %m");
- return p_strconcat(list->pool, cwd, "/", path, NULL);
+ return p_strdup(list->pool, t_abspath(path));
}
static void master_time_moved(time_t old_time, time_t new_time)
More information about the dovecot-cvs
mailing list