Here is the source code of the login script mentioned previously.
Vsys scripts receive as their first argument the name of the client slice. In this case, the script outputs the lines in the file /var/log/secure that contain the name of the slice, indicating login events involving the slice user. This output is sent to the slice via the corresponding output entry (login.out).
Input is received via STDIN. Consider the following script, written in C, for fetching pathnames based on an in-kernel tag called a directory cookie, used to temporarily save a filename and to restore it afterwards.
The script reads the values of the cookies via standard input, looks up the corresponding pathnames and sends them to the slice via standard output.
VSys scripts can be of two types: stateless and stateful. The example scripts defined thus far are stateless, in that they are instantiated anew for each request and do not retain any state between invocations. Scripts can also be persistent if need be. Writing a persistent script is easy - run in a loop and do not terminate. Instead, go to sleep, waiting for subsequent input. For such scripts, VSys keeps track of the pid of the first instance of the script and reuses this instance for subsequent interactions. Stateful scripts need to be prefixed with the string daem_ to indicate to Vsys that they are stateful. Here is an example of a stateful script (``daem_counter''):
In order to deploy such scripts, please make sure that the PERSISTENT flag is set in the Makefile at compilation time.