aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-10-05 14:30:20 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-10-06 20:38:58 +0200
commitbc7f6838bdffff00f8a752f1ce387d12fcb06ca0 (patch)
tree0652b4a447b7556a3ee8da48e7226146841fe722
parentc17c300a556580ae9c194b65a02efff48fa7df7c (diff)
downloadlibayatana-appindicator-bc7f6838bdffff00f8a752f1ce387d12fcb06ca0.tar.gz
libayatana-appindicator-bc7f6838bdffff00f8a752f1ce387d12fcb06ca0.tar.bz2
libayatana-appindicator-bc7f6838bdffff00f8a752f1ce387d12fcb06ca0.zip
src/app-indicator.c: Avoid usage of PATH_MAX macro. Fixes FTBFS on Debian GNU/Hurd.
-rw-r--r--src/app-indicator.c31
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;