[gnome-packagekit] Don't pass relative file-paths to the session-service



commit 0bf25c05171842b49864cbbe8e55eb2f5697159a
Author: Matthias Klumpp <matthias tenstral net>
Date:   Fri Jul 26 17:15:50 2013 +0200

    Don't pass relative file-paths to the session-service
    
    This is required if gpk-install-local-file is executed from the command-
    line using relative paths.
    (The session-service can never know the current working-directory, so
    only absolute paths are permitted)

 src/gpk-install-local-file.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/gpk-install-local-file.c b/src/gpk-install-local-file.c
index 7498f1b..b76b6f4 100644
--- a/src/gpk-install-local-file.c
+++ b/src/gpk-install-local-file.c
@@ -42,6 +42,9 @@ main (int argc, char *argv[])
        gboolean ret;
        GError *error = NULL;
        gchar **files = NULL;
+       gchar *tmp;
+       gchar *current_dir;
+       guint i;
        DBusGConnection *connection;
        DBusGProxy *proxy = NULL;
 
@@ -83,6 +86,18 @@ main (int argc, char *argv[])
                goto out;
        }
 
+       /* make sure we don't pass relative paths to the session-interface */
+       /* (this is needed if install-local-files is executed from the command-line) */
+       current_dir = g_get_current_dir ();
+       for (i = 0; files[i] != NULL; i++) {
+               if (!g_str_has_prefix (files[i], "/")) {
+                       tmp = g_build_filename (current_dir, files[i], NULL);
+                       g_free (files[i]);
+                       files[i] = tmp;
+               }
+       }
+       g_free (current_dir);
+
        /* check dbus connections, exit if not valid */
        connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
        if (connection == NULL) {


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