]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Use t_abspath() instead of duplicating code.
authorTimo Sirainen <tss@iki.fi>
Wed, 16 Dec 2009 18:42:45 +0000 (13:42 -0500)
committerTimo Sirainen <tss@iki.fi>
Wed, 16 Dec 2009 18:42:45 +0000 (13:42 -0500)
--HG--
branch : HEAD

src/lda/main.c
src/master/main.c

index 938da783d96e61e679d7f1f2696887e94ac05cf7..2c54a171aee07f60c452ddb5ff57fc4a9087ef5f 100644 (file)
@@ -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();
index dc299a8aa884a0237cc7d49a0a2bf9f952ae0e65..f4dc26dda9befee3bd60962d18d4e9db909d880a 100644 (file)
@@ -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 void main_deinit(void)
 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)