Exemplo n.º 1
0
void
myexecv_ (char *filename, char **argv, struct hostent *hp)
{
  char fnamebuf[MAXFILENAMELEN];
  char *mp;

  if (!hp || filename[0] != '/' || AM_NEVER)
    {
      lsfExecv (usePath (filename), argv);
      return;
    }

  if (AM_LAST)
    {
      lsfExecv (usePath (filename), argv);
      return;
    }

  if (strstr (filename, "/net/") == filename)
    {
      lsfExecv (usePath (filename), argv);
      return;
    }

  if (strstr (filename, "/tmp_mnt/") == filename)
    {
      lsfExecv (usePath (filename), argv);
      return;
    }

  if ((mp = mountNet_ (hp)) == NULL)
    {
      lsfExecv (usePath (filename), argv);
      return;
    }

  sprintf (fnamebuf, "%s%s", mp, filename);
  lsfExecv (usePath (fnamebuf), argv);

  lsfExecv (usePath (filename), argv);

}
Exemplo n.º 2
0
void
myexecv_(char *filename, char **argv, struct hostent *hp)
{
    char fnamebuf[MAXFILENAMELEN];
    char *mp;

    /*Bug#169, set hp to NULL to let the function do operation directly
     * and do not try /net and /tmp_mnt
     */
    hp = NULL;

    if (!hp || filename[0] != '/' || AM_NEVER) {
        lsfExecv(usePath(filename), argv);
	return;
    }

    if (AM_LAST) {
        lsfExecv(usePath(filename), argv);
        return;
    }

    if (strstr(filename, "/net/") == filename) {
	lsfExecv(usePath(filename), argv);
	return;
    }

    if (strstr(filename, "/tmp_mnt/") ==filename) {
	lsfExecv(usePath(filename), argv);
	return;
    }

    if ((mp=mountNet_(hp)) == NULL) {
	lsfExecv(usePath(filename), argv);
	return;
    }

    sprintf(fnamebuf, "%s%s", mp, filename);
    lsfExecv(usePath(fnamebuf), argv);

    lsfExecv(usePath(filename), argv);

}
Exemplo n.º 3
0
int
resParent (int s, struct passwd *pw, struct lsfAuth *auth,
	   struct resConnect *connReq, struct hostent *hostp)
{
  static char fname[] = "resParent";
  int cc;
  char *argv[7];
  char hndlbuf[64];
  struct resChildInfo childInfo;
  char buf[2 * MSGSIZE];
  XDR xdrs;
  int len;
  struct LSFHeader hdr;
  int hpipe[2];
  int wrapPipe[2];
  int pid;

  if (resParams[LSF_SERVERDIR].paramValue != NULL)
    {
      argv[0] = getDaemonPath_ ("/res", resParams[LSF_SERVERDIR].paramValue);
    }
  else
    {
      argv[0] = "res";
    }

  childInfo.resConnect = connReq;
  childInfo.lsfAuth = auth;
  childInfo.pw = pw;
  childInfo.host = hostp;
  childInfo.parentPort = ctrlAddr.sin_port;
  childInfo.currentRESSN = currentRESSN;


  if (resLogOn == 1)
    {
      char strLogCpuTime[32];

      sprintf (strLogCpuTime, "%d", resLogcpuTime);
      putEnv ("LSF_RES_LOGON", "1");
      putEnv ("LSF_RES_CPUTIME", strLogCpuTime);
      putEnv ("LSF_RES_ACCTPATH", resAcctFN);
    }
  else if (resLogOn == 0)
    {
      putEnv ("LSF_RES_LOGON", "0");
    }
  else if (resLogOn == -1)
    {
      putEnv ("LSF_RES_LOGON", "-1");
    }

  xdrmem_create (&xdrs, buf, 2 * MSGSIZE, XDR_ENCODE);
  memset ((void *) &hdr, 0, sizeof (struct LSFHeader));
  hdr.version = OPENLAVA_VERSION;
  if (!xdr_resChildInfo (&xdrs, &childInfo, &hdr))
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL, fname, "xdr_resChildInfo");
      return (-1);
    }
  len = XDR_GETPOS (&xdrs);

  if (socketpair (AF_UNIX, SOCK_STREAM, 0, hpipe) < 0)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "socketpair");
      return (-1);
    }
  if (socketpair (AF_UNIX, SOCK_STREAM, 0, wrapPipe) < 0)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "socketpair");
      return (-1);
    }
  sprintf (hndlbuf, "%d:%d", hpipe[1], s);

  cc = 1;
  argv[cc++] = "-d";
  argv[cc++] = env_dir;
  if (debug)
    {
      if (debug == 1)
	argv[cc++] = "-1";
      else
	argv[cc++] = "-2";
      argv[cc++] = "-s";
      argv[cc++] = hndlbuf;
      argv[cc++] = NULL;
    }
  else
    {
      argv[cc++] = "-s";
      argv[cc++] = hndlbuf;
      argv[cc++] = NULL;
    }


  if (getenv ("LSF_SETDCEPAG") == NULL)
    putEnv ("LSF_SETDCEPAG", "Y");

  pid = fork ();
  if (pid < 0)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "fork");
      close (hpipe[0]);
      close (hpipe[1]);
      close (wrapPipe[0]);
      close (wrapPipe[1]);
      return (-1);
    }

  if (pid == 0)
    {
      if (logclass & LC_TRACE)
	{
	  if (debug)
	    {
	      ls_syslog (LOG_DEBUG2, "%s: executing %s %s %s %s %s %s ",
			 fname, argv[0], argv[1], argv[2], argv[3], argv[4],
			 argv[5]);
	    }
	  else
	    {
	      ls_syslog (LOG_DEBUG2, "%s: executing %s %s %s %s %s ",
			 fname, argv[0], argv[1], argv[2], argv[3], argv[4]);
	    }
	}
      close (hpipe[0]);
      close (wrapPipe[0]);


      if (dup2 (wrapPipe[1], 0) == -1)
	{
	  ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "dup2");
	  exit (-1);
	}
      close (wrapPipe[1]);
      lsfExecv (argv[0], argv);
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "execv");
      exit (-1);
    }

  close (hpipe[1]);
  close (wrapPipe[1]);

  if (connReq->eexec.len > 0)
    {
      int cc1;
      if ((cc1 = b_write_fix (wrapPipe[0], connReq->eexec.data,
			      connReq->eexec.len)) != connReq->eexec.len)
	{
	  ls_syslog (LOG_ERR, _i18n_msg_get (ls_catd, NL_SETN, 5333, "%s: Falied in sending data to wrap for user <%s>, length = %d, cc=1%d: %m"), fname, pw->pw_name, connReq->eexec.len, cc1)	/* catgets 5333 */
	    ;
	  close (wrapPipe[0]);
	  close (hpipe[0]);
	  return (-1);
	}
    }
  close (wrapPipe[0]);

  if (write (hpipe[0], (char *) &len, sizeof (len)) != sizeof (len))
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "write");
      xdr_destroy (&xdrs);
      close (hpipe[0]);
      return (-1);
    }

  if (write (hpipe[0], buf, len) != len)
    {
      ls_syslog (LOG_ERR, I18N_FUNC_FAIL_M, fname, "write");
      xdr_destroy (&xdrs);
      close (hpipe[0]);
      return (-1);
    }
  xdr_destroy (&xdrs);
  close (hpipe[0]);
  return (0);
}