We used to do chdir(path), chroot(path). That's correct but not properly
handled coverity, so do chroot(path), chdir("/") instead as that's the
recommended way.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
SYSERROR("Failed to make tmp-/ at %s rslave", path);
return -1;
}
- if (chdir(path)) {
- SYSERROR("Failed to chdir into tmp-/");
- return -1;
- }
if (chroot(path)) {
SYSERROR("Failed to chroot into tmp-/");
return -1;
}
+ if (chdir("/")) {
+ SYSERROR("Failed to chdir into tmp-/");
+ return -1;
+ }
INFO("Chrooted into tmp-/ at %s", path);
return 0;
}
if (ret < 0 || ret >= MAXPATHLEN)
return false;
- if (chdir(chrootpath) < 0)
+ if (chroot(chrootpath) < 0)
exit(1);
- if (chroot(".") < 0)
+ if (chdir("/") < 0)
exit(1);
/* remove path if it exists */
if(faccessat(AT_FDCWD, path, F_OK, AT_SYMLINK_NOFOLLOW) == 0) {