void doSkipSection_conf(struct lsConf *conf, int *LineNum, char *lsfile, char *sectionName) { char *word; char *cp; if (conf == NULL) return; while ((cp = getNextLineC_conf(conf, LineNum, TRUE)) != NULL) { word = getNextWord_(&cp); if (strcasecmp(word, "end") == 0) { word = getNextWord_(&cp); if (! word) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5419, "%s(%d): Section ended without section name, ignored"), lsfile, *LineNum); /* catgets 5419 */ } else { if (strcasecmp(word, sectionName) != 0) ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5420, "%s(%d): Section %s ended with wrong section name: %s, ignored"), lsfile, *LineNum, sectionName, word); /* catgets 5420 */ } return; } } ls_syslog(LOG_ERR, I18N_PREMATURE_EOF, "doSkipSection_conf", lsfile, *LineNum, sectionName); }
int getLogClass_ (char *lsp, char *tsp) { char *word; int class = 0; timinglevel = 0; logclass = 0; if (tsp != NULL && isint_(tsp)) timinglevel = atoi(tsp); while (lsp != NULL && (word = getNextWord_(&lsp))) { if (strcmp (word, "LC_SCHED") == 0) class |= LC_SCHED; if (strcmp (word, "LC_PEND") == 0) class |= LC_PEND; if (strcmp (word, "LC_JLIMIT") == 0) class |= LC_JLIMIT; if (strcmp (word, "LC_EXEC") == 0) class |= LC_EXEC; if (strcmp (word, "LC_TRACE") == 0) class |= LC_TRACE; if (strcmp (word, "LC_COMM") == 0) class |= LC_COMM; if (strcmp (word, "LC_XDR") == 0) class |= LC_XDR; if (strcmp (word, "LC_CHKPNT") == 0) class |= LC_CHKPNT; if (strcmp (word, "LC_FILE") == 0) class |= LC_FILE; if (strcmp (word, "LC_AUTH") == 0) class |= LC_AUTH; if (strcmp (word, "LC_HANG") == 0) class |= LC_HANG; if (strcmp (word, "LC_SIGNAL") == 0) class |= LC_SIGNAL; if (strcmp (word, "LC_PIM") == 0) class |= LC_PIM; if (strcmp (word, "LC_SYS") == 0) class |= LC_SYS; if (strcmp (word, "LC_LOADINDX") == 0) class |= LC_LOADINDX; if (strcmp (word, "LC_JGRP") == 0) class |= LC_JGRP; if (strcmp (word, "LC_JARRAY") == 0) class |= LC_JARRAY; if (strcmp (word, "LC_MPI") == 0) class |= LC_MPI; if (strcmp (word, "LC_ELIM") == 0) class |= LC_ELIM; if (strcmp (word, "LC_M_LOG") == 0) class |= LC_M_LOG; if (strcmp (word, "LC_PERFM") == 0) class |= LC_PERFM; } logclass = class; return 0; }
static int checkHU (char *hostList, char *userList, struct qData *qp) { char *sp; if (hostList != NULL && qp->hostList != NULL) while ((sp = getNextWord_ (&hostList))) if (!hostQMember (sp, qp)) return (LSBE_QUEUE_HOST); if (userList != NULL && qp->uGPtr != NULL) while ((sp = getNextWord_ (&userList))) if (!gMember (sp, qp->uGPtr)) return (LSBE_QUEUE_USE); return (LSBE_NO_ERROR); }
int isQueAd (struct qData *qp, char *lsfUserName) { char *admins, *user; if (!qp->nAdmins || !qp->admins) return (FALSE); admins = qp->admins; for (user = getNextWord_ (&admins); user; user = getNextWord_ (&admins)) { if ((strcmp (user, lsfUserName) == 0) || (strcmp (user, "all users") == 0)) { return (TRUE); } } return (FALSE); }
static int isDefQueue (char *qname) { char *cp, *queue; if (defaultQueues == NULL) return FALSE; cp = defaultQueues; while ((queue = getNextWord_ (&cp))) if (strcmp (qname, queue) == 0) return TRUE; return FALSE; }
int isSectionEnd (char *linep, char *lsfile, int *LineNum, char *sectionName) { char *word; word = getNextWord_ (&linep); if (strcasecmp (word, "end") != 0) return FALSE; word = getNextWord_ (&linep); if (!word) { ls_syslog (LOG_ERR, _i18n_msg_get (ls_catd, NL_SETN, 5400, "%s(%d): section %s ended without section name, ignored"), lsfile, *LineNum, sectionName); /* catgets 5400 */ return TRUE; } if (strcasecmp (word, sectionName) != 0) ls_syslog (LOG_ERR, _i18n_msg_get (ls_catd, NL_SETN, 5401, "%s(%d): section %s ended with wrong section name %s,ignored"), lsfile, *LineNum, sectionName, word); /* catgets 5401 */ return TRUE; }
int keyMatch (struct keymap *keyList, char *line, int exact) { int pos = 0; int i; char *sp = line; char *word; int found; i = 0; while (keyList[i].key != NULL) { keyList[i].position = -1; i++; } while ((word = getNextWord_ (&sp)) != NULL) { i = 0; found = FALSE; while (keyList[i].key != NULL) { if (strcasecmp (word, keyList[i].key) == 0) { if (keyList[i].position != -1) return FALSE; found = TRUE; keyList[i].position = pos; break; } i++; } if (!found) return FALSE; pos++; } if (!exact) return TRUE; i = 0; while (keyList[i].key != NULL) { if (keyList[i].position == -1) return FALSE; i++; } return TRUE; }
char * getBeginLine(FILE *fp, int *LineNum) { char *sp; char *wp; for (;;) { sp = getNextLineC_(fp, LineNum, TRUE); if (! sp) return (NULL); wp = getNextWord_(&sp); if (wp && (strcasecmp(wp, "begin") == 0)) return sp; } }
char * getBeginLine_conf(struct lsConf *conf, int *LineNum) { char *sp; char *wp; if (conf == NULL) return (NULL); for (;;) { sp = getNextLineC_conf(conf, LineNum, TRUE); if (sp == NULL) return (NULL); wp = getNextWord_(&sp); if (wp && (strcasecmp(wp, "begin") == 0)) return sp; } }
static char *a_getNextWord_(char **line) { char *wordp, *word; if (!(word = getNextWord_(line))) return NULL; if ((wordp=strchr(word,'('))) { *(wordp+1)='\0'; while (**line!='(') (*line)--; (*line)++; } else if ((wordp=strchr(word, ')'))) { if (wordp!=word) { wordp--; while (isspace(*wordp)) wordp--; *(wordp+1)='\0'; while (**line!=')') (*line)--; } } return word; }
int readHvalues(struct keymap *keyList, char *linep, FILE *fp, char *lsfile, int *LineNum, int exact, char *section) { static char fname[] = "readHvalues"; char *key; char *value; char *sp, *sp1; char error = FALSE; int i=0; sp = linep; key = getNextWord_(&linep); if ((sp1 = strchr(key, '=')) != NULL) *sp1 = '\0'; value = strchr(sp, '='); if (!value) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5402, "%s: %s(%d): missing '=' after keyword %s, section %s ignoring the line"), fname, lsfile, *LineNum, key, section); /* catgets 5402 */ } else { value++; while (*value == ' ') value++; if (value[0] == '\0') { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5403, "%s: %s(%d): null value after keyword %s, section %s ignoring the line"), fname, lsfile, *LineNum, key, section); /* catgets 5403 */ } if (value[0] == '(') { value++; if ((sp1 = strrchr(value, ')')) != NULL) *sp1 = '\0'; } if (putValue(keyList, key, value) < 0) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5404, "%s: %s(%d): bad keyword %s in section %s, ignoring the line"), fname, lsfile, *LineNum, key, section); /* catgets 5404 */ } } if ((linep = getNextLineC_(fp, LineNum, TRUE)) != NULL) { if (isSectionEnd(linep, lsfile, LineNum, section)) { if (! exact) return 0; i = 0; while (keyList[i].key != NULL) { if (keyList[i].val == NULL) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5405, "%s: %s(%d): required keyword %s is missing in section %s, ignoring the section"), fname, lsfile, *LineNum, keyList[i].key, section); /* catgets 5405 */ error = TRUE; } i++; } if (error) { i = 0; while (keyList[i].key != NULL) { FREEUP(keyList[i].val); i++; } return -1; } return 0; } return readHvalues(keyList, linep, fp, lsfile, LineNum, exact, section); } ls_syslog(LOG_ERR, I18N_PREMATURE_EOF, fname, lsfile, *LineNum, section); return -1; }
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); }
static int lsadminDebug(int argc, char **argv, int opCode) { struct hostInfo *hostInfo; char opt[10]; char *hosts[20]; char *localHost; char *word; int fileOption = FALSE; int i,j, num, c; int numHosts = 0; struct debugReq debug; exitDebug = 0; debug.opCode = opCode ; debug.logClass = 0; debug.level = 0; debug.hostName = NULL; debug.options = 0; if (opCode == LIM_DEBUG || opCode == RES_DEBUG) strcpy(opt, "oc:l:f:"); else if (opCode == LIM_TIMING || opCode == RES_TIMING) strcpy (opt, "ol:f:"); else return -2; linux_optind = 1; linux_opterr = 1; if (strstr(argv[0],"lsadmin")) { linux_optind++; } while ((c = getopt(argc, argv, 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 (debug.logClass == 0) { fprintf(stderr, "Command denied. Invalid class name\n"); return -1; } break; case 'l': for (i=0;i<strlen(optarg);i++) { if (!isdigit(optarg[i])) { fprintf(stderr, "\ Command denied. Invalid level value\n"); return -1; } } debug.level = atoi(optarg); if (opCode == LIM_DEBUG || opCode == RES_DEBUG) { if (debug.level < 0 || debug.level > 3) { fprintf(stderr, "\ Command denied. Valid debug level value is [0-3]\n"); return -1; } } else if (debug.level < 1 || debug.level > 5) {
void do_switchjob(XDR * xdrs, int chfd, struct LSFHeader * reqHdr) { static char fname[] = "do_switchjob()"; char reply_buf[MSGSIZE]; XDR xdrs2; struct jobSpecs jobSpecs; struct jobReply jobReply; int i; sbdReplyType reply; char *cp; char *word; char found = FALSE; struct LSFHeader replyHdr; char *replyStruct; struct jobCard *jp; struct lsfAuth *auth = NULL; memset(&jobReply, 0, sizeof(struct jobReply)); if (!xdr_jobSpecs(xdrs, &jobSpecs, reqHdr)) { reply = ERR_BAD_REQ; ls_syslog(LOG_ERR, I18N_FUNC_FAIL, fname, "xdr_jobSpecs"); goto sendReply; } for (jp = jobQueHead->back; jp != jobQueHead; jp = jp->back) { if (jp->jobSpecs.jobId == jobSpecs.jobId) { found = TRUE; break; } } if (!found) { reply = ERR_NO_JOB; ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5807, "%s: mbatchd trying to switch a non-existent job <%s>"), fname, lsb_jobid2str(jobSpecs.jobId)); /* catgets 5807 */ goto sendReply; } if (jp->jobSpecs.jStatus & (JOB_STAT_DONE | JOB_STAT_EXIT)) { reply = ERR_JOB_FINISH; goto sendReply; } cp = jobSpecs.windows; freeWeek(jp->week); while ((word = getNextWord_(&cp)) != NULL) { if (addWindow(word, jp->week, "switchJob jobSpecs") < 0) { ls_syslog(LOG_ERR, I18N_JOB_FAIL_S_S_M, fname, lsb_jobid2str(jp->jobSpecs.jobId), "addWindow", word); freeWeek(jp->week); reply = ERR_BAD_REQ; goto sendReply; } } jp->windEdge = now; if ((jp->jobSpecs.jAttrib & Q_ATTRIB_EXCLUSIVE) && !(jobSpecs.jAttrib & Q_ATTRIB_EXCLUSIVE)) for (i = 0; i < jp->jobSpecs.numToHosts; i++) if (unlockHost_(jp->jobSpecs.toHosts[i]) < 0 && lserrno != LSE_LIM_NLOCKED) ls_syslog(LOG_ERR, I18N_JOB_FAIL_S_S_MM, fname, lsb_jobid2str(jp->jobSpecs.jobId), "unlockHost_", jp->jobSpecs.toHosts[i]); strcpy(jp->jobSpecs.queue, jobSpecs.queue); strcpy(jp->jobSpecs.windows, jobSpecs.windows); jp->jobSpecs.priority = jobSpecs.priority; jp->jobSpecs.nice = jobSpecs.nice; jp->jobSpecs.jAttrib = jobSpecs.jAttrib; freeThresholds (&jp->jobSpecs.thresholds); saveThresholds (&jp->jobSpecs, &jobSpecs.thresholds); memcpy((char *) &jp->jobSpecs.lsfLimits[LSF_RLIMIT_RUN], (char *) &jobSpecs.lsfLimits[LSF_RLIMIT_RUN], sizeof(struct lsfLimit)); strcpy (jp->jobSpecs.requeueEValues, jobSpecs.requeueEValues); strcpy (jp->jobSpecs.resumeCond, jobSpecs.resumeCond); strcpy (jp->jobSpecs.stopCond, jobSpecs.stopCond); lsbFreeResVal (&jp->resumeCondVal); if (jobSpecs.resumeCond && jobSpecs.resumeCond[0] != '\0') { if ((jp->resumeCondVal = checkThresholdCond (jobSpecs.resumeCond)) == NULL) ls_syslog(LOG_ERR, I18N_JOB_FAIL_S_S, fname, lsb_jobid2str(jp->jobSpecs.jobId), "checkThresholdCond", jobSpecs.resumeCond); } lsbFreeResVal (&jp->stopCondVal); if (jobSpecs.stopCond && jobSpecs.stopCond[0] != '\0') { if ((jp->stopCondVal = checkThresholdCond (jobSpecs.stopCond)) == NULL) ls_syslog(LOG_ERR, I18N_JOB_FAIL_S_S, fname, lsb_jobid2str(jp->jobSpecs.jobId), "checkThresholdCond", jobSpecs.stopCond); } if (jobSpecs.options & SUB_LOGIN_SHELL) { FREEUP (jp->jobSpecs.loginShell); jp->jobSpecs.loginShell = safeSave (jobSpecs.loginShell); } strcpy (jp->jobSpecs.suspendActCmd, jobSpecs.suspendActCmd); strcpy (jp->jobSpecs.resumeActCmd, jobSpecs.resumeActCmd); strcpy (jp->jobSpecs.terminateActCmd, jobSpecs.terminateActCmd); setRunLimit (jp, FALSE); offList ((struct listEntry *)jp); inJobLink (jp); if (reniceJob(jp) < 0) ls_syslog(LOG_DEBUG, "%s: renice job <%s> failed", fname, lsb_jobid2str(jp->jobSpecs.jobId)); reply = ERR_NO_ERROR; jobReply.jobId = jp->jobSpecs.jobId; jobReply.jobPid = jp->jobSpecs.jobPid; jobReply.jobPGid = jp->jobSpecs.jobPGid; jobReply.jStatus = jp->jobSpecs.jStatus; sendReply: xdr_lsffree(xdr_jobSpecs, (char *)&jobSpecs, reqHdr); xdrmem_create(&xdrs2, reply_buf, MSGSIZE, XDR_ENCODE); initLSFHeader_(&replyHdr); replyHdr.opCode = reply; if (reply == ERR_NO_ERROR) replyStruct = (char *) &jobReply; else { replyStruct = (char *) 0; } if (!xdr_encodeMsg(&xdrs2, replyStruct, &replyHdr, xdr_jobReply, 0, auth)) { ls_syslog(LOG_ERR, I18N_JOB_FAIL_S_M, fname, lsb_jobid2str(jp->jobSpecs.jobId), "xdr_jobReply"); relife(); } if (chanWrite_(chfd, reply_buf, XDR_GETPOS(&xdrs2)) <= 0) { ls_syslog(LOG_ERR, I18N_JOB_FAIL_S_M, fname, lsb_jobid2str(jp->jobSpecs.jobId), "chanWrite_"); } xdr_destroy(&xdrs2); return; }
static int parseLine (char *line, char **keyPtr, char **valuePtr) { char *sp = line; #define L_MAXLINELEN_4ENV (8*MAXLINELEN) static char key[L_MAXLINELEN_4ENV]; static char value[L_MAXLINELEN_4ENV]; char *word; char *cp; if (strlen (sp) >= L_MAXLINELEN_4ENV - 1) { lserrno = LSE_BAD_ENV; return -1; } *keyPtr = key; *valuePtr = value; word = getNextWord_ (&sp); strcpy (key, word); cp = strchr (key, '='); if (cp == NULL) { lserrno = LSE_CONF_SYNTAX; return -1; } *cp = '\0'; sp = strchr (line, '='); if (sp[1] == ' ' || sp[1] == '\t') { lserrno = LSE_CONF_SYNTAX; return -1; } if (sp[1] == '\0') { value[0] = '\0'; return 0; } sp++; word = getNextValueQ_ (&sp, '\"', '\"'); if (!word) return -1; strcpy (value, word); word = getNextValueQ_ (&sp, '\"', '\"'); if (word != NULL || lserrno != LSE_NO_ERR) { lserrno = LSE_CONF_SYNTAX; return -1; } return 0; }
int checkQueues (struct infoReq *queueInfoReqPtr, struct queueInfoReply *queueInfoReplyPtr) { static char fname[] = "checkQueues()"; struct qData *qp; struct qData *next; struct queueInfoEnt *qRep = NULL; int i; int j; int checkRet; int allQ = FALSE; int defaultQ = FALSE; int found = FALSE; char *checkUsers = NULL; char *checkHosts = NULL; float *cpuFactor; queueInfoReplyPtr->numQueues = 0; queueInfoReplyPtr->nIdx = allLsInfo->numIndx; if (queueInfoReqPtr->options & ALL_QUEUE) { queueInfoReqPtr->numNames = 1; allQ = TRUE; } else if (queueInfoReqPtr->options & DFT_QUEUE) { queueInfoReqPtr->numNames = 1; defaultQ = TRUE; } if ((checkRet = getCheckList (queueInfoReqPtr, &checkHosts, &checkUsers)) != LSBE_NO_ERROR) return (checkRet); for (j = 0; j < queueInfoReqPtr->numNames; j++) { for (qp = qDataList->back; (qp != qDataList); qp = next) { next = qp->back; if (strcmp (qp->queue, LOST_AND_FOUND) == 0 && qp->numJobs == 0) { continue; } if (!allQ && !defaultQ && strcmp (qp->queue, queueInfoReqPtr->names[j]) != 0) continue; if (!allQ && defaultQ && !isDefQueue (qp->queue)) continue; found = TRUE; if ((checkRet = checkHU (checkHosts, checkUsers, qp)) != LSBE_NO_ERROR) continue; for (i = 0; i < queueInfoReplyPtr->numQueues; i++) { if (strcmp (qp->queue, queueInfoReplyPtr->queues[i].queue) == 0) { if (strcmp (qp->queue, LOST_AND_FOUND) != 0) { break; } else { queueInfoReplyPtr->queues[i].numJobs += qp->numJobs; queueInfoReplyPtr->queues[i].numPEND += qp->numPEND; queueInfoReplyPtr->queues[i].numRUN += qp->numRUN; queueInfoReplyPtr->queues[i].numSSUSP += qp->numSSUSP; queueInfoReplyPtr->queues[i].numUSUSP += qp->numUSUSP; break; } } } if (i < queueInfoReplyPtr->numQueues) continue; qRep = &(queueInfoReplyPtr->queues[queueInfoReplyPtr->numQueues]); qRep->queue = qp->queue; qRep->description = qp->description; qRep->schedDelay = qp->schedDelay; qRep->mig = (qp->mig != INFINIT_INT) ? qp->mig / 60 : INFINIT_INT; if (qp->acceptIntvl == DEF_ACCEPT_INTVL || qp->acceptIntvl == INFINIT_INT) qRep->acceptIntvl = INFINIT_INT; else qRep->acceptIntvl = qp->acceptIntvl * msleeptime; if (qp->windows) qRep->windows = safeSave (qp->windows); else qRep->windows = safeSave (" "); if (qp->windowsD) qRep->windowsD = safeSave (qp->windowsD); else qRep->windowsD = safeSave (" "); if (qp->uGPtr) { qRep->userList = getGroupMembers (qp->uGPtr, FALSE); } else { qRep->userList = safeSave (" "); } if (qp->hostList) { char *word = NULL, *hostList = NULL; int len = 0; struct gData *gp = NULL; hostList = qp->hostList; while ((hostList = strstr (hostList, " ")) != NULL) { hostList++; len++; } qRep->hostList = (char *) calloc ((strlen (qp->hostList) + len * 2 + 2), sizeof (char)); if (qRep->hostList == NULL) { ls_syslog (LOG_ERR, I18N_FUNC_D_FAIL_M, fname, "calloc", (strlen (qp->hostList) + len * 2 + 2) * sizeof (char)); return (LSBE_NO_MEM); } hostList = qp->hostList; while ((word = getNextWord_ (&hostList)) != NULL) { strcat (qRep->hostList, word); if ((gp = getHGrpData (word)) != NULL) { strcat (qRep->hostList, "/"); } strcat (qRep->hostList, " "); } } else { qRep->hostList = safeSave (" "); } qRep->priority = qp->priority; qRep->nice = qp->nice; qRep->userJobLimit = qp->uJobLimit; if (qp->pJobLimit >= INFINIT_FLOAT) qRep->procJobLimit = INFINIT_FLOAT; else qRep->procJobLimit = qp->pJobLimit; qRep->hostJobLimit = qp->hJobLimit; qRep->maxJobs = qp->maxJobs; qRep->numJobs = qp->numJobs; qRep->numPEND = qp->numPEND; qRep->numRUN = qp->numRUN; qRep->numSSUSP = qp->numSSUSP; qRep->numUSUSP = qp->numUSUSP; qRep->numRESERVE = qp->numRESERVE; qRep->qAttrib = qp->qAttrib; qRep->qStatus = qp->qStatus; for (i = 0; i < LSF_RLIM_NLIMITS; i++) { qRep->rLimits[i] = qp->rLimits[i]; qRep->defLimits[i] = qp->defLimits[i]; } if (qp->hostSpec == NULL) qRep->hostSpec = safeSave (" "); else { qRep->hostSpec = safeSave (qp->hostSpec); if ((cpuFactor = getModelFactor (qp->hostSpec)) == NULL) { if ((cpuFactor = getHostFactor (qp->hostSpec)) == NULL) { float one = 1.0; ls_syslog (LOG_ERR, _i18n_msg_get (ls_catd, NL_SETN, 7500, "%s: Cannot find cpu factor for hostSpec <%s> in queue <%s>; cpuFactor is set to 1.0"), /* catgets 7500 */ fname, qp->hostSpec, qp->queue); cpuFactor = &one; } } if (cpuFactor != NULL) { if (qRep->rLimits[LSF_RLIMIT_CPU] > 0) qRep->rLimits[LSF_RLIMIT_CPU] /= *cpuFactor; if (qRep->rLimits[LSF_RLIMIT_RUN] > 0) qRep->rLimits[LSF_RLIMIT_RUN] /= *cpuFactor; if (qRep->defLimits[LSF_RLIMIT_CPU] > 0) qRep->defLimits[LSF_RLIMIT_CPU] /= *cpuFactor; if (qRep->defLimits[LSF_RLIMIT_RUN] > 0) qRep->defLimits[LSF_RLIMIT_RUN] /= *cpuFactor; } } if (qp->defaultHostSpec) qRep->defaultHostSpec = safeSave (qp->defaultHostSpec); else qRep->defaultHostSpec = safeSave (" "); qRep->loadSched = qp->loadSched; qRep->loadStop = qp->loadStop; qRep->procLimit = qp->procLimit; qRep->minProcLimit = qp->minProcLimit; qRep->defProcLimit = qp->defProcLimit; if (qp->nAdmins > 0) qRep->admins = safeSave (qp->admins); else qRep->admins = safeSave (" "); if (qp->preCmd) qRep->preCmd = safeSave (qp->preCmd); else qRep->preCmd = safeSave (" "); if (qp->prepostUsername) { qRep->prepostUsername = safeSave (qp->prepostUsername); } else { qRep->prepostUsername = safeSave (" "); } qRep->chkpntPeriod = qp->chkpntPeriod; if (qp->chkpntDir) qRep->chkpntDir = safeSave (qp->chkpntDir); else qRep->chkpntDir = safeSave (" "); if (qp->postCmd) qRep->postCmd = safeSave (qp->postCmd); else qRep->postCmd = safeSave (" "); if (qp->requeueEValues) qRep->requeueEValues = safeSave (qp->requeueEValues); else qRep->requeueEValues = safeSave (" "); if (qp->resReq) qRep->resReq = safeSave (qp->resReq); else qRep->resReq = safeSave (" "); qRep->slotHoldTime = qp->slotHoldTime; if (qp->resumeCond) qRep->resumeCond = safeSave (qp->resumeCond); else qRep->resumeCond = safeSave (" "); if (qp->stopCond) qRep->stopCond = safeSave (qp->stopCond); else qRep->stopCond = safeSave (" "); if (qp->jobStarter) qRep->jobStarter = safeSave (qp->jobStarter); else qRep->jobStarter = safeSave (" "); if (qp->suspendActCmd) { if (strcmp (qp->suspendActCmd, "SIG_CHKPNT") == 0) qRep->suspendActCmd = safeSave ("CHKPNT"); else qRep->suspendActCmd = safeSave (qp->suspendActCmd); } else qRep->suspendActCmd = safeSave (" "); if (qp->resumeActCmd) qRep->resumeActCmd = safeSave (qp->resumeActCmd); else qRep->resumeActCmd = safeSave (" "); if (qp->terminateActCmd) { if (strcmp (qp->terminateActCmd, "SIG_CHKPNT") == 0) qRep->terminateActCmd = safeSave ("CHKPNT"); else qRep->terminateActCmd = safeSave (qp->terminateActCmd); } else qRep->terminateActCmd = safeSave (" "); for (i = 0; i < LSB_SIG_NUM; i++) qRep->sigMap[i] = qp->sigMap[i]; queueInfoReplyPtr->numQueues++; } if (!allQ && !defaultQ && !found) { if (queueInfoReplyPtr->numQueues > 0) freeQueueInfoReply (queueInfoReplyPtr, "freeAll"); queueInfoReplyPtr->badQueue = j; queueInfoReplyPtr->numQueues = 0; FREEUP (checkUsers); FREEUP (checkHosts); return (LSBE_BAD_QUEUE); } found = FALSE; if (allQ || defaultQ) break; } FREEUP (checkUsers); FREEUP (checkHosts); if (queueInfoReplyPtr->numQueues == 0) { return (checkRet); } return (LSBE_NO_ERROR); }
static void prtGroups (struct groupInfoEnt *grpInfo, int numReply, int options) { int i; int j; int strLen; char *sp; char *cp ; char *save_sp; char *save_sp1; char word[256]; char gname[256]; char first = true; for (i = 0; i < numReply; i++) { sp = grpInfo[i].memberList; strcpy(gname, grpInfo[i].group); sprintf(word,"%-12.12s", gname); /* strip the end blank space */ strLen = strlen(gname); for (j = 0; j < strLen ; j++) if (gname[j] == ' ') { gname[j] = '\0'; break; } if (first) { if (options & USER_GRP) printf("%-12.12s %s\n", "GROUP_NAME", "USERS"); else printf("%-12.12s %s\n", "GROUP_NAME", "HOSTS"); first = FALSE; } printf("%s ", word); /* print the group name */ if (strcmp (sp, "all") == 0) { if(options & USER_GRP) { printf("all users \n"); continue; } else printf("all hosts used by the batch system\n"); continue; } /* Print out the group name. */ while ((cp = getNextWord_(&sp)) != NULL) { save_sp = sp; strcpy(word, cp); printf("%s ", word); save_sp1 = sp; while ((cp = getNextWord_(&sp)) != NULL) { if (strcmp(word, cp) == 0) { save_sp1 = strchr(save_sp1, *cp); for (j = 0; j < strlen(cp); j++) *(save_sp1 + j) = ' '; } save_sp1 = sp; } sp = save_sp; } putchar('\n'); } }