summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-08-06 17:35:34 +0200
committerLennart Poettering <lennart@poettering.net>2020-08-07 08:39:18 +0200
commit0bb4308014d587354d4dbd1cc3a122f0751974b2 (patch)
treea29c30ffbb90920b720fcbc1168fedf868284336 /src/shared
parentfdc6c4f49c808baafb9bb0e01b617b4f3471f46b (diff)
downloadsystemd-0bb4308014d587354d4dbd1cc3a122f0751974b2.tar.gz
userdb: add "description" field to group records
User records have the realname/gecos fields, groups never had that, but it would really be useful to have it, hence let's add it with similar semantics. We enforce the same syntax as for GECOS, since it's better to start with strict rules and losen them later instead of the opposite.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/group-record-show.c3
-rw-r--r--src/shared/group-record.c2
-rw-r--r--src/shared/group-record.h2
-rw-r--r--src/shared/user-record.c2
-rw-r--r--src/shared/user-record.h1
5 files changed, 9 insertions, 1 deletions
diff --git a/src/shared/group-record-show.c b/src/shared/group-record-show.c
index d0300e483c..8b59f919fa 100644
--- a/src/shared/group-record-show.c
+++ b/src/shared/group-record-show.c
@@ -68,6 +68,9 @@ void group_record_show(GroupRecord *gr, bool show_full_user_info) {
}
}
+ if (gr->description && !streq(gr->description, gr->group_name))
+ printf(" Description: %s\n", gr->description);
+
if (!strv_isempty(gr->hashed_password))
printf(" Passwords: %zu\n", strv_length(gr->hashed_password));
diff --git a/src/shared/group-record.c b/src/shared/group-record.c
index 3c9520693d..d999ff95f8 100644
--- a/src/shared/group-record.c
+++ b/src/shared/group-record.c
@@ -28,6 +28,7 @@ static GroupRecord *group_record_free(GroupRecord *g) {
free(g->group_name);
free(g->realm);
free(g->group_name_and_realm_auto);
+ free(g->description);
strv_free(g->members);
free(g->service);
@@ -192,6 +193,7 @@ int group_record_load(
static const JsonDispatch group_dispatch_table[] = {
{ "groupName", JSON_VARIANT_STRING, json_dispatch_user_group_name, offsetof(GroupRecord, group_name), JSON_RELAX},
{ "realm", JSON_VARIANT_STRING, json_dispatch_realm, offsetof(GroupRecord, realm), 0 },
+ { "description", JSON_VARIANT_STRING, json_dispatch_gecos, offsetof(GroupRecord, description), 0 },
{ "disposition", JSON_VARIANT_STRING, json_dispatch_user_disposition, offsetof(GroupRecord, disposition), 0 },
{ "service", JSON_VARIANT_STRING, json_dispatch_string, offsetof(GroupRecord, service), JSON_SAFE },
{ "lastChangeUSec", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(GroupRecord, last_change_usec), 0 },
diff --git a/src/shared/group-record.h b/src/shared/group-record.h
index b72a43e50d..85c91eb1f5 100644
--- a/src/shared/group-record.h
+++ b/src/shared/group-record.h
@@ -13,6 +13,8 @@ typedef struct GroupRecord {
char *realm;
char *group_name_and_realm_auto;
+ char *description;
+
UserDisposition disposition;
uint64_t last_change_usec;
diff --git a/src/shared/user-record.c b/src/shared/user-record.c
index 16edaa45fa..801de19774 100644
--- a/src/shared/user-record.c
+++ b/src/shared/user-record.c
@@ -203,7 +203,7 @@ int json_dispatch_realm(const char *name, JsonVariant *variant, JsonDispatchFlag
return 0;
}
-static int json_dispatch_gecos(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
+int json_dispatch_gecos(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
char **s = userdata;
const char *n;
int r;
diff --git a/src/shared/user-record.h b/src/shared/user-record.h
index 1bfd095d27..39580b6b76 100644
--- a/src/shared/user-record.h
+++ b/src/shared/user-record.h
@@ -388,6 +388,7 @@ int user_record_test_password_change_required(UserRecord *h);
/* The following six are user by group-record.c, that's why we export them here */
int json_dispatch_realm(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
+int json_dispatch_gecos(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
int json_dispatch_user_group_list(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
int json_dispatch_user_disposition(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);