The
sysjail function library may be used by dropping the
sysjail.h and
sysjail.c files into a source tree and interfacing with the functions. The source file does not require any specific compiler flags to run (assuming that
sysjail.h is in the same directory):
cc -c -o sysjail.o sysjail.c
Before using the function library, it must be initialised with
sj_init().
One or more (usually one) devices must then be initialised with
sj_dev_new(), which registers
physical devices with the system.
A
policy is the main concept in tracing processes. A policy, in the sense of
sysjail, defines the set of intercepted system calls and their corresponding function callbacks. Policies are created by
sj_pol_new() and filled in with
sj_pol_set(). Policies may be changed at any time during system run-time with
sj_pol_set(). This function dictates the routes taken by interceptions under given emulation modes.
The general strategy for a policy is to register a system call for all potential emulations. For example, to intercept
fcntl(2), one may set appropriate call-backs for 92 (native on OpenBSD) and 55 (Linux emulation). In many events, this call-back may be the same; however, some calls have different semantics between unices.
Once one or more policies have been generated and (optionally) filled-in, they may be assigned to processes with
sj_execv(). Policies are inherited by the children of the process executed by this function.
Finally, one begins the event loop with
sj_poll(). This function does not return until a
SIGTERM is detected, all controlled processes exit, or a call-back function returns an exit request. Before exiting the process,
sj_teardown() should be called to reclaim all resources properly.