mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
Merge pull request #30844 from keszybz/rename-uid-alloc-range
Rename uid-alloc-range.[ch] files
This commit is contained in:
commit
84960b7f3c
@ -96,7 +96,7 @@ basic_sources = files(
|
||||
'terminal-util.c',
|
||||
'time-util.c',
|
||||
'tmpfile-util.c',
|
||||
'uid-alloc-range.c',
|
||||
'uid-classification.c',
|
||||
'uid-range.c',
|
||||
'unit-def.c',
|
||||
'unit-file.c',
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "fileio.h"
|
||||
#include "missing_threads.h"
|
||||
#include "string-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
|
||||
static const UGIDAllocationRange default_ugid_allocation_range = {
|
@ -15,7 +15,7 @@
|
||||
#include "uid-range.h"
|
||||
#include "user-util.h"
|
||||
|
||||
UidRange *uid_range_free(UidRange *range) {
|
||||
UIDRange *uid_range_free(UIDRange *range) {
|
||||
if (!range)
|
||||
return NULL;
|
||||
|
||||
@ -23,14 +23,14 @@ UidRange *uid_range_free(UidRange *range) {
|
||||
return mfree(range);
|
||||
}
|
||||
|
||||
static bool uid_range_entry_intersect(const UidRangeEntry *a, const UidRangeEntry *b) {
|
||||
static bool uid_range_entry_intersect(const UIDRangeEntry *a, const UIDRangeEntry *b) {
|
||||
assert(a);
|
||||
assert(b);
|
||||
|
||||
return a->start <= b->start + b->nr && a->start + a->nr >= b->start;
|
||||
}
|
||||
|
||||
static int uid_range_entry_compare(const UidRangeEntry *a, const UidRangeEntry *b) {
|
||||
static int uid_range_entry_compare(const UIDRangeEntry *a, const UIDRangeEntry *b) {
|
||||
int r;
|
||||
|
||||
assert(a);
|
||||
@ -43,7 +43,7 @@ static int uid_range_entry_compare(const UidRangeEntry *a, const UidRangeEntry *
|
||||
return CMP(a->nr, b->nr);
|
||||
}
|
||||
|
||||
static void uid_range_coalesce(UidRange *range) {
|
||||
static void uid_range_coalesce(UIDRange *range) {
|
||||
assert(range);
|
||||
|
||||
if (range->n_entries <= 0)
|
||||
@ -52,10 +52,10 @@ static void uid_range_coalesce(UidRange *range) {
|
||||
typesafe_qsort(range->entries, range->n_entries, uid_range_entry_compare);
|
||||
|
||||
for (size_t i = 0; i < range->n_entries; i++) {
|
||||
UidRangeEntry *x = range->entries + i;
|
||||
UIDRangeEntry *x = range->entries + i;
|
||||
|
||||
for (size_t j = i + 1; j < range->n_entries; j++) {
|
||||
UidRangeEntry *y = range->entries + j;
|
||||
UIDRangeEntry *y = range->entries + j;
|
||||
uid_t begin, end;
|
||||
|
||||
if (!uid_range_entry_intersect(x, y))
|
||||
@ -68,7 +68,7 @@ static void uid_range_coalesce(UidRange *range) {
|
||||
x->nr = end - begin;
|
||||
|
||||
if (range->n_entries > j + 1)
|
||||
memmove(y, y + 1, sizeof(UidRangeEntry) * (range->n_entries - j - 1));
|
||||
memmove(y, y + 1, sizeof(UIDRangeEntry) * (range->n_entries - j - 1));
|
||||
|
||||
range->n_entries--;
|
||||
j--;
|
||||
@ -76,9 +76,9 @@ static void uid_range_coalesce(UidRange *range) {
|
||||
}
|
||||
}
|
||||
|
||||
int uid_range_add_internal(UidRange **range, uid_t start, uid_t nr, bool coalesce) {
|
||||
_cleanup_(uid_range_freep) UidRange *range_new = NULL;
|
||||
UidRange *p;
|
||||
int uid_range_add_internal(UIDRange **range, uid_t start, uid_t nr, bool coalesce) {
|
||||
_cleanup_(uid_range_freep) UIDRange *range_new = NULL;
|
||||
UIDRange *p;
|
||||
|
||||
assert(range);
|
||||
|
||||
@ -91,7 +91,7 @@ int uid_range_add_internal(UidRange **range, uid_t start, uid_t nr, bool coalesc
|
||||
if (*range)
|
||||
p = *range;
|
||||
else {
|
||||
range_new = new0(UidRange, 1);
|
||||
range_new = new0(UIDRange, 1);
|
||||
if (!range_new)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -101,7 +101,7 @@ int uid_range_add_internal(UidRange **range, uid_t start, uid_t nr, bool coalesc
|
||||
if (!GREEDY_REALLOC(p->entries, p->n_entries + 1))
|
||||
return -ENOMEM;
|
||||
|
||||
p->entries[p->n_entries++] = (UidRangeEntry) {
|
||||
p->entries[p->n_entries++] = (UIDRangeEntry) {
|
||||
.start = start,
|
||||
.nr = nr,
|
||||
};
|
||||
@ -115,7 +115,7 @@ int uid_range_add_internal(UidRange **range, uid_t start, uid_t nr, bool coalesc
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uid_range_add_str(UidRange **range, const char *s) {
|
||||
int uid_range_add_str(UIDRange **range, const char *s) {
|
||||
uid_t start, end;
|
||||
int r;
|
||||
|
||||
@ -129,7 +129,7 @@ int uid_range_add_str(UidRange **range, const char *s) {
|
||||
return uid_range_add_internal(range, start, end - start + 1, /* coalesce = */ true);
|
||||
}
|
||||
|
||||
int uid_range_next_lower(const UidRange *range, uid_t *uid) {
|
||||
int uid_range_next_lower(const UIDRange *range, uid_t *uid) {
|
||||
uid_t closest = UID_INVALID, candidate;
|
||||
|
||||
assert(range);
|
||||
@ -162,7 +162,7 @@ int uid_range_next_lower(const UidRange *range, uid_t *uid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool uid_range_covers(const UidRange *range, uid_t start, uid_t nr) {
|
||||
bool uid_range_covers(const UIDRange *range, uid_t start, uid_t nr) {
|
||||
if (nr == 0) /* empty range? always covered... */
|
||||
return true;
|
||||
|
||||
@ -204,8 +204,8 @@ int uid_map_read_one(FILE *f, uid_t *ret_base, uid_t *ret_shift, uid_t *ret_rang
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uid_range_load_userns(UidRange **ret, const char *path) {
|
||||
_cleanup_(uid_range_freep) UidRange *range = NULL;
|
||||
int uid_range_load_userns(UIDRange **ret, const char *path) {
|
||||
_cleanup_(uid_range_freep) UIDRange *range = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int r;
|
||||
|
||||
@ -230,7 +230,7 @@ int uid_range_load_userns(UidRange **ret, const char *path) {
|
||||
return r;
|
||||
}
|
||||
|
||||
range = new0(UidRange, 1);
|
||||
range = new0(UIDRange, 1);
|
||||
if (!range)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -6,31 +6,31 @@
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef struct UidRangeEntry {
|
||||
typedef struct UIDRangeEntry {
|
||||
uid_t start, nr;
|
||||
} UidRangeEntry;
|
||||
} UIDRangeEntry;
|
||||
|
||||
typedef struct UidRange {
|
||||
UidRangeEntry *entries;
|
||||
typedef struct UIDRange {
|
||||
UIDRangeEntry *entries;
|
||||
size_t n_entries;
|
||||
} UidRange;
|
||||
} UIDRange;
|
||||
|
||||
UidRange *uid_range_free(UidRange *range);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UidRange*, uid_range_free);
|
||||
UIDRange *uid_range_free(UIDRange *range);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UIDRange*, uid_range_free);
|
||||
|
||||
int uid_range_add_internal(UidRange **range, uid_t start, uid_t nr, bool coalesce);
|
||||
static inline int uid_range_add(UidRange **range, uid_t start, uid_t nr) {
|
||||
int uid_range_add_internal(UIDRange **range, uid_t start, uid_t nr, bool coalesce);
|
||||
static inline int uid_range_add(UIDRange **range, uid_t start, uid_t nr) {
|
||||
return uid_range_add_internal(range, start, nr, true);
|
||||
}
|
||||
int uid_range_add_str(UidRange **range, const char *s);
|
||||
int uid_range_add_str(UIDRange **range, const char *s);
|
||||
|
||||
int uid_range_next_lower(const UidRange *range, uid_t *uid);
|
||||
int uid_range_next_lower(const UIDRange *range, uid_t *uid);
|
||||
|
||||
bool uid_range_covers(const UidRange *range, uid_t start, uid_t nr);
|
||||
static inline bool uid_range_contains(const UidRange *range, uid_t uid) {
|
||||
bool uid_range_covers(const UIDRange *range, uid_t start, uid_t nr);
|
||||
static inline bool uid_range_contains(const UIDRange *range, uid_t uid) {
|
||||
return uid_range_covers(range, uid, 1);
|
||||
}
|
||||
|
||||
int uid_map_read_one(FILE *f, uid_t *ret_base, uid_t *ret_shift, uid_t *ret_range);
|
||||
|
||||
int uid_range_load_userns(UidRange **ret, const char *path);
|
||||
int uid_range_load_userns(UIDRange **ret, const char *path);
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
|
||||
/* Takes a value generated randomly or by hashing and turns it into a UID in the right range */
|
||||
|
@ -4767,7 +4767,7 @@ int manager_dispatch_user_lookup_fd(sd_event_source *source, int fd, uint32_t re
|
||||
}
|
||||
|
||||
static int short_uid_range(const char *path) {
|
||||
_cleanup_(uid_range_freep) UidRange *p = NULL;
|
||||
_cleanup_(uid_range_freep) UIDRange *p = NULL;
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "strv.h"
|
||||
#include "sync-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
|
||||
/* The maximum size up to which we process coredumps. We use 1G on 32-bit systems, and 32G on 64-bit systems */
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
#include "vpick.h"
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "rlimit-util.h"
|
||||
#include "spawn-polkit-agent.h"
|
||||
#include "terminal-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-record.h"
|
||||
#include "user-record-password-quality.h"
|
||||
#include "user-record-show.h"
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "stat-util.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-record-password-quality.h"
|
||||
#include "user-record-sign.h"
|
||||
#include "user-record-util.h"
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "syslog-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
#include "varlink-io.systemd.Journal.h"
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct sd_device_monitor {
|
||||
union sockaddr_union snl_trusted_sender;
|
||||
bool bound;
|
||||
|
||||
UidRange *mapped_userns_uid_range;
|
||||
UIDRange *mapped_userns_uid_range;
|
||||
|
||||
Hashmap *subsystem_filter;
|
||||
Set *tag_filter;
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "syslog-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
|
||||
#define JOURNAL_FILES_RECHECK_USEC (2 * USEC_PER_SEC)
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
|
||||
#define RELEASE_USEC (20*USEC_PER_SEC)
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "unit-name.h"
|
||||
#include "user-util.h"
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "string-util.h"
|
||||
#include "tomoyo-util.h"
|
||||
#include "tpm2-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
#include "virt.h"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "group-record.h"
|
||||
#include "strv.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
|
||||
GroupRecord* group_record_new(void) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "rlimit-util.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-record.h"
|
||||
#include "user-util.h"
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "strv.h"
|
||||
#include "sync-util.h"
|
||||
#include "tmpfile-util-label.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "uid-range.h"
|
||||
#include "user-util.h"
|
||||
#include "utf8.h"
|
||||
@ -117,7 +117,7 @@ typedef struct Context {
|
||||
Set *names;
|
||||
|
||||
uid_t search_uid;
|
||||
UidRange *uid_range;
|
||||
UIDRange *uid_range;
|
||||
|
||||
UGIDAllocationRange login_defs;
|
||||
bool login_defs_need_warning;
|
||||
|
@ -171,7 +171,7 @@ simple_tests += files(
|
||||
'test-terminal-util.c',
|
||||
'test-tmpfile-util.c',
|
||||
'test-udev-util.c',
|
||||
'test-uid-alloc-range.c',
|
||||
'test-uid-classification.c',
|
||||
'test-uid-range.c',
|
||||
'test-umask-util.c',
|
||||
'test-unaligned.c',
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "tests.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "tomoyo-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
#include "user-util.h"
|
||||
#include "virt.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "fs-util.h"
|
||||
#include "tests.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "uid-alloc-range.h"
|
||||
#include "uid-classification.h"
|
||||
|
||||
static void test_read_login_defs_one(const char *path) {
|
||||
log_info("/* %s(\"%s\") */", __func__, path ?: "<custom>");
|
@ -14,7 +14,7 @@
|
||||
#include "virt.h"
|
||||
|
||||
TEST(uid_range) {
|
||||
_cleanup_(uid_range_freep) UidRange *p = NULL;
|
||||
_cleanup_(uid_range_freep) UIDRange *p = NULL;
|
||||
uid_t search;
|
||||
|
||||
assert_se(uid_range_covers(p, 0, 0));
|
||||
@ -93,7 +93,7 @@ TEST(uid_range) {
|
||||
}
|
||||
|
||||
TEST(load_userns) {
|
||||
_cleanup_(uid_range_freep) UidRange *p = NULL;
|
||||
_cleanup_(uid_range_freep) UIDRange *p = NULL;
|
||||
_cleanup_(unlink_and_freep) char *fn = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int r;
|
||||
@ -134,7 +134,7 @@ TEST(load_userns) {
|
||||
}
|
||||
|
||||
TEST(uid_range_coalesce) {
|
||||
_cleanup_(uid_range_freep) UidRange *p = NULL;
|
||||
_cleanup_(uid_range_freep) UIDRange *p = NULL;
|
||||
|
||||
for (size_t i = 0; i < 10; i++) {
|
||||
assert_se(uid_range_add_internal(&p, i * 10, 10, /* coalesce = */ false) >= 0);
|
||||
|
@ -169,7 +169,7 @@ static const struct {
|
||||
},
|
||||
};
|
||||
|
||||
static int table_add_uid_boundaries(Table *table, const UidRange *p) {
|
||||
static int table_add_uid_boundaries(Table *table, const UIDRange *p) {
|
||||
int r;
|
||||
|
||||
assert(table);
|
||||
@ -301,7 +301,7 @@ static int add_unavailable_uid(Table *table, uid_t start, uid_t end) {
|
||||
|
||||
static int table_add_uid_map(
|
||||
Table *table,
|
||||
const UidRange *p,
|
||||
const UIDRange *p,
|
||||
int (*add_unavailable)(Table *t, uid_t start, uid_t end)) {
|
||||
|
||||
uid_t focus = 0;
|
||||
@ -311,7 +311,7 @@ static int table_add_uid_map(
|
||||
assert(add_unavailable);
|
||||
|
||||
for (size_t i = 0; p && i < p->n_entries; i++) {
|
||||
UidRangeEntry *x = p->entries + i;
|
||||
UIDRangeEntry *x = p->entries + i;
|
||||
|
||||
if (focus < x->start) {
|
||||
r = add_unavailable(table, focus, x->start-1);
|
||||
@ -425,7 +425,7 @@ static int display_user(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
|
||||
if (table) {
|
||||
_cleanup_(uid_range_freep) UidRange *uid_range = NULL;
|
||||
_cleanup_(uid_range_freep) UIDRange *uid_range = NULL;
|
||||
int boundary_lines, uid_map_lines;
|
||||
|
||||
r = uid_range_load_userns(&uid_range, "/proc/self/uid_map");
|
||||
@ -526,7 +526,7 @@ static int show_group(GroupRecord *gr, Table *table) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int table_add_gid_boundaries(Table *table, const UidRange *p) {
|
||||
static int table_add_gid_boundaries(Table *table, const UIDRange *p) {
|
||||
int r;
|
||||
|
||||
assert(table);
|
||||
@ -728,7 +728,7 @@ static int display_group(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
|
||||
if (table) {
|
||||
_cleanup_(uid_range_freep) UidRange *gid_range = NULL;
|
||||
_cleanup_(uid_range_freep) UIDRange *gid_range = NULL;
|
||||
int boundary_lines, gid_map_lines;
|
||||
|
||||
r = uid_range_load_userns(&gid_range, "/proc/self/gid_map");
|
||||
|
Loading…
Reference in New Issue
Block a user