42 lines
876 B
C
42 lines
876 B
C
|
#include <stdio.h>
|
||
|
#include "api.h"
|
||
|
#include "stdlib.h"
|
||
|
#include "prototypes.h"
|
||
|
|
||
|
const char *Prog;
|
||
|
|
||
|
void usage(void)
|
||
|
{
|
||
|
fprintf(stderr, "Usage: %s [-g] user\n", Prog);
|
||
|
fprintf(stderr, " list subuid ranges for user\n");
|
||
|
fprintf(stderr, " pass -g to list subgid ranges\n");
|
||
|
exit(EXIT_FAILURE);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
int i;
|
||
|
struct subordinate_range **ranges;
|
||
|
|
||
|
Prog = Basename (argv[0]);
|
||
|
if (argc < 2) {
|
||
|
usage();
|
||
|
}
|
||
|
if (argc == 3 && strcmp(argv[1], "-g") == 0)
|
||
|
ranges = get_subgid_ranges(argv[2]);
|
||
|
else if (argc == 2 && strcmp(argv[1], "-h") == 0)
|
||
|
usage();
|
||
|
else
|
||
|
ranges = get_subuid_ranges(argv[1]);
|
||
|
if (!ranges) {
|
||
|
fprintf(stderr, "Error fetching ranges\n");
|
||
|
exit(1);
|
||
|
}
|
||
|
for (i = 0; ranges[i]; i++) {
|
||
|
printf("%d: %s %lu %lu\n", i, ranges[i]->owner,
|
||
|
ranges[i]->start, ranges[i]->count);
|
||
|
}
|
||
|
subid_free_ranges(ranges);
|
||
|
return 0;
|
||
|
}
|