[gnome-packagekit] Use /proc/%i/exe instead of cmdline when getting the exec of a sender



commit 2513476d3242952a12610bcc898ae1cc13f4984e
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 6 16:37:54 2010 +0100

    Use /proc/%i/exe instead of cmdline when getting the exec of a sender

 src/gpk-dbus.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/src/gpk-dbus.c b/src/gpk-dbus.c
index e7f603f..f775a22 100644
--- a/src/gpk-dbus.c
+++ b/src/gpk-dbus.c
@@ -207,7 +207,6 @@ out:
 static gchar *
 gpk_dbus_get_exec_for_sender (GpkDbus *dbus, const gchar *sender)
 {
-	gboolean ret;
 	gchar *filename = NULL;
 	gchar *cmdline = NULL;
 	GError *error = NULL;
@@ -224,19 +223,12 @@ gpk_dbus_get_exec_for_sender (GpkDbus *dbus, const gchar *sender)
 	}
 
 	/* get command line from proc */
-	filename = g_strdup_printf ("/proc/%i/cmdline", pid);
-	ret = g_file_get_contents (filename, &cmdline, NULL, &error);
-	if (!ret) {
-		egg_warning ("failed to get cmdline: %s", error->message);
+	filename = g_strdup_printf ("/proc/%i/exe", pid);
+	cmdline = g_file_read_link (filename, &error);
+	if (cmdline == NULL) {
+		egg_warning ("failed to find exec: %s", error->message);
 		g_error_free (error);
 	}
-
-	/* if command line contains (deleted) the original binary is invalid */
-	if (g_strstr_len (cmdline, -1, "(deleted)") != NULL) {
-		g_free (cmdline);
-		cmdline = NULL;
-		goto out;
-	}
 out:
 	g_free (filename);
 	return cmdline;



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