if (imap_urlauth_settings->verbose_proctitle)
verbose_proctitle = TRUE;
- login_set.auth_socket_path = t_abspath(auth_socket_path);
+ if (t_abspath(auth_socket_path, &login_set.auth_socket_path, &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", auth_socket_path, error);
+ }
login_set.callback = login_client_connected;
login_set.failure_callback = login_client_failed;
main_stdio_run(username);
} T_END;
} else T_BEGIN {
- login_set.auth_socket_path = t_abspath(auth_socket_path);
+ const char *error;
+ if (t_abspath(auth_socket_path, &login_set.auth_socket_path,
+ &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", auth_socket_path,
+ error);
+ }
+
if (argv[optind] != NULL) {
- login_set.postlogin_socket_path =
- t_abspath(argv[optind]);
+ if (t_abspath(argv[optind], &login_set.postlogin_socket_path, &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", argv[optind], error);
+ }
}
login_set.callback = login_client_connected;
login_set.failure_callback = login_client_failed;
break;
case 'p':
/* input path */
- path = t_abspath(optarg);
+ if (t_abspath(optarg, &path, &errstr) < 0) {
+ i_fatal("t_abspath(%s) failed: %s",
+ optarg, errstr);
+ }
break;
case 'r':
/* final recipient address */
return t_realpath(t_strconcat(root, "/", path, NULL), npath_r, error_r);
}
-const char *t_abspath(const char *path)
+int t_abspath(const char *path, const char **abspath_r, const char **error_r)
{
i_assert(path != NULL);
+ i_assert(abspath_r != NULL);
+ i_assert(error_r != NULL);
- if (*path == '/')
- return path;
+ if (*path == '/') {
+ *abspath_r = path;
+ return 0;
+ }
const char *dir, *error;
- if (t_get_working_dir(&dir, &error) < 0)
- i_fatal("Failed to get working directory: %s", error);
- return t_strconcat(dir, "/", path, NULL);
+ if (t_get_working_dir(&dir, &error) < 0) {
+ *error_r = t_strconcat("Failed to get working directory: ",
+ error, NULL);
+ return -1;
+ }
+ *abspath_r = t_strconcat(dir, "/", path, NULL);
+ return 0;
}
const char *t_abspath_to(const char *path, const char *root)
return TRUE;
} else if (strchr(*binpath, '/') != NULL) {
/* relative to current directory */
- *binpath = t_abspath(*binpath);
+ const char *error;
+ if (t_abspath(*binpath, binpath, &error) < 0) {
+ i_error("t_abspath(%s) failed: %s",
+ *binpath, error);
+ return FALSE;
+ }
return TRUE;
} else if ((path_env = getenv("PATH")) != NULL) {
/* we have to find our executable from path */
* In the t_abspath functions, the returned paths are not normalized. This
* means that './' and '../' are not resolved, but they left in the returned
* path as given in the parameters. Symbolic links are not resolved either.
+ *
+ * Returns 0 on success, and -1 on failure. error_r is set on failure, and
+ * cannot be NULL.
*/
-const char *t_abspath(const char *path);
+int t_abspath(const char *path, const char **abspath_r, const char **error_r);
/* Like t_abspath(), but path is relative to given root. */
const char *t_abspath_to(const char *path, const char *root);
i_zero(&conn);
(void)client_create(STDIN_FILENO, STDOUT_FILENO, &conn);
}
- dns_client_socket_path = i_strdup(t_abspath(DNS_CLIENT_SOCKET_PATH));
+
+ const char *error, *tmp_socket_path;
+ if (t_abspath(DNS_CLIENT_SOCKET_PATH, &tmp_socket_path, &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", DNS_CLIENT_SOCKET_PATH, error);
+ }
+ dns_client_socket_path = i_strdup(tmp_socket_path);
}
static void main_deinit(void)
if (*path == '/')
return path;
- return p_strdup(list->pool, t_abspath(path));
+ const char *abspath, *error;
+ if (t_abspath(path, &abspath, &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", path, error);
+ }
+ return p_strdup(list->pool, abspath);
}
static void master_time_moved(time_t old_time, time_t new_time)
}
}
- login_set.auth_socket_path = t_abspath(auth_socket_path);
- if (argv[optind] != NULL)
- login_set.postlogin_socket_path = t_abspath(argv[optind]);
+ const char *error;
+ if (t_abspath(auth_socket_path, &login_set.auth_socket_path, &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", auth_socket_path, error);
+ }
+ if (argv[optind] != NULL) {
+ if (t_abspath(argv[optind], &login_set.postlogin_socket_path, &error) < 0) {
+ i_fatal("t_abspath(%s) failed: %s", argv[optind], error);
+ }
+ }
login_set.callback = login_client_connected;
login_set.failure_callback = login_client_failed;