From 544e146b0e2f6227e28476e36becd1019b14ef70 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 12 May 2020 23:36:27 +0200 Subject: journalctl,elsewhere: make sure --file=foo fails with sane error msg if foo is not readable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It annoyed me for quite a while that running "journalctl --file=…" on a file that is not readable failed with a "File not found" error instead of a permission error. Let's fix that. We make this work by using the GLOB_NOCHECK flag for glob() which means that files are not accessible will be returned in the array as they are instead of being filtered away. This then means that our later attemps to open the files will fail cleanly with a good error message. --- src/sysctl/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sysctl') diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 3b3305d7f6..5274cd24b3 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -138,7 +138,7 @@ static int apply_all(OrderedHashmap *sysctl_options) { if (!pattern) return log_oom(); - k = glob_extend(&paths, pattern); + k = glob_extend(&paths, pattern, GLOB_NOCHECK); if (k < 0) { if (option->ignore_failure || ERRNO_IS_PRIVILEGE(k)) log_debug_errno(k, "Failed to resolve glob '%s', ignoring: %m", -- cgit v1.2.1