From fdb444e33ab2b731ae791192bac7a61a93d042f6 Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Sun, 15 Jan 2017 14:45:29 +0200 Subject: Ensure state files are world-writable --- brightnessctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'brightnessctl.c') 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); -- cgit v1.2.3