bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack This file is part of systemd.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack Copyright 2014 Daniel Mack
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack systemd is free software; you can redistribute it and/or modify it
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack under the terms of the GNU Lesser General Public License as published by
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack the Free Software Foundation; either version 2.1 of the License, or
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack (at your option) any later version.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack systemd is distributed in the hope that it will be useful, but
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack WITHOUT ANY WARRANTY; without even the implied warranty of
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack Lesser General Public License for more details.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack You should have received a copy of the GNU Lesser General Public License
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack along with systemd; If not, see <http://www.gnu.org/licenses/>.
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poetteringint bus_kernel_set_endpoint_policy(int fd, uid_t uid, BusEndpoint *ep) {
b2086f601b313939db160aa028e66649ba81bd01David Herrmann size = ALIGN8(offsetof(struct kdbus_cmd, items));
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering HASHMAP_FOREACH(po, ep->policy_hash, i) {
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering size += ALIGN8(offsetof(struct kdbus_item, str) + strlen(po->name) + 1);
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering size += ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering HASHMAP_FOREACH(po, ep->policy_hash, i) {
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering n->size = offsetof(struct kdbus_item, str) + strlen(po->name) + 1;
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering n->size = offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access);
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering n->policy_access.type = KDBUS_POLICY_ACCESS_USER;
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering n->policy_access.access = bus_kernel_translate_access(po->access);
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poettering r = ioctl(fd, KDBUS_CMD_ENDPOINT_UPDATE, update);
3c70e3bb022f0de3317f3600c9366a2f4597339eLennart Poetteringint bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess access) {
96f2f3b1b5f44eb59d23d2abeac12b33a18e1e21Philippe De Swert _cleanup_free_ BusEndpointPolicy *po = NULL;
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert(access > _BUS_POLICY_ACCESS_INVALID && access < _BUS_POLICY_ACCESS_MAX);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack /* check if we already have this name in the policy list. If we do, see if the new access level
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack * is higher than the exising one, and upgrade the entry in that case. Otherwise, do nothing.
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt ep->policy_hash = hashmap_new(&string_hash_ops);