summaryrefslogtreecommitdiff
path: root/srcx/jails.c
diff options
context:
space:
mode:
Diffstat (limited to 'srcx/jails.c')
-rw-r--r--srcx/jails.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/srcx/jails.c b/srcx/jails.c
index 0394a35..40b12a7 100644
--- a/srcx/jails.c
+++ b/srcx/jails.c
@@ -77,40 +77,15 @@ static void usage()
static void list_jails()
{
- struct xprison* sxp;
struct xprison* xp;
size_t len, i;
+ jails jls;
/* ... otherwise it's a name */
+ jails_load(&jls);
- if(sysctlbyname("security.jail.list", NULL, &len, NULL, 0) == -1)
- err(1, "couldn't list jails");
+ while((xp = jails_next(&jls)) != NULL)
+ printf("%s\n", xp->pr_host);
-retry:
-
- if(len <= 0)
- return;
-
- sxp = xp = calloc(len, 1);
- if(sxp == NULL)
- err(1, "out of memory");
-
- if(sysctlbyname("security.jail.list", xp, &len, NULL, 0) == -1)
- {
- if(errno == ENOMEM)
- {
- free(sxp);
- goto retry;
- }
-
- err(1, "couldn't list jails");
- }
-
- if(len < sizeof(*xp) || len % sizeof(*xp) || xp->pr_version != XPRISON_VERSION)
- errx(1, "kernel and userland out of sync");
-
- for(i = 0; i < (len / sizeof(*xp)); i++)
- printf("%s\n", xp[i].pr_host);
-
- free(sxp);
+ jails_done(&jls);
}