From a1d2b44c4316be1567b209f0b3d584207c215477 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 31 Dec 2018 18:09:17 +0100 Subject: Warned about missing local server certificates. --- src/analysis/db/server.c | 17 +++++++++++++++++ src/main.c | 12 +++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/analysis/db/server.c b/src/analysis/db/server.c index 5f6660f..deb54e9 100644 --- a/src/analysis/db/server.c +++ b/src/analysis/db/server.c @@ -277,6 +277,7 @@ GDbServer *g_db_server_new_internal(const char *author, char *kfile) GDbServer *result; /* Adresse à retourner */ bool status; /* Bilan d'un chargement */ char *working; /* Répertoire par le client */ + int ret[2]; /* Bilan d'une vérification */ result = g_object_new(G_TYPE_DB_SERVER, NULL); @@ -292,6 +293,20 @@ GDbServer *g_db_server_new_internal(const char *author, char *kfile) result->cert_file = build_absolute_filename(working, "server-cert.pem"); result->key_file = build_absolute_filename(working, "server-key.pem"); + ret[0] = access(result->cert_file, R_OK); + ret[1] = access(result->key_file, R_OK); + + if (ret[0] != 0 || ret[1] != 0) + { + log_variadic_message(LMT_ERROR, _("The serveur certificate is missing in the '%s' directory!"), working); + log_simple_message(LMT_ERROR, _("Generate it using the menu (Tool > Identity) and restart the program.")); + + free(working); + + goto gdsni_missing_pem; + + } + free(working); /* Détermination du point d'écoute */ @@ -317,6 +332,8 @@ GDbServer *g_db_server_new_internal(const char *author, char *kfile) return result; + gdsni_missing_pem: + gdsni_error: g_object_unref(G_OBJECT(result)); diff --git a/src/main.c b/src/main.c index bbd4d11..94a34f2 100644 --- a/src/main.c +++ b/src/main.c @@ -309,9 +309,9 @@ int main(int argc, char **argv) pub = get_xdg_config_dir("chrysalide" G_DIR_SEPARATOR_S "id_rsa.pub"); server = g_db_server_new_internal(author, pub); - if (server == NULL) goto no_internal_server; - g_db_server_start(server); + if (server != NULL) + g_db_server_start(server); /* Charge le dernier projet ? */ @@ -379,11 +379,13 @@ int main(int argc, char **argv) bad_project: - g_db_server_stop(server); + if (server != NULL) + { + g_db_server_stop(server); - g_object_unref(G_OBJECT(server)); + g_object_unref(G_OBJECT(server)); - no_internal_server: + } exit_complete_gui: -- cgit v0.11.2-87-g4458