summaryrefslogtreecommitdiff
path: root/srcx/jid.c
blob: a201822907b21a015074ed1e77fdde5631b82b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "util.h"

#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif

static void usage();

int main(int argc, char* argv[])
{
	int i;
	int jid = 0;

	/* Remove the program name */
	argc--;
	argv++;

	if(argc != 1)
		usage();

	if(in_jail())
		errx(1, "can't run from inside jail");

	jid = translate_jail_id(argv[0]);
	if(jid == -1)
		errx(1, "unknown jail host name: %s", argv[0]);

	printf("%d \n", (int)jid);
	return 0;
}

static void usage()
{
	fprintf(stderr, "usage: jid hostname \n");
	exit(2);
}