Don't return owner in list_owner_ranges API call.

Closes: 339

struct subordinate_range is pretty closely tied to the existing
subid code and /etc/subuid format, so it includes an owner.  Dropping
that or even renaming it is more painful than I'd first thought.
So introduce a 'struct subid_range' which is only the start and
count, leaving 'struct subordinate_range' as the owner, start and
count.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
This commit is contained in:
Serge Hallyn
2021-05-16 21:47:05 -05:00
parent f9831a4a1a
commit 322db32971
7 changed files with 63 additions and 38 deletions

View File

@@ -101,9 +101,9 @@ enum subid_status shadow_subid_find_subid_owners(unsigned long id, enum subid_ty
return SUBID_STATUS_SUCCESS;
}
enum subid_status shadow_subid_list_owner_ranges(const char *owner, enum subid_type id_type, struct subordinate_range ***in_ranges, int *count)
enum subid_status shadow_subid_list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_range ***in_ranges, int *count)
{
struct subordinate_range **ranges;
struct subid_range **ranges;
*count = 0;
if (strcmp(owner, "error") == 0)
@@ -121,16 +121,15 @@ enum subid_status shadow_subid_list_owner_ranges(const char *owner, enum subid_t
return SUBID_STATUS_SUCCESS;
if (id_type == ID_TYPE_UID && strcmp(owner, "group1") == 0)
return SUBID_STATUS_SUCCESS;
ranges = (struct subordinate_range **)malloc(sizeof(struct subordinate_range *));
ranges = (struct subid_range **)malloc(sizeof(struct subid_range *));
if (!*ranges)
return SUBID_STATUS_ERROR;
ranges[0] = (struct subordinate_range *)malloc(sizeof(struct subordinate_range));
ranges[0] = (struct subid_range *)malloc(sizeof(struct subid_range));
if (!ranges[0]) {
free(*ranges);
*ranges = NULL;
return SUBID_STATUS_ERROR;
}
ranges[0]->owner = strdup(owner);
if (strcmp(owner, "user1") == 0 || strcmp(owner, "group1") == 0) {
ranges[0]->start = 100000;
ranges[0]->count = 65536;