f3read, f3write: chroot(2) to source/target dir if allowed

This commit is contained in:
Alexander A. Klimov 2022-11-08 22:30:43 +01:00
parent d01f5cad6e
commit 2a6ac36ca7

View File

@ -29,6 +29,12 @@ void adjust_dev_path(const char **dev_path)
err(errno, "Can't change working directory to %s at %s()", *dev_path, __func__); err(errno, "Can't change working directory to %s at %s()", *dev_path, __func__);
} }
if (!chroot(*dev_path)) {
assert(!chdir("/"));
} else if (errno != EPERM) {
err(errno, "Can't change root directory to %s at %s()", *dev_path, __func__);
}
*dev_path = "."; *dev_path = ".";
} }