Initialize an application for remote execution

Before executing a task remotely, an application must call the ls_initrex():

int ls_initrex(numports, options)

ls_initrex()

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.

Tip:

ls_initrex() must be called before any other remote execution function (see ls_rex(3)) or any remote file operation function (see ls_rfs(3)) in LSLIB can be called.

ls_initrex() has the following parameters:

int numports;    The number of priviliged ports to create 
int options;      Either KEEPUID or 0

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().

CAUTION:

If KEEPUID flag is set in options, you must make sure that your application restores back to the real user ID at a proper time of the program execution.

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.