summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-11-30 11:35:49 +0100
committerBenjamin Berg <benjamin@sipsolutions.net>2021-11-30 10:41:58 +0000
commit1e8b4be01e42b076ad491d522d6e98b4fd4b5e57 (patch)
treebbd2926874277d70746d399f85509fb5abdcb285 /plugins
parent95380d78c79c49cd92b36cc5b995e8a7c23ae716 (diff)
downloadgnome-settings-daemon-1e8b4be01e42b076ad491d522d6e98b4fd4b5e57.tar.gz
power: Do not print an error for failures from realpath
Doing so leaks information about whether a file/directory exists even if it is outside of the /sys/class/backlight directory. Closes: #634
Diffstat (limited to 'plugins')
-rw-r--r--plugins/power/gsd-backlight-helper.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/plugins/power/gsd-backlight-helper.c b/plugins/power/gsd-backlight-helper.c
index c370c791..f0fbbb59 100644
--- a/plugins/power/gsd-backlight-helper.c
+++ b/plugins/power/gsd-backlight-helper.c
@@ -85,13 +85,6 @@ main (int argc, char *argv[])
goto done;
}
- device = realpath (argv[1], NULL);
- if (device == NULL) {
- fprintf (stderr, "Error: Could not canonicalize given path (%d: %s)\n", errno, strerror (errno));
- result = GSD_BACKLIGHT_HELPER_EXIT_CODE_FAILED;
- goto done;
- }
-
dp = opendir ("/sys/class/backlight");
if (dp == NULL) {
fprintf (stderr, "Error: Could not open /sys/class/backlight (%d: %s)\n", errno, strerror (errno));
@@ -99,6 +92,9 @@ main (int argc, char *argv[])
goto done;
}
+ /* May be NULL if the path cannot be resolved */
+ device = realpath (argv[1], NULL);
+
while ((ep = readdir (dp))) {
char *path;
@@ -108,7 +104,7 @@ main (int argc, char *argv[])
/* Leave room for "/brightness" */
snprintf (tmp, sizeof(tmp) - 11, "/sys/class/backlight/%s", ep->d_name);
path = realpath (tmp, NULL);
- if (strcmp (path, device) == 0) {
+ if (path && device && strcmp (path, device) == 0) {
free (path);
strcat (tmp, "/brightness");