summaryrefslogtreecommitdiff
path: root/srcx/jid.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-05-17 17:52:45 +0000
committerStef Walter <stef@memberwebs.com>2004-05-17 17:52:45 +0000
commit887d8b57c4aa291919c8eec6b2af5a5f5259ac6d (patch)
treeb1bd6b228a39d3f867f882467891e1291c229425 /srcx/jid.c
parent58c696e88cfeb6d97d836b9f328d683b0e187d65 (diff)
Initial 5.2.x files
Diffstat (limited to 'srcx/jid.c')
-rw-r--r--srcx/jid.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/srcx/jid.c b/srcx/jid.c
new file mode 100644
index 0000000..a201822
--- /dev/null
+++ b/srcx/jid.c
@@ -0,0 +1,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);
+}