diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-10-05 14:30:20 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-10-05 14:30:20 +0200 |
commit | aa08e2871f03f9c3a0d99f639b0495e62c5c7bf2 (patch) | |
tree | 0652b4a447b7556a3ee8da48e7226146841fe722 | |
parent | c17c300a556580ae9c194b65a02efff48fa7df7c (diff) | |
download | libayatana-appindicator-pr/avoid-path-max.tar.gz libayatana-appindicator-pr/avoid-path-max.tar.bz2 libayatana-appindicator-pr/avoid-path-max.zip |
src/app-indicator.c: Avoid usage of PATH_MAX macro. Fixes FTBFS on Debian GNU/Hurd.pr/avoid-path-max
-rw-r--r-- | src/app-indicator.c | 31 |
1 files 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 <stdlib.h> + #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-glib/server.h> #include <libdbusmenu-gtk/client.h> @@ -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; |