if (asprintf(&procdir, "%s/proc", jail_root) < 0)
return ENOMEM;
- mkdir(procdir, 0700);
+ if (mkdir(procdir, 0700))
+ return errno;
+
if (mount("proc", procdir, "proc", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0))
return EPERM;
if (strcmp(path, "/dev")) {
DEBUG("creating directory %s\n", path);
- mkdir_p(path, 0755);
+ if (mkdir_p(path, 0755))
+ return errno;
}
*tmp = '/';
char jailetc[PATH_MAX], jaillink[PATH_MAX];
snprintf(jailetc, PATH_MAX, "%s/etc", jail_root);
- mkdir_p(jailetc, 0755);
+ if (mkdir_p(jailetc, 0755)) {
+ ERROR("mkdir(%s) failed: %m\n", jailetc);
+ return -1;
+ }
snprintf(jaillink, PATH_MAX, "%s/etc/resolv.conf", jail_root);
if (overlaydir)
unlink(jaillink);
char dirbuf[sizeof(jail_root) + 4];
snprintf(dirbuf, sizeof(dirbuf), "%s/old", jail_root);
- mkdir(dirbuf, 0755);
-
+ if (mkdir(dirbuf, 0755)) {
+ ERROR("mkdir(%s) failed: %m\n", dirbuf);
+ free_and_exit(-1);
+ }
if (pivot_root(jail_root, dirbuf) == -1) {
ERROR("pivot_root(%s, %s) failed: %m\n", jail_root, dirbuf);
free_and_exit(-1);
char hostdir[PATH_MAX];
snprintf(hostdir, PATH_MAX, "/tmp/resolv.conf-%s.d", opts.name);
- mkdir_p(hostdir, 0755);
+ if (mkdir_p(hostdir, 0755)) {
+ ERROR("mkdir(%s) failed: %m\n", hostdir);
+ free_and_exit(-1);
+ }
add_mount(hostdir, "/dev/resolv.conf.d", NULL,
MS_BIND | MS_NOEXEC | MS_NOATIME | MS_NOSUID | MS_NODEV | MS_RDONLY, 0, NULL, 0);
}