secret-agent: drop unused private-socket code from secret-agent

In the past, we had a private unix socket. That is long gone.
Drop the remains in "nm-secret-agent.c". The request here really
always comes from the main D-Bus connection.

Maybe the private unix socket makes sense and we might resurrect it one
day. But at that point it would be an entire rewrite and the existing
code is probably not useful either way. Drop it.
This commit is contained in:
Thomas Haller
2019-08-03 18:52:48 +02:00
parent 58e5e55f17
commit 8a347dbd55

View File

@@ -26,7 +26,6 @@
#include "nm-glib-aux/nm-dbus-aux.h"
#include "nm-dbus-interface.h"
#include "nm-dbus-manager.h"
#include "nm-core-internal.h"
#include "nm-auth-subject.h"
#include "nm-simple-connection.h"
@@ -51,14 +50,9 @@ typedef struct {
NMSecretAgentCapabilities capabilities;
GSList *permissions;
GDBusProxy *proxy;
NMDBusManager *bus_mgr;
GDBusConnection *connection;
CList requests;
union {
gulong obj_signal;
guint dbus_signal;
} on_disconnected_id;
bool connection_is_private:1;
guint on_disconnected_id;
} NMSecretAgentPrivate;
struct _NMSecretAgent {
@@ -617,33 +611,10 @@ nm_secret_agent_delete_secrets (NMSecretAgent *self,
static void
_on_disconnected_cleanup (NMSecretAgentPrivate *priv)
{
if (priv->connection_is_private) {
nm_clear_g_signal_handler (priv->bus_mgr,
&priv->on_disconnected_id.obj_signal);
} else {
nm_clear_g_dbus_connection_signal (priv->connection,
&priv->on_disconnected_id.dbus_signal);
}
&priv->on_disconnected_id);
g_clear_object (&priv->connection);
g_clear_object (&priv->proxy);
g_clear_object (&priv->bus_mgr);
}
static void
_on_disconnected_private_connection (NMDBusManager *mgr,
GDBusConnection *connection,
NMSecretAgent *self)
{
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
if (priv->connection != connection)
return;
_LOGt ("private connection disconnected");
_on_disconnected_cleanup (priv);
g_signal_emit (self, signals[DISCONNECTED], 0);
}
static void
@@ -693,6 +664,7 @@ nm_secret_agent_new (GDBusMethodInvocation *context,
char buf_caps[150];
gulong uid;
GDBusConnection *connection;
gs_free_error GError *error = NULL;
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL);
@@ -715,15 +687,12 @@ nm_secret_agent_new (GDBusMethodInvocation *context,
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
priv->bus_mgr = g_object_ref (nm_dbus_manager_get ());
priv->connection = g_object_ref (connection);
priv->connection_is_private = !!nm_dbus_manager_connection_get_private_name (priv->bus_mgr, connection);
_LOGT ("constructed: %s, owner=%s%s%s (%s), private-connection=%d, unique-name=%s%s%s, capabilities=%s",
_LOGT ("constructed: %s, owner=%s%s%s (%s), unique-name=%s%s%s, capabilities=%s",
(description = _create_description (dbus_owner, identifier, uid)),
NM_PRINT_FMT_QUOTE_STRING (owner_username),
nm_auth_subject_to_string (subject, buf_subject, sizeof (buf_subject)),
priv->connection_is_private,
NM_PRINT_FMT_QUOTE_STRING (g_dbus_connection_get_unique_name (priv->connection)),
_capabilities_to_string (capabilities, buf_caps, sizeof (buf_caps)));
@@ -734,27 +703,28 @@ nm_secret_agent_new (GDBusMethodInvocation *context,
priv->capabilities = capabilities;
priv->subject = g_object_ref (subject);
priv->proxy = nm_dbus_manager_new_proxy (priv->bus_mgr,
priv->connection,
G_TYPE_DBUS_PROXY,
priv->proxy = g_dbus_proxy_new_sync (priv->connection,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
priv->dbus_owner,
NM_DBUS_PATH_SECRET_AGENT,
NM_DBUS_INTERFACE_SECRET_AGENT);
NM_DBUS_INTERFACE_SECRET_AGENT,
NULL,
&error);
if (!priv->proxy) {
_LOGW ("could not create proxy for %s on connection %s: %s",
NM_DBUS_INTERFACE_SECRET_AGENT,
priv->dbus_owner,
error->message);
g_clear_error (&error);
}
/* we cannot subscribe to notify::g-name-owner because that doesn't work
* for unique names and it doesn't work for private connections. */
if (priv->connection_is_private) {
priv->on_disconnected_id.obj_signal = g_signal_connect (priv->bus_mgr,
NM_DBUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED,
G_CALLBACK (_on_disconnected_private_connection),
self);
} else {
priv->on_disconnected_id.dbus_signal = nm_dbus_connection_signal_subscribe_name_owner_changed (priv->connection,
priv->on_disconnected_id = nm_dbus_connection_signal_subscribe_name_owner_changed (priv->connection,
priv->dbus_owner,
_on_disconnected_name_owner_changed,
self,
NULL);
}
return self;
}
@@ -823,4 +793,3 @@ nm_secret_agent_class_init (NMSecretAgentClass *config_class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}