bus-policy.c revision 18d703816300790b041c4fd6991e3561aa2704cb
/***
This file is part of systemd.
Copyright 2014 Daniel Mack
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdlib.h>
#include "kdbus.h"
#include "util.h"
#include "bus-kernel.h"
#include "bus-policy.h"
switch (access) {
case BUS_POLICY_ACCESS_SEE:
return KDBUS_POLICY_SEE;
case BUS_POLICY_ACCESS_TALK:
return KDBUS_POLICY_TALK;
case BUS_POLICY_ACCESS_OWN:
return KDBUS_POLICY_OWN;
default:
assert_not_reached("Unknown policy access");
}
}
int r;
case BUSNAME_POLICY_TYPE_USER: {
if (r < 0)
return r;
break;
}
case BUSNAME_POLICY_TYPE_GROUP: {
if (r < 0)
return r;
break;
}
default:
assert_not_reached("Unknown policy type");
}
return 0;
}
int fd,
const char *name,
bool activating,
bool accept_fd,
struct kdbus_cmd_hello *hello;
struct kdbus_item *n;
size_t policy_cnt = 0;
int r;
policy_cnt++;
if (world_policy >= 0)
policy_cnt++;
policy_cnt * ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
n->type = KDBUS_ITEM_NAME;
n = KDBUS_ITEM_NEXT(n);
n->type = KDBUS_ITEM_POLICY_ACCESS;
r = bus_kernel_translate_policy(po, n);
if (r < 0)
return r;
n = KDBUS_ITEM_NEXT(n);
}
if (world_policy >= 0) {
n->type = KDBUS_ITEM_POLICY_ACCESS;
}
(accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
return -errno;
/* not interested in any output values */
/* The higher 32bit of the bus_flags fields are considered
* 'incompatible flags'. Refuse them all for now. */
return -ENOTSUP;
return fd;
}
static const char* const bus_policy_access_table[_BUS_POLICY_ACCESS_MAX] = {
[BUS_POLICY_ACCESS_SEE] = "see",
[BUS_POLICY_ACCESS_TALK] = "talk",
[BUS_POLICY_ACCESS_OWN] = "own",
};