#816410 "/usr/share/mdadm/mkconf generate" can erase mdadm.conf if it encounters an error

Package:
mdadm
Source:
mdadm
Description:
Tool to administer Linux MD arrays (software RAID)
Submitter:
Adam Heath
Date:
2023-03-01 07:39:16 UTC
Severity:
important
#816410#5
Date:
2016-03-01 17:12:30 UTC
From:
To:
If you pass 'generate' to the mkconf script, it attempts to parse some
existing values out of the file, then does an "exec >$CONFIG".  At this
point, the output file has been removed, and is effectively 0 bytes in
size.  All the existing content is gone.

Later on, if there is an error, the script might abort writing the full
file out; this is because set -e is in place.

Please write to a temp file, and do an atomic move at the very end.