mirror of
https://github.com/systemd/systemd.git
synced 2024-11-26 19:53:45 +08:00
user-record: distinguish explicit and implicit empty modifiable lists case
We now distinguish two cases: where the list of self modifiable fields is explicitly set to empty, and where the default is empty. Let's display them differently in the output. When set explicitly to empty let's mention the admin, otherwise just say "none".
This commit is contained in:
parent
ac8e381e26
commit
ebe37f771c
@ -28,21 +28,28 @@ const char* user_record_state_color(const char *state) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dump_self_modifiable(const char *heading, char **field, const char **value) {
|
||||
static void dump_self_modifiable(
|
||||
const char *heading,
|
||||
char **field,
|
||||
const char **value) {
|
||||
|
||||
assert(heading);
|
||||
|
||||
/* Helper function for printing the various self_modifiable_* fields from the user record */
|
||||
|
||||
if (strv_isempty((char**) value))
|
||||
/* Case 1: the array is explicitly set to be empty by the administrator */
|
||||
printf("%13s %sDisabled by Administrator%s\n", heading, ansi_highlight_red(), ansi_normal());
|
||||
if (!value)
|
||||
/* Case 1: no value is set and no default either */
|
||||
printf("%13s %snone%s\n", heading, ansi_highlight(), ansi_normal());
|
||||
else if (strv_isempty((char**) value))
|
||||
/* Case 2: the array is explicitly set to empty by the administrator */
|
||||
printf("%13s %sdisabled by administrator%s\n", heading, ansi_highlight_red(), ansi_normal());
|
||||
else if (!field)
|
||||
/* Case 2: we have values, but the field is NULL. This means that we're using the defaults.
|
||||
/* Case 3: we have values, but the field is NULL. This means that we're using the defaults.
|
||||
* We list them anyways, because they're security-sensitive to the administrator */
|
||||
STRV_FOREACH(i, value)
|
||||
printf("%13s %s%s%s\n", i == value ? heading : "", ansi_grey(), *i, ansi_normal());
|
||||
else
|
||||
/* Case 3: we have a list provided by the administrator */
|
||||
/* Case 4: we have a list provided by the administrator */
|
||||
STRV_FOREACH(i, value)
|
||||
printf("%13s %s\n", i == value ? heading : "", *i);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user