write_file: introduce O_NOFOLLOW, use sane mask

Don't follow symlinks when writing to a file.
Don't create world-writable files.

Bug: 10802869
Change-Id: Ifb55600d574307a535df878acb3347e02028cd30
1 file changed