Created
September 6, 2011 09:43
-
-
Save dnaeon/1197138 to your computer and use it in GitHub Desktop.
get-jail-info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/param.h> | |
#include <sys/jail.h> | |
#include <sys/uio.h> | |
#include <arpa/inet.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <jail.h> | |
#include <stdio.h> | |
int | |
main(void) | |
{ | |
struct iovec params[6]; | |
struct in_addr ia; | |
char hostbuf[MAXHOSTNAMELEN]; | |
int lastjid = 0; | |
*(const void **)¶ms[0].iov_base = "lastjid"; | |
params[0].iov_len = sizeof("lastjid"); | |
params[1].iov_base = &lastjid; | |
params[1].iov_len = sizeof(lastjid); | |
*(const void **)¶ms[2].iov_base = "host.hostname"; | |
params[2].iov_len = sizeof("host.hostname"); | |
params[3].iov_base = hostbuf; | |
params[3].iov_len = MAXHOSTNAMELEN; | |
*(const void **)¶ms[4].iov_base = "ip4.addr"; | |
params[4].iov_len = sizeof("ip4.addr"); | |
params[5].iov_len = sizeof(struct in_addr); | |
params[5].iov_base = &ia; | |
while ((lastjid = jail_get(params, 6, 0)) > 0) { | |
printf("JID: %d\n", lastjid); | |
printf("\thost.hostname: %s\n", hostbuf); | |
printf("\tip4.addr: %s\n", inet_ntoa(ia)); | |
} | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment