mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
Access pathname relative to root of mntns
Use faccessat() in check_path_remap() to check if the file (relative to root of mnt ns) is accessible or not. Signed-off-by: Ashutosh Mehra <asmehra1@in.ibm.com>
This commit is contained in:
committed by
Andrei Vagin
parent
31f3a6a737
commit
9f176a9686
@@ -1137,6 +1137,9 @@ static int check_path_remap(struct fd_link *link, const struct fd_parms *parms,
|
||||
*/
|
||||
if (pid != 0) {
|
||||
bool is_dead = strip_deleted(link);
|
||||
mntns_root = mntns_get_root_fd(nsid);
|
||||
if (mntns_root < 0)
|
||||
return -1;
|
||||
|
||||
/* /proc/<pid> will be "/proc/1 (deleted)" when it is
|
||||
* dead, but a path like /proc/1/mountinfo won't have
|
||||
@@ -1148,7 +1151,7 @@ static int check_path_remap(struct fd_link *link, const struct fd_parms *parms,
|
||||
*/
|
||||
if (!is_dead) {
|
||||
*end = 0;
|
||||
is_dead = access(rpath, F_OK);
|
||||
is_dead = faccessat(mntns_root, rpath, F_OK, 0);
|
||||
*end = '/';
|
||||
}
|
||||
|
||||
|
@@ -209,6 +209,7 @@ TST_NOFILE := \
|
||||
unlink_multiple_largefiles \
|
||||
config_inotify_irmap \
|
||||
thp_disable \
|
||||
pid_file \
|
||||
# jobctl00 \
|
||||
|
||||
ifneq ($(SRCARCH),arm)
|
||||
|
52
test/zdtm/static/pid_file.c
Normal file
52
test/zdtm/static/pid_file.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
const char *test_doc = "Check that environment didn't change";
|
||||
const char *test_author = "Andrei Vagin <avagin@gmail.com>";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd, fd2;
|
||||
struct stat st, st2;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
fd = open("/proc/1/status", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
pr_perror("Unable to open /proc/1/status");
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
fd2 = open("/proc/1/status", O_RDONLY);
|
||||
if (fd2 < 0) {
|
||||
pr_perror("Unable to open /proc/1/status");
|
||||
return 1;
|
||||
}
|
||||
if (fstat(fd, &st)) {
|
||||
pr_perror("fstat");
|
||||
return 1;
|
||||
}
|
||||
if (fstat(fd2, &st2)) {
|
||||
pr_perror("fstat");
|
||||
return 1;
|
||||
}
|
||||
close(fd);
|
||||
close(fd2);
|
||||
|
||||
if (st.st_ino != st2.st_ino) {
|
||||
fail("inode numbers mismatch");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pass();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user