Skip to content
Snippets Groups Projects
Commit 5535b051 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

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
parent 3a0d4b34
Branches
Tags
No related merge requests found
...@@ -57,7 +57,7 @@ static int write_file(const char *path, const char *value) ...@@ -57,7 +57,7 @@ static int write_file(const char *path, const char *value)
{ {
int fd, ret, len; int fd, ret, len;
fd = open(path, O_WRONLY|O_CREAT, 0622); fd = open(path, O_WRONLY|O_CREAT|O_NOFOLLOW, 0600);
if (fd < 0) if (fd < 0)
return -errno; return -errno;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment