Remmina - The GTK+ Remote Desktop Client  v1.4.2
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
kwallet_plugin_main.c
Go to the documentation of this file.
1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2016-2020 Antenore Gatta & Giovanni Panozzo
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give
21  * permission to link the code of portions of this program with the
22  * OpenSSL library under certain conditions as described in each
23  * individual source file, and distribute linked combinations
24  * including the two.
25  * You must obey the GNU General Public License in all respects
26  * for all of the code used other than OpenSSL.
27  * If you modify file(s) with this exception, you may extend this exception
28  * to your version of the file(s), but you are not obligated to do so.
29  * If you do not wish to do so, delete this exception statement from your
30  * version.
31  * If you delete this exception statement from all source
32  * files in the program, then also delete it here.
33  *
34  */
35 
36 #include "config.h"
37 #include <gtk/gtk.h>
38 #include <glib.h>
39 #include <glib/gi18n-lib.h>
40 #include <glib/gstdio.h>
41 #include <remmina/plugin.h>
42 
43 #include "kwallet_plugin.h"
44 
46 
48 {
50 }
51 
52 
53 static gchar *build_kwallet_key(RemminaFile *remminafile, const gchar *key)
54 {
55  const gchar *path;
56  gchar *kwkey;
57  size_t kwkey_sz;
58 
59  path = remmina_plugin_service->file_get_path(remminafile);
60 
61  kwkey_sz = strlen(key) + 1 + strlen(path) + 1;
62  kwkey = g_malloc(kwkey_sz);
63 
64  strcpy(kwkey, key);
65  strcat(kwkey, ";");
66  strcat(kwkey, path);
67 
68  return kwkey;
69 }
70 
71 void remmina_plugin_kwallet_store_password(RemminaFile *remminafile, const gchar *key, const gchar *password)
72 {
73  TRACE_CALL(__func__);
74  gchar *kwkey;
75  kwkey = build_kwallet_key(remminafile, key);
76  rp_kwallet_store_password(kwkey, password);
77  g_free(kwkey);
78 }
79 
80 gchar*
81 remmina_plugin_kwallet_get_password(RemminaFile *remminafile, const gchar *key)
82 {
83  TRACE_CALL(__func__);
84  gchar *kwkey, *password;
85 
86  kwkey = build_kwallet_key(remminafile, key);
87  password = rp_kwallet_get_password(kwkey);
88  g_free(kwkey);
89 
90  return password;
91 }
92 
93 void remmina_plugin_kwallet_delete_password(RemminaFile *remminafile, const gchar *key)
94 {
95  TRACE_CALL(__func__);
96  gchar *kwkey;
97  kwkey = build_kwallet_key(remminafile, key);
99  g_free(kwkey);
100 }
101 
103 {
104  /* Activates only when KDE is running */
105  const gchar *envvar;
106 
107  envvar = g_environ_getenv(g_get_environ(), "XDG_CURRENT_DESKTOP");
108  if (!envvar || strcmp(envvar, "KDE") != 0)
109  return FALSE;
110 
111  return rp_kwallet_init();
112 
113 }
114 
117  "kwallet",
118  N_("Secured password storage in KWallet"),
119  NULL,
120  VERSION,
121  1000,
127 };
128 
129 G_MODULE_EXPORT gboolean
131 {
132  TRACE_CALL(__func__);
133 
134  /* This function should only register the secret plugin. No init action
135  * should be performed here. Initialization will be done later
136  * with remmina_plugin_xxx_init() . */
137 
138  remmina_plugin_service = service;
139  if (!service->register_plugin((RemminaPlugin*)&remmina_plugin_kwallet)) {
140  return FALSE;
141  }
142 
143  return TRUE;
144 
145 }
146 
static RemminaPluginService * remmina_plugin_service
gboolean remmina_plugin_kwallet_init()
int rp_kwallet_is_service_available(void)
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
Definition: types.h:41
static gchar * build_kwallet_key(RemminaFile *remminafile, const gchar *key)
gboolean remmina_plugin_kwallet_is_service_available()
G_MODULE_EXPORT gboolean remmina_plugin_entry(RemminaPluginService *service)
static RemminaSecretPlugin remmina_plugin_kwallet
gboolean(* register_plugin)(RemminaPlugin *plugin)
Definition: plugin.h:148
void remmina_plugin_kwallet_store_password(RemminaFile *remminafile, const gchar *key, const gchar *password)
const gchar *(* file_get_path)(RemminaFile *remminafile)
Definition: plugin.h:198
gchar * remmina_plugin_kwallet_get_password(RemminaFile *remminafile, const gchar *key)
void rp_kwallet_store_password(const char *key, const char *password)
void rp_kwallet_delete_password(const char *key)
void remmina_plugin_kwallet_delete_password(RemminaFile *remminafile, const gchar *key)
char * rp_kwallet_get_password(const char *key)
N_("Unable to connect to VNC server")
Definition: vnc_plugin.c:907
int rp_kwallet_init(void)