Create Jail fail by c language
freekai
freekai at outlook.com
Sat Apr 18 15:35:37 UTC 2015
This is My Code:
1 #include<sys/param.h>
2 #include<sys/jail.h>
3 #include<arpa/inet.h>
4 #include<stdio.h>
5 #include<errno.h>
6
7 int main()
8 {
9 int jid;
10 struct jail j;
11 struct in_addr ip4;
12 const char *cp="192.168.1.10";
13
14 j.version=JAIL_API_VERSION;
15 j.path="/home/mk/jail";
16 j.hostname="testJail";
17 j.jailname="test";
18 j.ip4s=inet_addr(cp);
19 j.ip6s=0;
20
21 if(1!=inet_aton(cp,&ip4))
22 printf("the address is invalid\r\n");
23
24 j.ip4=&ip4;
25 j.ip6=NULL;
26
27 jid=jail(&j);
28
29 switch(errno){
30 case EPERM:
31 printf("eperm\r\n");
32 break;
33 case EFAULT:
34 printf("efault\r\n");
35 break;
36 case EINVAL:
37 printf("einval\r\n");
38 break;
39
40 case EAGAIN:
41 printf("eagain\r\n");
42 }
47 return 0;
48 }
The problem is it will print `einval`,it means `The version number of the argument is not correct.`
How to solve it?
More information about the freebsd-jail
mailing list