Hello,
I'm attaching the patch I wrote for bug #452042 , same as Debian bug #512883, i.e. incorrect exit code when files couldn't be written for "Permission denied" errors.
I put the check where the tmpfile gets created, just because I got lost while trying to understand the code where files are actually written to disk.
Hope you'll merge it.
Thank you,
David
merged, thanks!