[gnome-keyring/wip/dueno/ssh-agent: 22/24] ssh-agent: refactor ssh-agent process creation
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring/wip/dueno/ssh-agent: 22/24] ssh-agent: refactor ssh-agent process creation
- Date: Mon, 12 Feb 2018 17:02:32 +0000 (UTC)
commit 359b86dd1d4bb65160e0859d6cea3ad5eacad07a
Author: Daiki Ueno <dueno src gnome org>
Date: Mon Feb 12 06:21:59 2018 +0100
ssh-agent: refactor ssh-agent process creation
daemon/ssh-agent/gkd-ssh-agent-process.c | 15 ++-------------
daemon/ssh-agent/gkd-ssh-agent-process.h | 2 +-
daemon/ssh-agent/gkd-ssh-agent.c | 19 +++++++++++++++----
3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/daemon/ssh-agent/gkd-ssh-agent-process.c b/daemon/ssh-agent/gkd-ssh-agent-process.c
index 268b87f..52ddc2e 100644
--- a/daemon/ssh-agent/gkd-ssh-agent-process.c
+++ b/daemon/ssh-agent/gkd-ssh-agent-process.c
@@ -294,18 +294,7 @@ gkd_ssh_agent_process_clear_keys (GkdSshAgentProcess *self)
}
GkdSshAgentProcess *
-gkd_ssh_agent_process_get_default (void)
+gkd_ssh_agent_process_new (const gchar *path)
{
- static volatile gsize initialized = 0;
- static GkdSshAgentProcess *instance = NULL;
-
- if (g_once_init_enter (&initialized)) {
- const gchar *directory = gkd_util_get_master_directory ();
- gchar *path = g_build_filename (directory, "ssh-agent-real", NULL);
- instance = g_object_new (GKD_TYPE_SSH_AGENT_PROCESS, "path", path, NULL);
- g_free (path);
- g_once_init_leave (&initialized, 1);
- }
-
- return instance;
+ return g_object_new (GKD_TYPE_SSH_AGENT_PROCESS, "path", path, NULL);
}
diff --git a/daemon/ssh-agent/gkd-ssh-agent-process.h b/daemon/ssh-agent/gkd-ssh-agent-process.h
index cb24fda..805b6aa 100644
--- a/daemon/ssh-agent/gkd-ssh-agent-process.h
+++ b/daemon/ssh-agent/gkd-ssh-agent-process.h
@@ -31,7 +31,7 @@
#define GKD_TYPE_SSH_AGENT_PROCESS gkd_ssh_agent_process_get_type ()
G_DECLARE_FINAL_TYPE(GkdSshAgentProcess, gkd_ssh_agent_process, GKD, SSH_AGENT_PROCESS, GObject)
-GkdSshAgentProcess *gkd_ssh_agent_process_get_default (void);
+GkdSshAgentProcess *gkd_ssh_agent_process_new (const gchar *path);
gboolean gkd_ssh_agent_process_connect (GkdSshAgentProcess *self);
gboolean gkd_ssh_agent_process_call (GkdSshAgentProcess *self,
EggBuffer *req,
diff --git a/daemon/ssh-agent/gkd-ssh-agent.c b/daemon/ssh-agent/gkd-ssh-agent.c
index bae3449..6e31bc6 100644
--- a/daemon/ssh-agent/gkd-ssh-agent.c
+++ b/daemon/ssh-agent/gkd-ssh-agent.c
@@ -46,6 +46,12 @@ typedef int socklen_t;
EGG_SECURE_DECLARE (ssh_agent);
+/* The path of the inferior ssh-agent process listening on */
+static char process_path[1024] = { 0, };
+
+/* The ssh-agent process */
+static GkdSshAgentProcess *process = NULL;
+
static gboolean
read_all (int fd, guchar *buf, int len)
{
@@ -163,9 +169,7 @@ run_client_thread (gpointer data)
call.req = &req;
call.resp = &resp;
- call.process = gkd_ssh_agent_process_get_default ();
- if (!call.process)
- goto out;
+ call.process = process;
if (!gkd_ssh_agent_process_connect (call.process))
goto out;
@@ -288,7 +292,8 @@ gkd_ssh_agent_shutdown (void)
g_list_free (socket_clients);
socket_clients = NULL;
- g_object_unref (gkd_ssh_agent_process_get_default ());
+ g_object_unref (process);
+ process = NULL;
}
int
@@ -326,5 +331,11 @@ gkd_ssh_agent_startup (const gchar *prefix)
g_setenv ("SSH_AUTH_SOCK", socket_path, TRUE);
socket_fd = sock;
+
+ snprintf (process_path, sizeof (process_path), "%s/.ssh", prefix);
+ unlink (process_path);
+
+ process = gkd_ssh_agent_process_new (process_path);
+
return sock;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]