Files
shadow/src/check_subid_range.c
Skyler Ferrante e6c2e43937 Hardcoding Prog to known value
See #959. We now set Prog (program name) based on hardcoded value instead
of argv[0]. This is to help prevent escape sequence injection.
2024-03-07 22:23:04 +01:00

54 lines
1.1 KiB
C

// This program is for testing purposes only.
// usage is "[program] owner [u|g] start count
// Exits 0 if owner has subid range starting start, of size count
// Exits 1 otherwise.
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "atoi/strtou_noneg.h"
#include "defines.h"
#include "prototypes.h"
#include "subordinateio.h"
#include "idmapping.h"
#include "shadowlog.h"
static const char Prog[] = "check_subid_range";
int main(int argc, char **argv)
{
char *owner;
unsigned long start, count;
bool check_uids;
log_set_progname(Prog);
log_set_logfd(stderr);
if (argc != 5)
exit(1);
owner = argv[1];
check_uids = argv[2][0] == 'u';
errno = 0;
start = strtoul_noneg(argv[3], NULL, 10);
if (errno != 0)
exit(1);
count = strtoul_noneg(argv[4], NULL, 10);
if (errno != 0)
exit(1);
if (check_uids) {
if (have_sub_uids(owner, start, count))
exit(0);
exit(1);
}
if (have_sub_gids(owner, start, count))
exit(0);
exit(1);
}