#include "user-util.h"
#include "userdb.h"
#include "verbs.h"
+#include "virt.h"
static enum {
OUTPUT_CLASSIC,
return 0;
}
+static bool test_show_mapped(void) {
+ /* Show mapped user range only in environments where user mapping is a thing. */
+ return running_in_userns() > 0;
+}
+
static const struct {
uid_t first, last;
const char *name;
UserDisposition disposition;
+ bool (*test)(void);
} uid_range_table[] = {
{
.first = 1,
.last = MAP_UID_MAX,
.name = "mapped",
.disposition = USER_REGULAR,
+ .test = test_show_mapped,
},
};
if (!uid_range_covers(p, i->first, i->last - i->first + 1))
continue;
+ if (i->test && !i->test())
+ continue;
+
name = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_DOWN),
" begin ", i->name, " users ",
special_glyph(SPECIAL_GLYPH_ARROW_DOWN));
if (!uid_range_covers(p, i->first, i->last - i->first + 1))
continue;
+ if (i->test && !i->test())
+ continue;
+
name = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_DOWN),
" begin ", i->name, " groups ",
special_glyph(SPECIAL_GLYPH_ARROW_DOWN));