Skip to content

Commit d89542c

Browse files
authored
Merge pull request #1784 from giuseppe/revert-chroot-realpath
Revert "chroot_realpath: do not return non-existing paths"
2 parents 073b9b8 + 7407bbc commit d89542c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libcrun/chroot_realpath.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ char *chroot_realpath(const char *chroot, const char *path, char resolved_path[]
133133
*new_path = '\0';
134134
n = readlink(got_path, link_path, PATH_MAX - 1);
135135
if (n < 0) {
136+
/* If a component doesn't exist, then return what we could translate. */
137+
if (errno == ENOENT) {
138+
sprintf (resolved_path, "%s%s%s", got_path, path[0] == '/' || path[0] == '\0' ? "" : "/", path);
139+
return resolved_path;
140+
}
136141
/* EINVAL means the file exists but isn't a symlink. */
137142
if (errno != EINVAL)
138143
return NULL;

0 commit comments

Comments
 (0)