mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-09 23:40:33 +01:00
agent: log agent registration
This commit is contained in:
parent
a30cf19858
commit
e716e7507b
3 changed files with 54 additions and 3 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-agent-manager.h"
|
||||
#include "nm-secret-agent.h"
|
||||
#include "nm-manager-auth.h"
|
||||
|
|
@ -128,6 +129,11 @@ remove_agent (NMAgentManager *self, const char *owner)
|
|||
|
||||
/* FIXME: signal agent removal */
|
||||
|
||||
nm_log_dbg (LOGD_AGENTS, "(%s/%s) agent unregistered for UID %ld",
|
||||
nm_secret_agent_get_dbus_owner (agent),
|
||||
nm_secret_agent_get_identifier (agent),
|
||||
nm_secret_agent_get_owner_uid (agent));
|
||||
|
||||
g_hash_table_remove (priv->agents, owner);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -233,7 +239,7 @@ impl_agent_manager_register (NMAgentManager *self,
|
|||
goto done;
|
||||
|
||||
/* Success, add the new agent */
|
||||
agent = nm_secret_agent_new (sender, identifier);
|
||||
agent = nm_secret_agent_new (sender, identifier, sender_uid);
|
||||
if (!agent) {
|
||||
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR,
|
||||
NM_AGENT_MANAGER_ERROR_INTERNAL_ERROR,
|
||||
|
|
@ -242,6 +248,10 @@ impl_agent_manager_register (NMAgentManager *self,
|
|||
}
|
||||
|
||||
g_hash_table_insert (priv->agents, g_strdup (sender), agent);
|
||||
nm_log_dbg (LOGD_AGENTS, "(%s/%s) agent registered for UID %ld",
|
||||
nm_secret_agent_get_dbus_owner (agent),
|
||||
nm_secret_agent_get_identifier (agent),
|
||||
nm_secret_agent_get_owner_uid (agent));
|
||||
dbus_g_method_return (context);
|
||||
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -37,12 +37,44 @@ typedef struct {
|
|||
|
||||
char *owner;
|
||||
char *identifier;
|
||||
uid_t owner_uid;
|
||||
} NMSecretAgentPrivate;
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
const char *
|
||||
nm_secret_agent_get_dbus_owner (NMSecretAgent *agent)
|
||||
{
|
||||
g_return_val_if_fail (agent != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_SECRET_AGENT (agent), NULL);
|
||||
|
||||
return NM_SECRET_AGENT_GET_PRIVATE (agent)->owner;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_secret_agent_get_identifier (NMSecretAgent *agent)
|
||||
{
|
||||
g_return_val_if_fail (agent != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_SECRET_AGENT (agent), NULL);
|
||||
|
||||
return NM_SECRET_AGENT_GET_PRIVATE (agent)->identifier;
|
||||
}
|
||||
|
||||
uid_t
|
||||
nm_secret_agent_get_owner_uid (NMSecretAgent *agent)
|
||||
{
|
||||
g_return_val_if_fail (agent != NULL, G_MAXUINT);
|
||||
g_return_val_if_fail (NM_IS_SECRET_AGENT (agent), G_MAXUINT);
|
||||
|
||||
return NM_SECRET_AGENT_GET_PRIVATE (agent)->owner_uid;
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
NMSecretAgent *
|
||||
nm_secret_agent_new (const char *owner, const char *identifier)
|
||||
nm_secret_agent_new (const char *owner,
|
||||
const char *identifier,
|
||||
uid_t owner_uid)
|
||||
{
|
||||
NMSecretAgent *self;
|
||||
NMSecretAgentPrivate *priv;
|
||||
|
|
@ -56,6 +88,7 @@ nm_secret_agent_new (const char *owner, const char *identifier)
|
|||
|
||||
priv->owner = g_strdup (owner);
|
||||
priv->identifier = g_strdup (identifier);
|
||||
priv->owner_uid = owner_uid;
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,14 @@ typedef struct {
|
|||
|
||||
GType nm_secret_agent_get_type (void);
|
||||
|
||||
NMSecretAgent *nm_secret_agent_new (const char *owner, const char *identifier);
|
||||
NMSecretAgent *nm_secret_agent_new (const char *owner,
|
||||
const char *identifier,
|
||||
uid_t owner_uid);
|
||||
|
||||
const char *nm_secret_agent_get_dbus_owner (NMSecretAgent *agent);
|
||||
|
||||
const char *nm_secret_agent_get_identifier (NMSecretAgent *agent);
|
||||
|
||||
uid_t nm_secret_agent_get_owner_uid (NMSecretAgent *agent);
|
||||
|
||||
#endif /* NM_SECRET_AGENT_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue