mirror of https://github.com/proot-me/proot.git
Don't canonicalize named file descriptors that reference special objects.
Named file descriptors may reference special objects like pipes, sockets, inodes, ... Such objects do not belong to the file-system.
This commit is contained in:
parent
a8791f4e68
commit
564b2e6bdc
|
@ -412,6 +412,12 @@ int translate_path(Tracee *tracee, char result[PATH_MAX], int dir_fd,
|
|||
if (status < 0)
|
||||
return status;
|
||||
|
||||
/* Named file descriptors may reference special
|
||||
* objects like pipes, sockets, inodes, ... Such
|
||||
* objects do not belong to the file-system. */
|
||||
if (result[0] != '/')
|
||||
return -ENOTDIR;
|
||||
|
||||
/* Remove the leading "root" part of the base
|
||||
* (required!). */
|
||||
status = detranslate_path(tracee, result, NULL);
|
||||
|
|
|
@ -70,6 +70,9 @@ check-test-a3e68988.c: test-a3e68988
|
|||
@which gdb >/dev/null 2>&1 || rm -f $<
|
||||
$(call check_c,$<,$(PROOT) gdb -return-child-result -ex run -ex quit ./$<)
|
||||
|
||||
check-test-fdf487a0.c: test-fdf487a0
|
||||
$(call check_c,$<,echo test | $(PROOT) ./$<)
|
||||
|
||||
check_c = $(Q)if [ -e $< ]; then \
|
||||
$(2) $(silently); $(call check,$(1)) \
|
||||
else \
|
||||
|
@ -144,6 +147,9 @@ test-c5a7a0f0: test-c5a7a0f0.c
|
|||
test-a3e68988: test-a3e68988.c
|
||||
$(Q)$(CC) $< -o $@ $(silently) || true
|
||||
|
||||
test-fdf487a0: test-fdf487a0.c
|
||||
$(Q)$(CC) $< -o $@ $(silently) || true
|
||||
|
||||
######################################################################
|
||||
# Beautified output
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = openat(0, "foo", O_RDONLY);
|
||||
if (fd >= 0 || errno != ENOTDIR) {
|
||||
printf("1. %d %d\n", fd, (int) errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fd = openat(0, "", O_RDONLY);
|
||||
if (fd >= 0 || errno != ENOENT) {
|
||||
printf("2. %d %d\n", fd, (int) errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fd = openat(0, NULL, O_RDONLY);
|
||||
if (fd >= 0 || errno != EFAULT) {
|
||||
printf("3. %d %d\n", fd, (int) errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
Loading…
Reference in New Issue