186d7f5d3SJohn Marino.\" 286d7f5d3SJohn Marino.\"---------------------------------------------------------------------------- 386d7f5d3SJohn Marino.\""THE BEER-WARE LICENSE" (Revision 42): 486d7f5d3SJohn Marino.\"<phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 586d7f5d3SJohn Marino.\"can do whatever you want with this stuff. If we meet some day, and you think 686d7f5d3SJohn Marino.\"this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 786d7f5d3SJohn Marino.\"---------------------------------------------------------------------------- 886d7f5d3SJohn Marino.\" 986d7f5d3SJohn Marino.\"$FreeBSD: src/lib/libc/sys/jail.2,v 1.10.2.10 2002/12/12 05:26:38 trhodes Exp $ 1086d7f5d3SJohn Marino.\"$DragonFly: src/lib/libc/sys/jail.2,v 1.11 2007/11/21 19:12:40 swildner Exp $ 1186d7f5d3SJohn Marino.\" 1286d7f5d3SJohn Marino.Dd April 28, 1999 1386d7f5d3SJohn Marino.Dt JAIL 2 1486d7f5d3SJohn Marino.Os 1586d7f5d3SJohn Marino.Sh NAME 1686d7f5d3SJohn Marino.Nm jail 1786d7f5d3SJohn Marino.Nd imprison current process and future descendants 1886d7f5d3SJohn Marino.Sh LIBRARY 1986d7f5d3SJohn Marino.Lb libc 2086d7f5d3SJohn Marino.Sh SYNOPSIS 2186d7f5d3SJohn Marino.In sys/types.h 2286d7f5d3SJohn Marino.In sys/jail.h 2386d7f5d3SJohn Marino.Ft int 2486d7f5d3SJohn Marino.Fn jail "struct jail *jail" 2586d7f5d3SJohn Marino.Sh DESCRIPTION 2686d7f5d3SJohn MarinoThe 2786d7f5d3SJohn Marino.Nm 2886d7f5d3SJohn Marinosystem call sets up a jail and locks the current process in it. 2986d7f5d3SJohn Marino.Pp 3086d7f5d3SJohn MarinoThe argument is a pointer to a structure describing the prison: 3186d7f5d3SJohn Marino.Bd -literal -offset indent 3286d7f5d3SJohn Marinostruct jail { 3386d7f5d3SJohn Marino uint32_t version; 3486d7f5d3SJohn Marino char *path; 3586d7f5d3SJohn Marino char *hostname; 3686d7f5d3SJohn Marino uint32_t n_ips; 3786d7f5d3SJohn Marino struct sockaddr_storage *ips; 3886d7f5d3SJohn Marino}; 3986d7f5d3SJohn Marino.Ed 4086d7f5d3SJohn Marino.Pp 4186d7f5d3SJohn Marino.Dq Li version 4286d7f5d3SJohn Marinodefines the version of the API in use. It should be set to 1 at this time. 4386d7f5d3SJohn Marino.Pp 4486d7f5d3SJohn MarinoThe 4586d7f5d3SJohn Marino.Dq Li path 4686d7f5d3SJohn Marinopointer should be set to the directory which is to be the root of the 4786d7f5d3SJohn Marinoprison. 4886d7f5d3SJohn Marino.Pp 4986d7f5d3SJohn MarinoThe 5086d7f5d3SJohn Marino.Dq Li hostname 5186d7f5d3SJohn Marinopointer can be set to the hostname of the prison. This can be changed 5286d7f5d3SJohn Marinofrom the inside of the prison. 5386d7f5d3SJohn Marino.Pp 5486d7f5d3SJohn Marino.Dq Li n_ips 5586d7f5d3SJohn Marinois the number of IP addresses that are on ips. 5686d7f5d3SJohn Marino.Pp 5786d7f5d3SJohn MarinoThe 5886d7f5d3SJohn Marino.Dq ips 5986d7f5d3SJohn Marinopointer contains the IP addresses assigned to the jail. 6086d7f5d3SJohn Marino.Sh PRISON 6186d7f5d3SJohn MarinoOnce a process has been put in a prison, it and its descendants cannot escape 6286d7f5d3SJohn Marinothe prison. 6386d7f5d3SJohn MarinoA process can be attached to a prison by calling 6486d7f5d3SJohn Marino.Xr jail_attach 2 . 6586d7f5d3SJohn Marino.Pp 6686d7f5d3SJohn MarinoInside the prison, the concept of "superuser" is very diluted. In general, 6786d7f5d3SJohn Marinoit can be assumed that nothing can be mangled from inside a prison which 6886d7f5d3SJohn Marinodoes not exist entirely inside that prison. For instance the directory 6986d7f5d3SJohn Marinotree below 7086d7f5d3SJohn Marino.Dq Li path 7186d7f5d3SJohn Marinocan be manipulated all the ways a root can normally do it, including 7286d7f5d3SJohn Marino.Dq Li "rm -rf /*" 7386d7f5d3SJohn Marinobut new device special nodes cannot be created because they reference 7486d7f5d3SJohn Marinoshared resources (the device drivers in the kernel). 7586d7f5d3SJohn Marino.Pp 7686d7f5d3SJohn MarinoAll IP activity will be forced to happen to/from the IP numbers specified, 7786d7f5d3SJohn Marinowhich should be an alias on one or more of the network interfaces. 7886d7f5d3SJohn Marino.Pp 7986d7f5d3SJohn MarinoIt is possible to identify a process as jailed by examining 8086d7f5d3SJohn Marino.Dq Li /proc/<pid>/status : 8186d7f5d3SJohn Marinoit will show a field near the end of the line, either as 8286d7f5d3SJohn Marinoa single hyphen for a process at large, or the hostname currently 8386d7f5d3SJohn Marinoset for the prison for jailed processes. 8486d7f5d3SJohn Marino.Pp 8586d7f5d3SJohn MarinoThe program 8686d7f5d3SJohn Marino.Xr jls 8 8786d7f5d3SJohn Marinoca be used to identify all active jails. 8886d7f5d3SJohn Marino.Sh RETURN VALUES 8986d7f5d3SJohn MarinoIf successful, 9086d7f5d3SJohn Marino.Fn jail 9186d7f5d3SJohn Marinoreturns a non-negative integer, termed the jail identifier (JID). 9286d7f5d3SJohn MarinoIt returns -1 on failure, and sets 9386d7f5d3SJohn Marino.Va errno 9486d7f5d3SJohn Marinoto indicate the error. 9586d7f5d3SJohn Marino.Sh ERRORS 9686d7f5d3SJohn MarinoThe 9786d7f5d3SJohn Marino.Fn jail 9886d7f5d3SJohn Marinosystem call will fail if: 9986d7f5d3SJohn Marino.Bl -tag -width Er 10086d7f5d3SJohn Marino.It Bq Er EINVAL 10186d7f5d3SJohn MarinoThe version number of the argument is not correct. 10286d7f5d3SJohn Marino.El 10386d7f5d3SJohn Marino.Pp 10486d7f5d3SJohn MarinoFurther 10586d7f5d3SJohn Marino.Fn jail 10686d7f5d3SJohn Marinocalls 10786d7f5d3SJohn Marino.Xr chroot 2 10886d7f5d3SJohn Marinointernally, so it can fail for all the same reasons. 10986d7f5d3SJohn MarinoPlease consult the 11086d7f5d3SJohn Marino.Xr chroot 2 11186d7f5d3SJohn Marinomanual page for details. 11286d7f5d3SJohn Marino.Sh SEE ALSO 11386d7f5d3SJohn Marino.Xr chdir 2 , 11486d7f5d3SJohn Marino.Xr chroot 2 , 11586d7f5d3SJohn Marino.Xr jail_attach 2 , 11686d7f5d3SJohn Marino.Xr jail 8 , 11786d7f5d3SJohn Marino.Xr jexec 8 , 11886d7f5d3SJohn Marino.Xr jls 8 11986d7f5d3SJohn Marino.Sh HISTORY 12086d7f5d3SJohn MarinoThe 12186d7f5d3SJohn Marino.Fn jail 12286d7f5d3SJohn Marinofunction call appeared in 12386d7f5d3SJohn Marino.Fx 4.0 . 12486d7f5d3SJohn Marino.Sh AUTHORS 12586d7f5d3SJohn MarinoThe jail feature was written by 12686d7f5d3SJohn Marino.An Poul-Henning Kamp 12786d7f5d3SJohn Marinofor R&D Associates 12886d7f5d3SJohn Marino.Dq Pa http://www.rndassociates.com/ 12986d7f5d3SJohn Marinowho contributed it to 13086d7f5d3SJohn Marino.Fx . 131