aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-07-28 21:00:30 +0200
committerFlorian Dold <florian@dold.me>2021-07-28 21:00:30 +0200
commit3012383a1682c3bda9da12c15bfa7c0c384bc757 (patch)
treea3acda3b9777a6290c5270680206149c51f2b454 /src/util/configuration.c
parent346706b1857dd9ec129cf40897468133f3c6bdd3 (diff)
downloadgnunet-3012383a1682c3bda9da12c15bfa7c0c384bc757.tar.gz
gnunet-3012383a1682c3bda9da12c15bfa7c0c384bc757.zip
config: report stats for secret sections
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index cc71a239d..016088eee 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -97,11 +97,16 @@ struct ConfigSection
97 bool inaccessible; 97 bool inaccessible;
98 98
99 /** 99 /**
100 * Diagnostics hint for the inaccessible file. 100 * Diagnostics hint for the secret file.
101 */ 101 */
102 char *hint_secret_filename; 102 char *hint_secret_filename;
103 103
104 /** 104 /**
105 * Extra information regarding permissions of the secret file.
106 */
107 char *hint_secret_stat;
108
109 /**
105 * For secret sections: Where was this inlined from? 110 * For secret sections: Where was this inlined from?
106 */ 111 */
107 char *hint_inlined_from_filename; 112 char *hint_inlined_from_filename;
@@ -498,8 +503,27 @@ handle_inline (struct GNUNET_CONFIGURATION_Handle *cfg,
498 } 503 }
499 if (cfg->diagnostics) 504 if (cfg->diagnostics)
500 { 505 {
501 if (NULL != inline_path) 506 char *sfn = GNUNET_STRINGS_filename_expand (inline_path);
502 cs->hint_secret_filename = GNUNET_strdup (inline_path); 507 struct stat istat;
508
509 cs->hint_secret_filename = sfn;
510 if (0 == stat (sfn, &istat))
511 {
512 struct passwd *pw = getpwuid (istat.st_uid);
513 struct group *gr = getgrgid (istat.st_gid);
514 char *pwname = (NULL == pw) ? "<unknown>" : pw->pw_name;
515 char *grname = (NULL == gr) ? "<unknown>" : gr->gr_name;
516
517 GNUNET_asprintf (&cs->hint_secret_stat,
518 "%s:%s %o",
519 pwname,
520 grname,
521 istat.st_mode);
522 }
523 else
524 {
525 cs->hint_secret_stat = GNUNET_strdup ("<can't stat file>");
526 }
503 if (source_filename) 527 if (source_filename)
504 { 528 {
505 cs->hint_inlined_from_filename = GNUNET_strdup (source_filename); 529 cs->hint_inlined_from_filename = GNUNET_strdup (source_filename);
@@ -1159,8 +1183,9 @@ GNUNET_CONFIGURATION_serialize_diagnostics (const struct
1159 { 1183 {
1160 if (sec->hint_secret_filename) 1184 if (sec->hint_secret_filename)
1161 GNUNET_buffer_write_fstr (&buf, 1185 GNUNET_buffer_write_fstr (&buf,
1162 "# secret section from %s\n", 1186 "# secret section from %s\n# secret file stat %s\n",
1163 sec->hint_secret_filename); 1187 sec->hint_secret_filename,
1188 sec->hint_secret_stat);
1164 if (sec->hint_inlined_from_filename) 1189 if (sec->hint_inlined_from_filename)
1165 { 1190 {
1166 GNUNET_buffer_write_fstr (&buf, 1191 GNUNET_buffer_write_fstr (&buf,
@@ -1371,6 +1396,7 @@ GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg,
1371 } 1396 }
1372 GNUNET_free (spos->name); 1397 GNUNET_free (spos->name);
1373 GNUNET_free (spos->hint_secret_filename); 1398 GNUNET_free (spos->hint_secret_filename);
1399 GNUNET_free (spos->hint_secret_stat);
1374 GNUNET_free (spos->hint_inlined_from_filename); 1400 GNUNET_free (spos->hint_inlined_from_filename);
1375 GNUNET_free (spos); 1401 GNUNET_free (spos);
1376 return; 1402 return;