Ejemplo n.º 1
0
//	////////////////////////////////////////////////////////////////////////////
int LSF_initrex(unsigned int numports, int options)
{
	int result;

	if ((result = ls_initrex(numports, options)) == -1) {
		std::ostringstream error_text;
		error_text << "Invocation of 'ls_initrex(" << numports << ", " <<
			options << ")' returned " << result << ".";
		throw MLB::LSFWrapper::LSFExceptionStatus(lserrno,	error_text);
	}

	return(result);
}
Ejemplo n.º 2
0
static int
useTmp (char *exHost, char *fname)
{
  int pid;
  LS_WAIT_T status;
  struct stat st;
  char *fName;

  fName = "useTmp";
  if ((pid = fork ()) == 0)
    {
      if (ls_initrex (1, 0) < 0)
	{
	  ls_perror ("ls_initrex");
	  exit (FALSE);
	}

      ls_rfcontrol (RF_CMD_RXFLAGS, REXF_CLNTDIR);

      if (ls_rstat (exHost, fname, &st) < 0)
	{
	  if (lserrno == LSE_FILE_SYS && (errno == ENOENT || errno == EACCES))
	    {
	      exit (TRUE);
	    }

	  ls_perror ("ls_rstat");
	}

      exit (FALSE);
    }

  if (pid == -1)
    {
      perror ("fork");
      return (FALSE);
    }

  if (waitpid (pid, &status, 0) == -1)
    {
      perror ("waitpid");
      return (FALSE);
    }

  return (WEXITSTATUS (status));
}
Ejemplo n.º 3
0
static void
remoteOutput (int fidx, char **disOut, char *exHost, char *fname,
	      char *execUsername, char **envp)
{
  char buf[MAXFILENAMELEN];
  char *args[MAX_PEEK_ARGS + 4];
  char lsfUserName[MAXLINELEN];

#   define RSHCMD "rsh"

  if ((getLSFUser_ (lsfUserName, MAXLINELEN) == 0)
      && strcmp (lsfUserName, execUsername))
    {


      if (useTmp (exHost, fname))
	{
	  sprintf (buf, "/tmp/.lsbtmp%d/%s", (int) getuid (), fname);
	  disOut[fidx] = buf;
	}
      else
	{
	  disOut[fidx] = fname;
	}

      args[0] = RSHCMD;
      args[1] = exHost;
      args[2] = "-l";
      args[3] = execUsername;
      if (fidx == 2)
	{
	  args[4] = disOut[0];
	  args[5] = disOut[1];
	  args[6] = disOut[2];
	  args[7] = NULL;
	}
      else
	{
	  args[4] = disOut[0];
	  args[5] = disOut[1];
	  args[6] = NULL;
	}


      lsfExecvp (RSHCMD, args);
      fprintf (stderr, I18N_FUNC_S_S_FAIL_S, "execvp", args[0],
	       strerror (errno));
      return;
    }

  if (useTmp (exHost, fname))
    {
      sprintf (buf, "/tmp/.lsbtmp%d/%s", (int) getuid (), fname);
      disOut[fidx] = buf;
    }
  else
    disOut[fidx] = fname;

  if (ls_initrex (1, 0) < 0)
    {
      ls_perror ("ls_initrex");
      return;
    }

  ls_rfcontrol (RF_CMD_RXFLAGS, REXF_CLNTDIR);
  ls_rexecve (exHost, disOut, REXF_CLNTDIR, envp);

  fprintf (stderr, I18N_FUNC_S_S_FAIL_S, "ls_rexecv", disOut[0],
	   ls_sysmsg ());

}
Ejemplo n.º 4
0
int
main( int argc, char *argv[] )
{

    lsRcpXfer lsXfer;
    int iCount;
    char* buf;
    int rc;

    rc = _i18n_init ( I18N_CAT_MIN );


    Signal_(SIGUSR1, SIG_IGN);



    if (ls_initdebug(argv[0]) < 0) {
        ls_perror("ls_initdebug");
        exit(-1);
    }


    if (ls_initrex(1,0) == -1) {
        ls_perror("lsrcp: ls_initrex");
        return(-1);
    }


    ls_rfcontrol(RF_CMD_RXFLAGS, REXF_CLNTDIR);


    if (setuid(getuid()) < 0) {
        perror("lsrcp: setuid");
        goto handle_error;
    }

    if (createXfer(&lsXfer)) {
        perror("lsrcp");
        goto handle_error;
    }

    doXferOptions(&lsXfer, argc, argv);



    buf = (char*)malloc(LSRCP_MSGSIZE);
    if(!buf) {

        ls_donerex();
        ls_syslog(LOG_ERR, I18N_FUNC_FAIL_S,"lsrcp","main",
	    _i18n_msg_get(ls_catd,NL_SETN,2301,"try rcp...")); /* catgets 2301 */
        if (doXferRcp(&lsXfer, 0) < 0)
            return(-1);
        return(0);
    }
    for (iCount=0;iCount < lsXfer.iNumFiles; iCount++) {
        if (copyFile(&lsXfer, buf, 0)) {

                ls_donerex();
        	ls_syslog(LOG_ERR, I18N_FUNC_FAIL_S,"lsrcp","main",
		    _i18n_msg_get(ls_catd,NL_SETN,2301,"try rcp..."));
                if (doXferRcp(&lsXfer, 0) < 0)
		    return(-1);
                return(0);
        }
	if (logclass & (LC_FILE))
            ls_syslog(LOG_DEBUG, "main(), copy file succeeded.");
    }
    free(buf);

    ls_donerex();

    if (destroyXfer(&lsXfer)) {
        perror("lsrcp");
        return(-1);
    }


    _i18n_end ( ls_catd );

    return(0);

handle_error:
    ls_donerex();
    return(-1);

}