bus-policy.c revision 524d896ac17518b824b2c94b3b0b2a23c23da08f
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers This file is part of systemd.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers Copyright 2014 Daniel Mack
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers systemd is free software; you can redistribute it and/or modify it
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers under the terms of the GNU Lesser General Public License as published by
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers the Free Software Foundation; either version 2.1 of the License, or
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers (at your option) any later version.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers systemd is distributed in the hope that it will be useful, but
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers Lesser General Public License for more details.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers You should have received a copy of the GNU Lesser General Public License
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sieversint bus_kernel_translate_access(BusPolicyAccess access) {
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sieversint bus_kernel_translate_policy(const BusNamePolicy *policy, struct kdbus_item *item) {
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers r = get_user_creds(&user, &uid, NULL, NULL, NULL);
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers item->policy_access.type = KDBUS_POLICY_ACCESS_USER;
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers item->policy_access.type = KDBUS_POLICY_ACCESS_GROUP;
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers item->policy_access.access = bus_kernel_translate_access(policy->access);
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers const char *name,
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers struct kdbus_cmd_free cmd_free = { .size = sizeof(cmd_free) };
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers size = offsetof(struct kdbus_cmd_hello, items) +
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers ALIGN8(offsetof(struct kdbus_item, str) + strlen(name) + 1) +
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers policy_cnt * ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers n->size = offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access);
de892aea1c486b59e04884268b612081d1660514Kay Sievers n->size = offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access);
3c123e0899b56c0587db36420da5e049c56d9e19Lukas Nykryn n->policy_access.type = KDBUS_POLICY_ACCESS_WORLD;
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers n->policy_access.access = bus_kernel_translate_access(world_policy);
de892aea1c486b59e04884268b612081d1660514Kay Sievers (activating ? KDBUS_HELLO_ACTIVATOR : KDBUS_HELLO_POLICY_HOLDER) |
de892aea1c486b59e04884268b612081d1660514Kay Sievers /* not interested in any output values */
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers /* The higher 32bit of the bus_flags fields are considered
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * 'incompatible flags'. Refuse them all for now. */
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sieversstatic const char* const bus_policy_access_table[_BUS_POLICY_ACCESS_MAX] = {