From 54d76c92868838e17d6aad0a3bb0cc7a5b11e35f Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Thu, 6 Mar 2014 22:42:42 +0100 Subject: busname: add parser for bus name policies There are three directives to specify bus name polices in .busname files: * AllowUser [username] [access] * AllowGroup [groupname] [access] * AllowWorld [access] Where [access] is one of * 'see': The user/group/world is allowed to see a name on the bus * 'talk': The user/group/world is allowed to talk to a name * 'own': The user/group/world is allowed to own a name There is no user added yet in this commit. --- src/core/busname.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/core/busname.h') diff --git a/src/core/busname.h b/src/core/busname.h index 6debd48551..f79f510ea2 100644 --- a/src/core/busname.h +++ b/src/core/busname.h @@ -22,6 +22,7 @@ ***/ typedef struct BusName BusName; +typedef struct BusNamePolicy BusNamePolicy; #include "unit.h" @@ -54,6 +55,36 @@ struct BusName { BusNameResult result; sd_event_source *event_source; + + LIST_HEAD(BusNamePolicy, policy); +}; + +typedef enum BusNamePolicyType { + BUSNAME_POLICY_TYPE_USER, + BUSNAME_POLICY_TYPE_GROUP, + BUSNAME_POLICY_TYPE_WORLD, + _BUSNAME_POLICY_TYPE_MAX, + _BUSNAME_POLICY_TYPE_INVALID = -1 +} BusNamePolicyType; + +typedef enum BusNamePolicyAccess { + BUSNAME_POLICY_ACCESS_SEE, + BUSNAME_POLICY_ACCESS_TALK, + BUSNAME_POLICY_ACCESS_OWN, + _BUSNAME_POLICY_ACCESS_MAX, + _BUSNAME_POLICY_ACCESS_INVALID = -1 +} BusNamePolicyAccess; + +struct BusNamePolicy { + BusNamePolicyType type; + BusNamePolicyAccess access; + + union { + uid_t uid; + gid_t gid; + }; + + LIST_FIELDS(BusNamePolicy, policy); }; extern const UnitVTable busname_vtable; @@ -63,3 +94,6 @@ BusNameState busname_state_from_string(const char *s) _pure_; const char* busname_result_to_string(BusNameResult i) _const_; BusNameResult busname_result_from_string(const char *s) _pure_; + +const char* busname_policy_access_to_string(BusNamePolicyAccess i) _const_; +BusNamePolicyAccess busname_policy_access_from_string(const char *s) _pure_; -- cgit v1.2.3-54-g00ecf