From d04af54d5b0bf34c71c4695716e480a171b5a32b Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 18 Mar 2009 20:35:09 +0000 Subject: Changes that support FreeBSD 7.2 --- srcx/jails.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'srcx/jails.c') 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); } -- cgit v1.2.3