xref: /freebsd/lib/libjail/jail.h (revision 30e6e008bc06385a66756bebb41676f4f9017eca)
1de6f3704SJamie Gritton /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni  *
4de6f3704SJamie Gritton  * Copyright (c) 2009 James Gritton.
5de6f3704SJamie Gritton  * All rights reserved.
6de6f3704SJamie Gritton  *
7de6f3704SJamie Gritton  * Redistribution and use in source and binary forms, with or without
8de6f3704SJamie Gritton  * modification, are permitted provided that the following conditions
9de6f3704SJamie Gritton  * are met:
10de6f3704SJamie Gritton  * 1. Redistributions of source code must retain the above copyright
11de6f3704SJamie Gritton  *    notice, this list of conditions and the following disclaimer.
12de6f3704SJamie Gritton  * 2. Redistributions in binary form must reproduce the above copyright
13de6f3704SJamie Gritton  *    notice, this list of conditions and the following disclaimer in the
14de6f3704SJamie Gritton  *    documentation and/or other materials provided with the distribution.
15de6f3704SJamie Gritton  *
16de6f3704SJamie Gritton  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17de6f3704SJamie Gritton  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18de6f3704SJamie Gritton  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19de6f3704SJamie Gritton  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20de6f3704SJamie Gritton  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21de6f3704SJamie Gritton  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22de6f3704SJamie Gritton  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23de6f3704SJamie Gritton  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24de6f3704SJamie Gritton  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25de6f3704SJamie Gritton  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26de6f3704SJamie Gritton  * SUCH DAMAGE.
27de6f3704SJamie Gritton  */
28de6f3704SJamie Gritton 
29de6f3704SJamie Gritton #ifndef _JAIL_H
30de6f3704SJamie Gritton #define _JAIL_H
31de6f3704SJamie Gritton 
32de6f3704SJamie Gritton #define	JP_RAWVALUE	0x01
33de6f3704SJamie Gritton #define	JP_BOOL		0x02
34de6f3704SJamie Gritton #define	JP_NOBOOL	0x04
357cbf7213SJamie Gritton #define	JP_JAILSYS	0x08
36*30e6e008SIgor Ostapenko #define	JP_KEYVALUE	0x10
37de6f3704SJamie Gritton 
38de6f3704SJamie Gritton #define JAIL_ERRMSGLEN	1024
39de6f3704SJamie Gritton 
40de6f3704SJamie Gritton extern char jail_errmsg[];
41de6f3704SJamie Gritton 
42de6f3704SJamie Gritton struct jailparam {
43de6f3704SJamie Gritton 	char		*jp_name;
44de6f3704SJamie Gritton 	void		*jp_value;
45de6f3704SJamie Gritton 	size_t		 jp_valuelen;
46de6f3704SJamie Gritton 	size_t		 jp_elemlen;
47de6f3704SJamie Gritton 	int		 jp_ctltype;
48de6f3704SJamie Gritton 	int		 jp_structtype;
49de6f3704SJamie Gritton 	unsigned	 jp_flags;
50de6f3704SJamie Gritton };
51de6f3704SJamie Gritton 
52de6f3704SJamie Gritton __BEGIN_DECLS
53de6f3704SJamie Gritton extern int jail_getid(const char *name);
54de6f3704SJamie Gritton extern char *jail_getname(int jid);
55de6f3704SJamie Gritton extern int jail_setv(int flags, ...);
56de6f3704SJamie Gritton extern int jail_getv(int flags, ...);
57de6f3704SJamie Gritton extern int jailparam_all(struct jailparam **jpp);
58de6f3704SJamie Gritton extern int jailparam_init(struct jailparam *jp, const char *name);
59de6f3704SJamie Gritton extern int jailparam_import(struct jailparam *jp, const char *value);
60de6f3704SJamie Gritton extern int jailparam_import_raw(struct jailparam *jp, void *value,
61de6f3704SJamie Gritton 	       size_t valuelen);
62de6f3704SJamie Gritton extern int jailparam_set(struct jailparam *jp, unsigned njp, int flags);
63de6f3704SJamie Gritton extern int jailparam_get(struct jailparam *jp, unsigned njp, int flags);
64de6f3704SJamie Gritton extern char *jailparam_export(struct jailparam *jp);
65de6f3704SJamie Gritton extern void jailparam_free(struct jailparam *jp, unsigned njp);
66de6f3704SJamie Gritton __END_DECLS
67de6f3704SJamie Gritton 
68de6f3704SJamie Gritton #endif /* _JAIL_H  */
69de6f3704SJamie Gritton 
70de6f3704SJamie Gritton 
71