From aa08e2871f03f9c3a0d99f639b0495e62c5c7bf2 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 5 Oct 2017 14:30:20 +0200 Subject: src/app-indicator.c: Avoid usage of PATH_MAX macro. Fixes FTBFS on Debian GNU/Hurd. --- src/app-indicator.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 875c0b1..b94b060 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -31,6 +31,9 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#define _GNU_SOURCE +#include + #include #include #include @@ -2067,35 +2070,33 @@ static gchar * append_snap_prefix (const gchar *path) { gint i; - gchar real_path[PATH_MAX]; const gchar *snap = get_snap_prefix (); + g_autofree gchar *canon_path = NULL; if (snap != NULL && path != NULL) { - if (realpath (path, real_path) != NULL) { - path = real_path; - } + canon_path = canonicalize_file_name(path); - if (g_str_has_prefix (path, "/tmp/")) { + if (g_str_has_prefix (canon_path, "/tmp/")) { g_warning ("Using '/tmp' paths in SNAP environment will lead to unreadable resources"); return NULL; } - if (g_str_has_prefix (path, snap) || - g_str_has_prefix (path, g_get_home_dir ()) || - g_str_has_prefix (path, g_get_user_cache_dir ()) || - g_str_has_prefix (path, g_get_user_config_dir ()) || - g_str_has_prefix (path, g_get_user_data_dir ()) || - g_str_has_prefix (path, g_get_user_runtime_dir ())) { - return g_strdup (path); + if (g_str_has_prefix (canon_path, snap) || + g_str_has_prefix (canon_path, g_get_home_dir ()) || + g_str_has_prefix (canon_path, g_get_user_cache_dir ()) || + g_str_has_prefix (canon_path, g_get_user_config_dir ()) || + g_str_has_prefix (canon_path, g_get_user_data_dir ()) || + g_str_has_prefix (canon_path, g_get_user_runtime_dir ())) { + return g_strdup (canon_path); } for (i = 0; i < G_USER_N_DIRECTORIES; ++ i) { - if (g_str_has_prefix (path, g_get_user_special_dir (i))) { - return g_strdup (path); + if (g_str_has_prefix (canon_path, g_get_user_special_dir (i))) { + return g_strdup (canon_path); } } - return g_build_path (G_DIR_SEPARATOR_S, snap, path, NULL); + return g_build_path (G_DIR_SEPARATOR_S, snap, canon_path, NULL); } return NULL; -- cgit v1.2.3