summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--srcx/jails.c2
-rw-r--r--srcx/jid.c41
-rw-r--r--srcx/jkill.c5
-rw-r--r--srcx/jps.c1
-rw-r--r--srcx/util.c2
5 files changed, 20 insertions, 31 deletions
diff --git a/srcx/jails.c b/srcx/jails.c
index 5651f8a..b2b3d17 100644
--- a/srcx/jails.c
+++ b/srcx/jails.c
@@ -62,7 +62,7 @@ int main(int argc, char* argv[])
if(argc > 1)
usage();
- if(running_in_jail())
+ if(running_in_jail() != 0)
errx(1, "can't run from inside jail");
list_jails();
diff --git a/srcx/jid.c b/srcx/jid.c
index 5d2e4d0..93d0e94 100644
--- a/srcx/jid.c
+++ b/srcx/jid.c
@@ -54,7 +54,9 @@ static void usage();
int main(int argc, char* argv[])
{
- int jid = 0;
+ struct xprison* sxp = NULL;
+ struct xprison* xp = NULL;
+ size_t len;
char* e;
/* Remove the program name */
@@ -64,45 +66,30 @@ int main(int argc, char* argv[])
if(argc != 1)
usage();
- if(running_in_jail())
+ if(running_in_jail() != 0)
errx(1, "can't run from inside jail");
- jid = strtol(argv[0], &e, 10);
+ len = get_jail_sysctl(&xp);
+ xp = find_jail(argv[0], len, sxp);
+
+ strtol(argv[0], &e, 10);
/* If it was all a number ... */
if(!*e)
{
- struct xprison* xp;
- size_t len, i;
-
- len = get_jail_sysctl(&xp);
- if(len > 0)
- {
- for(i = 0; i < len; i++)
- {
- if(xp[i].pr_id == jid)
- {
- printf("%s\n", xp[i].pr_host);
- jid = -1;
- break;
- }
- }
-
- free(xp);
-
- if(jid != -1)
- errx(1, "unknown jail id: %s", argv[0]);
- }
+ if(xp == NULL)
+ errx(1, "unknown jail id: %s", argv[0]);
+
+ printf("%s\n", xp->pr_host);
}
/* otherwise it's a host name */
else
{
- jid = translate_jail_name(argv[0]);
- if(jid == -1)
+ if(xp == NULL)
errx(1, "unknown jail host name: %s", argv[0]);
- printf("%d\n", (int)jid);
+ printf("%d\n", xp->pr_host);
}
return 0;
diff --git a/srcx/jkill.c b/srcx/jkill.c
index 953095e..4afb703 100644
--- a/srcx/jkill.c
+++ b/srcx/jkill.c
@@ -43,6 +43,7 @@
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/wait.h>
+#include <sys/jail.h>
#include <paths.h>
#include <signal.h>
@@ -121,7 +122,7 @@ int main(int argc, char* argv[])
/* For each jail */
for(; argc > 0; argc--, argv++)
{
- xp = find_jail(str, len, sxp);
+ xp = find_jail(argv[0], len, sxp);
if(xp == NULL)
{
@@ -149,7 +150,7 @@ int main(int argc, char* argv[])
/* The child */
case 0:
#endif
- jid = xp->pri_id;
+ jid = xp->pr_id;
/* Always free jail info before going into jail */
free_jail_sysctl(len, sxp);
diff --git a/srcx/jps.c b/srcx/jps.c
index 867364d..85f7184 100644
--- a/srcx/jps.c
+++ b/srcx/jps.c
@@ -40,6 +40,7 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
+#include <sys/jail.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/srcx/util.c b/srcx/util.c
index 137ca24..c406163 100644
--- a/srcx/util.c
+++ b/srcx/util.c
@@ -153,7 +153,7 @@ int translate_jail_name(const char* str)
len = get_jail_sysctl(&sxp);
if(sxp)
{
- xp = find_jail(str, sxp);
+ xp = find_jail(str, len, sxp);
if(xp != NULL)
jid = xp->pr_id;