Beispiel #1
0
static int
getEAuth(struct eauth *eauth, char *host)
{
    char *argv[4];
    char path[MAXPATHLEN];
    struct lenData ld;

    memset(path,0,sizeof(path));
    ls_strcat(path,sizeof(path),genParams_[LSF_SERVERDIR].paramValue);
    ls_strcat(path,sizeof(path),"/");
    ls_strcat(path,sizeof(path),EAUTHNAME);
    argv[0] = path;
    argv[1] = "-c";
    argv[2] = host;
    argv[3] = NULL;

    if (logclass & LC_TRACE)
        ls_syslog(LOG_DEBUG, "runEAuth(): path=<%s>", path);

    if (runEClient_(&ld, argv) == -1) {
        if (logclass & (LC_AUTH |LC_TRACE))
            ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL,  "runEAuth", "runEClient", path);
        lserrno = LSE_EAUTH;
        return -1;
    }

    if (ld.len == 0) {
        if (logclass & (LC_AUTH |LC_TRACE))
            ls_syslog(LOG_DEBUG, "runEAuth: <%s> got no data", path);
        FREEUP(ld.data);
        lserrno = LSE_EAUTH;
        return -1;
    }

    if (ld.len > EAUTH_SIZE) {
        if (logclass & (LC_AUTH |LC_TRACE))
            ls_syslog(LOG_DEBUG, "runEAuth: <%s> got too much data, size=%d",
                      path, ld.len);
        FREEUP(ld.data);
        lserrno = LSE_EAUTH;
        return -1;
    }

    memcpy(eauth->data, ld.data, ld.len);
    eauth->data[ld.len] = '\0';
    if (logclass & (LC_AUTH |LC_TRACE))
        ls_syslog(LOG_DEBUG, "runEAuth: <%s> got data=%s",
                  path, ld.data);
    eauth->len = ld.len;

    FREEUP(ld.data);
    if (logclass & (LC_AUTH |LC_TRACE))
        ls_syslog(LOG_DEBUG, "runEAuth: <%s> got len=%d",
                  path, ld.len);

    return 0;

}
Beispiel #2
0
int
verifyEAuth_(struct lsfAuth *auth, struct sockaddr_in *from)
{
    static char fname[] = "verifyEAuth/lib.eauth.c";
    char path[MAXPATHLEN], uData[256], ok;
    char *eauth_client, *eauth_server, *eauth_aux_data, *eauth_aux_status;
    int cc, i;
    static int connected = FALSE;
    static int in[2], out[2];

    if (logclass & LC_TRACE)
        ls_syslog(LOG_DEBUG, "%s ...", fname);

    if (!(genParams_[LSF_AUTH].paramValue &&
          !strcmp(genParams_[LSF_AUTH].paramValue, AUTH_PARAM_EAUTH)))
        return -1;

    eauth_client = getenv("LSF_EAUTH_CLIENT");
    eauth_server = getenv("LSF_EAUTH_SERVER");
    eauth_aux_data = getenv("LSF_EAUTH_AUX_DATA");
    eauth_aux_status = getenv("LSF_EAUTH_AUX_STATUS");

    sprintf(uData, "%d %d %s %s %d %d %s %s %s %s\n", auth->uid, auth->gid,
            auth->lsfUserName, inet_ntoa(from->sin_addr),
            (int) ntohs(from->sin_port), auth->k.eauth.len,
            (eauth_client ? eauth_client : "NULL"),
            (eauth_server ? eauth_server : "NULL"),
            (eauth_aux_data ? eauth_aux_data : "NULL"),
            (eauth_aux_status ? eauth_aux_status : "NULL"));

    memset(path,0,sizeof(path));
    ls_strcat(path,sizeof(path),genParams_[LSF_SERVERDIR].paramValue);
    ls_strcat(path,sizeof(path),"/");
    ls_strcat(path,sizeof(path),EAUTHNAME);

    if (logclass & (LC_AUTH | LC_TRACE))
        ls_syslog(LOG_DEBUG, "%s: <%s> path <%s> connected=%d", fname, uData,
                  path, connected);

    if (connected) {
        struct timeval tv;
        fd_set  mask;

        FD_ZERO(&mask);
        FD_SET(out[0], &mask);

        tv.tv_sec = 0;
        tv.tv_usec = 0;

        if ((cc = select(out[0] + 1, &mask, NULL, NULL, &tv)) > 0) {
            if (logclass & (LC_AUTH | LC_TRACE))
                ls_syslog(LOG_DEBUG, "%s: <%s> got exception",
                          fname, uData);
            connected = FALSE;
            close(in[1]);
            close(out[0]);
        } else {
            if (cc < 0)
                ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "select", uData);
        }

        if (logclass & (LC_AUTH | LC_TRACE))
            ls_syslog(LOG_DEBUG, "%s: <%s> select returned cc=%d", fname,
                      uData, cc);

    }

    if (!connected) {

        int pid;
        char *user;

        {
            if ((user = getLSFAdmin()) == NULL) {
                return -1;
            }
        }

        if (pipe(in) < 0) {
            ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "pipe(in)", uData);
            lserrno = LSE_SOCK_SYS;
            return -1;
        }

        if (pipe(out) < 0) {
            ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "pipe(out)", uData);
            lserrno = LSE_SOCK_SYS;
            return -1;
        }


        if ((pid = fork()) == 0) {
            char *myargv[3];
            struct passwd *pw;

            if ((pw = getpwnam(user)) == (struct passwd *)NULL) {
                ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "getpwnam", user);
                exit(-1);
            }

            if (setuid(pw->pw_uid) < 0) {
                ls_syslog(LOG_ERR, I18N_FUNC_D_FAIL_M, fname, "setuid", (int)pw->pw_uid);
                exit(-1);
            }

            for (i = 1; i < NSIG; i++)
                Signal_(i, SIG_DFL);

            alarm(0);

            close(in[1]);
            if (dup2(in[0], 0) == -1) {
                ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "dup2(in[0])", uData);
            }

            close(out[0]);
            if (dup2(out[1], 1) == -1) {
                ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "dup2(out[1])", uData);
            }

            for (i = 3; i < sysconf(_SC_OPEN_MAX); i++)
                close(i);

            myargv[0] = path;
            myargv[1] = "-s";
            myargv[2] = NULL;

            execvp(myargv[0], myargv);
            ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "execvp", myargv[0]);
            exit(-1);
        }

        close(in[0]);
        close(out[1]);

        if (pid == -1) {
            ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_M, fname, "fork", path);
            close(in[1]);
            close(out[0]);
            lserrno = LSE_FORK;
            return -1;
        }

        connected = TRUE;
    }

    i = strlen(uData);

    if ((cc = b_write_fix(in[1], uData, i)) != i) {
        ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5513,
                                         "%s: b_write_fix <%s> failed, cc=%d, i=%d: %m"), /* catgets 5513 */
                  fname, uData, cc, i);
        CLOSEHANDLE(in[1]);
        CLOSEHANDLE(out[0]);
        connected = FALSE;
        return -1;
    }
    if(logclass & (LC_AUTH | LC_TRACE))
        ls_syslog(LOG_DEBUG, _i18n_msg_get(ls_catd , NL_SETN, 5514,
                                           "%s: b_write_fix <%s> ok, cc=%d, i=%d"),
                  fname, uData, cc, i);

    if ((cc = b_write_fix(in[1], auth->k.eauth.data, auth->k.eauth.len))
        != auth->k.eauth.len) {
        ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5515,
                                         "%s: b_write_fix <%s> failed, eauth.len=%d, cc=%d"), /* catgets 5515 */
                  fname, uData, auth->k.eauth.len, cc);
        CLOSEHANDLE(in[1]);
        CLOSEHANDLE(out[0]);
        connected = FALSE;
        return -1;
    }
    if(logclass & (LC_AUTH | LC_TRACE))
        ls_syslog(LOG_DEBUG, _i18n_msg_get(ls_catd , NL_SETN, 5516,
                                           "%s: b_write_fix <%s> ok, eauth.len=%d, eauth.data=%.*s cc=%d:"),
                  fname, uData, auth->k.eauth.len,
                  auth->k.eauth.len, auth->k.eauth.data,cc);

    if ((cc = b_read_fix(out[0], &ok, 1)) != 1) {
        ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5517,
                                         "%s: b_read_fix <%s> failed, cc=%d: %m"), /* catgets 5517 */
                  fname, uData, cc);
        CLOSEHANDLE(in[1]);
        CLOSEHANDLE(out[0]);
        connected = FALSE;
        return -1;
    }

    if (ok != '1') {
        ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5518,
                                         "%s: eauth <%s> len=%d failed, rc=%c"), /* catgets 5518 */
                  fname, uData, auth->k.eauth.len, ok);
        return -1;
    }

    return 0;
}
static int
badminDebug (int nargc, char *nargv[], int opCode)
{

  struct hostInfoEnt *hostInfo;

  char opt[10];
  char **hostPoint;
  char *word;

  char **hosts = NULL;
  int i, c;
  int send;
  int retCode = 0;
  int all = FALSE, numHosts = 0;
  struct debugReq debug;




  debug.opCode = opCode;
  debug.logClass = 0;
  debug.level = 0;
  debug.hostName = NULL;

  debug.logFileName[0] = '\0';
  debug.options = 0;

  if (opCode == MBD_DEBUG || opCode == SBD_DEBUG)
    strcpy (opt, "oc:l:f:");
  else if (opCode == MBD_TIMING || opCode == SBD_TIMING)
    strcpy (opt, "ol:f:");
  else
    return (-2);
  linux_optind = 1;
  linux_opterr = 1;
  if (strstr (nargv[0], "badmin"))
    {
      linux_optind++;
    }
  while ((c = getopt (nargc, nargv, opt)) != EOF)
    {

      switch (c)
	{
	case 'c':
	  while (optarg != NULL && (word = getNextWord_ (&optarg)))
	    {
	      if (strcmp (word, "LC_SCHED") == 0)
		debug.logClass |= LC_SCHED;

	      if (strcmp (word, "LC_EXEC") == 0)
		debug.logClass |= LC_EXEC;

	      if (strcmp (word, "LC_TRACE") == 0)
		debug.logClass |= LC_TRACE;

	      if (strcmp (word, "LC_COMM") == 0)
		debug.logClass |= LC_COMM;

	      if (strcmp (word, "LC_XDR") == 0)
		debug.logClass |= LC_XDR;

	      if (strcmp (word, "LC_CHKPNT") == 0)
		debug.logClass |= LC_CHKPNT;

	      if (strcmp (word, "LC_FILE") == 0)
		debug.logClass |= LC_FILE;

	      if (strcmp (word, "LC_AUTH") == 0)
		debug.logClass |= LC_AUTH;

	      if (strcmp (word, "LC_HANG") == 0)
		debug.logClass |= LC_HANG;

	      if (strcmp (word, "LC_SIGNAL") == 0)
		debug.logClass |= LC_SIGNAL;

	      if (strcmp (word, "LC_PIM") == 0)
		debug.logClass |= LC_PIM;

	      if (strcmp (word, "LC_SYS") == 0)
		debug.logClass |= LC_SYS;

	      if (strcmp (word, "LC_JLIMIT") == 0)
		debug.logClass |= LC_JLIMIT;

	      if (strcmp (word, "LC_PEND") == 0)
		debug.logClass |= LC_PEND;

	      if (strcmp (word, "LC_LOADINDX") == 0)
		debug.logClass |= LC_LOADINDX;

	      if (strcmp (word, "LC_M_LOG") == 0)
		{
		  debug.logClass |= LC_M_LOG;
		}

	      if (strcmp (word, "LC_PERFM") == 0)
		{
		  debug.logClass |= LC_PERFM;
		}

	      if (strcmp (word, "LC_MPI") == 0)
		{
		  debug.logClass |= LC_MPI;
		}

	      if (strcmp (word, "LC_JGRP") == 0)
		{
		  debug.logClass |= LC_JGRP;
		}

	    }
	  if (debug.logClass == 0)
	    {
	      fprintf (stderr, I18N (2572, "Command denied.Invalid class name\n"));	/* catgets 2572 */
	      return (-1);
	    }
	  break;

	case 'l':
	  for (i = 0; i < strlen (optarg); i++)
	    {
	      if (!isdigit (optarg[i]))
		{
		  fprintf (stderr, I18N (2573, "Command denied. Invalid level value\n"));	/* catgets 2573 */
		  return (-1);
		}
	    }
	  debug.level = atoi (optarg);
	  if (opCode == MBD_DEBUG || opCode == SBD_DEBUG)
	    {
	      if (debug.level < 0 || debug.level > 3)
		{
		  fprintf (stderr, I18N (2574, "Command denied. Valid debug level is [0-3] \n"));	/* catgets 2574 */
		  return (-1);
		}
	    }
	  else if (debug.level < 1 || debug.level > 5)
	    {
	      fprintf (stderr, I18N (2575, "Command denied. Valid timing level is [1-5]\n"));	/* catgets 2575 */
	      return (-1);
	    }
	  break;

	case 'f':
	  if (strstr (optarg, "/") && strstr (optarg, "\\"))
	    {
	      fprintf (stderr, I18N (2576, "Command denied. Invalid file name\n"));	/*  catgets 2576 */
	      return (-1);
	    }
	  memset (debug.logFileName, 0, sizeof (debug.logFileName));
	  ls_strcat (debug.logFileName, sizeof (debug.logFileName), optarg);
	  if (debug.logFileName[strlen (debug.logFileName) - 1] == '/' ||
	      debug.logFileName[strlen (debug.logFileName) - 1] == '\\')
	    {
	      fprintf (stderr, I18N (2577, "Command denied. File name is needed after the path\n"));	/*  catgets 2577 */
	      return (-1);
	    }
	  break;
	case 'o':
	  debug.options = 1;
	  break;

	default:
	  return (-2);
	}
    }


  if (opCode == SBD_DEBUG || opCode == SBD_TIMING)
    {

      numHosts = getNames (nargc, nargv, optind, &hosts, &all, "hostC");
      hostPoint = NULL;
      if (!numHosts && !all)
	numHosts = 1;
      else if (numHosts)
	hostPoint = hosts;

      if ((hostInfo = lsb_hostinfo (hostPoint, &numHosts)) == NULL)
	{
	  lsb_perror (NULL);
	  return (-1);
	}

      for (i = 0; i < numHosts; i++)
	{
	  if (strcmp (hostInfo[i].host, "lost_and_found") == 0)
	    {
	      if (!all)
		fprintf (stderr, "%s.\n", _i18n_msg_get (ls_catd, NL_SETN, 2568, "<lost_and_found> is not a real host, ignored"));	/* catgets  2568  */
	      continue;
	    }

	  fflush (stderr);
	  if (hostInfo[i].hStatus & (HOST_STAT_UNAVAIL | HOST_STAT_UNREACH))
	    {
	      if (hostInfo[i].hStatus & HOST_STAT_UNAVAIL)
		fprintf (stderr, I18N (2578, "failed : LSF daemon (LIM) is unavailable on host %s\n"),	/* catgets 2578 */
			 hostInfo[i].host);
	      else
		fprintf (stderr, I18N (2579, "failed : Slave batch daemon (sbatchd) is unreachable now on host %s\n"),	/* catgets 2579 */
			 hostInfo[i].host);
	      continue;
	    }

	  if ((send = lsb_debugReq (&debug, hostInfo[i].host)) < 0)
	    {
	      char msg[100];
	      sprintf (msg, I18N (2580, "Operation denied by SBD on <%s>"),	/* catgets 2580 */
		       hostInfo[i].host);
	      lsb_perror (msg);
	      retCode = -1;
	    }
	}
      return (retCode);
    }

  else
    {
      numHosts = getNames (nargc, nargv, optind, &hosts, &all, "hostC");
      if (numHosts > 0)
	{
	  fprintf (stderr, I18N (2581, "Host name does not need to be specified, set debug to the host which runs MBD\n"));	/* catgets 2581 */
	}
      if ((send = lsb_debugReq (&debug, NULL)) < 0)
	{

	  char msg[100];
	  sprintf (msg, I18N (2582, "Operation denied by MBD"));	/* catgets 2582 */
	  lsb_perror (msg);
	  return (-1);
	}
    }
  return (0);

}
Beispiel #4
0
int
ctrlSbdDebug(struct debugReq  *pdebug)
{
    static char   fname[]="ctrlSbdDebug()";
    int           opCode;
    int           level;
    int           newClass;
    int           options;
    char          logFileName[MAXLSFNAMELEN];
    char          lsfLogDir[MAXPATHLEN];
    char          *dir;
    char          dynDbgEnv[MAXPATHLEN];

    memset(logFileName, 0, sizeof(logFileName));
    memset(lsfLogDir, 0, sizeof(lsfLogDir));

    opCode = pdebug->opCode;
    level = pdebug->level;
    newClass = pdebug->logClass;
    options = pdebug->options;

    if (pdebug->logFileName[0] != '\0') {
        if (((dir = strrchr(pdebug->logFileName,'/')) != NULL) ||
            ((dir = strrchr(pdebug->logFileName,'\\')) != NULL)) {
            dir++;
            ls_strcat(logFileName, sizeof(logFileName), dir);
            *(--dir) = '\0';
            ls_strcat(lsfLogDir, sizeof(lsfLogDir), pdebug->logFileName);
        }
        else {
            ls_strcat(logFileName, sizeof(logFileName), pdebug->logFileName);
            if (daemonParams[LSF_LOGDIR].paramValue
                && *(daemonParams[LSF_LOGDIR].paramValue)) {
                ls_strcat(lsfLogDir, sizeof(lsfLogDir),
                          daemonParams[LSF_LOGDIR].paramValue);
            }
            else {
                lsfLogDir[0] = '\0';
            }
        }
        ls_strcat(logFileName, sizeof(logFileName), ".sbatchd");
    }
    else {
  	ls_strcat(logFileName, sizeof(logFileName), "sbatchd");
        if (daemonParams[LSF_LOGDIR].paramValue
            && *(daemonParams[LSF_LOGDIR].paramValue)) {
            ls_strcat(lsfLogDir, sizeof(lsfLogDir),
                      daemonParams[LSF_LOGDIR].paramValue);
        } else {
            lsfLogDir[0] = '\0';
        }
    }

    if (options==1) {
        struct config_param *plp;
        for (plp = daemonParams; plp->paramName != NULL; plp++) {
            if (plp->paramValue != NULL)
                FREEUP(plp->paramValue);
        }

        if (initenv_(daemonParams, env_dir) < 0){
            ls_openlog("sbatchd", daemonParams[LSF_LOGDIR].paramValue,
                       (debug > 1), daemonParams[LSF_LOG_MASK].paramValue);
  	    ls_syslog(LOG_ERR, I18N_FUNC_FAIL_MM, fname, "initenv_");
            die(SLAVE_FATAL);
            return -1;
        }

        getLogClass_(daemonParams[LSB_DEBUG_SBD].paramValue,
                     daemonParams[LSB_TIME_SBD].paramValue);
        closelog();
        if (debug > 1)
            ls_openlog("sbatchd", daemonParams[LSF_LOGDIR].paramValue, TRUE,
                       daemonParams[LSF_LOG_MASK].paramValue);
        else
            ls_openlog("sbatchd", daemonParams[LSF_LOGDIR].paramValue, FALSE,
                       daemonParams[LSF_LOG_MASK].paramValue);

        if (logclass & LC_TRACE)
            ls_syslog(LOG_DEBUG, "%s: logclass=%x", fname, logclass);

        cleanDynDbgEnv();

        return(LSBE_NO_ERROR);
    }

    if (opCode==SBD_DEBUG) {
        putMaskLevel(level, &(daemonParams[LSF_LOG_MASK].paramValue));

        if (newClass>=0) {
            logclass = newClass;

            sprintf(dynDbgEnv, "%d", logclass);
            putEnv("DYN_DBG_LOGCLASS", dynDbgEnv);
        }

        if ( pdebug->level>=0 ){
            closelog();
            if (debug > 1)
                ls_openlog(logFileName, lsfLogDir, TRUE,
                           daemonParams[LSF_LOG_MASK].paramValue);
            else
                ls_openlog(logFileName, lsfLogDir, FALSE,
                           daemonParams[LSF_LOG_MASK].paramValue);

            putEnv("DYN_DBG_LOGDIR", lsfLogDir);
            putEnv("DYN_DBG_LOGFILENAME", logFileName);
            sprintf(dynDbgEnv, "%d", pdebug->level);
            putEnv("DYN_DBG_LOGLEVEL", dynDbgEnv);
        }
    }
    else if (opCode == SBD_TIMING) {
        if (level>=0)
 	    timinglevel = level;
        if (pdebug->logFileName[0] != '\0') {
            if (debug > 1)
                ls_openlog(logFileName, lsfLogDir,
                           TRUE, daemonParams[LSF_LOG_MASK].paramValue);
            else
                ls_openlog(logFileName, lsfLogDir,
                           FALSE, daemonParams[LSF_LOG_MASK].paramValue);
        }
    }
    else {
        ls_perror("No this debug command!\n");
        return -1;
    }
    return (LSBE_NO_ERROR);
}
Beispiel #5
0
int
searchEventFile(struct histReq *req, int *eventFound)
{
    char eventFileName[MAXFILENAMELEN];
    int lineNum = 0;
    struct stat statBuf;
    struct eventRec *log;
    FILE *log_fp;
    char *envdir;

    struct config_param histParams[] = {
#define LSB_SHAREDIR 0
        {"LSB_SHAREDIR", NULL},
        {NULL, NULL}
    };

    if ((envdir = getenv("LSF_ENVDIR")) == NULL)
	envdir = "/etc";

    if (ls_readconfenv(histParams, envdir) < 0) {
	ls_perror("ls_readconfenv");
	return(-1);
    }

    if (!req->eventFileName) {
	memset(eventFileName, 0, sizeof(eventFileName));
	ls_strcat(eventFileName, sizeof(eventFileName),
                  histParams[LSB_SHAREDIR].paramValue);
	ls_strcat(eventFileName, sizeof(eventFileName),"/logdir/lsb.events");
    } else {
	memset(eventFileName,0, sizeof(eventFileName));
	ls_strcat(eventFileName, sizeof(eventFileName),req->eventFileName);
    }

    FREEUP (histParams[LSB_SHAREDIR].paramValue);

    if (stat(eventFileName, &statBuf) < 0) {
        perror(eventFileName);
        return (-1);
    }

    if ((log_fp = fopen(eventFileName, "r")) == NULL) {
	perror(eventFileName);
	return(-1);
    }

    eventMatched = FALSE;
    while (TRUE) {

	log = lsb_geteventrec(log_fp, &lineNum);
        if (log) {
	    displayEvent(log, req);
	    continue;
        }

        if (lsberrno == LSBE_EOF)
	    break;
	fprintf(stderr, "\
File %s at line %d: %s\n", eventFileName, lineNum, lsb_sysmsg());
    }

    if (!eventMatched)
        fprintf(stderr, "No matching event found\n");
    *eventFound = eventMatched;

    fclose(log_fp);

    return 0;
}
int
readconfenv_ (struct config_param *pList1,
	      struct config_param *pList2, char *confPath)
{
  char *key;
  char *value;
  char *line;
  FILE *fp;
  char filename[MAXFILENAMELEN];
  struct config_param *plp;
  int lineNum = 0, saveErrNo;

  if (pList1)
    for (plp = pList1; plp->paramName != NULL; plp++)
      {
	if (plp->paramValue != NULL)
	  {

	    lserrno = LSE_BAD_ARGS;
	    return (-1);
	  }
      }

  if (pList2)
    for (plp = pList2; plp->paramName != NULL; plp++)
      {
	if (plp->paramValue != NULL)
	  {

	    lserrno = LSE_BAD_ARGS;
	    return (-1);
	  }
      }
  if (confPath)
    {
      {
	memset (filename, 0, sizeof (filename));
	ls_strcat (filename, sizeof (filename), confPath);
	ls_strcat (filename, sizeof (filename), "/lsf.conf");
	fp = fopen (filename, "r");
      }
    }
  else
    {
      char *ep = getenv ("LSF_ENVDIR");
      char buf[MAXFILENAMELEN];

      if (ep == NULL)
	{
	  sprintf (buf, "%s/lsf.conf", LSETCDIR);
	  fp = fopen (buf, "r");
	}
      else
	{
	  memset (buf, 0, sizeof (buf));
	  ls_strcat (buf, sizeof (buf), ep);
	  ls_strcat (buf, sizeof (buf), "/lsf.conf");
	  fp = fopen (buf, "r");
	}
    }

  if (!fp)
    {

      lserrno = LSE_LSFCONF;
      return (-1);
    }

  lineNum = 0;
  errLineNum_ = 0;
  while ((line = getNextLineC_ (fp, &lineNum, TRUE)) != NULL)
    {
      int cc;
      cc = parseLine (line, &key, &value);
      if (cc < 0 && errLineNum_ == 0)
	{
	  errLineNum_ = lineNum;
	  saveErrNo = lserrno;
	  continue;
	}
      if (!matchEnv (key, pList1) && !matchEnv (key, pList2))
	continue;

      if (!setConfEnv (key, value, pList1)
	  || !setConfEnv (key, value, pList2))
	{
	  fclose (fp);
	  return (-1);
	}
    }
  fclose (fp);
  if (errLineNum_ != 0)
    {
      lserrno = saveErrNo;
      return (-1);
    }

  return (0);

}