Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions container.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include <stdbool.h>
#include <sys/stat.h>

#define PROCD_NOAFILE_DIR "/tmp/.ujail"
#define PROCD_NOAFILE PROCD_NOAFILE_DIR "/noafile"

static inline bool is_container() {
struct stat s;
int r = stat("/.dockerenv", &s);
Expand Down
20 changes: 20 additions & 0 deletions initd/early.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ early_console(const char *dev)
fcntl(STDERR_FILENO, F_SETFL, fcntl(STDERR_FILENO, F_GETFL) | O_NONBLOCK);
}

static void
early_noafile(void)
{
int fd;

mkdir(PROCD_NOAFILE_DIR, 0000);
if (mount("tmpfs", PROCD_NOAFILE_DIR, "tmpfs",
MS_NOSUID | MS_NODEV | MS_NOEXEC, "size=4k,mode=000"))
return;

fd = creat(PROCD_NOAFILE, 0000);
if (fd >= 0)
close(fd);

if (mount(NULL, PROCD_NOAFILE_DIR, NULL,
MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NODEV | MS_NOEXEC, NULL))
ERROR("failed to lock %s read-only: %m\n", PROCD_NOAFILE_DIR);
}

static void
early_mounts(void)
{
Expand All @@ -73,6 +92,7 @@ early_mounts(void)
early_console("/dev/console");

mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOATIME, "mode=01777");
early_noafile();
mkdir("/tmp/shm", 01777);

mkdir("/tmp/run", 0755);
Expand Down
2 changes: 2 additions & 0 deletions jail/cgroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void cgroups_free(void)
free(valp);
}
free(cgroup_path);
cgroup_path = NULL;
initialized = false;
}
}

Expand Down
Loading
Loading