Skip to content

Commit

Permalink
cgroup,setup: make CGROUP_PATH optional
Browse files Browse the repository at this point in the history
Some users of bst are still stuck on cgroups v1, and 588d370
("cgroup,setup: set CGROUP_PATH in setup program with full path to
current cgroup") broke the basic, non-cgroup use of bst.

This commit makes the failure to determine the current cgroup path
non-fatal; the setup program has the responsibility to fail if it needs
it.
  • Loading branch information
Snaipe committed Oct 30, 2023
1 parent b65ff75 commit a68886f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ int enter(struct entry_settings *opts)
to get the real path to the cgroup */
char cgroup_path[PATH_MAX];
if (!cgroup_read_current(cgroup_path)) {
errx(1, "could not determine current cgroup; are you using cgroups v2?");
cgroup_path[0] = '\0';
}
ns_enter_postfork(namespaces, ns_len);

Expand Down Expand Up @@ -486,7 +486,9 @@ int enter(struct entry_settings *opts)
/* Set some extra useful environment */
setenv("ROOT", root, 1);
setenv("EXECUTABLE", opts->pathname, 1);
setenv("CGROUP_PATH", cgroup_path, 1);
if (cgroup_path[0] != '\0') {
setenv("CGROUP_PATH", cgroup_path, 1);
}

extern char **environ;

Expand Down
4 changes: 3 additions & 1 deletion man/bst.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,9 @@ The following environment variables are accessible to the setup program:
Set to the executable name that will be executed after the setup is done.

*CGROUP_PATH*
Set to the path of the cgroup of the process that will be executed.
Set to the path of the cgroup of the process that will be executed. Can
be missing if bst could not determine the cgroup path (e.g. only cgroups v1
are available, or /proc isn't mounted)

# NETWORKING

Expand Down

0 comments on commit a68886f

Please sign in to comment.