Managing interpreter versions is done by means of manipulating a set of symbolic links that point to different versions of interpreter binaries. For example, if default PHP binary is /usr/local/bin/php:
•First we move the default binary inside CageFS to /usr/share/cagefs-skeleton/usr/selector, and make /usr/local/bin/php a symlink pointing to /etc/cl.selector/php. This operation is done as part of CageFS deployment.
•Next suppose we have additional PHP version, say 5.4.2. The information about all additional interpreter binaries and paths for them is kept in /etc/cl.selelector/selector.conf. This config file is updated by RPM package manager each time alternative PHP package is added, removed or updated
•/usr/bin/cl-selector --list=php will get us list of all available PHP interpreter versions out of /etc/cl.selector/selector.conf file.
Next we want to know which PHP version is active for a given user (to supply a selected option in options list). We type:
•/usr/bin/cl-selector --current=php --user=USERNAME will retrieve PHP version set for a particular user. The script gets the path from /var/cagefs/USERID/USERNAME/etc/cl.sel/php symlink, compares it with contents of /etc/cl.selector/selector.conf file and if path is valid, prints out the current interpreter version.
•/usr/bin/cl-selector --select=php --version=5.3 --user=USERNAME sets the current PHP version for particular user by creating symlink in /var/cagefs/USERID/USERNAME/etc/cl.selector directory. All old symlinks are removed, and new symlinks are set.