mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 08:42:34 +01:00
Add privilegeset_extend().
This commit is contained in:
parent
9c3f080b99
commit
353f862553
2 changed files with 25 additions and 0 deletions
|
@ -40,6 +40,7 @@ struct PrivilegeSet {
|
|||
|
||||
int privilegeset_in_set(struct PrivilegeSet *set, const char *priv);
|
||||
struct PrivilegeSet *privilegeset_set_new(const char *name, const char *privs, PrivilegeFlags flags);
|
||||
struct PrivilegeSet *privilegeset_extend(struct PrivilegeSet *parent, const char *name, const char *privs, PrivilegeFlags flags);
|
||||
struct PrivilegeSet *privilegeset_get(const char *name);
|
||||
void privilegeset_ref(struct PrivilegeSet *set);
|
||||
void privilegeset_unref(struct PrivilegeSet *set);
|
||||
|
|
|
@ -40,6 +40,8 @@ privilegeset_set_new(const char *name, const char *privs, PrivilegeFlags flags)
|
|||
{
|
||||
struct PrivilegeSet *set;
|
||||
|
||||
s_assert(privilegeset_get(name) == NULL);
|
||||
|
||||
set = rb_malloc(sizeof(struct PrivilegeSet));
|
||||
set->refs = 1;
|
||||
set->name = rb_strdup(name);
|
||||
|
@ -51,6 +53,28 @@ privilegeset_set_new(const char *name, const char *privs, PrivilegeFlags flags)
|
|||
return set;
|
||||
}
|
||||
|
||||
struct PrivilegeSet *
|
||||
privilegeset_extend(struct PrivilegeSet *parent, const char *name, const char *privs, PrivilegeFlags flags)
|
||||
{
|
||||
struct PrivilegeSet *set;
|
||||
|
||||
s_assert(parent != NULL);
|
||||
s_assert(name != NULL);
|
||||
s_assert(privs != NULL);
|
||||
s_assert(privilegeset_get(name) == NULL);
|
||||
|
||||
set = rb_malloc(sizeof(struct PrivilegeSet));
|
||||
set->refs = 1;
|
||||
set->name = rb_strdup(name);
|
||||
set->flags = flags;
|
||||
set->privs = rb_malloc(strlen(parent->privs) + 1 + strlen(privs) + 1);
|
||||
strcpy(parent->privs, set->privs);
|
||||
strcat(set->privs, " ");
|
||||
strcat(set->privs, privs);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
struct PrivilegeSet *
|
||||
privilegeset_get(const char *name)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue