2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $FreeBSD: src/sys/sys/jail.h,v 1.8.2.2 2000/11/01 17:58:06 rwatson Exp $
10 * $DragonFly: src/sys/sys/jail.h,v 1.9 2006/12/29 18:02:56 victor Exp $
18 #include <sys/types.h>
21 #include <sys/param.h>
24 #include <sys/queue.h>
27 #include <sys/ucred.h>
37 uint32_t n_ips; /* Number of ips */
38 struct sockaddr_storage *ips;
50 int jail(struct jail *);
55 #ifndef _SYS_NAMECACHE_H_
56 #include <sys/namecache.h>
58 #ifndef _SYS_VARSYM_H_
59 #include <sys/varsym.h>
63 MALLOC_DECLARE(M_PRISON);
66 #define JAIL_MAX 999999
68 /* Used to store the IPs of the jail */
70 struct jail_ip_storage {
71 SLIST_ENTRY(jail_ip_storage) entries;
72 struct sockaddr_storage ip;
76 * This structure describes a prison. It is pointed to by all struct
77 * proc's of the inmates. pr_ref keeps track of them and is used to
78 * delete the struture when the last inmate is dead.
82 LIST_ENTRY(prison) pr_list; /* all prisons */
83 int pr_id; /* prison id */
84 int pr_ref; /* reference count */
85 struct nchandle pr_root; /* namecache entry of root */
86 char pr_host[MAXHOSTNAMELEN]; /* host name */
87 SLIST_HEAD(iplist, jail_ip_storage) pr_ips; /* list of IP addresses */
88 struct sockaddr_storage *local_ip4; /* cache for a loopback ipv4 address */
89 struct sockaddr_storage *nonlocal_ip4; /* cache for a non loopback ipv4 address */
90 struct sockaddr_storage *local_ip6; /* cache for a loopback ipv6 address */
91 struct sockaddr_storage *nonlocal_ip6; /* cache for a non loopback ipv6 address */
92 void *pr_linux; /* Linux ABI emulation */
93 int pr_securelevel; /* jail securelevel */
94 struct varsymset pr_varsymset; /* jail varsyms */
98 * Sysctl-set variables that determine global jail policy
100 extern int jail_set_hostname_allowed;
101 extern int jail_socket_unixiproute_only;
102 extern int jail_sysvipc_allowed;
103 extern int jail_chflags_allowed;
105 void prison_hold(struct prison *);
106 void prison_free(struct prison *);
107 int jailed_ip(struct prison *, struct sockaddr *);
108 int prison_get_local(struct prison *pr, struct sockaddr *);
109 int prison_get_nonlocal(struct prison *pr, struct sockaddr *);
112 * Return 1 if the passed credential is in a jail, otherwise 0.
115 jailed(struct ucred *cred)
117 return(cred->cr_prison != NULL);
120 #endif /* !_KERNEL */
121 #endif /* !_SYS_JAIL_H_ */