Bug#816410: "/usr/share/mdadm/mkconf generate" can erase mdadm.conf if it encounters an error
    Adam Heath 
    doogie at brainfood.com
       
    Tue Mar  1 17:12:30 UTC 2016
    
    
  
Package: mdadm
Severity: important
Version: 3.3.2-5+deb8u1
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.
    
    
More information about the pkg-mdadm-devel
mailing list