- pam_get_data(handle, "systemd.created", &created);
-
- if ((id = pam_getenv(handle, "XDG_SESSION_ID")) && created) {
-
- if (asprintf(&session_path, "/user/%s/%s", username, id) < 0 ||
- asprintf(&nosession_path, "/user/%s/master", username) < 0) {
- r = PAM_BUF_ERR;
- goto finish;
- }
-
- if (kill_session) {
- pam_syslog(handle, LOG_INFO, "Killing remaining processes of user session %s of %s.", id, username);
-
- /* Kill processes in session cgroup, and delete it */
- if ((r = cg_kill_recursive_and_wait(SYSTEMD_CGROUP_CONTROLLER, session_path, true)) < 0)
- pam_syslog(handle, LOG_ERR, "Failed to kill session cgroup: %s", strerror(-r));
- } else {
- pam_syslog(handle, LOG_INFO, "Moving remaining processes of user session %s of %s into control group %s.", id, username, nosession_path);
-
- /* Migrate processes from session to user
- * cgroup. First, try to create the user group
- * in case it doesn't exist yet. Also, delete
- * the session group. */
- create_user_group(handle, SYSTEMD_CGROUP_CONTROLLER, nosession_path, pw, false, false);
-
- if ((r = cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, session_path, nosession_path, false, true)) < 0)
- pam_syslog(handle, LOG_ERR, "Failed to migrate session cgroup: %s", strerror(-r));
- }
+ r = pam_misc_setenv(handle, "XDG_SESSION_ID", id, 0);
+ if (r != PAM_SUCCESS) {
+ pam_syslog(handle, LOG_ERR, "Failed to set session id.");
+ goto finish;
+ }