Blame SOURCES/0125-basic-add-fallback-in-chase_symlinks_and_opendir-for.patch
|
|
2aacef |
From 47c0c5108b39d01283ba040c41d556b160d45a55 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
2aacef |
Date: Wed, 30 Nov 2022 18:01:01 +0100
|
|
|
2aacef |
Subject: [PATCH] basic: add fallback in chase_symlinks_and_opendir() for cases
|
|
|
2aacef |
when /proc is not mounted
|
|
|
2aacef |
|
|
|
2aacef |
rhel-only
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2138081
|
|
|
2aacef |
---
|
|
|
2aacef |
src/basic/chase-symlinks.c | 14 +++++++++++---
|
|
|
2aacef |
1 file changed, 11 insertions(+), 3 deletions(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c
|
|
|
2aacef |
index afab54f067..c09aab389e 100644
|
|
|
2aacef |
--- a/src/basic/chase-symlinks.c
|
|
|
2aacef |
+++ b/src/basic/chase-symlinks.c
|
|
|
2aacef |
@@ -466,14 +466,22 @@ int chase_symlinks_and_opendir(
|
|
|
2aacef |
return 0;
|
|
|
2aacef |
}
|
|
|
2aacef |
|
|
|
2aacef |
- r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
|
|
|
2aacef |
+ r = chase_symlinks(path, root, chase_flags, &p, &path_fd);
|
|
|
2aacef |
if (r < 0)
|
|
|
2aacef |
return r;
|
|
|
2aacef |
assert(path_fd >= 0);
|
|
|
2aacef |
|
|
|
2aacef |
d = opendir(FORMAT_PROC_FD_PATH(path_fd));
|
|
|
2aacef |
- if (!d)
|
|
|
2aacef |
- return -errno;
|
|
|
2aacef |
+ if (!d) {
|
|
|
2aacef |
+ /* Hmm, we have the fd already but we got ENOENT, most likely /proc is not mounted.
|
|
|
2aacef |
+ * Let's try opendir() again on the full path. */
|
|
|
2aacef |
+ if (errno == ENOENT) {
|
|
|
2aacef |
+ d = opendir(p);
|
|
|
2aacef |
+ if (!d)
|
|
|
2aacef |
+ return -errno;
|
|
|
2aacef |
+ } else
|
|
|
2aacef |
+ return -errno;
|
|
|
2aacef |
+ }
|
|
|
2aacef |
|
|
|
2aacef |
if (ret_path)
|
|
|
2aacef |
*ret_path = TAKE_PTR(p);
|