bus/connection: don't check cmdline in session dbus-daemon
[platform/upstream/dbus.git] / bus / connection.c
index dcb47ba..6b85ba3 100644 (file)
@@ -591,6 +591,13 @@ bus_connections_unref (BusConnections *connections)
     }
 }
 
+static dbus_bool_t
+is_context_type_session (BusConnectionData *d)
+{
+  const char *context_type = bus_context_get_type (d->connections->context);
+  return context_type && !strcmp (context_type, "session");
+}
+
 /* Used for logging */
 static dbus_bool_t
 cache_peer_loginfo_string (BusConnectionData *d, 
@@ -624,8 +631,19 @@ cache_peer_loginfo_string (BusConnectionData *d,
       if (!_dbus_string_append_printf (&loginfo_buf, "pid=%ld comm=\"", pid))
         goto oom;
       /* Ignore errors here; we may not have permissions to read the
-       * proc file. */
-      _dbus_command_for_pid (pid, &loginfo_buf, MAX_LOG_COMMAND_LEN, NULL);
+       * proc file.
+       * Don't even try it for the session daemon, to avoid cluttering logs with security error logs for
+       * accessing the proc file.
+       */
+      if (!is_context_type_session(d))
+        {
+          _dbus_command_for_pid (pid, &loginfo_buf, MAX_LOG_COMMAND_LEN, NULL);
+        }
+      else
+        {
+          if (!_dbus_string_append (&loginfo_buf, "<not-read>"))   /* for session daemon just say that we didn't try */
+            goto oom;
+        }
       if (!_dbus_string_append_byte (&loginfo_buf, '"'))
         goto oom;
       else
@@ -2842,29 +2860,6 @@ bus_connection_queue_deferred_message (DBusConnection *connection,
   return FALSE;
 }
 
-dbus_bool_t
-bus_connection_replace_deferred_message (DBusConnection *connection,
-                                         BusDeferredMessage *oldMessage,
-                                         BusDeferredMessage *newMessage)
-{
-  DBusList *link;
-  BusConnectionData *d = BUS_CONNECTION_DATA(connection);
-
-  _dbus_assert (d != NULL);
-
-  link = _dbus_list_find_first(&d->deferred_messages, oldMessage);
-  if (link == NULL)
-    return FALSE;
-
-  if (!_dbus_list_insert_after(&d->deferred_messages, link, newMessage))
-    return FALSE;
-
-  bus_deferred_message_ref(newMessage);
-  _dbus_list_remove_link(&d->deferred_messages, link);
-  bus_deferred_message_unref(oldMessage);
-  return TRUE;
-}
-
 BusDeferredMessage *
 bus_connection_pop_deferred_message (DBusConnection *connection)
 {