On success, ls_initrex() initializes the LSLIB for remote execution. If your application is installed as a setuid program, ls_initrex() returns the number of socket descriptors bound to privileged ports. If your program is not installed as a setuid to root program, ls_initrex() returns numports on success.
On failure, ls_initrex() returns ‑1 and sets the global variable lserrno to indicate the error.
ls_initrex() has the following parameters:
If your program is installed as a setuid to root program, numports file descriptors, starting from FIRST_RES_SOCK (defined in <lsf/lsf.h>), are bound to privileged ports by ls_initrex(). These sockets are used only for remote connections to RES. If numports is 0, then the system will use the default value LSF_DEFAULT_SOCKS defined in lsf.h.
By default, ls_initrex() restores the effective user ID to real user ID if the program is installed as a setuid to root program. If options is set to KEEPUID (defined in lsf.h), ls_initrex() preserves the current effective user ID. This option is useful if the application needs to be a setuid to root program for some other purpose as well and does not want to go back to real user ID immediately after ls_initrex().
ls_initrex() function selects the security option according to the following rule: if the application program invoking it has an effective uid of root, then privileged ports are created. If there are no privileged port created and, at remote task start-up time, RES will use the authentication protocol defined by LSF_AUTH in the lsf.conf file.