From e4992b3e567d8aefaaa3c9e24726b723d120bfe0 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 11 Mar 2017 13:58:10 +0100 Subject: [PATCH] pam_cgfs: error out on failure in cgv2_init() Signed-off-by: Christian Brauner --- pam/pam_cgfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pam/pam_cgfs.c b/pam/pam_cgfs.c index e5818f9..fc21c45 100644 --- a/pam/pam_cgfs.c +++ b/pam/pam_cgfs.c @@ -1322,10 +1322,12 @@ static bool cgv2_init(uid_t uid, gid_t gid) char *current_cgroup = NULL, *init_cgroup = NULL; char * line = NULL; size_t len = 0; + int ret = false; current_cgroup = cgv2_get_current_cgroup(getpid()); if (!current_cgroup) { /* No v2 hierarchy present. We're done. */ + ret = true; goto cleanup; } @@ -1358,12 +1360,13 @@ static bool cgv2_init(uid_t uid, gid_t gid) cgv2_add_controller(NULL, mountpoint, current_cgroup, init_cgroup, has_user_slice); + ret = true; goto cleanup; } f = fopen("/proc/self/mountinfo", "r"); if (!f) - return false; + goto cleanup; /* we support simple cgroup mounts and lxcfs mounts */ while (getline(&line, &len, f) != -1) { @@ -1398,7 +1401,7 @@ cleanup: fclose(f); free(line); - return true; + return ret; } /* Detect and store information about mounted cgroupfs v1 hierarchies and the -- 2.39.2