Line data Source code
1 : /*
2 : * gnome-keyring
3 : *
4 : * Copyright (C) 2010 Stefan Walter
5 : *
6 : * This program is free software; you can redistribute it and/or modify
7 : * it under the terms of the GNU Lesser General Public License as
8 : * published by the Free Software Foundation; either version 2.1 of
9 : * the License, or (at your option) any later version.
10 : *
11 : * This program is distributed in the hope that it will be useful, but
12 : * WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : * Lesser General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU Lesser General Public
17 : * License along with this program; if not, see
18 : * <http://www.gnu.org/licenses/>.
19 : */
20 :
21 : #include "config.h"
22 :
23 : #include "gkd-glue.h"
24 : #include "gkd-util.h"
25 :
26 : #include "ssh-agent/gkd-ssh-agent-service.h"
27 : #include "ssh-agent/gkd-ssh-agent-interaction.h"
28 :
29 : #include "egg/egg-cleanup.h"
30 :
31 : static void
32 0 : pkcs11_ssh_cleanup (gpointer data)
33 : {
34 0 : GkdSshAgentService *service = GKD_SSH_AGENT_SERVICE (data);
35 0 : gkd_ssh_agent_service_stop (service);
36 0 : g_object_unref (service);
37 0 : }
38 :
39 : gboolean
40 0 : gkd_daemon_startup_ssh (void)
41 : {
42 : const gchar *base_dir;
43 : GTlsInteraction *interaction;
44 : GkdSshAgentPreload *preload;
45 : GkdSshAgentService *service;
46 :
47 0 : base_dir = gkd_util_get_master_directory ();
48 0 : g_return_val_if_fail (base_dir, FALSE);
49 :
50 0 : interaction = gkd_ssh_agent_interaction_new (NULL);
51 0 : preload = gkd_ssh_agent_preload_new ("~/.ssh");
52 :
53 0 : service = gkd_ssh_agent_service_new (base_dir, interaction, preload);
54 0 : g_object_unref (interaction);
55 0 : g_object_unref (preload);
56 :
57 0 : if (!gkd_ssh_agent_service_start (service))
58 0 : return FALSE;
59 :
60 : /* ssh-agent sets the environment variable */
61 0 : gkd_util_push_environment ("SSH_AUTH_SOCK", g_getenv ("SSH_AUTH_SOCK"));
62 :
63 0 : egg_cleanup_register (pkcs11_ssh_cleanup, service);
64 :
65 0 : return TRUE;
66 : }
|