diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-01-15 14:45:29 +0200 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-01-15 14:45:29 +0200 |
commit | fdb444e33ab2b731ae791192bac7a61a93d042f6 (patch) | |
tree | c9cfc004709d012edb3479f723af89b391366b72 | |
parent | e1f35ce84836302c9debc232d8d8e9de685a6adf (diff) |
Ensure state files are world-writable
-rw-r--r-- | brightnessctl.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/brightnessctl.c b/brightnessctl.c index 960f769..1d43a2a 100644 --- a/brightnessctl.c +++ b/brightnessctl.c @@ -400,6 +400,7 @@ int save_device_data(struct device *dev) { char *c_path = dir_child(run_dir, dev->class); char *d_path = dir_child(c_path, dev->id); FILE *fp; + mode_t old = 0; int error = 0; errno = 0; if (s <= 0) { @@ -411,7 +412,10 @@ int save_device_data(struct device *dev) { goto fail; if (!ensure_dir(c_path)) goto fail; - if (!(fp = fopen(d_path, "w"))) + old = umask(0); + fp = fopen(d_path, "w"); + umask(old); + if (!fp) goto fail; if (fwrite(c, 1, s, fp) < s) { fprintf(stderr, "Error writing to '%s'.\n", d_path); |