Skip to content

Commit e217d97

Browse files
committed
discourse-doctor: prevent others from reading sensitive log content
The log file is world-readable until the script finished, while sensitive settings are written to it at the very start. If the container is not running, a rebuild is done, which can leave the file with sensitive content world-readable for quite a long time. This commit makes the log file readable to root only, while the script is running, and applies default mode only after sensitive content has been reducted, for convenience and to remain a non-breaking change. An alternative would be to redact sensitive content right after it was written, in the `get_discourse_config()` function, but it would require more code and sensitive content might be printed later as well if a rebuild is done. Signed-off-by: MichaIng <micha@dietpi.com>
1 parent 0d9189d commit e217d97

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

discourse-doctor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ clean_up_log_file() {
307307
echo "Replacing: $VAR"
308308
sed -i -e 's/'"$VAR"'\([=: ]\)\S*/'"$VAR"'\1REDACTED /g' $LOG_FILE
309309
done
310+
# allow others to read the log for convenience, now that sensitive content has been redacted
311+
chmod 0644 $LOG_FILE
310312
}
311313

312314
print_done() {
@@ -348,6 +350,8 @@ print_done() {
348350
initialize_log_file() {
349351
rm -f $LOG_FILE
350352
touch $LOG_FILE
353+
# prevent others from reading sensitive content from the log
354+
chmod 0600 $LOG_FILE
351355
log DISCOURSE DOCTOR $(date)
352356
log -e "OS: $(uname -a)\n\n"
353357
}

0 commit comments

Comments
 (0)