about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-10-16 10:43:56 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-10-16 10:45:41 +0200
commit46f0304f898f7f7a27b2cf8aedf30b85d22fb75c (patch)
tree0b41c1bb3719fc5b45b28b2a8a4129fcacd85fe0
parentf9eb302a5965312713a1bd388904a26e7dadadb0 (diff)
downloadprofani-tty-46f0304f898f7f7a27b2cf8aedf30b85d22fb75c.tar.gz
Use random string for random-bytes identifier
And rename `instance` to `identifier`.

Regards https://github.com/profanity-im/profanity/issues/1207
-rw-r--r--src/xmpp/connection.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 5632f51d..2d2e5773 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -49,6 +49,7 @@
 #include <strophe.h>
 #endif
 
+#include "common.h"
 #include "log.h"
 #include "config/files.h"
 #include "config/preferences.h"
@@ -632,11 +633,11 @@ static void _random_bytes_init()
     rndbytes = g_key_file_new();
     g_key_file_load_from_file(rndbytes, rndbytes_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
 
-    if (g_key_file_has_group(rndbytes, "instance")) {
-        random_bytes = g_key_file_get_string(rndbytes, "instance", "random_bytes", NULL);
+    if (g_key_file_has_group(rndbytes, "identifier")) {
+        random_bytes = g_key_file_get_string(rndbytes, "identifier", "random_bytes", NULL);
     } else {
-        random_bytes = g_strdup("ASDF");
-        g_key_file_set_string(rndbytes, "instance", "random_bytes", random_bytes);
+        random_bytes = get_random_string(10);
+        g_key_file_set_string(rndbytes, "identifier", "random_bytes", random_bytes);
 
         gsize g_data_size;
         gchar *g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL);