Merge pull request #340 from hallyn/2021-05-16/subidrange

Don't return owner in list_owner_ranges API call.
This commit is contained in:
Serge Hallyn
2021-05-22 18:16:43 -05:00
committed by GitHub
8 changed files with 60 additions and 70 deletions

View File

@@ -68,26 +68,21 @@ bool libsubid_init(const char *progname, FILE * logfd)
}
static
int get_subid_ranges(const char *owner, enum subid_type id_type, struct subordinate_range ***ranges)
int get_subid_ranges(const char *owner, enum subid_type id_type, struct subid_range **ranges)
{
return list_owner_ranges(owner, id_type, ranges);
}
int get_subuid_ranges(const char *owner, struct subordinate_range ***ranges)
int get_subuid_ranges(const char *owner, struct subid_range **ranges)
{
return get_subid_ranges(owner, ID_TYPE_UID, ranges);
}
int get_subgid_ranges(const char *owner, struct subordinate_range ***ranges)
int get_subgid_ranges(const char *owner, struct subid_range **ranges)
{
return get_subid_ranges(owner, ID_TYPE_GID, ranges);
}
void subid_free_ranges(struct subordinate_range **ranges, int count)
{
return free_subordinate_ranges(ranges, count);
}
static
int get_subid_owner(unsigned long id, enum subid_type id_type, uid_t **owner)
{

View File

@@ -3,6 +3,15 @@
#ifndef SUBID_RANGE_DEFINED
#define SUBID_RANGE_DEFINED 1
/* subid_range is just a starting point and size of a range */
struct subid_range {
unsigned long start;
unsigned long count;
};
/* subordinage_range is a subid_range plus an owner, representing
* a range in /etc/subuid or /etc/subgid */
struct subordinate_range {
const char *owner;
unsigned long start;
@@ -41,32 +50,27 @@ bool libsubid_init(const char *progname, FILE *logfd);
* get_subuid_ranges: return a list of UID ranges for a user
*
* @owner: username being queried
* @ranges: a pointer to a subordinate range ** in which the result will be
* returned.
* @ranges: a pointer to an array of subid_range structs in which the result
* will be returned.
*
* The caller must free(ranges) when done.
*
* returns: number of ranges found, ir < 0 on error.
*/
int get_subuid_ranges(const char *owner, struct subordinate_range ***ranges);
int get_subuid_ranges(const char *owner, struct subid_range **ranges);
/*
* get_subgid_ranges: return a list of GID ranges for a user
*
* @owner: username being queried
* @ranges: a pointer to a subordinate range ** in which the result will be
* returned.
* @ranges: a pointer to an array of subid_range structs in which the result
* will be returned.
*
* The caller must free(ranges) when done.
*
* returns: number of ranges found, ir < 0 on error.
*/
int get_subgid_ranges(const char *owner, struct subordinate_range ***ranges);
/*
* subid_free_ranges: free an array of subordinate_ranges returned by either
* get_subuid_ranges() or get_subgid_ranges().
*
* @ranges: the ranges to free
* @count: the number of ranges in @ranges
*/
void subid_free_ranges(struct subordinate_range **ranges, int count);
int get_subgid_ranges(const char *owner, struct subid_range **ranges);
/*
* get_subuid_owners: return a list of uids to which the given uid has been