Last active
February 17, 2018 21:03
-
-
Save briandowns/0ec6520f1906d50ce949e1f7f15714a1 to your computer and use it in GitHub Desktop.
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 <dirent.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/param.h> | |
#include <sys/jail.h> | |
#include <sys/uio.h> | |
#include <sys/types.h> | |
int | |
main(int argc, char** argv) { | |
struct jail jp; | |
jp.version = 0; | |
jp.path = "/zroot/jails/build"; | |
jp.hostname = "test1"; | |
jp.jailname = "test1"; | |
int jid; | |
jid = jail(&jp); | |
if (jid == -1) { | |
perror("jail"); | |
return EXIT_FAILURE; | |
} | |
printf("JAIL ID: %d\n", jid); | |
sleep(5); | |
int fd = creat("/hello_from_c", 0666); | |
close(fd); | |
DIR *dp; | |
struct dirent *ep; | |
dp = opendir("/"); | |
if (dp != NULL) { | |
while ((ep = readdir(dp))) | |
puts (ep->d_name); | |
(void) closedir (dp); | |
} | |
else | |
perror ("Couldn't open the directory"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment