diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-08-07 15:25:36 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-01-15 15:27:04 +0100 |
commit | 71d0b9d42263272cb05a7587404e6f2d9006bdb2 (patch) | |
tree | 631617aacccee2af512f4487f3cf6e9e4b8a437a /src/shared/group-record.h | |
parent | libcrypt-util: add superficial validator for UNIX hashed password strings (diff) | |
download | systemd-71d0b9d42263272cb05a7587404e6f2d9006bdb2.tar.xz systemd-71d0b9d42263272cb05a7587404e6f2d9006bdb2.zip |
shared: add generic user/group record structures and JSON parsers
Diffstat (limited to 'src/shared/group-record.h')
-rw-r--r-- | src/shared/group-record.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/shared/group-record.h b/src/shared/group-record.h new file mode 100644 index 0000000000..b72a43e50d --- /dev/null +++ b/src/shared/group-record.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ +#pragma once + +#include "json.h" +#include "user-record.h" + +typedef struct GroupRecord { + unsigned n_ref; + UserRecordMask mask; + bool incomplete; + + char *group_name; + char *realm; + char *group_name_and_realm_auto; + + UserDisposition disposition; + uint64_t last_change_usec; + + gid_t gid; + + char **members; + + char *service; + + /* The following exist mostly so that we can cover the full /etc/gshadow set of fields, we currently + * do not actually make use of these */ + char **administrators; /* maps to 'struct sgrp' .sg_adm field */ + char **hashed_password; /* maps to 'struct sgrp' .sg_passwd field */ + + JsonVariant *json; +} GroupRecord; + +GroupRecord* group_record_new(void); +GroupRecord* group_record_ref(GroupRecord *g); +GroupRecord* group_record_unref(GroupRecord *g); + +DEFINE_TRIVIAL_CLEANUP_FUNC(GroupRecord*, group_record_unref); + +int group_record_load(GroupRecord *h, JsonVariant *v, UserRecordLoadFlags flags); +int group_record_build(GroupRecord **ret, ...); +int group_record_clone(GroupRecord *g, UserRecordLoadFlags flags, GroupRecord **ret); + +const char *group_record_group_name_and_realm(GroupRecord *h); +UserDisposition group_record_disposition(GroupRecord *h); |