Skip to content

Commit f8e35af

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 c73028a commit f8e35af

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

discourse-doctor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ clean_up_log_file() {
312312
echo "Replacing: $VAR"
313313
sed -i -e 's/'"$VAR"'\([=: ]\)\S*/'"$VAR"'\1REDACTED /g' $LOG_FILE
314314
done
315+
# allow others to read the log for convenience, now that sensitive content has been redacted
316+
chmod 0644 $LOG_FILE
315317
}
316318

317319
print_done() {
@@ -352,7 +354,7 @@ print_done() {
352354

353355
initialize_log_file() {
354356
rm -f $LOG_FILE
355-
touch $LOG_FILE
357+
install -m 0600 /dev/null $LOG_FILE
356358
log DISCOURSE DOCTOR $(date)
357359
log -e "OS: $(uname -a)\n\n"
358360
}

0 commit comments

Comments
 (0)