diff options
-rw-r--r-- | src/analysis/db/server.c | 17 | ||||
-rw-r--r-- | 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)); @@ -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: |