summaryrefslogtreecommitdiff
path: root/src/pam-module.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-11 00:50:49 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-11 00:50:49 +0200
commitc6c18be35bb1d300d0b62a568783cc1c477f7151 (patch)
treee4bad2452f20b6d1d6df9714d6abe72cdc56599c /src/pam-module.c
parent55096547212928b0ba83fca2595cae0d66d3c0b0 (diff)
cgroup: kill processes, not tasks and other cgroup changes
Diffstat (limited to 'src/pam-module.c')
-rw-r--r--src/pam-module.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/pam-module.c b/src/pam-module.c
index 1834dd92e6..1441987fdc 100644
--- a/src/pam-module.c
+++ b/src/pam-module.c
@@ -217,17 +217,17 @@ static int create_user_group(pam_handle_t *handle, const char *group, struct pas
assert(group);
if (attach)
- r = cg_create_and_attach("name=systemd", group, 0);
+ r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, group, 0);
else
- r = cg_create("name=systemd", group);
+ r = cg_create(SYSTEMD_CGROUP_CONTROLLER, group);
if (r < 0) {
pam_syslog(handle, LOG_ERR, "Failed to create cgroup: %s", strerror(-r));
return PAM_SESSION_ERR;
}
- if ((r = cg_set_task_access("name=systemd", group, 0755, pw->pw_uid, pw->pw_gid)) < 0 ||
- (r = cg_set_group_access("name=systemd", group, 0755, pw->pw_uid, pw->pw_gid)) < 0) {
+ if ((r = cg_set_task_access(SYSTEMD_CGROUP_CONTROLLER, group, 0755, pw->pw_uid, pw->pw_gid)) < 0 ||
+ (r = cg_set_group_access(SYSTEMD_CGROUP_CONTROLLER, group, 0755, pw->pw_uid, pw->pw_gid)) < 0) {
pam_syslog(handle, LOG_ERR, "Failed to change access modes: %s", strerror(-r));
return PAM_SESSION_ERR;
}
@@ -258,8 +258,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (sd_booted() <= 0)
return PAM_SUCCESS;
- if ((r = cgroup_init()) != 0) {
- pam_syslog(handle, LOG_ERR, "libcgroup initialization failed: %s", cgroup_strerror(r));
+ if ((r = cg_init()) < 0) {
+ pam_syslog(handle, LOG_ERR, "libcgroup initialization failed: %s", strerror(-r));
r = PAM_SESSION_ERR;
goto finish;
}
@@ -361,7 +361,7 @@ static int session_remains(pam_handle_t *handle, const char *user_path) {
zero(info);
- r = cgroup_walk_tree_begin("name=systemd", user_path, 0, &iterator, &info, &level);
+ r = cgroup_walk_tree_begin(SYSTEMD_CGROUP_CONTROLLER, user_path, 0, &iterator, &info, &level);
while (r == 0) {
if (info.type != CGROUP_FILE_TYPE_DIR)
@@ -440,7 +440,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
if (kill_session) {
/* Kill processes in session cgroup */
- if ((r = cg_kill_recursive_and_wait("name=systemd", session_path)) < 0)
+ if ((r = cg_kill_recursive_and_wait(SYSTEMD_CGROUP_CONTROLLER, session_path)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to kill session cgroup: %s", strerror(-r));
} else {
@@ -450,7 +450,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
* yet. */
create_user_group(handle, nosession_path, pw, 0);
- if ((r = cg_migrate_recursive("name=systemd", session_path, nosession_path, false)) < 0)
+ if ((r = cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, session_path, nosession_path, false)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to migrate session cgroup: %s", strerror(-r));
}
@@ -458,13 +458,13 @@ _public_ PAM_EXTERN int pam_sm_close_session(
if (r < 0)
pam_syslog(handle, LOG_INFO, "Couldn't empty session cgroup, not deleting.");
else {
- if ((r = cg_delete("name=systemd", session_path)) < 0)
+ if ((r = cg_delete(SYSTEMD_CGROUP_CONTROLLER, session_path)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to delete session cgroup: %s", strerror(-r));
}
}
/* GC user tree */
- cg_trim("name=systemd", user_path, false);
+ cg_trim(SYSTEMD_CGROUP_CONTROLLER, user_path, false);
if ((r = session_remains(handle, user_path)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to determine whether a session remains: %s", strerror(-r));
@@ -473,11 +473,11 @@ _public_ PAM_EXTERN int pam_sm_close_session(
if (kill_user && r == 0) {
/* Kill no-session cgroup */
- if ((r = cg_kill_recursive_and_wait("name=systemd", user_path)) < 0)
+ if ((r = cg_kill_recursive_and_wait(SYSTEMD_CGROUP_CONTROLLER, user_path)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to kill user cgroup: %s", strerror(-r));
} else {
- if ((r = cg_is_empty_recursive("name=systemd", user_path, true)) < 0)
+ if ((r = cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, user_path, true)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to check user cgroup: %s", strerror(-r));
/* If we managed to kill somebody, don't cleanup the cgroup. */
@@ -489,7 +489,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
const char *runtime_dir;
/* Remove user cgroup */
- if ((r = cg_delete("name=systemd", user_path)) < 0)
+ if ((r = cg_delete(SYSTEMD_CGROUP_CONTROLLER, user_path)) < 0)
pam_syslog(handle, LOG_ERR, "Failed to delete user cgroup: %s", strerror(-r));
/* This will migrate us to the /user cgroup. */