[gnome-builder/gnome-builder-3-32] src: check users home directory up to root for symlinks



commit ade1104dbf474badc13ef7ce6afac4b928427c63
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 17 14:26:58 2019 -0700

    src: check users home directory up to root for symlinks
    
    We don't care much about /home if the user's home directory is not there.

 src/main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/main.c b/src/main.c
index a517b8e9d..09a35058c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -76,6 +76,26 @@ early_params_check (gint       *argc,
   g_option_context_parse (context, argc, argv, NULL);
 }
 
+static gboolean
+_home_contains_symlink (const gchar *path)
+{
+  g_autofree gchar *parent = NULL;
+
+  if (g_file_test (path, G_FILE_TEST_IS_SYMLINK))
+    return TRUE;
+
+  if ((parent = g_path_get_dirname (path)) && !g_str_equal (parent, "/"))
+    return _home_contains_symlink (parent);
+
+  return FALSE;
+}
+
+static gboolean
+home_contains_symlink (void)
+{
+  return _home_contains_symlink (g_get_home_dir ());
+}
+
 gint
 main (gint   argc,
       gchar *argv[])
@@ -127,7 +147,7 @@ main (gint   argc,
    *
    * https://gitlab.gnome.org/GNOME/gnome-builder/issues/859
    */
-  if (g_file_test ("/home", G_FILE_TEST_IS_SYMLINK))
+  if (home_contains_symlink ())
     g_critical ("User home directory uses a symlink. "
                 "This is not supported and may result in unforseen issues.");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]