library: adapted to the latest lxc conventions (again)

Well, shit! With release 4.0 on March 25th the lxc/lxd
folks have stuck it to us once again. They changed the
cgroup lxc prefix used to identify the container name.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-04-14 00:00:00 -05:00 committed by Craig Small
parent 95c1fbec86
commit 8e0c33be46

View File

@ -910,15 +910,17 @@ static const char *lxc_containers (const char *path) {
1:cpuset,cpu,cpuacct,devices,freezer,net_cls,blkio,perf_event,net_prio:/lxc/lxc-P 1:cpuset,cpu,cpuacct,devices,freezer,net_cls,blkio,perf_event,net_prio:/lxc/lxc-P
*/ */
if (file2str(path, "cgroup", &ub) > 0) { if (file2str(path, "cgroup", &ub) > 0) {
/* ouch, next two defaults could be changed at lxc ./configure time /* ouch, the next defaults could be changed at lxc ./configure time
( and a changed 'lxc.cgroup.pattern' is only available to root ) */ ( and a changed 'lxc.cgroup.pattern' is only available to root ) */
static const char *lxc_delm1 = "lxc.payload/"; // with lxc-3.1.0 static const char *lxc_delm1 = "lxc.payload."; // with lxc-4.0.0
static const char *lxc_delm2 = "lxc/"; // thru lxc-3.0.3 static const char *lxc_delm2 = "lxc.payload/"; // thru lxc-3.2.1
static const char *lxc_delm3 = "lxc/"; // thru lxc-3.0.3
const char *delim; const char *delim;
char *p1; char *p1;
if ((p1 = strstr(ub.buf, (delim = lxc_delm1))) if ((p1 = strstr(ub.buf, (delim = lxc_delm1)))
|| ((p1 = strstr(ub.buf, (delim = lxc_delm2))))) { || ((p1 = strstr(ub.buf, (delim = lxc_delm2)))
|| ((p1 = strstr(ub.buf, (delim = lxc_delm3)))))) {
static struct lxc_ele { static struct lxc_ele {
struct lxc_ele *next; struct lxc_ele *next;
const char *name; const char *name;