pam-module.c revision e2acb67baaa1d63685dcaf80becf10291f13d086
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering This file is part of systemd.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering Copyright 2010 Lennart Poettering
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering systemd is free software; you can redistribute it and/or modify it
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering under the terms of the GNU Lesser General Public License as published by
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering (at your option) any later version.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering systemd is distributed in the hope that it will be useful, but
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering Lesser General Public License for more details.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering You should have received a copy of the GNU Lesser General Public License
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
#include "strv.h"
#include "dbus-common.h"
#include "def.h"
#include "socket-util.h"
#include "fileio.h"
char ***controllers,
char ***reset_controllers,
bool *kill_processes,
char ***kill_only_users,
char ***kill_exclude_users,
const char **class,
bool *debug) {
for (i = 0; i < (unsigned) argc; i++) {
if (kill_processes)
*kill_processes = k;
if (kill_processes)
*kill_processes = k;
if (controllers) {
return -ENOMEM;
*controllers = l;
if (reset_controllers) {
return -ENOMEM;
*reset_controllers = l;
if (kill_only_users) {
return -ENOMEM;
*kill_only_users = l;
if (kill_exclude_users) {
return -ENOMEM;
*kill_exclude_users = l;
if (class)
if (debug)
*debug = k;
return -EINVAL;
static int get_user_data(
const char **ret_username,
if (r != PAM_SUCCESS) {
return PAM_AUTH_ERR;
if (!pw) {
return PAM_USER_UNKNOWN;
return PAM_SUCCESS;
static bool check_user_lists(
char **kill_only_users,
char **kill_exclude_users) {
if (uid == 0)
if (pw)
uid_t u;
if (parse_uid(*l, &u) >= 0)
if (u == uid)
uid_t u;
if (parse_uid(*l, &u) >= 0)
if (u == uid)
socklen_t l;
if (fd < 0)
return -errno;
return -errno;
l = sizeof(ucred);
return -errno;
return -ENOENT;
if (seat)
int flags,
const char *username, *id, *object_path, *runtime_path, *service = NULL, *tty = NULL, *display = NULL, *remote_user = NULL, *remote_host = NULL, *seat = NULL, *type = NULL, *class = NULL, *class_pam = NULL, *cvtnr = NULL;
char **controllers = NULL, **reset_controllers = NULL, **kill_only_users = NULL, **kill_exclude_users = NULL;
if (!logind_running())
return PAM_SUCCESS;
r = PAM_SESSION_ERR;
goto finish;
if (r != PAM_SUCCESS)
goto finish;
r = PAM_BUF_ERR;
goto finish;
NULL);
free(p);
if (r < 0 && r != -ENOENT) {
r = PAM_SESSION_ERR;
goto finish;
if (rt) {
if (r != PAM_SUCCESS) {
goto finish;
r = PAM_SUCCESS;
goto finish;
if (kill_processes)
if (!bus) {
r = PAM_SESSION_ERR;
goto finish;
"/org/freedesktop/login1",
r = PAM_BUF_ERR;
goto finish;
if (!type)
if (!dbus_message_append_args(m,
r = PAM_BUF_ERR;
goto finish;
r = PAM_BUF_ERR;
goto finish;
r = PAM_BUF_ERR;
goto finish;
r = PAM_BUF_ERR;
goto finish;
if (debug)
"uid=%u pid=%u service=%s type=%s class=%s seat=%s vtnr=%u tty=%s display=%s remote=%s remote_user=%s remote_host=%s",
uid, pid, service, type, class, seat, vtnr, tty, display, yes_no(remote), remote_user, remote_host);
if (!reply) {
r = PAM_SESSION_ERR;
goto finish;
r = PAM_SESSION_ERR;
goto finish;
if (debug)
if (r != PAM_SUCCESS) {
goto finish;
if (r != PAM_SUCCESS) {
goto finish;
if (r != PAM_SUCCESS) {
goto finish;
if (vtnr > 0) {
if (r != PAM_SUCCESS) {
goto finish;
if (r != PAM_SUCCESS) {
if (session_fd >= 0) {
if (r != PAM_SUCCESS) {
r = PAM_SUCCESS;
if (bus) {
if (reply)
if (session_fd >= 0)
int flags,
const char *id;
if (!bus) {
r = PAM_SESSION_ERR;
goto finish;
"/org/freedesktop/login1",
r = PAM_BUF_ERR;
goto finish;
if (!dbus_message_append_args(m,
r = PAM_BUF_ERR;
goto finish;
if (!reply) {
r = PAM_SESSION_ERR;
goto finish;
r = PAM_SUCCESS;
if (bus) {
if (reply)