Comment 30 for bug 439784

Revision history for this message
Jordan (jordanu) wrote : Re: invalid: environment block

Looking at grub-editenv.c, as Colin said, it does call fsync explicitly so my theory was wrong.

However, it looks like grub-editenv is still not atomic: If you run "grub-editenv /boot/grub/grubenv set foo=bar" the first thing it does in create_env_blk_file() is call fopen( "/boot/grub/grubenv", "wb" ) truncating the actual file, not a temporary version. So if grub-editenv crashes between the fopen() and the fwrite() ( admittedly only two real lines of code ) or somehow fopen() succeeds but fwrite() fails, you will be left with a zero byte file.

Is there a reason why grub-editenv doesn't write to a temporary file? Would grub-editenv calling grub_util_error() or otherwise crashing trigger apport?