]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/group-record-show.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 #include "format-util.h"
4 #include "group-record-show.h"
9 void group_record_show(GroupRecord
*gr
, bool show_full_user_info
) {
12 printf(" Group name: %s\n",
13 group_record_group_name_and_realm(gr
));
15 printf(" Disposition: %s\n", user_disposition_to_string(group_record_disposition(gr
)));
17 if (gr
->last_change_usec
!= USEC_INFINITY
) {
18 char buf
[FORMAT_TIMESTAMP_MAX
];
19 printf(" Last Change: %s\n", format_timestamp(buf
, sizeof(buf
), gr
->last_change_usec
));
22 if (gid_is_valid(gr
->gid
))
23 printf(" GID: " GID_FMT
"\n", gr
->gid
);
25 if (show_full_user_info
) {
26 _cleanup_(userdb_iterator_freep
) UserDBIterator
*iterator
= NULL
;
28 r
= membershipdb_by_group(gr
->group_name
, 0, &iterator
);
31 printf(" Members: (can't acquire: %m)");
33 const char *prefix
= " Members:";
36 _cleanup_free_
char *user
= NULL
;
38 r
= membershipdb_iterator_get(iterator
, &user
, NULL
);
43 printf("%s (can't iterate: %m\n", prefix
);
47 printf("%s %s\n", prefix
, user
);
52 const char *prefix
= " Members:";
55 STRV_FOREACH(i
, gr
->members
) {
56 printf("%s %s\n", prefix
, *i
);
61 if (!strv_isempty(gr
->administrators
)) {
62 const char *prefix
= " Admins:";
65 STRV_FOREACH(i
, gr
->administrators
) {
66 printf("%s %s\n", prefix
, *i
);
71 if (gr
->description
&& !streq(gr
->description
, gr
->group_name
))
72 printf(" Description: %s\n", gr
->description
);
74 if (!strv_isempty(gr
->hashed_password
))
75 printf(" Passwords: %zu\n", strv_length(gr
->hashed_password
));
78 printf(" Service: %s\n", gr
->service
);