[gnome-packagekit/gnome-2-28] Use /proc/%i/exe instead of cmdline when getting the exec of a sender
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit/gnome-2-28] Use /proc/%i/exe instead of cmdline when getting the exec of a sender
- Date: Wed, 14 Apr 2010 10:02:55 +0000 (UTC)
commit 14129c2d1f7fc628d32c2696ab0ed6c6e03ada2c
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 17747a0..3bff3ce 100644
--- a/src/gpk-dbus.c
+++ b/src/gpk-dbus.c
@@ -188,7 +188,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;
@@ -205,19 +204,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]