polkit.c revision 89f134406af6a4b4c7493f624a89dcd654b48e81
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include "util.h"
#include "dbus-common.h"
#include "polkit.h"
/* This mimics dbus_bus_get_unix_user() */
static pid_t get_unix_process_id(
const char *name,
"GetConnectionUnixProcessID");
if (!m) {
goto finish;
}
if (!dbus_message_append_args(
m,
goto finish;
}
if (!reply)
goto finish;
goto finish;
if (!dbus_message_get_args(
goto finish;
if (m)
if (reply)
}
int verify_polkit(
DBusConnection *c,
const char *action,
bool interactive,
bool *_challenge,
const char *unix_process = "unix-process", *pid = "pid", *starttime = "start-time", *cancel_id = "";
const char *sender;
unsigned long long starttime_raw;
int r;
assert(c);
if (!sender)
return -EINVAL;
if (pid_raw == 0)
return -EINVAL;
if (r < 0)
return r;
"org.freedesktop.PolicyKit1",
"org.freedesktop.PolicyKit1.Authority",
"CheckAuthorization");
if (!m)
return -ENOMEM;
r = -ENOMEM;
goto finish;
}
if (!reply) {
r = -EIO;
goto finish;
}
r = -EIO;
goto finish;
}
r = -EIO;
goto finish;
}
r = -EIO;
goto finish;
}
if (!dbus_message_iter_next(&iter_struct) ||
r = -EIO;
goto finish;
}
if (authorized)
r = 1;
else if (_challenge) {
*_challenge = !!challenge;
r = 0;
} else
r = -EPERM;
if (m)
if (reply)
return r;
}