mirror of
https://github.com/systemd/systemd
synced 2026-04-21 14:34:51 +02:00
Compare commits
No commits in common. "0234f0c0531682e7f28a4ef51852c102c6e97267" and "3414394e0b978501a4b0dd9c4582a60ffce238e9" have entirely different histories.
0234f0c053
...
3414394e0b
@ -1902,7 +1902,7 @@ static int assess(const SecurityInfo *info,
|
|||||||
name = info->id;
|
name = info->id;
|
||||||
|
|
||||||
printf("\n%s %sOverall exposure level for %s%s: %s%" PRIu64 ".%" PRIu64 " %s%s %s\n",
|
printf("\n%s %sOverall exposure level for %s%s: %s%" PRIu64 ".%" PRIu64 " %s%s %s\n",
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
special_glyph(SPECIAL_GLYPH_ARROW),
|
||||||
ansi_highlight(),
|
ansi_highlight(),
|
||||||
name,
|
name,
|
||||||
ansi_normal(),
|
ansi_normal(),
|
||||||
|
|||||||
@ -41,7 +41,7 @@ static int log_unsafe_transition(int a, int b, const char *path, unsigned flags)
|
|||||||
|
|
||||||
return log_warning_errno(SYNTHETIC_ERRNO(ENOLINK),
|
return log_warning_errno(SYNTHETIC_ERRNO(ENOLINK),
|
||||||
"Detected unsafe path transition %s (owned by %s) %s %s (owned by %s) during canonicalization of %s.",
|
"Detected unsafe path transition %s (owned by %s) %s %s (owned by %s) during canonicalization of %s.",
|
||||||
strna(n1), strna(user_a), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), strna(n2), strna(user_b), path);
|
strna(n1), strna(user_a), special_glyph(SPECIAL_GLYPH_ARROW), strna(n2), strna(user_b), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int log_autofs_mount_point(int fd, const char *path, unsigned flags) {
|
static int log_autofs_mount_point(int fd, const char *path, unsigned flags) {
|
||||||
|
|||||||
@ -39,7 +39,6 @@ const char *special_glyph(SpecialGlyph code) {
|
|||||||
[SPECIAL_GLYPH_TREE_BRANCH] = "|-",
|
[SPECIAL_GLYPH_TREE_BRANCH] = "|-",
|
||||||
[SPECIAL_GLYPH_TREE_RIGHT] = "`-",
|
[SPECIAL_GLYPH_TREE_RIGHT] = "`-",
|
||||||
[SPECIAL_GLYPH_TREE_SPACE] = " ",
|
[SPECIAL_GLYPH_TREE_SPACE] = " ",
|
||||||
[SPECIAL_GLYPH_TREE_TOP] = ",-",
|
|
||||||
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = ">",
|
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = ">",
|
||||||
[SPECIAL_GLYPH_BLACK_CIRCLE] = "*",
|
[SPECIAL_GLYPH_BLACK_CIRCLE] = "*",
|
||||||
[SPECIAL_GLYPH_WHITE_CIRCLE] = "*",
|
[SPECIAL_GLYPH_WHITE_CIRCLE] = "*",
|
||||||
@ -52,9 +51,7 @@ const char *special_glyph(SpecialGlyph code) {
|
|||||||
[SPECIAL_GLYPH_LIGHT_SHADE] = "-",
|
[SPECIAL_GLYPH_LIGHT_SHADE] = "-",
|
||||||
[SPECIAL_GLYPH_DARK_SHADE] = "X",
|
[SPECIAL_GLYPH_DARK_SHADE] = "X",
|
||||||
[SPECIAL_GLYPH_SIGMA] = "S",
|
[SPECIAL_GLYPH_SIGMA] = "S",
|
||||||
[SPECIAL_GLYPH_ARROW_RIGHT] = "->",
|
[SPECIAL_GLYPH_ARROW] = "->",
|
||||||
[SPECIAL_GLYPH_ARROW_UP] = "^",
|
|
||||||
[SPECIAL_GLYPH_ARROW_DOWN] = "v",
|
|
||||||
[SPECIAL_GLYPH_ELLIPSIS] = "...",
|
[SPECIAL_GLYPH_ELLIPSIS] = "...",
|
||||||
[SPECIAL_GLYPH_EXTERNAL_LINK] = "[LNK]",
|
[SPECIAL_GLYPH_EXTERNAL_LINK] = "[LNK]",
|
||||||
[SPECIAL_GLYPH_ECSTATIC_SMILEY] = ":-]",
|
[SPECIAL_GLYPH_ECSTATIC_SMILEY] = ":-]",
|
||||||
@ -78,7 +75,6 @@ const char *special_glyph(SpecialGlyph code) {
|
|||||||
[SPECIAL_GLYPH_TREE_BRANCH] = "\342\224\234\342\224\200", /* ├─ */
|
[SPECIAL_GLYPH_TREE_BRANCH] = "\342\224\234\342\224\200", /* ├─ */
|
||||||
[SPECIAL_GLYPH_TREE_RIGHT] = "\342\224\224\342\224\200", /* └─ */
|
[SPECIAL_GLYPH_TREE_RIGHT] = "\342\224\224\342\224\200", /* └─ */
|
||||||
[SPECIAL_GLYPH_TREE_SPACE] = " ", /* */
|
[SPECIAL_GLYPH_TREE_SPACE] = " ", /* */
|
||||||
[SPECIAL_GLYPH_TREE_TOP] = "\u250C\342\224\200", /* ┌─ */
|
|
||||||
|
|
||||||
/* Single glyphs in both cases */
|
/* Single glyphs in both cases */
|
||||||
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = "\342\200\243", /* ‣ */
|
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = "\342\200\243", /* ‣ */
|
||||||
@ -93,11 +89,9 @@ const char *special_glyph(SpecialGlyph code) {
|
|||||||
[SPECIAL_GLYPH_LIGHT_SHADE] = "\342\226\221", /* ░ */
|
[SPECIAL_GLYPH_LIGHT_SHADE] = "\342\226\221", /* ░ */
|
||||||
[SPECIAL_GLYPH_DARK_SHADE] = "\342\226\223", /* ▒ */
|
[SPECIAL_GLYPH_DARK_SHADE] = "\342\226\223", /* ▒ */
|
||||||
[SPECIAL_GLYPH_SIGMA] = "\316\243", /* Σ */
|
[SPECIAL_GLYPH_SIGMA] = "\316\243", /* Σ */
|
||||||
[SPECIAL_GLYPH_ARROW_UP] = "\u2191", /* ↑ (actually called: UPWARDS ARROW) */
|
|
||||||
[SPECIAL_GLYPH_ARROW_DOWN] = "\u2193", /* ↓ (actually called: DOWNWARDS ARROW) */
|
|
||||||
|
|
||||||
/* Single glyph in Unicode, two in ASCII */
|
/* Single glyph in Unicode, two in ASCII */
|
||||||
[SPECIAL_GLYPH_ARROW_RIGHT] = "\342\206\222", /* → (actually called: RIGHTWARDS ARROW) */
|
[SPECIAL_GLYPH_ARROW] = "\342\206\222", /* → (actually called: RIGHTWARDS ARROW) */
|
||||||
|
|
||||||
/* Single glyph in Unicode, three in ASCII */
|
/* Single glyph in Unicode, three in ASCII */
|
||||||
[SPECIAL_GLYPH_ELLIPSIS] = "\342\200\246", /* … (actually called: HORIZONTAL ELLIPSIS) */
|
[SPECIAL_GLYPH_ELLIPSIS] = "\342\200\246", /* … (actually called: HORIZONTAL ELLIPSIS) */
|
||||||
|
|||||||
@ -11,7 +11,6 @@ typedef enum SpecialGlyph {
|
|||||||
SPECIAL_GLYPH_TREE_BRANCH,
|
SPECIAL_GLYPH_TREE_BRANCH,
|
||||||
SPECIAL_GLYPH_TREE_RIGHT,
|
SPECIAL_GLYPH_TREE_RIGHT,
|
||||||
SPECIAL_GLYPH_TREE_SPACE,
|
SPECIAL_GLYPH_TREE_SPACE,
|
||||||
SPECIAL_GLYPH_TREE_TOP,
|
|
||||||
SPECIAL_GLYPH_TRIANGULAR_BULLET,
|
SPECIAL_GLYPH_TRIANGULAR_BULLET,
|
||||||
SPECIAL_GLYPH_BLACK_CIRCLE,
|
SPECIAL_GLYPH_BLACK_CIRCLE,
|
||||||
SPECIAL_GLYPH_WHITE_CIRCLE,
|
SPECIAL_GLYPH_WHITE_CIRCLE,
|
||||||
@ -21,9 +20,7 @@ typedef enum SpecialGlyph {
|
|||||||
SPECIAL_GLYPH_MU,
|
SPECIAL_GLYPH_MU,
|
||||||
SPECIAL_GLYPH_CHECK_MARK,
|
SPECIAL_GLYPH_CHECK_MARK,
|
||||||
SPECIAL_GLYPH_CROSS_MARK,
|
SPECIAL_GLYPH_CROSS_MARK,
|
||||||
SPECIAL_GLYPH_ARROW_RIGHT,
|
SPECIAL_GLYPH_ARROW,
|
||||||
SPECIAL_GLYPH_ARROW_UP,
|
|
||||||
SPECIAL_GLYPH_ARROW_DOWN,
|
|
||||||
SPECIAL_GLYPH_ELLIPSIS,
|
SPECIAL_GLYPH_ELLIPSIS,
|
||||||
SPECIAL_GLYPH_LIGHT_SHADE,
|
SPECIAL_GLYPH_LIGHT_SHADE,
|
||||||
SPECIAL_GLYPH_DARK_SHADE,
|
SPECIAL_GLYPH_DARK_SHADE,
|
||||||
|
|||||||
@ -12,14 +12,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
|
|
||||||
#define HOME_UID_MIN 60001
|
|
||||||
#define HOME_UID_MAX 60513
|
|
||||||
|
|
||||||
/* Users mapped from host into a container */
|
|
||||||
#define MAP_UID_MIN 60514
|
|
||||||
#define MAP_UID_MAX 60577
|
|
||||||
|
|
||||||
bool uid_is_valid(uid_t uid);
|
bool uid_is_valid(uid_t uid);
|
||||||
|
|
||||||
static inline bool gid_is_valid(gid_t gid) {
|
static inline bool gid_is_valid(gid_t gid) {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ static int notify_override_masked(const char *top, const char *bottom) {
|
|||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight_red(), "[MASKED]", ansi_normal(),
|
ansi_highlight_red(), "[MASKED]", ansi_normal(),
|
||||||
top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
|
top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ static int notify_override_equivalent(const char *top, const char *bottom) {
|
|||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight_green(), "[EQUIVALENT]", ansi_normal(),
|
ansi_highlight_green(), "[EQUIVALENT]", ansi_normal(),
|
||||||
top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
|
top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ static int notify_override_redirected(const char *top, const char *bottom) {
|
|||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight(), "[REDIRECTED]", ansi_normal(),
|
ansi_highlight(), "[REDIRECTED]", ansi_normal(),
|
||||||
top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
|
top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ static int notify_override_overridden(const char *top, const char *bottom) {
|
|||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight(), "[OVERRIDDEN]", ansi_normal(),
|
ansi_highlight(), "[OVERRIDDEN]", ansi_normal(),
|
||||||
top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
|
top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ static int notify_override_extended(const char *top, const char *bottom) {
|
|||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight(), "[EXTENDED]", ansi_normal(),
|
ansi_highlight(), "[EXTENDED]", ansi_normal(),
|
||||||
top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
|
top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ static int enumerate_dir_d(
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
d = p + strlen(toppath) + 1;
|
d = p + strlen(toppath) + 1;
|
||||||
|
|
||||||
log_debug("Adding at top: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
|
log_debug("Adding at top: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW), p);
|
||||||
k = ordered_hashmap_put(top, d, p);
|
k = ordered_hashmap_put(top, d, p);
|
||||||
if (k >= 0) {
|
if (k >= 0) {
|
||||||
p = strdup(p);
|
p = strdup(p);
|
||||||
@ -248,7 +248,7 @@ static int enumerate_dir_d(
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("Adding at bottom: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
|
log_debug("Adding at bottom: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW), p);
|
||||||
free(ordered_hashmap_remove(bottom, d));
|
free(ordered_hashmap_remove(bottom, d));
|
||||||
k = ordered_hashmap_put(bottom, d, p);
|
k = ordered_hashmap_put(bottom, d, p);
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
@ -272,7 +272,7 @@ static int enumerate_dir_d(
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
log_debug("Adding to drops: %s %s %s %s %s",
|
log_debug("Adding to drops: %s %s %s %s %s",
|
||||||
unit, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), basename(p), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
|
unit, special_glyph(SPECIAL_GLYPH_ARROW), basename(p), special_glyph(SPECIAL_GLYPH_ARROW), p);
|
||||||
k = ordered_hashmap_put(h, basename(p), p);
|
k = ordered_hashmap_put(h, basename(p), p);
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
free(p);
|
free(p);
|
||||||
@ -349,7 +349,7 @@ static int enumerate_dir(
|
|||||||
if (!p)
|
if (!p)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
log_debug("Adding at top: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
|
log_debug("Adding at top: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW), p);
|
||||||
r = ordered_hashmap_put(top, basename(p), p);
|
r = ordered_hashmap_put(top, basename(p), p);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
p = strdup(p);
|
p = strdup(p);
|
||||||
@ -358,7 +358,7 @@ static int enumerate_dir(
|
|||||||
} else if (r != -EEXIST)
|
} else if (r != -EEXIST)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
log_debug("Adding at bottom: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
|
log_debug("Adding at bottom: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW), p);
|
||||||
free(ordered_hashmap_remove(bottom, basename(p)));
|
free(ordered_hashmap_remove(bottom, basename(p)));
|
||||||
r = ordered_hashmap_put(bottom, basename(p), p);
|
r = ordered_hashmap_put(bottom, basename(p), p);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|||||||
@ -8,6 +8,10 @@
|
|||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
#include "user-record.h"
|
#include "user-record.h"
|
||||||
|
|
||||||
|
/* See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
|
||||||
|
#define HOME_UID_MIN 60001
|
||||||
|
#define HOME_UID_MAX 60513
|
||||||
|
|
||||||
/* Put some limits on disk sizes: not less than 5M, not more than 5T */
|
/* Put some limits on disk sizes: not less than 5M, not more than 5T */
|
||||||
#define USER_DISK_SIZE_MIN (UINT64_C(5)*1024*1024)
|
#define USER_DISK_SIZE_MIN (UINT64_C(5)*1024*1024)
|
||||||
#define USER_DISK_SIZE_MAX (UINT64_C(5)*1024*1024*1024*1024)
|
#define USER_DISK_SIZE_MAX (UINT64_C(5)*1024*1024*1024*1024)
|
||||||
|
|||||||
@ -797,9 +797,6 @@ static bool address_is_in_pool(sd_dhcp_server *server, be32_t address) {
|
|||||||
if (server->pool_size == 0)
|
if (server->pool_size == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (address == server->address)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (be32toh(address) < (be32toh(server->subnet) | server->pool_offset) ||
|
if (be32toh(address) < (be32toh(server->subnet) | server->pool_offset) ||
|
||||||
be32toh(address) >= (be32toh(server->subnet) | (server->pool_offset + server->pool_size)))
|
be32toh(address) >= (be32toh(server->subnet) | (server->pool_offset + server->pool_size)))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -2058,10 +2058,10 @@ static int update_schedule_file(Manager *m) {
|
|||||||
|
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"USEC="USEC_FMT"\n"
|
"USEC="USEC_FMT"\n"
|
||||||
"WARN_WALL=%s\n"
|
"WARN_WALL=%i\n"
|
||||||
"MODE=%s\n",
|
"MODE=%s\n",
|
||||||
m->scheduled_shutdown_timeout,
|
m->scheduled_shutdown_timeout,
|
||||||
one_zero(m->enable_wall_messages),
|
m->enable_wall_messages,
|
||||||
handle_action_to_string(m->scheduled_shutdown_type->handle));
|
handle_action_to_string(m->scheduled_shutdown_type->handle));
|
||||||
|
|
||||||
if (!isempty(m->wall_message)) {
|
if (!isempty(m->wall_message)) {
|
||||||
@ -3116,7 +3116,7 @@ static int method_set_wall_message(
|
|||||||
int r;
|
int r;
|
||||||
Manager *m = userdata;
|
Manager *m = userdata;
|
||||||
char *wall_message;
|
char *wall_message;
|
||||||
int enable_wall_messages;
|
unsigned enable_wall_messages;
|
||||||
|
|
||||||
assert(message);
|
assert(message);
|
||||||
assert(m);
|
assert(m);
|
||||||
@ -3277,13 +3277,13 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
|
|||||||
static const sd_bus_vtable manager_vtable[] = {
|
static const sd_bus_vtable manager_vtable[] = {
|
||||||
SD_BUS_VTABLE_START(0),
|
SD_BUS_VTABLE_START(0),
|
||||||
|
|
||||||
SD_BUS_WRITABLE_PROPERTY("EnableWallMessages", "b", bus_property_get_bool, bus_property_set_bool, offsetof(Manager, enable_wall_messages), 0),
|
SD_BUS_WRITABLE_PROPERTY("EnableWallMessages", "b", NULL, NULL, offsetof(Manager, enable_wall_messages), 0),
|
||||||
SD_BUS_WRITABLE_PROPERTY("WallMessage", "s", NULL, NULL, offsetof(Manager, wall_message), 0),
|
SD_BUS_WRITABLE_PROPERTY("WallMessage", "s", NULL, NULL, offsetof(Manager, wall_message), 0),
|
||||||
|
|
||||||
SD_BUS_PROPERTY("NAutoVTs", "u", NULL, offsetof(Manager, n_autovts), SD_BUS_VTABLE_PROPERTY_CONST),
|
SD_BUS_PROPERTY("NAutoVTs", "u", NULL, offsetof(Manager, n_autovts), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||||
SD_BUS_PROPERTY("KillOnlyUsers", "as", NULL, offsetof(Manager, kill_only_users), SD_BUS_VTABLE_PROPERTY_CONST),
|
SD_BUS_PROPERTY("KillOnlyUsers", "as", NULL, offsetof(Manager, kill_only_users), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||||
SD_BUS_PROPERTY("KillExcludeUsers", "as", NULL, offsetof(Manager, kill_exclude_users), SD_BUS_VTABLE_PROPERTY_CONST),
|
SD_BUS_PROPERTY("KillExcludeUsers", "as", NULL, offsetof(Manager, kill_exclude_users), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||||
SD_BUS_PROPERTY("KillUserProcesses", "b", bus_property_get_bool, offsetof(Manager, kill_user_processes), SD_BUS_VTABLE_PROPERTY_CONST),
|
SD_BUS_PROPERTY("KillUserProcesses", "b", NULL, offsetof(Manager, kill_user_processes), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||||
SD_BUS_PROPERTY("RebootParameter", "s", property_get_reboot_parameter, 0, 0),
|
SD_BUS_PROPERTY("RebootParameter", "s", property_get_reboot_parameter, 0, 0),
|
||||||
SD_BUS_PROPERTY("RebootToFirmwareSetup", "b", property_get_reboot_to_firmware_setup, 0, 0),
|
SD_BUS_PROPERTY("RebootToFirmwareSetup", "b", property_get_reboot_to_firmware_setup, 0, 0),
|
||||||
SD_BUS_PROPERTY("RebootToBootLoaderMenu", "t", property_get_reboot_to_boot_loader_menu, 0, 0),
|
SD_BUS_PROPERTY("RebootToBootLoaderMenu", "t", property_get_reboot_to_boot_loader_menu, 0, 0),
|
||||||
|
|||||||
@ -87,7 +87,7 @@ struct Manager {
|
|||||||
bool unlink_nologin;
|
bool unlink_nologin;
|
||||||
|
|
||||||
char *wall_message;
|
char *wall_message;
|
||||||
bool enable_wall_messages;
|
unsigned enable_wall_messages;
|
||||||
sd_event_source *wall_message_timeout_source;
|
sd_event_source *wall_message_timeout_source;
|
||||||
|
|
||||||
bool shutdown_dry_run;
|
bool shutdown_dry_run;
|
||||||
|
|||||||
@ -10,6 +10,9 @@
|
|||||||
#include "user-util.h"
|
#include "user-util.h"
|
||||||
#include "userdb.h"
|
#include "userdb.h"
|
||||||
|
|
||||||
|
#define MAP_UID_START 60514
|
||||||
|
#define MAP_UID_END 60577
|
||||||
|
|
||||||
static int check_etc_passwd_collisions(
|
static int check_etc_passwd_collisions(
|
||||||
const char *directory,
|
const char *directory,
|
||||||
const char *name,
|
const char *name,
|
||||||
@ -154,11 +157,11 @@ static int find_free_uid(const char *directory, uid_t max_uid, uid_t *current_ui
|
|||||||
assert(current_uid);
|
assert(current_uid);
|
||||||
|
|
||||||
for (;; (*current_uid) ++) {
|
for (;; (*current_uid) ++) {
|
||||||
if (*current_uid > MAP_UID_MAX || *current_uid > max_uid)
|
if (*current_uid > MAP_UID_END || *current_uid > max_uid)
|
||||||
return log_error_errno(
|
return log_error_errno(
|
||||||
SYNTHETIC_ERRNO(EBUSY),
|
SYNTHETIC_ERRNO(EBUSY),
|
||||||
"No suitable available UID in range " UID_FMT "…" UID_FMT " in container detected, can't map user.",
|
"No suitable available UID in range " UID_FMT "…" UID_FMT " in container detected, can't map user.",
|
||||||
MAP_UID_MIN, MAP_UID_MAX);
|
MAP_UID_START, MAP_UID_END);
|
||||||
|
|
||||||
r = check_etc_passwd_collisions(directory, NULL, *current_uid);
|
r = check_etc_passwd_collisions(directory, NULL, *current_uid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -199,7 +202,7 @@ int bind_user_prepare(
|
|||||||
BindUserContext **ret) {
|
BindUserContext **ret) {
|
||||||
|
|
||||||
_cleanup_(bind_user_context_freep) BindUserContext *c = NULL;
|
_cleanup_(bind_user_context_freep) BindUserContext *c = NULL;
|
||||||
uid_t current_uid = MAP_UID_MIN;
|
uid_t current_uid = MAP_UID_START;
|
||||||
char **n;
|
char **n;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|||||||
@ -1969,9 +1969,9 @@ static int format_size_change(uint64_t from, uint64_t to, char **ret) {
|
|||||||
if (from == to || to == UINT64_MAX)
|
if (from == to || to == UINT64_MAX)
|
||||||
t = strdup(FORMAT_BYTES(from));
|
t = strdup(FORMAT_BYTES(from));
|
||||||
else
|
else
|
||||||
t = strjoin(FORMAT_BYTES(from), " ", special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), " ", FORMAT_BYTES(to));
|
t = strjoin(FORMAT_BYTES(from), " ", special_glyph(SPECIAL_GLYPH_ARROW), " ", FORMAT_BYTES(to));
|
||||||
} else if (to != UINT64_MAX)
|
} else if (to != UINT64_MAX)
|
||||||
t = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), " ", FORMAT_BYTES(to));
|
t = strjoin(special_glyph(SPECIAL_GLYPH_ARROW), " ", FORMAT_BYTES(to));
|
||||||
else {
|
else {
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -1052,14 +1052,14 @@ static int install_profile_dropin(
|
|||||||
|
|
||||||
r = copy_file_atomic(from, dropin, 0644, 0, 0, COPY_REFLINK);
|
r = copy_file_atomic(from, dropin, 0644, 0, 0, COPY_REFLINK);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_debug_errno(r, "Failed to copy %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), dropin);
|
return log_debug_errno(r, "Failed to copy %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW), dropin);
|
||||||
|
|
||||||
(void) portable_changes_add(changes, n_changes, PORTABLE_COPY, dropin, from);
|
(void) portable_changes_add(changes, n_changes, PORTABLE_COPY, dropin, from);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (symlink(from, dropin) < 0)
|
if (symlink(from, dropin) < 0)
|
||||||
return log_debug_errno(errno, "Failed to link %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), dropin);
|
return log_debug_errno(errno, "Failed to link %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW), dropin);
|
||||||
|
|
||||||
(void) portable_changes_add(changes, n_changes, PORTABLE_SYMLINK, dropin, from);
|
(void) portable_changes_add(changes, n_changes, PORTABLE_SYMLINK, dropin, from);
|
||||||
}
|
}
|
||||||
@ -1229,7 +1229,7 @@ static int install_image_symlink(
|
|||||||
(void) mkdir_parents(sl, 0755);
|
(void) mkdir_parents(sl, 0755);
|
||||||
|
|
||||||
if (symlink(image_path, sl) < 0)
|
if (symlink(image_path, sl) < 0)
|
||||||
return log_debug_errno(errno, "Failed to link %s %s %s: %m", image_path, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), sl);
|
return log_debug_errno(errno, "Failed to link %s %s %s: %m", image_path, special_glyph(SPECIAL_GLYPH_ARROW), sl);
|
||||||
|
|
||||||
(void) portable_changes_add(changes, n_changes, PORTABLE_SYMLINK, sl, image_path);
|
(void) portable_changes_add(changes, n_changes, PORTABLE_SYMLINK, sl, image_path);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -502,12 +502,12 @@ static int print_changes(sd_bus_message *m) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (streq(type, "symlink"))
|
if (streq(type, "symlink"))
|
||||||
log_info("Created symlink %s %s %s.", path, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), source);
|
log_info("Created symlink %s %s %s.", path, special_glyph(SPECIAL_GLYPH_ARROW), source);
|
||||||
else if (streq(type, "copy")) {
|
else if (streq(type, "copy")) {
|
||||||
if (isempty(source))
|
if (isempty(source))
|
||||||
log_info("Copied %s.", path);
|
log_info("Copied %s.", path);
|
||||||
else
|
else
|
||||||
log_info("Copied %s %s %s.", source, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), path);
|
log_info("Copied %s %s %s.", source, special_glyph(SPECIAL_GLYPH_ARROW), path);
|
||||||
} else if (streq(type, "unlink"))
|
} else if (streq(type, "unlink"))
|
||||||
log_info("Removed %s.", path);
|
log_info("Removed %s.", path);
|
||||||
else if (streq(type, "write"))
|
else if (streq(type, "write"))
|
||||||
|
|||||||
@ -484,7 +484,7 @@ static int vl_method_resolve_address(Varlink *link, JsonVariant *parameters, Var
|
|||||||
if (p.ifindex < 0)
|
if (p.ifindex < 0)
|
||||||
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
|
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
|
||||||
|
|
||||||
if (!IN_SET(p.family, AF_INET, AF_INET6))
|
if (!IN_SET(p.family, AF_UNSPEC, AF_INET, AF_INET6))
|
||||||
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
|
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
|
||||||
|
|
||||||
if (FAMILY_ADDRESS_SIZE(p.family) != p.address_size)
|
if (FAMILY_ADDRESS_SIZE(p.family) != p.address_size)
|
||||||
|
|||||||
@ -228,7 +228,7 @@ static int show_cgroup_name(
|
|||||||
printf("%s%s%s %s%s%s: %s\n",
|
printf("%s%s%s %s%s%s: %s\n",
|
||||||
prefix,
|
prefix,
|
||||||
glyph == SPECIAL_GLYPH_TREE_BRANCH ? special_glyph(SPECIAL_GLYPH_TREE_VERTICAL) : " ",
|
glyph == SPECIAL_GLYPH_TREE_BRANCH ? special_glyph(SPECIAL_GLYPH_TREE_VERTICAL) : " ",
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
special_glyph(SPECIAL_GLYPH_ARROW),
|
||||||
ansi_blue(), x, ansi_normal(),
|
ansi_blue(), x, ansi_normal(),
|
||||||
y);
|
y);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -336,7 +336,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
|
|||||||
if (!quiet)
|
if (!quiet)
|
||||||
log_info("Created symlink %s %s %s.",
|
log_info("Created symlink %s %s %s.",
|
||||||
changes[i].path,
|
changes[i].path,
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
special_glyph(SPECIAL_GLYPH_ARROW),
|
||||||
changes[i].source);
|
changes[i].source);
|
||||||
break;
|
break;
|
||||||
case UNIT_FILE_UNLINK:
|
case UNIT_FILE_UNLINK:
|
||||||
|
|||||||
@ -93,16 +93,13 @@ TEST(dump_special_glyphs) {
|
|||||||
dump_glyph(SPECIAL_GLYPH_TREE_BRANCH);
|
dump_glyph(SPECIAL_GLYPH_TREE_BRANCH);
|
||||||
dump_glyph(SPECIAL_GLYPH_TREE_RIGHT);
|
dump_glyph(SPECIAL_GLYPH_TREE_RIGHT);
|
||||||
dump_glyph(SPECIAL_GLYPH_TREE_SPACE);
|
dump_glyph(SPECIAL_GLYPH_TREE_SPACE);
|
||||||
dump_glyph(SPECIAL_GLYPH_TREE_TOP);
|
|
||||||
dump_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET);
|
dump_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET);
|
||||||
dump_glyph(SPECIAL_GLYPH_BLACK_CIRCLE);
|
dump_glyph(SPECIAL_GLYPH_BLACK_CIRCLE);
|
||||||
dump_glyph(SPECIAL_GLYPH_WHITE_CIRCLE);
|
dump_glyph(SPECIAL_GLYPH_WHITE_CIRCLE);
|
||||||
dump_glyph(SPECIAL_GLYPH_MULTIPLICATION_SIGN);
|
dump_glyph(SPECIAL_GLYPH_MULTIPLICATION_SIGN);
|
||||||
dump_glyph(SPECIAL_GLYPH_CIRCLE_ARROW);
|
dump_glyph(SPECIAL_GLYPH_CIRCLE_ARROW);
|
||||||
dump_glyph(SPECIAL_GLYPH_BULLET);
|
dump_glyph(SPECIAL_GLYPH_BULLET);
|
||||||
dump_glyph(SPECIAL_GLYPH_ARROW_RIGHT);
|
dump_glyph(SPECIAL_GLYPH_ARROW);
|
||||||
dump_glyph(SPECIAL_GLYPH_ARROW_UP);
|
|
||||||
dump_glyph(SPECIAL_GLYPH_ARROW_DOWN);
|
|
||||||
dump_glyph(SPECIAL_GLYPH_ELLIPSIS);
|
dump_glyph(SPECIAL_GLYPH_ELLIPSIS);
|
||||||
dump_glyph(SPECIAL_GLYPH_MU);
|
dump_glyph(SPECIAL_GLYPH_MU);
|
||||||
dump_glyph(SPECIAL_GLYPH_CHECK_MARK);
|
dump_glyph(SPECIAL_GLYPH_CHECK_MARK);
|
||||||
|
|||||||
@ -39,29 +39,6 @@ static bool arg_chain = false;
|
|||||||
|
|
||||||
STATIC_DESTRUCTOR_REGISTER(arg_services, strv_freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_services, strv_freep);
|
||||||
|
|
||||||
static const char *user_disposition_to_color(UserDisposition d) {
|
|
||||||
assert(d >= 0);
|
|
||||||
assert(d < _USER_DISPOSITION_MAX);
|
|
||||||
|
|
||||||
switch (d) {
|
|
||||||
case USER_INTRINSIC:
|
|
||||||
return ansi_red();
|
|
||||||
|
|
||||||
case USER_SYSTEM:
|
|
||||||
case USER_DYNAMIC:
|
|
||||||
return ansi_green();
|
|
||||||
|
|
||||||
case USER_CONTAINER:
|
|
||||||
return ansi_cyan();
|
|
||||||
|
|
||||||
case USER_RESERVED:
|
|
||||||
return ansi_red();
|
|
||||||
|
|
||||||
default:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int show_user(UserRecord *ur, Table *table) {
|
static int show_user(UserRecord *ur, Table *table) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -97,29 +74,23 @@ static int show_user(UserRecord *ur, Table *table) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_TABLE: {
|
case OUTPUT_TABLE:
|
||||||
UserDisposition d;
|
|
||||||
|
|
||||||
assert(table);
|
assert(table);
|
||||||
d = user_record_disposition(ur);
|
|
||||||
|
|
||||||
r = table_add_many(
|
r = table_add_many(
|
||||||
table,
|
table,
|
||||||
TABLE_STRING, "",
|
|
||||||
TABLE_STRING, ur->user_name,
|
TABLE_STRING, ur->user_name,
|
||||||
TABLE_SET_COLOR, user_disposition_to_color(d),
|
TABLE_STRING, user_disposition_to_string(user_record_disposition(ur)),
|
||||||
TABLE_STRING, user_disposition_to_string(d),
|
|
||||||
TABLE_UID, ur->uid,
|
TABLE_UID, ur->uid,
|
||||||
TABLE_GID, user_record_gid(ur),
|
TABLE_GID, user_record_gid(ur),
|
||||||
TABLE_STRING, empty_to_null(ur->real_name),
|
TABLE_STRING, empty_to_null(ur->real_name),
|
||||||
TABLE_STRING, user_record_home_directory(ur),
|
TABLE_STRING, user_record_home_directory(ur),
|
||||||
TABLE_STRING, user_record_shell(ur),
|
TABLE_STRING, user_record_shell(ur),
|
||||||
TABLE_INT, 0);
|
TABLE_INT, (int) user_record_disposition(ur));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return table_log_add_error(r);
|
return table_log_add_error(r);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
@ -128,115 +99,6 @@ static int show_user(UserRecord *ur, Table *table) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct {
|
|
||||||
uid_t first, last;
|
|
||||||
const char *name;
|
|
||||||
UserDisposition disposition;
|
|
||||||
} uid_range_table[] = {
|
|
||||||
{
|
|
||||||
.first = 1,
|
|
||||||
.last = SYSTEM_UID_MAX,
|
|
||||||
.name = "system",
|
|
||||||
.disposition = USER_SYSTEM,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.first = DYNAMIC_UID_MIN,
|
|
||||||
.last = DYNAMIC_UID_MAX,
|
|
||||||
.name = "dynamic system",
|
|
||||||
.disposition = USER_DYNAMIC,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.first = CONTAINER_UID_BASE_MIN,
|
|
||||||
.last = CONTAINER_UID_BASE_MAX,
|
|
||||||
.name = "container",
|
|
||||||
.disposition = USER_CONTAINER,
|
|
||||||
},
|
|
||||||
#if ENABLE_HOMED
|
|
||||||
{
|
|
||||||
.first = HOME_UID_MIN,
|
|
||||||
.last = HOME_UID_MAX,
|
|
||||||
.name = "systemd-homed",
|
|
||||||
.disposition = USER_REGULAR,
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
.first = MAP_UID_MIN,
|
|
||||||
.last = MAP_UID_MAX,
|
|
||||||
.name = "mapped",
|
|
||||||
.disposition = USER_REGULAR,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static int table_add_uid_boundaries(Table *table) {
|
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(table);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < ELEMENTSOF(uid_range_table); i++) {
|
|
||||||
_cleanup_free_ char *name = NULL, *comment = NULL;
|
|
||||||
|
|
||||||
name = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_DOWN),
|
|
||||||
" begin ", uid_range_table[i].name, " users ",
|
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_DOWN));
|
|
||||||
if (!name)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
comment = strjoin("First ", uid_range_table[i].name, " user");
|
|
||||||
if (!comment)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
r = table_add_many(
|
|
||||||
table,
|
|
||||||
TABLE_STRING, special_glyph(SPECIAL_GLYPH_TREE_TOP),
|
|
||||||
TABLE_STRING, name,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_STRING, user_disposition_to_string(uid_range_table[i].disposition),
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_UID, uid_range_table[i].first,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_EMPTY,
|
|
||||||
TABLE_STRING, comment,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_EMPTY,
|
|
||||||
TABLE_EMPTY,
|
|
||||||
TABLE_INT, -1); /* sort before an other entry with the same UID */
|
|
||||||
if (r < 0)
|
|
||||||
return table_log_add_error(r);
|
|
||||||
|
|
||||||
free(name);
|
|
||||||
name = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_UP),
|
|
||||||
" end ", uid_range_table[i].name, " users ",
|
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_UP));
|
|
||||||
if (!name)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
free(comment);
|
|
||||||
comment = strjoin("Last ", uid_range_table[i].name, " user");
|
|
||||||
if (!comment)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
r = table_add_many(
|
|
||||||
table,
|
|
||||||
TABLE_STRING, special_glyph(SPECIAL_GLYPH_TREE_RIGHT),
|
|
||||||
TABLE_STRING, name,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_STRING, user_disposition_to_string(uid_range_table[i].disposition),
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_UID, uid_range_table[i].last,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_EMPTY,
|
|
||||||
TABLE_STRING, comment,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_EMPTY,
|
|
||||||
TABLE_EMPTY,
|
|
||||||
TABLE_INT, 1); /* sort after an other entry with the same UID */
|
|
||||||
if (r < 0)
|
|
||||||
return table_log_add_error(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ELEMENTSOF(uid_range_table) * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int display_user(int argc, char *argv[], void *userdata) {
|
static int display_user(int argc, char *argv[], void *userdata) {
|
||||||
_cleanup_(table_unrefp) Table *table = NULL;
|
_cleanup_(table_unrefp) Table *table = NULL;
|
||||||
bool draw_separator = false;
|
bool draw_separator = false;
|
||||||
@ -246,15 +108,15 @@ static int display_user(int argc, char *argv[], void *userdata) {
|
|||||||
arg_output = argc > 1 ? OUTPUT_FRIENDLY : OUTPUT_TABLE;
|
arg_output = argc > 1 ? OUTPUT_FRIENDLY : OUTPUT_TABLE;
|
||||||
|
|
||||||
if (arg_output == OUTPUT_TABLE) {
|
if (arg_output == OUTPUT_TABLE) {
|
||||||
table = table_new(" ", "name", "disposition", "uid", "gid", "realname", "home", "shell", "order");
|
table = table_new("name", "disposition", "uid", "gid", "realname", "home", "shell", "disposition-numeric");
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
(void) table_set_align_percent(table, table_get_cell(table, 0, 2), 100);
|
||||||
(void) table_set_align_percent(table, table_get_cell(table, 0, 3), 100);
|
(void) table_set_align_percent(table, table_get_cell(table, 0, 3), 100);
|
||||||
(void) table_set_align_percent(table, table_get_cell(table, 0, 4), 100);
|
|
||||||
(void) table_set_empty_string(table, "-");
|
(void) table_set_empty_string(table, "-");
|
||||||
(void) table_set_sort(table, (size_t) 3, (size_t) 8);
|
(void) table_set_sort(table, (size_t) 7, (size_t) 2);
|
||||||
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, (size_t) 5, (size_t) 6, (size_t) 7);
|
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, (size_t) 5, (size_t) 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
@ -324,12 +186,6 @@ static int display_user(int argc, char *argv[], void *userdata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
int boundary_lines;
|
|
||||||
|
|
||||||
boundary_lines = table_add_uid_boundaries(table);
|
|
||||||
if (boundary_lines < 0)
|
|
||||||
return boundary_lines;
|
|
||||||
|
|
||||||
if (table_get_rows(table) > 1) {
|
if (table_get_rows(table) > 1) {
|
||||||
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
|
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -338,7 +194,7 @@ static int display_user(int argc, char *argv[], void *userdata) {
|
|||||||
|
|
||||||
if (arg_legend) {
|
if (arg_legend) {
|
||||||
if (table_get_rows(table) > 1)
|
if (table_get_rows(table) > 1)
|
||||||
printf("\n%zu users listed.\n", table_get_rows(table) - 1 - boundary_lines);
|
printf("\n%zu users listed.\n", table_get_rows(table) - 1);
|
||||||
else
|
else
|
||||||
printf("No users.\n");
|
printf("No users.\n");
|
||||||
}
|
}
|
||||||
@ -385,26 +241,20 @@ static int show_group(GroupRecord *gr, Table *table) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_TABLE: {
|
case OUTPUT_TABLE:
|
||||||
UserDisposition d;
|
|
||||||
|
|
||||||
assert(table);
|
assert(table);
|
||||||
d = group_record_disposition(gr);
|
|
||||||
|
|
||||||
r = table_add_many(
|
r = table_add_many(
|
||||||
table,
|
table,
|
||||||
TABLE_STRING, "",
|
|
||||||
TABLE_STRING, gr->group_name,
|
TABLE_STRING, gr->group_name,
|
||||||
TABLE_SET_COLOR, user_disposition_to_color(d),
|
TABLE_STRING, user_disposition_to_string(group_record_disposition(gr)),
|
||||||
TABLE_STRING, user_disposition_to_string(d),
|
|
||||||
TABLE_GID, gr->gid,
|
TABLE_GID, gr->gid,
|
||||||
TABLE_STRING, gr->description,
|
TABLE_STRING, gr->description,
|
||||||
TABLE_INT, 0);
|
TABLE_INT, (int) group_record_disposition(gr));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return table_log_add_error(r);
|
return table_log_add_error(r);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
@ -413,69 +263,6 @@ static int show_group(GroupRecord *gr, Table *table) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int table_add_gid_boundaries(Table *table) {
|
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(table);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < ELEMENTSOF(uid_range_table); i++) {
|
|
||||||
_cleanup_free_ char *name = NULL, *comment = NULL;
|
|
||||||
|
|
||||||
name = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_DOWN),
|
|
||||||
" begin ", uid_range_table[i].name, " groups ",
|
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_DOWN));
|
|
||||||
if (!name)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
comment = strjoin("First ", uid_range_table[i].name, " group");
|
|
||||||
if (!comment)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
r = table_add_many(
|
|
||||||
table,
|
|
||||||
TABLE_STRING, special_glyph(SPECIAL_GLYPH_TREE_TOP),
|
|
||||||
TABLE_STRING, name,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_STRING, user_disposition_to_string(uid_range_table[i].disposition),
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_GID, uid_range_table[i].first,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_STRING, comment,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_INT, -1); /* sort before an other entry with the same GID */
|
|
||||||
if (r < 0)
|
|
||||||
return table_log_add_error(r);
|
|
||||||
|
|
||||||
free(name);
|
|
||||||
name = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_UP),
|
|
||||||
" end ", uid_range_table[i].name, " groups ",
|
|
||||||
special_glyph(SPECIAL_GLYPH_ARROW_UP));
|
|
||||||
if (!name)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
free(comment);
|
|
||||||
comment = strjoin("Last ", uid_range_table[i].name, " group");
|
|
||||||
if (!comment)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
r = table_add_many(
|
|
||||||
table,
|
|
||||||
TABLE_STRING, special_glyph(SPECIAL_GLYPH_TREE_RIGHT),
|
|
||||||
TABLE_STRING, name,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_STRING, user_disposition_to_string(uid_range_table[i].disposition),
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_GID, uid_range_table[i].last,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_STRING, comment,
|
|
||||||
TABLE_SET_COLOR, ansi_grey(),
|
|
||||||
TABLE_INT, 1); /* sort after an other entry with the same GID */
|
|
||||||
if (r < 0)
|
|
||||||
return table_log_add_error(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ELEMENTSOF(uid_range_table) * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int display_group(int argc, char *argv[], void *userdata) {
|
static int display_group(int argc, char *argv[], void *userdata) {
|
||||||
_cleanup_(table_unrefp) Table *table = NULL;
|
_cleanup_(table_unrefp) Table *table = NULL;
|
||||||
@ -486,14 +273,14 @@ static int display_group(int argc, char *argv[], void *userdata) {
|
|||||||
arg_output = argc > 1 ? OUTPUT_FRIENDLY : OUTPUT_TABLE;
|
arg_output = argc > 1 ? OUTPUT_FRIENDLY : OUTPUT_TABLE;
|
||||||
|
|
||||||
if (arg_output == OUTPUT_TABLE) {
|
if (arg_output == OUTPUT_TABLE) {
|
||||||
table = table_new(" ", "name", "disposition", "gid", "description", "order");
|
table = table_new("name", "disposition", "gid", "description", "disposition-numeric");
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
(void) table_set_align_percent(table, table_get_cell(table, 0, 3), 100);
|
(void) table_set_align_percent(table, table_get_cell(table, 0, 2), 100);
|
||||||
(void) table_set_empty_string(table, "-");
|
(void) table_set_empty_string(table, "-");
|
||||||
(void) table_set_sort(table, (size_t) 3, (size_t) 5);
|
(void) table_set_sort(table, (size_t) 3, (size_t) 2);
|
||||||
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4);
|
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
@ -564,12 +351,6 @@ static int display_group(int argc, char *argv[], void *userdata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
int boundary_lines;
|
|
||||||
|
|
||||||
boundary_lines = table_add_gid_boundaries(table);
|
|
||||||
if (boundary_lines < 0)
|
|
||||||
return boundary_lines;
|
|
||||||
|
|
||||||
if (table_get_rows(table) > 1) {
|
if (table_get_rows(table) > 1) {
|
||||||
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
|
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -578,7 +359,7 @@ static int display_group(int argc, char *argv[], void *userdata) {
|
|||||||
|
|
||||||
if (arg_legend) {
|
if (arg_legend) {
|
||||||
if (table_get_rows(table) > 1)
|
if (table_get_rows(table) > 1)
|
||||||
printf("\n%zu groups listed.\n", table_get_rows(table) - 1 - boundary_lines);
|
printf("\n%zu groups listed.\n", table_get_rows(table) - 1);
|
||||||
else
|
else
|
||||||
printf("No groups.\n");
|
printf("No groups.\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user