[hotssh] hostdb: Also store last-used even for hosts not in ~/.ssh/known_hosts
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hotssh] hostdb: Also store last-used even for hosts not in ~/.ssh/known_hosts
- Date: Mon, 2 Dec 2013 20:37:26 +0000 (UTC)
commit 1560470a89a89e4560a5afc37bd9df95409057e0
Author: Colin Walters <walters verbum org>
Date: Mon Dec 2 15:35:39 2013 -0500
hostdb: Also store last-used even for hosts not in ~/.ssh/known_hosts
This is moving us a bit away from having ~/.ssh/known_hosts as the
canonical data set.
src/hotssh-hostdb.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/hotssh-hostdb.c b/src/hotssh-hostdb.c
index 82aaaa0..560fc8a 100644
--- a/src/hotssh-hostdb.c
+++ b/src/hotssh-hostdb.c
@@ -331,6 +331,23 @@ hostname_to_iter (HotSshHostDB *self,
}
static void
+get_or_create_host_in_db (HotSshHostDB *self,
+ const char *hostname,
+ GtkTreeIter *iter)
+{
+ G_GNUC_UNUSED HotSshHostDBPrivate *priv = hotssh_hostdb_get_instance_private (self);
+
+ if (hostname_to_iter (self, hostname, iter))
+ return;
+
+ gtk_list_store_append (priv->model, iter);
+ gtk_list_store_set (priv->model, iter,
+ HOTSSH_HOSTDB_COLUMN_HOSTNAME, hostname,
+ HOTSSH_HOSTDB_COLUMN_IS_KNOWN, FALSE,
+ -1);
+}
+
+static void
on_replace_extradb_contents_complete (GObject *src,
GAsyncResult *result,
gpointer user_data)
@@ -388,8 +405,7 @@ hotssh_hostdb_host_used (HotSshHostDB *self,
GtkTreeIter iter;
gs_free char *groupname = g_strdup_printf ("host \"%s\"", hostname);
- if (!hostname_to_iter (self, hostname, &iter))
- return;
+ get_or_create_host_in_db (self, hostname, &iter);
g_key_file_set_uint64 (priv->extradb, groupname, "last-used", g_get_real_time () / G_USEC_PER_SEC);
queue_save_extradb (self);
@@ -404,8 +420,7 @@ hotssh_hostdb_set_username (HotSshHostDB *self,
GtkTreeIter iter;
gs_free char *groupname = g_strdup_printf ("host \"%s\"", hostname);
- if (!hostname_to_iter (self, hostname, &iter))
- return;
+ get_or_create_host_in_db (self, hostname, &iter);
g_key_file_set_string (priv->extradb, groupname, "username", username);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]