summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-31 17:09:17 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-31 17:09:17 (GMT)
commita1d2b44c4316be1567b209f0b3d584207c215477 (patch)
treee8883750f8f3514aa0f836a0ecbd00f6f4e70348 /src
parent0846c211ca24bc4e88bbc517362e1e08deb837b5 (diff)
Warned about missing local server certificates.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/db/server.c17
-rw-r--r--src/main.c12
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: