Merge lp:~noskcaj/ubuntu/trusty/torque/merge into lp:ubuntu/trusty/torque

Proposed by Jackson Doak
Status: Needs review
Proposed branch: lp:~noskcaj/ubuntu/trusty/torque/merge
Merge into: lp:ubuntu/trusty/torque
Diff against target: 20653 lines (+491/-19927)
28 files modified
.pc/applied-patches (+0/-5)
.pc/c90string.patch/src/resmom/mom_main.c (+0/-8362)
.pc/c90string.patch/src/server/pbsd_main.c (+0/-3044)
.pc/freebsd5_manpages.patch/doc/Makefile.am (+0/-141)
.pc/freebsd5_manpages.patch/doc/Makefile.in (+0/-1012)
.pc/gnu_fixes.patch/src/gui/Ccode/xpbs_scriptload.c (+0/-1119)
.pc/gnu_fixes.patch/src/pam/pam_pbssimpleauth.c (+0/-246)
.pc/gnu_fixes.patch/src/resmom/linux/mom_mach.c (+0/-4468)
.pc/gnu_fixes.patch/src/resmom/mom_inter.c (+0/-793)
.pc/tcl85.patch/src/tools/xpbsmon/entry.tk (+0/-358)
.pc/xpbs_xpbsmon_tclIndex.patch/src/gui/buildindex.src (+0/-159)
.pc/xpbs_xpbsmon_tclIndex.patch/src/tools/xpbsmon/buildindex.src (+0/-159)
debian/changelog (+38/-0)
debian/patches/CVE-2013-4319.patch (+41/-0)
debian/patches/CVE-2013-4495.patch (+382/-0)
debian/patches/fix-FTBFS-on-kfreebsd.patch (+20/-0)
debian/patches/series (+3/-0)
doc/Makefile.am (+1/-3)
doc/Makefile.in (+1/-3)
src/gui/Ccode/xpbs_scriptload.c (+1/-1)
src/gui/buildindex.src (+0/-1)
src/pam/pam_pbssimpleauth.c (+0/-7)
src/resmom/linux/mom_mach.c (+0/-42)
src/resmom/mom_inter.c (+1/-1)
src/resmom/mom_main.c (+1/-1)
src/server/pbsd_main.c (+1/-1)
src/tools/xpbsmon/buildindex.src (+0/-1)
src/tools/xpbsmon/entry.tk (+1/-0)
To merge this branch: bzr merge lp:~noskcaj/ubuntu/trusty/torque/merge
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+199191@code.launchpad.net

Description of the change

Merge from debian to fix multiple RC bugs

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Thanks. Uploaded.

review: Approve

Unmerged revisions

16. By Jackson Doak

* Merge from debian. Remaining changes:
  - Build using dh-autoreconf.
  - Specified multiarch Tcl and Tk locations during configure,
    fixing FTBFS.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '.pc/applied-patches'
2--- .pc/applied-patches 2011-05-12 23:55:29 +0000
3+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
4@@ -1,5 +0,0 @@
5-freebsd5_manpages.patch
6-gnu_fixes.patch
7-c90string.patch
8-xpbs_xpbsmon_tclIndex.patch
9-tcl85.patch
10
11=== removed directory '.pc/c90string.patch'
12=== removed directory '.pc/c90string.patch/src'
13=== removed directory '.pc/c90string.patch/src/resmom'
14=== removed file '.pc/c90string.patch/src/resmom/mom_main.c'
15--- .pc/c90string.patch/src/resmom/mom_main.c 2011-08-01 20:05:47 +0000
16+++ .pc/c90string.patch/src/resmom/mom_main.c 1970-01-01 00:00:00 +0000
17@@ -1,8362 +0,0 @@
18-/*
19-* OpenPBS (Portable Batch System) v2.3 Software License
20-*
21-* Copyright (c) 1999-2000 Veridian Information Solutions, Inc.
22-* All rights reserved.
23-*
24-* ---------------------------------------------------------------------------
25-* For a license to use or redistribute the OpenPBS software under conditions
26-* other than those described below, or to purchase support for this software,
27-* please contact Veridian Systems, PBS Products Department ("Licensor") at:
28-*
29-* www.OpenPBS.org +1 650 967-4675 sales@OpenPBS.org
30-* 877 902-4PBS (US toll-free)
31-* ---------------------------------------------------------------------------
32-*
33-* This license covers use of the OpenPBS v2.3 software (the "Software") at
34-* your site or location, and, for certain users, redistribution of the
35-* Software to other sites and locations. Use and redistribution of
36-* OpenPBS v2.3 in source and binary forms, with or without modification,
37-* are permitted provided that all of the following conditions are met.
38-* After December 31, 2001, only conditions 3-6 must be met:
39-*
40-* 1. Commercial and/or non-commercial use of the Software is permitted
41-* provided a current software registration is on file at www.OpenPBS.org.
42-* If use of this software contributes to a publication, product, or
43-* service, proper attribution must be given; see www.OpenPBS.org/credit.html
44-*
45-* 2. Redistribution in any form is only permitted for non-commercial,
46-* non-profit purposes. There can be no charge for the Software or any
47-* software incorporating the Software. Further, there can be no
48-* expectation of revenue generated as a consequence of redistributing
49-* the Software.
50-*
51-* 3. Any Redistribution of source code must retain the above copyright notice
52-* and the acknowledgment contained in paragraph 6, this list of conditions
53-* and the disclaimer contained in paragraph 7.
54-*
55-* 4. Any Redistribution in binary form must reproduce the above copyright
56-* notice and the acknowledgment contained in paragraph 6, this list of
57-* conditions and the disclaimer contained in paragraph 7 in the
58-* documentation and/or other materials provided with the distribution.
59-*
60-* 5. Redistributions in any form must be accompanied by information on how to
61-* obtain complete source code for the OpenPBS software and any
62-* modifications and/or additions to the OpenPBS software. The source code
63-* must either be included in the distribution or be available for no more
64-* than the cost of distribution plus a nominal fee, and all modifications
65-* and additions to the Software must be freely redistributable by any party
66-* (including Licensor) without restriction.
67-*
68-* 6. All advertising materials mentioning features or use of the Software must
69-* display the following acknowledgment:
70-*
71-* "This product includes software developed by NASA Ames Research Center,
72-* Lawrence Livermore National Laboratory, and Veridian Information
73-* Solutions, Inc.
74-* Visit www.OpenPBS.org for OpenPBS software support,
75-* products, and information."
76-*
77-* 7. DISCLAIMER OF WARRANTY
78-*
79-* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ANY EXPRESS
80-* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
81-* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT
82-* ARE EXPRESSLY DISCLAIMED.
83-*
84-* IN NO EVENT SHALL VERIDIAN CORPORATION, ITS AFFILIATED COMPANIES, OR THE
85-* U.S. GOVERNMENT OR ANY OF ITS AGENCIES BE LIABLE FOR ANY DIRECT OR INDIRECT,
86-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
87-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
88-* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
89-* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90-* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
91-* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92-*
93-* This license will be governed by the laws of the Commonwealth of Virginia,
94-* without reference to its choice of law rules.
95-*/
96-/*
97- * The entry point function for MOM.
98- */
99-
100-#include <pbs_config.h> /* the master config generated by configure */
101-
102-#include <assert.h>
103-#include <stdio.h>
104-#include <stdlib.h>
105-#include <unistd.h>
106-#include <stdarg.h>
107-
108-#ifdef _CRAY
109-#include <termios.h>
110-#endif /* _CRAY */
111-
112-#include <pwd.h>
113-#include <signal.h>
114-#include <string.h>
115-#include <ctype.h>
116-#include <errno.h>
117-#include <fcntl.h>
118-#include <time.h>
119-#include <limits.h>
120-#include <netdb.h>
121-#include <grp.h>
122-#include <sys/types.h>
123-#include <sys/param.h>
124-#include <sys/times.h>
125-#include <sys/stat.h>
126-#if (PLOCK_DAEMONS & 4)
127-#include <sys/lock.h>
128-#endif /* PLOCK_DAEMONS */
129-#include <netinet/in.h>
130-#include <sys/socket.h>
131-#ifdef _CRAY
132-#include <sys/category.h>
133-#include <sys/usrv.h>
134-#include <sys/sysv.h>
135-#endif /* _CRAY */
136-#include <sys/time.h>
137-#include <sys/resource.h>
138-#include <sys/utsname.h>
139-#if defined(NTOHL_NEEDS_ARPA_INET_H) && defined(HAVE_ARPA_INET_H)
140-#include <arpa/inet.h>
141-#endif
142-
143-
144-#include "libpbs.h"
145-#include "pbs_ifl.h"
146-#include "server_limits.h"
147-#include "list_link.h"
148-#include "attribute.h"
149-#include "resource.h"
150-#include "pbs_job.h"
151-#include "mom_mach.h"
152-#include "mom_func.h"
153-#include "svrfunc.h"
154-#include "pbs_error.h"
155-#include "log.h"
156-#include "net_connect.h"
157-#include "rpp.h"
158-#include "dis.h"
159-#include "dis_init.h"
160-#include "resmon.h"
161-#include "pbs_nodes.h"
162-#include "dis.h"
163-#include "csv.h"
164-#include "utils.h"
165-
166-#include "mcom.h"
167-
168-#ifdef NOPOSIXMEMLOCK
169-#undef _POSIX_MEMLOCK
170-#endif /* NOPOSIXMEMLOCK */
171-
172-#ifdef _POSIX_MEMLOCK
173-#include <sys/mman.h>
174-#endif /* _POSIX_MEMLOCK */
175-
176-#define CHECK_POLL_TIME 45
177-#define DEFAULT_SERVER_STAT_UPDATES 45
178-
179-#define PMAX_PORT 32000
180-#define MAX_RESEND_JOBS 512
181-#define DUMMY_JOB_PTR 1
182-
183-/* Global Data Items */
184-
185-char *program_name;
186-int MOMIsLocked = 0;
187-int MOMIsPLocked = 0;
188-int ServerStatUpdateInterval = DEFAULT_SERVER_STAT_UPDATES;
189-int CheckPollTime = CHECK_POLL_TIME;
190-int ForceServerUpdate = 0;
191-
192-int verbositylevel = 0;
193-double cputfactor = 1.00;
194-unsigned int default_server_port = 0;
195-int exiting_tasks = 0;
196-float ideal_load_val = -1.0;
197-int internal_state = 0;
198-/* by default, enforce these policies */
199-int ignwalltime = 0;
200-int ignmem = 0;
201-int igncput = 0;
202-int ignvmem = 0;
203-int spoolasfinalname = 0;
204-int killdelay = 0;
205-/* end policies */
206-int lockfds = -1;
207-time_t loopcnt; /* used for MD5 calc */
208-float max_load_val = -1.0;
209-int hostname_specified = 0;
210-char mom_host[PBS_MAXHOSTNAME + 1];
211-char TMOMRejectConn[1024]; /* most recent rejected connection */
212-char mom_short_name[PBS_MAXHOSTNAME + 1];
213-int num_var_env;
214-char *path_epilog;
215-char *path_epilogp;
216-char *path_epiloguser;
217-char *path_epiloguserp;
218-char *path_epilogpdel;
219-char *path_jobs;
220-char *path_prolog;
221-char *path_prologp;
222-char *path_prologuser;
223-char *path_prologuserp;
224-char *path_spool;
225-char *path_undeliv;
226-char *path_aux;
227-char *path_server_name;
228-char *path_home = PBS_SERVER_HOME;
229-char *mom_home;
230-extern char *msg_daemonname; /* for logs */
231-extern char *msg_info_mom; /* Mom information message */
232-extern int pbs_errno;
233-gid_t pbsgroup;
234-unsigned int pbs_mom_port = 0;
235-unsigned int pbs_rm_port = 0;
236-tlist_head mom_polljobs; /* jobs that must have resource limits polled */
237-tlist_head svr_newjobs; /* jobs being sent to MOM */
238-tlist_head svr_alljobs; /* all jobs under MOM's control */
239-tlist_head mom_varattrs; /* variable attributes */
240-int termin_child = 0; /* boolean - one or more children need to be terminated this iteration */
241-time_t time_now = 0;
242-time_t last_poll_time = 0;
243-extern tlist_head svr_requests;
244-
245-extern struct var_table vtable; /* see start_exec.c */
246-double wallfactor = 1.00;
247-long log_file_max_size = 0;
248-long log_file_roll_depth = 1;
249-
250-time_t last_log_check;
251-char *nodefile_suffix = NULL; /* suffix to append to each host listed in job host file */
252-char *submithost_suffix = NULL; /* suffix to append to submithost for interactive jobs */
253-char *TNoSpoolDirList[TMAX_NSDCOUNT];
254-char *TRemChkptDirList[TMAX_RCDCOUNT];
255-
256-job *JobsToResend[MAX_RESEND_JOBS];
257-
258-char *AllocParCmd = NULL; /* (alloc) */
259-
260-int src_login_batch = TRUE;
261-int src_login_interactive = TRUE;
262-
263-/* externs */
264-
265-extern unsigned int pe_alarm_time;
266-extern time_t pbs_tcp_timeout;
267-extern long MaxConnectTimeout;
268-
269-char tmpdir_basename[MAXPATHLEN]; /* for $TMPDIR */
270-
271-char rcp_path[MAXPATHLEN];
272-char rcp_args[MAXPATHLEN];
273-char xauth_path[MAXPATHLEN];
274-
275-time_t LastServerUpdateTime = 0; /* NOTE: all servers updated together */
276-
277-time_t MOMStartTime = 0;
278-int MOMPrologTimeoutCount;
279-int MOMPrologFailureCount;
280-
281-char MOMConfigVersion[64];
282-char MOMUNameMissing[64];
283-
284-int MOMConfigDownOnError = 0;
285-int MOMConfigRestart = 0;
286-int MOMConfigRReconfig = 0;
287-long system_ncpus = 0;
288-char *auto_ideal_load = NULL;
289-char *auto_max_load = NULL;
290-
291-#define TMAX_JE 64
292-
293-pjobexec_t TMOMStartInfo[TMAX_JE];
294-
295-
296-/* prototypes */
297-
298-extern void add_resc_def(char *, char *);
299-extern void mom_server_all_diag(char **BPtr, int *BSpace);
300-extern void mom_server_update_receive_time(int stream, const char *command_name);
301-extern void mom_server_all_init(void);
302-extern void mom_server_all_update_stat(void);
303-extern int mark_for_resend(job *);
304-extern int mom_server_all_check_connection(void);
305-extern int mom_server_all_send_state(void);
306-extern int mom_server_add(char *name);
307-extern int mom_server_count;
308-extern int post_epilogue(job *, int);
309-extern int mom_checkpoint_init(void);
310-extern void mom_checkpoint_check_periodic_timer(job *pjob);
311-extern void mom_checkpoint_set_directory_path(char *str);
312-
313-void prepare_child_tasks_for_delete();
314-
315-#define PMOMTCPTIMEOUT 60 /* duration in seconds mom TCP requests will block */
316-
317-
318-/* Local Data Items */
319-
320-static char *log_file = NULL;
321-
322-enum PMOMStateEnum
323- {
324- MOM_RUN_STATE_RUNNING,
325- MOM_RUN_STATE_EXIT,
326- MOM_RUN_STATE_KILLALL,
327- MOM_RUN_STATE_RESTART,
328- MOM_RUN_STATE_LAST
329- };
330-
331-static enum PMOMStateEnum mom_run_state;
332-
333-static int recover = JOB_RECOV_RUNNING;
334-static int recover_set = FALSE;
335-
336-static int call_hup = 0;
337-static int nconfig;
338-static char *path_log;
339-
340-struct config_list
341- {
342- struct config c;
343-
344- struct config_list *c_link;
345- };
346-
347-/* NOTE: must adjust RM_NPARM in resmom.h to be larger than number of parameters
348- specified below */
349-
350-static unsigned long setxauthpath(char *);
351-static unsigned long setrcpcmd(char *);
352-static unsigned long setpbsclient(char *);
353-static unsigned long configversion(char *);
354-static unsigned long cputmult(char *);
355-static unsigned long setallocparcmd(char *);
356-static unsigned long setidealload(char *);
357-static unsigned long setignwalltime(char *);
358-static unsigned long setignmem(char *);
359-static unsigned long setigncput(char *);
360-static unsigned long setignvmem(char *);
361-static unsigned long setlogevent(char *);
362-static unsigned long setloglevel(char *);
363-static unsigned long setumask(char *);
364-static unsigned long setpreexec(char *);
365-static unsigned long setmaxload(char *);
366-static unsigned long setenablemomrestart(char *);
367-static unsigned long prologalarm(char *);
368-static unsigned long restricted(char *);
369-static unsigned long jobstartblocktime(char *);
370-static unsigned long usecp(char *);
371-static unsigned long wallmult(char *);
372-static unsigned long setpbsserver(char *);
373-static unsigned long setnodecheckscript(char *);
374-static unsigned long setnodecheckinterval(char *);
375-static unsigned long settimeout(char *);
376-extern unsigned long mom_checkpoint_set_checkpoint_interval(char *);
377-extern unsigned long mom_checkpoint_set_checkpoint_script(char *);
378-extern unsigned long mom_checkpoint_set_restart_script(char *);
379-extern unsigned long mom_checkpoint_set_checkpoint_run_exe_name(char *);
380-static unsigned long setdownonerror(char *);
381-static unsigned long setstatusupdatetime(char *);
382-static unsigned long setcheckpolltime(char *);
383-static unsigned long settmpdir(char *);
384-static unsigned long setlogfilemaxsize(char *);
385-static unsigned long setlogfilerolldepth(char *);
386-static unsigned long setlogfilesuffix(char *);
387-static unsigned long setlogdirectory(char *);
388-static unsigned long setlogkeepdays(char *);
389-static unsigned long setvarattr(char *);
390-static unsigned long setautoidealload(char *);
391-static unsigned long setautomaxload(char *);
392-static unsigned long setnodefilesuffix(char *);
393-static unsigned long setnospooldirlist(char *);
394-static unsigned long setmomhost(char *);
395-static unsigned long setrreconfig(char *);
396-static unsigned long setsourceloginbatch(char *);
397-static unsigned long setsourcelogininteractive(char *);
398-static unsigned long setspoolasfinalname(char *);
399-static unsigned long setremchkptdirlist(char *);
400-static unsigned long setmaxconnecttimeout(char *);
401-static unsigned long setkilldelay(char *);
402-
403-
404-static struct specials
405- {
406- char *name;
407- u_long(*handler)();
408- } special[] = {
409- { "alloc_par_cmd", setallocparcmd },
410- { "auto_ideal_load", setautoidealload },
411- { "auto_max_load", setautomaxload },
412- { "xauthpath", setxauthpath },
413- { "rcpcmd", setrcpcmd },
414- { "rcp_cmd", setrcpcmd },
415- { "pbsclient", setpbsclient },
416- { "configversion", configversion },
417- { "cputmult", cputmult },
418- { "ideal_load", setidealload },
419- { "ignwalltime", setignwalltime },
420- { "ignmem", setignmem },
421- { "igncput", setigncput },
422- { "ignvmem", setignvmem },
423- { "logevent", setlogevent },
424- { "loglevel", setloglevel },
425- { "max_load", setmaxload },
426- { "enablemomrestart", setenablemomrestart },
427- { "prologalarm", prologalarm },
428- { "restricted", restricted },
429- { "jobstartblocktime", jobstartblocktime },
430- { "usecp", usecp },
431- { "wallmult", wallmult },
432- { "clienthost", setpbsserver }, /* deprecated - use pbsserver */
433- { "pbsserver", setpbsserver },
434- { "node_check_script", setnodecheckscript },
435- { "node_check_interval", setnodecheckinterval },
436- { "timeout", settimeout },
437- { "checkpoint_interval", mom_checkpoint_set_checkpoint_interval },
438- { "checkpoint_script", mom_checkpoint_set_checkpoint_script },
439- { "restart_script", mom_checkpoint_set_restart_script },
440- { "checkpoint_run_exe", mom_checkpoint_set_checkpoint_run_exe_name },
441- { "down_on_error", setdownonerror },
442- { "status_update_time", setstatusupdatetime },
443- { "check_poll_time", setcheckpolltime },
444- { "tmpdir", settmpdir },
445- { "log_directory", setlogdirectory },
446- { "log_file_max_size", setlogfilemaxsize },
447- { "log_file_roll_depth", setlogfilerolldepth },
448- { "log_file_suffix", setlogfilesuffix },
449- { "log_keep_days", setlogkeepdays },
450- { "varattr", setvarattr },
451- { "nodefile_suffix", setnodefilesuffix },
452- { "nospool_dir_list", setnospooldirlist },
453- { "mom_host", setmomhost },
454- { "remote_reconfig", setrreconfig },
455- { "job_output_file_umask", setumask },
456- { "preexec", setpreexec },
457- { "source_login_batch", setsourceloginbatch },
458- { "source_login_interactive", setsourcelogininteractive },
459- { "spool_as_final_name", setspoolasfinalname },
460- { "remote_checkpoint_dirs", setremchkptdirlist },
461- { "max_conn_timeout_micro_sec", setmaxconnecttimeout },
462- { "kill_delay", setkilldelay },
463- { NULL, NULL }
464- };
465-
466-
467-static char *arch(struct rm_attribute *);
468-static char *opsys(struct rm_attribute *);
469-static char *requname(struct rm_attribute *);
470-static char *validuser(struct rm_attribute *);
471-static char *reqmsg(struct rm_attribute *);
472-char *reqgres(struct rm_attribute *);
473-static char *reqstate(struct rm_attribute *);
474-static char *getjoblist(struct rm_attribute *);
475-static char *reqvarattr(struct rm_attribute *);
476-/* static char *nullproc(struct rm_attribute *); */
477-
478-
479-struct config common_config[] =
480- {
481- { "arch", {arch} }, /* machine architecture */
482- { "opsys", {opsys} }, /* operating system */
483- { "uname", {requname} }, /* user name ??? */
484- { "validuser", {validuser} }, /* valid user ??? */
485- { "message", {reqmsg} }, /* message ??? */
486- { "gres", {reqgres} }, /* generic resource (licenses...) */
487- { "state", {reqstate} }, /* state of pbs_mom */
488- { "jobs", {getjoblist} }, /* job list this pbs_mom */
489- { "varattr", {reqvarattr} }, /* ??? */
490- { NULL, {NULL} }
491- };
492-
493-int LOGLEVEL = 0; /* valid values (0 - 10) */
494-int LOGKEEPDAYS = 0; /* days each log file should be kept before deleting */
495-int DEBUGMODE = 0;
496-int DOBACKGROUND = 1;
497-char DEFAULT_UMASK[1024];
498-char PRE_EXEC[1024];
499-long TJobStartBlockTime = 5; /* seconds to wait for job to launch before backgrounding */
500-long TJobStartTimeout = 300; /* seconds to wait for job to launch before purging */
501-
502-
503-char *ret_string;
504-int ret_size;
505-
506-struct config *config_array = NULL;
507-
508-struct config_list *config_list = NULL;
509-sigset_t allsigs;
510-int rm_errno;
511-unsigned int reqnum = 0; /* the packet number */
512-
513-int port_care = TRUE; /* secure connecting ports */
514-uid_t uid = 0; /* uid we are running with */
515-unsigned int alarm_time = 10; /* time before alarm */
516-
517-extern tree *okclients; /* accept connections from */
518-char **maskclient = NULL; /* wildcard connections */
519-int mask_num = 0;
520-int mask_max = 0;
521-u_long localaddr = 0;
522-
523-char extra_parm[] = "extra parameter(s)";
524-char no_parm[] = "required parameter not found";
525-char varattr_delimiter[] = ";";
526-
527-int cphosts_num = 0;
528-
529-struct cphosts *pcphosts = NULL;
530-
531-static int config_file_specified = 0;
532-static char config_file[_POSIX_PATH_MAX] = "config";
533-
534-char PBSNodeMsgBuf[1024];
535-char PBSNodeCheckPath[1024];
536-int PBSNodeCheckInterval;
537-int PBSNodeCheckProlog = 0;
538-int PBSNodeCheckEpilog = 0;
539-static char *MOMExePath = NULL;
540-static time_t MOMExeTime = 0;
541-
542-
543-/* sync w/#define JOB_SUBSTATE_XXX (in include/pbs_job.h)*/
544-
545-const char *PJobSubState[] =
546- {
547- "TRANSIN", /* Transit in, wait for commit */
548- "TRANSICM", /* Transit in, wait for commit */
549- "TRNOUT", /* transiting job outbound */
550- "TRNOUTCM", /* transiting outbound, rdy to commit */
551- "SUBSTATE04",
552- "SUBSTATE05",
553- "SUBSTATE06",
554- "SUBSTATE07",
555- "SUBSTATE08",
556- "SUBSTATE09",
557- "QUEUED", /* job queued and ready for selection */
558- "PRESTAGEIN", /* job queued, has files to stage in */
559- "SUBSTATE12",
560- "SYNCRES", /* job waiting on sync start ready */
561- "STAGEIN", /* job staging in files then wait */
562- "STAGEGO", /* job staging in files and then run */
563- "STAGECMP", /* job stage in complete */
564- "SUBSTATE17",
565- "SUBSTATE18",
566- "SUBSTATE19",
567- "HELD", /* job held - user or operator */
568- "SYNCHOLD", /* job held - waiting on sync regist */
569- "DEPNHOLD", /* job held - waiting on dependency */
570- "SUBSTATE23",
571- "SUBSTATE24",
572- "SUBSTATE25",
573- "SUBSTATE26",
574- "SUBSTATE27",
575- "SUBSTATE28",
576- "SUBSTATE29",
577- "WAITING", /* job waiting on execution time */
578- "SUBSTATE31",
579- "SUBSTATE32",
580- "SUBSTATE33",
581- "SUBSTATE34",
582- "SUBSTATE35",
583- "SUBSTATE36",
584- "STAGEFAIL", /* job held - file stage in failed */
585- "SUBSTATE38",
586- "SUBSTATE39",
587- "PRERUN", /* job sent to MOM to run */
588- "STARTING", /* final job start initiated */
589- "RUNNING", /* job running */
590- "SUSPEND", /* job suspended, CRAY only */
591- "SUBSTATE44",
592- "SUBSTATE45",
593- "SUBSTATE46",
594- "SUBSTATE47",
595- "SUBSTATE48",
596- "SUBSTATE49",
597- "EXITING", /* Start of job exiting processing */
598- "STAGEOUT", /* job staging out (other) files */
599- "STAGEDEL", /* job deleteing staged out files */
600- "EXITED", /* job exit processing completed */
601- "ABORT", /* job is being aborted by server */
602- "SUBSTATE55",
603- "SUBSTATE56",
604- "PREOBIT", /* preobit job status */
605- "OBIT", /* (MOM) job obit notice sent */
606- "COMPLETED",
607- "RERUN", /* job is rerun, recover output stage */
608- "RERUN1", /* job is rerun, stageout phase */
609- "RERUN2", /* job is rerun, delete files stage */
610- "RERUN3", /* job is rerun, mom delete job */
611- "RETSTD", /* job has checkpoint file, return stdout / stderr files to server
612- * spool dir so that job can be restarted
613- */
614- NULL
615- };
616-
617-
618-/* sync w/#define IS_XXX */
619-
620-const char *PBSServerCmds[] =
621- {
622- "NULL",
623- "HELLO",
624- "CLUSTER_ADDRS",
625- "UPDATE",
626- "STATUS",
627- NULL
628- };
629-
630-
631-/*
632-** These routines are in the "dependent" code.
633-*/
634-
635-extern void dep_initialize A_((void));
636-extern void dep_cleanup A_((void));
637-
638-/* External Functions */
639-
640-extern void catch_child A_((int));
641-extern void init_abort_jobs A_((int));
642-extern void scan_for_exiting();
643-extern void scan_for_terminated();
644-extern int TMomCheckJobChild(pjobexec_t *, int, int *, int *);
645-extern int TMomFinalizeJob3(pjobexec_t *, int, int, int *);
646-extern void exec_bail(job *, int);
647-extern void check_state(int);
648-extern void DIS_tcp_funcs();
649-
650-
651-/* Local public functions */
652-
653-static void stop_me A_((int));
654-static void PBSAdjustLogLevel A_((int));
655-int TMOMScanForStarting(void);
656-
657-
658-/* Local private functions */
659-
660-void check_log A_((void));
661-
662-
663-
664-
665-
666-char *nullproc(
667-
668- struct rm_attribute *attrib)
669-
670- {
671- char *id = "nullproc";
672-
673- log_err(-1,id,"should not be called");
674-
675- return(NULL);
676- } /* END nullproc() */
677-
678-
679-
680-
681-static char *arch(
682-
683- struct rm_attribute *attrib) /* I */
684-
685- {
686- char *id = "arch";
687-
688- struct config *cp;
689-
690- if (attrib != NULL)
691- {
692- log_err(-1, id, extra_parm);
693-
694- rm_errno = RM_ERR_BADPARAM;
695-
696- return(NULL);
697- }
698-
699- if (config_array == NULL)
700- {
701- return(PBS_MACH);
702- }
703-
704- /* locate arch string */
705-
706- for (cp = config_array;cp->c_name != NULL;cp++)
707- {
708- if (cp->c_u.c_value == NULL)
709- continue;
710-
711- if (strcmp(cp->c_name, "arch"))
712- continue;
713-
714- return(cp->c_u.c_value);
715- } /* END for (cp) */
716-
717- return(PBS_MACH);
718- } /* END arch() */
719-
720-
721-
722-
723-static char *opsys(
724-
725- struct rm_attribute *attrib) /* I */
726-
727- {
728- char *id = "opsys";
729-
730- struct config *cp;
731-
732- if (attrib != NULL)
733- {
734- log_err(-1, id, extra_parm);
735-
736- rm_errno = RM_ERR_BADPARAM;
737-
738- return(NULL);
739- }
740-
741- if (config_array == NULL)
742- {
743- return(PBS_MACH);
744- }
745-
746- /* locate opsys string */
747-
748- for (cp = config_array;cp->c_name != NULL;cp++)
749- {
750- if (cp->c_u.c_value == NULL)
751- continue;
752-
753- if (strcmp(cp->c_name, "opsys"))
754- continue;
755-
756- return(cp->c_u.c_value);
757- } /* END for (cp) */
758-
759- return(PBS_MACH);
760- } /* END opsys() */
761-
762-
763-
764-
765-
766-char *
767-getuname(void)
768-
769- {
770-
771- struct utsname n;
772- static char *name = NULL;
773-
774- if (name == NULL)
775- {
776- if (uname(&n) == -1)
777- {
778- return(NULL);
779- }
780-
781- sprintf(ret_string, "%s %s %s %s %s",
782-
783- n.sysname,
784- n.nodename,
785- n.release,
786- n.version,
787- n.machine);
788-
789- name = strdup(ret_string);
790- } /* END if (name == NULL) */
791-
792- return(name);
793- } /* END getuname() */
794-
795-
796-
797-
798-static char *reqmsg(
799-
800- struct rm_attribute *attrib)
801-
802- {
803- char *id = "reqmsg";
804-
805- if (attrib != NULL)
806- {
807- log_err(-1, id, extra_parm);
808-
809- rm_errno = RM_ERR_BADPARAM;
810-
811- return(NULL);
812- }
813-
814- return(PBSNodeMsgBuf);
815- } /* END reqmsg() */
816-
817-
818-
819-
820-static char *getjoblist(
821-
822- struct rm_attribute *attrib) /* I */
823-
824- {
825- static char *list = NULL;
826- static int listlen = 0;
827- job *pjob;
828- int firstjob = 1;
829-
830- if (list == NULL)
831- {
832- if ((list = calloc(BUFSIZ + 50, sizeof(char)))==NULL)
833- {
834- /* FAILURE - cannot alloc memory */
835-
836- fprintf(stderr,"ERROR: could not calloc!\n");
837-
838- /* since memory cannot be allocated, report no jobs */
839-
840- return (" ");
841- }
842-
843- listlen = BUFSIZ;
844- }
845-
846- *list = '\0'; /* reset the list */
847-
848- if ((pjob = (job *)GET_NEXT(svr_alljobs)) == NULL)
849- {
850- /* no jobs - return space character */
851-
852- return(" ");
853- }
854-
855- for (;pjob != NULL;pjob = (job *)GET_NEXT(pjob->ji_alljobs))
856- {
857- if (!firstjob)
858- strcat(list, " ");
859-
860- strcat(list, pjob->ji_qs.ji_jobid);
861-
862- if ((int)strlen(list) >= listlen)
863- {
864- char *tmpList;
865-
866- listlen += BUFSIZ;
867-
868- tmpList = realloc(list,listlen);
869-
870- if (tmpList == NULL)
871- {
872- /* FAILURE - cannot alloc memory */
873-
874- fprintf(stderr,"ERROR: could not realloc!\n");
875-
876- /* since memory cannot be allocated, report no jobs */
877-
878- return(" ");
879- }
880-
881- list = tmpList;
882- }
883-
884- firstjob = 0;
885- } /* END for (pjob) */
886-
887- if (list[0] == '\0')
888- {
889- /* no jobs - return space character */
890-
891- strcat(list, " ");
892- }
893-
894- return(list);
895- } /* END getjoblist() */
896-
897-
898-
899-
900-#define TMAX_VARBUF 65536
901-
902-static char *reqvarattr(
903-
904- struct rm_attribute *attrib) /* I */
905-
906- {
907- static char id[] = "reqvarattr";
908-
909- static char *list = NULL, *child_spot;
910- static int listlen = 0;
911-
912- struct varattr *pva;
913- int fd, len, child_len;
914- int first_line;
915- FILE *child;
916-
917- char *ptr;
918- char *ptr2;
919-
920- char tmpBuf[TMAX_VARBUF + 1];
921-
922- if (list == NULL)
923- {
924- list = calloc(BUFSIZ + 1024, sizeof(char));
925-
926- if (list == NULL)
927- {
928- /* FAILURE - cannot alloc memory */
929-
930- log_err(errno,id,"cannot alloc memory");
931-
932- return(" ");
933- }
934-
935- listlen = BUFSIZ;
936- }
937-
938- *list = '\0'; /* reset the list */
939-
940- if ((pva = (struct varattr *)GET_NEXT(mom_varattrs)) == NULL)
941- {
942- return(" ");
943- }
944-
945- for (;pva != NULL;pva = (struct varattr *)GET_NEXT(pva->va_link))
946- {
947- /* loop for each $varattr parameter */
948-
949- if ((pva->va_lasttime == 0) || (time_now >= (pva->va_ttl + pva->va_lasttime)))
950- {
951- if ((pva->va_ttl == -1) && (pva->va_lasttime != 0))
952- {
953- if (pva->va_value[0] != '\0')
954- {
955- if (*list != '\0')
956- strcat(list, varattr_delimiter);
957-
958- strcat(list, pva->va_value);
959- }
960-
961- if ((int)strlen(list) >= listlen)
962- {
963- listlen += BUFSIZ;
964-
965- list = realloc(list, listlen);
966-
967- if (list == NULL)
968- {
969- log_err(errno,id,"cannot alloc memory");
970-
971- return(" ");
972- }
973- }
974-
975- continue; /* ttl of -1 is only run once */
976- }
977-
978- /* TTL is satisfied, reload value */
979-
980- pva->va_lasttime = time_now;
981-
982- if (pva->va_value == NULL)
983- pva->va_value = calloc(TMAX_VARBUF, sizeof(char));
984-
985- /* execute script and get a new value */
986-
987- if ((child = popen(pva->va_cmd, "r")) == NULL)
988- {
989- sprintf(pva->va_value, "error: %d %s",
990- errno,
991- strerror(errno));
992- }
993- else
994- {
995- fd = fileno(child);
996-
997- child_spot = tmpBuf;
998- child_len = 0;
999- child_spot[0] = '\0';
1000-
1001-retryread:
1002-
1003- while ((len = read(fd, child_spot, TMAX_VARBUF - child_len)) > 0)
1004- {
1005- child_len += len;
1006- child_spot += len;
1007-
1008- if (child_len >= TMAX_VARBUF - 1)
1009- break;
1010- } /* END while ((len = read() > 0) */
1011-
1012- if (len == -1)
1013- {
1014- /* FAILURE - cannot read var script output */
1015-
1016- if (errno == EINTR)
1017- goto retryread;
1018-
1019- log_err(errno, id, "pipe read");
1020-
1021- sprintf(pva->va_value, "? %d",
1022- RM_ERR_SYSTEM);
1023-
1024- pclose(child);
1025-
1026- continue;
1027- }
1028-
1029- /* SUCCESS */
1030-
1031- pclose(child);
1032-
1033- tmpBuf[child_len] = '\0';
1034-
1035- /* Transfer returned data into var value field */
1036-
1037- first_line = TRUE;
1038-
1039- ptr = strtok(tmpBuf,"\n;");
1040-
1041- ptr2 = pva->va_value;
1042-
1043- ptr2[0] = '\0';
1044-
1045- /*
1046- * OUTPUT FORMAT: Take what script gives us.
1047- * Script should output 1 or more lines of Name=value1+value2+...
1048- */
1049-
1050- while (ptr != NULL)
1051- {
1052- if (!first_line)
1053- strcat(ptr2,varattr_delimiter);
1054-
1055- strcat(ptr2,ptr);
1056-
1057- first_line = FALSE;
1058-
1059- ptr = strtok(NULL,"\n;");
1060- } /* END while (ptr != NULL) */
1061- } /* END else ((child = popen(pva->va_cmd,"r")) == NULL) */
1062- } /* END if ((pva->va_lasttime == 0) || ...) */
1063-
1064- if (pva->va_value[0] != '\0')
1065- {
1066- if (*list != '\0')
1067- strcat(list, varattr_delimiter);
1068-
1069- strcat(list, pva->va_value);
1070- }
1071-
1072- if ((int)strlen(list) >= listlen)
1073- {
1074- listlen += BUFSIZ;
1075- list = realloc(list, listlen);
1076-
1077- if (list == NULL)
1078- {
1079- log_err(errno,id,"cannot alloc memory");
1080-
1081- return(" ");
1082- }
1083- }
1084- } /* END for (pva) */
1085-
1086- if (list[0] == '\0')
1087- strcat(list, " ");
1088-
1089- return(list);
1090- } /* END reqvarattr() */
1091-
1092-
1093-
1094-
1095-
1096-char *reqgres(
1097-
1098- struct rm_attribute *attrib) /* I (ignored) */
1099-
1100- {
1101- char *id = "reqgres";
1102-
1103- struct config *cp;
1104-
1105- static char GResBuf[1024];
1106- char tmpLine[1024];
1107-
1108- int sindex;
1109-
1110- if (attrib != NULL)
1111- {
1112- log_err(-1, id, extra_parm);
1113-
1114- rm_errno = RM_ERR_BADPARAM;
1115-
1116- return(NULL);
1117- }
1118-
1119- /* build gres string */
1120-
1121- /* FORMAT: <GRES>:<VALUE>[+<GRES>:<VALUE>]... */
1122-
1123- GResBuf[0] = '\0';
1124-
1125- if (config_array == NULL)
1126- {
1127- return(GResBuf);
1128- }
1129-
1130- for (cp = config_array;cp->c_name != NULL;cp++)
1131- {
1132- if (cp->c_u.c_value == NULL)
1133- continue;
1134-
1135- /* verify parameter is not special */
1136-
1137- for (sindex = 0;sindex < RM_NPARM;sindex++)
1138- {
1139- if (special[sindex].name == NULL)
1140- break;
1141-
1142- if (!strcmp(special[sindex].name, cp->c_name))
1143- break;
1144- } /* END for (sindex) */
1145-
1146- if ((sindex < RM_NPARM) &&
1147- (special[sindex].name != NULL) &&
1148- (!strcmp(special[sindex].name, cp->c_name)))
1149- {
1150- /* specified parameter is special parameter */
1151-
1152- continue;
1153- }
1154-
1155- /* verify parameter is not common */
1156-
1157- for (sindex = 0;sindex < RM_NPARM;sindex++)
1158- {
1159- if (common_config[sindex].c_name == NULL)
1160- break;
1161-
1162- if (!strcmp(common_config[sindex].c_name, cp->c_name))
1163- break;
1164- } /* END for (sindex) */
1165-
1166- if ((sindex < RM_NPARM) &&
1167- (common_config[sindex].c_name != NULL) &&
1168- !strcmp(common_config[sindex].c_name, cp->c_name) &&
1169- strcmp(common_config[sindex].c_name, "gres"))
1170- {
1171- /* specified parameter is common parameter */
1172-
1173- continue;
1174- }
1175-
1176- if (!strncmp(cp->c_name, "size", strlen("size")))
1177- continue;
1178-
1179- if (GResBuf[0] != '\0')
1180- strncat(GResBuf, "+", 1024);
1181-
1182- snprintf(tmpLine, 1024, "%s:%s",
1183- cp->c_name,
1184- cp->c_u.c_value);
1185-
1186- strncat(GResBuf, tmpLine, (sizeof(GResBuf) - strlen(GResBuf) - 1));
1187- } /* END for (cp) */
1188-
1189- return(GResBuf);
1190- } /* END reqgres() */
1191-
1192-
1193-
1194-
1195-static char *reqstate(
1196-
1197- struct rm_attribute *attrib) /* I (ignored) */
1198-
1199- {
1200- static char state[1024];
1201-
1202- if ((internal_state & INUSE_DOWN) && (MOMConfigDownOnError != 0))
1203- strcpy(state, "down");
1204- else if (internal_state & INUSE_BUSY)
1205- strcpy(state, "busy");
1206- else
1207- strcpy(state, "free");
1208-
1209- return(state);
1210- } /* END reqstate() */
1211-
1212-
1213-
1214-
1215-static char *requname(
1216-
1217- struct rm_attribute *attrib)
1218-
1219- {
1220- char *id = "uname";
1221- char *cp;
1222-
1223- if (attrib != NULL)
1224- {
1225- log_err(-1, id, extra_parm);
1226-
1227- rm_errno = RM_ERR_BADPARAM;
1228-
1229- return(NULL);
1230- }
1231-
1232- cp = getuname();
1233-
1234- return(cp);
1235- } /* END requname() */
1236-
1237-
1238-
1239-
1240-
1241-static char *validuser(
1242-
1243- struct rm_attribute *attrib)
1244-
1245- {
1246- char *id = "valid_user";
1247-
1248- struct passwd *p;
1249-
1250- if ((attrib == NULL) || (attrib->a_value == NULL))
1251- {
1252- log_err(-1, id, no_parm);
1253- rm_errno = RM_ERR_NOPARAM;
1254-
1255- return(NULL);
1256- }
1257-
1258- p = getpwnam(attrib->a_value);
1259-
1260- if (p != NULL)
1261- {
1262- return("yes");
1263- }
1264-
1265- return("no");
1266- } /* END validuser() */
1267-
1268-
1269-
1270-
1271-
1272-char *loadave(
1273-
1274- struct rm_attribute *attrib)
1275-
1276- {
1277- char *id = "loadave";
1278- static char ret_string[20];
1279- double la;
1280-
1281- if (attrib)
1282- {
1283- log_err(-1, id, extra_parm);
1284-
1285- rm_errno = RM_ERR_BADPARAM;
1286-
1287- return(NULL);
1288- }
1289-
1290- if (get_la(&la) != 0)
1291- {
1292- rm_errno = RM_ERR_SYSTEM;
1293-
1294- return(NULL);
1295- }
1296-
1297- sprintf(ret_string, "%.2f",
1298-
1299- la);
1300-
1301- return(ret_string);
1302- } /* END loadave() */
1303-
1304-
1305-
1306-
1307-
1308-/*
1309-** Search the array of resources read from the config files.
1310-*/
1311-
1312-struct config *rm_search(
1313-
1314- struct config *where, /* I */
1315- char *what) /* I */
1316-
1317- {
1318-
1319- struct config *cp;
1320-
1321- if (where == NULL || what == NULL)
1322- {
1323- return NULL;
1324- }
1325-
1326- for (cp = where;cp->c_name != NULL;cp++)
1327- {
1328- if (strcmp(cp->c_name, what) == 0)
1329- {
1330- return(cp);
1331- }
1332- } /* END for (cp) */
1333-
1334- return(NULL);
1335- } /* END rm_search() */
1336-
1337-
1338-
1339-
1340-
1341-/*
1342-** Search the various resource lists.
1343-*/
1344-
1345-char *dependent(
1346-
1347- char *res, /* I */
1348- struct rm_attribute *attr) /* I */
1349-
1350- {
1351-
1352- struct config *ap;
1353-
1354- extern struct config standard_config[];
1355-
1356- extern struct config dependent_config[];
1357-
1358- ap = rm_search(common_config, res);
1359-
1360- if (ap != NULL)
1361- {
1362- return(ap->c_u.c_func(attr));
1363- }
1364-
1365- ap = rm_search(standard_config, res);
1366-
1367- if (ap != NULL)
1368- {
1369- return(ap->c_u.c_func(attr));
1370- }
1371-
1372- ap = rm_search(dependent_config, res);
1373-
1374- if (ap != NULL)
1375- {
1376- return(ap->c_u.c_func(attr));
1377- }
1378-
1379- rm_errno = RM_ERR_UNKNOWN;
1380-
1381- return(NULL);
1382- } /* END dependent() */
1383-
1384-
1385-
1386-
1387-
1388-
1389-void
1390-DIS_rpp_reset(void)
1391-
1392- {
1393- if (dis_getc != rpp_getc)
1394- {
1395- dis_getc = rpp_getc;
1396- dis_puts = (int (*) A_((int, const char *, size_t)))rpp_write;
1397- dis_gets = (int (*) A_((int, char *, size_t)))rpp_read;
1398- disr_skip = (int (*) A_((int, size_t)))rpp_skip;
1399-
1400- disr_commit = rpp_rcommit;
1401- disw_commit = rpp_wcommit;
1402- }
1403-
1404- return;
1405- } /* END DIS_rpp_reset() */
1406-
1407-
1408-
1409-
1410-
1411-/*
1412-** Initialize standard resource array
1413-*/
1414-
1415-void
1416-initialize(void)
1417-
1418- {
1419- char *id = "initialize";
1420-
1421- log_record(PBSEVENT_SYSTEM, 0, id, "independent");
1422-
1423- dep_initialize();
1424-
1425- return;
1426- }
1427-
1428-
1429-
1430-
1431-void
1432-cleanup(void)
1433-
1434- {
1435- dep_cleanup();
1436-
1437- return;
1438- }
1439-
1440-
1441-
1442-
1443-/*
1444-** Clean up after a signal.
1445-*/
1446-
1447-void die(
1448-
1449- int sig)
1450-
1451- {
1452- char *id = "die";
1453-
1454- if (sig > 0)
1455- {
1456- sprintf(log_buffer, "caught signal %d",
1457- sig);
1458-
1459- log_record(PBSEVENT_SYSTEM, 0, id, log_buffer);
1460- }
1461- else
1462- {
1463- log_record(PBSEVENT_SYSTEM, 0, id, "abnormal termination");
1464- }
1465-
1466- cleanup();
1467-
1468- log_close(1);
1469-
1470- exit(1);
1471- } /* END die() */
1472-
1473-
1474-
1475-
1476-/*
1477-** Check for fatal memory allocation error.
1478-*/
1479-
1480-void memcheck(
1481-
1482- char *buf)
1483-
1484- {
1485- if (buf != NULL)
1486- {
1487- return;
1488- }
1489-
1490- log_err(-1, "memcheck", "memory allocation failed");
1491-
1492- die(0);
1493-
1494- return;
1495- } /* END memcheck() */
1496-
1497-
1498-
1499-
1500-
1501-/*
1502-** Check the ret_string buffer to make sure that there is
1503-** enought room starting at *spot to hold len characters more.
1504-** If not, realloc the buffer and make *spot point to
1505-** the corresponding place that it used to point to in
1506-** the old buffer.
1507-*/
1508-
1509-void checkret(
1510-
1511- char **spot,
1512- int len)
1513-
1514- {
1515- char *id = "checkret";
1516- char *hold;
1517-
1518- if ((*spot - ret_string) < (ret_size - len))
1519- {
1520- return;
1521- }
1522-
1523- ret_size += len * 2; /* new buf size */
1524-
1525- sprintf(log_buffer, "size increased to %d",
1526- ret_size);
1527-
1528- log_record(PBSEVENT_SYSTEM, 0, id, log_buffer);
1529-
1530- hold = realloc(ret_string, ret_size); /* new buf */
1531-
1532- memcheck(hold);
1533-
1534- *spot = *spot - ret_string + hold; /* new spot in buf */
1535-
1536- ret_string = hold;
1537-
1538- return;
1539- } /* END checkret() */
1540-
1541-
1542-
1543-
1544-
1545-char *skipwhite(
1546-
1547- char *str)
1548-
1549- {
1550- for (;*str;str++)
1551- {
1552- if (!isspace(*str))
1553- break;
1554- }
1555-
1556- return(str);
1557- }
1558-
1559-
1560-
1561-
1562-
1563-char *tokcpy(
1564-
1565- char *str,
1566- char *tok)
1567-
1568- {
1569- for (;*str;str++, tok++)
1570- {
1571- if (!isalnum(*str) && *str != ':' && *str != '_')
1572- break;
1573-
1574- *tok = *str;
1575- } /* END tokcpy() */
1576-
1577- *tok = '\0';
1578-
1579- return(str);
1580- } /* END tokcpy() */
1581-
1582-
1583-
1584-
1585-void rmnl(
1586-
1587- char *str)
1588-
1589- {
1590- int i;
1591-
1592- i = strlen(str);
1593-
1594- while (--i)
1595- {
1596- if ((*(str + i) != '\n') && !isspace((int)*(str + i)))
1597- break;
1598-
1599- *(str + i) = '\0';
1600- }
1601-
1602- return;
1603- }
1604-
1605-
1606-
1607-
1608-
1609-u_long addclient(
1610-
1611- char *name) /* I */
1612-
1613- {
1614- static char id[] = "addclient";
1615-
1616- struct hostent *host;
1617-
1618- struct in_addr saddr;
1619- u_long ipaddr;
1620-
1621- /* FIXME: must be able to retry failed lookups later */
1622-
1623- if ((host = gethostbyname(name)) == NULL)
1624- {
1625- sprintf(log_buffer, "host %s not found",
1626- name);
1627-
1628- log_err(-1, id, log_buffer);
1629-
1630- return(0);
1631- }
1632-
1633- memcpy(&saddr, host->h_addr, host->h_length);
1634-
1635- ipaddr = ntohl(saddr.s_addr);
1636-
1637- tinsert(ipaddr, NULL, &okclients);
1638-
1639- return(ipaddr);
1640- } /* END addclient() */
1641-
1642-
1643-
1644-
1645-
1646-static u_long setpbsclient(
1647-
1648- char *value) /* I */
1649-
1650- {
1651- u_long rc;
1652-
1653- if ((value == NULL) || (value[0] == '\0'))
1654- {
1655- /* FAILURE */
1656-
1657- return(1);
1658- }
1659-
1660- rc = addclient(value);
1661-
1662- if (rc != 0)
1663- {
1664- /* FAILURE */
1665-
1666- return(1);
1667- }
1668-
1669- return(0);
1670- } /* END setpbsclient() */
1671-
1672-
1673-
1674-
1675-/* FIXME: we need to handle a non-default port number */
1676-
1677-static u_long setpbsserver(
1678-
1679- char *value) /* I */
1680-
1681- {
1682- static char id[] = "setpbsserver";
1683-
1684- if ((value == NULL) || (*value == '\0'))
1685- {
1686- return(1); /* FAILURE - nothing specified */
1687- }
1688-
1689- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value);
1690-
1691-
1692- return(mom_server_add(value));
1693- } /* END setpbsserver() */
1694-
1695-
1696-
1697-
1698-static u_long settmpdir(
1699-
1700- char *Value)
1701-
1702- {
1703- static char id[] = "settmpdir";
1704-
1705- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1706-
1707- if (*Value != '/')
1708- {
1709- log_err(-1, id, "tmpdir must be a full path");
1710-
1711- return(0);
1712- }
1713-
1714- strncpy(tmpdir_basename, Value, sizeof(tmpdir_basename));
1715-
1716- return(1);
1717- }
1718-
1719-static u_long setxauthpath(
1720-
1721- char *Value)
1722-
1723- {
1724- static char id[] = "setxauthpath";
1725-
1726- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1727-
1728- if (*Value != '/')
1729- {
1730- log_err(-1, id, "xauthpath must be a full path");
1731-
1732- return(0);
1733- }
1734-
1735- strncpy(xauth_path, Value, sizeof(xauth_path));
1736-
1737- return(1);
1738- }
1739-
1740-
1741-
1742-
1743-
1744-static u_long setrcpcmd(
1745-
1746- char *Value) /* I */
1747-
1748- {
1749- static char id[] = "rcpcmd";
1750- static char *ptr;
1751-
1752- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1753-
1754- if (*Value != '/')
1755- {
1756- log_err(-1, id, "rcpcmd must be a full path");
1757-
1758- /* FAILURE */
1759-
1760- return(0);
1761- }
1762-
1763- strncpy(rcp_path, Value, sizeof(rcp_path));
1764-
1765- strcpy(rcp_args, "");
1766-
1767- if ((ptr = strchr(rcp_path, ' ')) != NULL)
1768- {
1769- *ptr = '\0';
1770-
1771- if (*(ptr + 1) != '\0')
1772- {
1773- strncpy(rcp_args, ptr + 1, sizeof(rcp_args));
1774- }
1775- }
1776-
1777- /* SUCCESS */
1778-
1779- return(1);
1780- } /* END setrcpcmd() */
1781-
1782-
1783-
1784-
1785-
1786-static u_long setlogevent(
1787-
1788- char *value)
1789-
1790- {
1791- char *bad;
1792-
1793- *log_event_mask = strtol(value, &bad, 0);
1794-
1795- if ((*bad == '\0') || isspace((int)*bad))
1796- {
1797- return(1);
1798- }
1799-
1800- return(0);
1801- } /* END setlogevent() */
1802-
1803-
1804-
1805-
1806-
1807-/* NOTE: maskclient is global */
1808-
1809-static u_long restricted(
1810-
1811- char *name)
1812-
1813- {
1814- static char id[] = "restricted";
1815-
1816- char **tmpMaskClient;
1817-
1818- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, name);
1819-
1820- if (mask_max == 0)
1821- {
1822- if ((maskclient = (char **)calloc(4, sizeof(char *))) == NULL)
1823- {
1824- /* FAILURE - cannot alloc memory */
1825-
1826- log_err(errno,id,"cannot alloc memory");
1827-
1828- return(-1);
1829- }
1830-
1831- mask_max = 4;
1832- }
1833-
1834- maskclient[mask_num] = strdup(name);
1835-
1836- if (maskclient[mask_num] == NULL)
1837- {
1838- /* FAILURE - cannot alloc memory */
1839-
1840- log_err(errno,id,"cannot alloc memory");
1841-
1842- return(-1);
1843- }
1844-
1845- mask_num++;
1846-
1847- if (mask_num == mask_max)
1848- {
1849- mask_max *= 2;
1850-
1851- tmpMaskClient = (char **)realloc(
1852- maskclient,
1853- mask_max * sizeof(char *));
1854-
1855- if (tmpMaskClient == NULL)
1856- {
1857- /* FAILURE - cannot alloc memory */
1858-
1859- log_err(errno,id,"cannot alloc memory");
1860-
1861- return(-1);
1862- }
1863-
1864- maskclient = tmpMaskClient;
1865- }
1866-
1867- /* SUCCESS */
1868-
1869- return(1);
1870- } /* END restricted() */
1871-
1872-
1873-
1874-
1875-
1876-static u_long configversion(
1877-
1878- char *Value) /* I */
1879-
1880- {
1881- static char id[] = "configversion";
1882-
1883- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1884-
1885- if (Value == NULL)
1886- {
1887- /* FAILURE */
1888-
1889- return(0);
1890- }
1891-
1892- strncpy(MOMConfigVersion, Value, sizeof(MOMConfigVersion));
1893-
1894- /* SUCCESS */
1895-
1896- return(1);
1897- } /* END configversion() */
1898-
1899-
1900-
1901-
1902-
1903-static u_long setdownonerror(
1904-
1905- char *Value) /* I */
1906-
1907- {
1908- static char id[] = "setdownonerror";
1909- int enable = -1;
1910-
1911- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1912-
1913- if (Value == NULL)
1914- {
1915- /* FAILURE */
1916-
1917- return(0);
1918- }
1919-
1920- /* accept various forms of "true", "yes", and "1" */
1921- switch (Value[0])
1922- {
1923-
1924- case 't':
1925-
1926- case 'T':
1927-
1928- case 'y':
1929-
1930- case 'Y':
1931-
1932- case '1':
1933-
1934- enable = 1;
1935-
1936- break;
1937-
1938- case 'f':
1939-
1940- case 'F':
1941-
1942- case 'n':
1943-
1944- case 'N':
1945-
1946- case '0':
1947-
1948- enable = 0;
1949-
1950- break;
1951-
1952- }
1953-
1954- if (enable != -1)
1955- {
1956- MOMConfigDownOnError = enable;
1957- }
1958-
1959- return(1);
1960- } /* END setdownonerror() */
1961-
1962-
1963-static u_long setenablemomrestart(
1964-
1965- char *Value) /* I */
1966-
1967- {
1968- static char id[] = "setenablemomrestart";
1969- int enable = -1;
1970-
1971- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1972-
1973- if (Value == NULL)
1974- {
1975- /* FAILURE */
1976-
1977- return(0);
1978- }
1979-
1980- /* accept various forms of "true", "yes", and "1" */
1981- switch (Value[0])
1982- {
1983-
1984- case 't':
1985-
1986- case 'T':
1987-
1988- case 'y':
1989-
1990- case 'Y':
1991-
1992- case '1':
1993-
1994- enable = 1;
1995-
1996- break;
1997-
1998- case 'f':
1999-
2000- case 'F':
2001-
2002- case 'n':
2003-
2004- case 'N':
2005-
2006- case '0':
2007-
2008- enable = 0;
2009-
2010- break;
2011-
2012- }
2013-
2014- if (enable != -1)
2015- {
2016- MOMConfigRestart = enable;
2017- }
2018-
2019- return(1);
2020- } /* END setenablemomrestart() */
2021-
2022-
2023-
2024-
2025-static u_long cputmult(
2026-
2027- char *value) /* I */
2028-
2029- {
2030- static char id[] = "cputmult";
2031-
2032- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value);
2033-
2034- if ((cputfactor = atof(value)) == 0.0)
2035- {
2036- return(0); /* error */
2037- }
2038-
2039- return(1);
2040- } /* END cputmult() */
2041-
2042-
2043-
2044-
2045-
2046-static u_long wallmult(
2047-
2048- char *value)
2049-
2050- {
2051- static char id[] = "wallmult";
2052-
2053- double tmpD;
2054-
2055- if (value == NULL)
2056- {
2057- /* FAILURE */
2058-
2059- return(0);
2060- }
2061-
2062- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value);
2063-
2064- tmpD = atof(value);
2065-
2066- if ((tmpD == 0.0) && (value[0] != '\0'))
2067- {
2068- /* FAILURE */
2069-
2070- return(0);
2071- }
2072-
2073- /* SUCCESS */
2074-
2075- wallfactor = tmpD;
2076-
2077- return(1);
2078- } /* END wallmult() */
2079-
2080-
2081-
2082-
2083-static u_long usecp(
2084-
2085- char *value) /* I */
2086-
2087- {
2088- char *pnxt;
2089- static int cphosts_max = 0;
2090-
2091- struct cphosts *newp = NULL;
2092-
2093- static char *id = "usecp";
2094-
2095- /* FORMAT: <HOST>:<FROM> <TO> */
2096-
2097- /*
2098- * HvB and Willem added this for logging purpose
2099- */
2100-
2101- log_record(
2102- PBSEVENT_SYSTEM,
2103- PBS_EVENTCLASS_SERVER,
2104- id,
2105- value);
2106-
2107- if (cphosts_max == 0)
2108- {
2109- pcphosts = malloc(2 * sizeof(struct cphosts));
2110-
2111- if (pcphosts == NULL)
2112- {
2113- sprintf(log_buffer, "%s: out of memory while allocating pcphosts",
2114- id);
2115-
2116- log_err(-1, id, log_buffer);
2117-
2118- return(0);
2119- }
2120-
2121- cphosts_max = 2;
2122- }
2123- else if (cphosts_max == cphosts_num)
2124- {
2125- newp = realloc(
2126- pcphosts,
2127- (cphosts_max + 2) * sizeof(struct cphosts));
2128-
2129- if (newp == NULL)
2130- {
2131- /* FAILURE */
2132-
2133- sprintf(log_buffer,"%s: out of memory while reallocating pcphosts",
2134- id);
2135-
2136- log_err(-1,id,log_buffer);
2137-
2138- return(0);
2139- }
2140-
2141- pcphosts = newp;
2142-
2143- cphosts_max += 2;
2144- }
2145-
2146- pnxt = strchr(value, (int)':');
2147-
2148- if (pnxt == NULL)
2149- {
2150- /* request failed */
2151-
2152- sprintf(log_buffer, "invalid host specification: %s",
2153- value);
2154-
2155- log_err(-1, id, log_buffer);
2156-
2157- return(0);
2158- }
2159-
2160- *pnxt++ = '\0';
2161-
2162- pcphosts[cphosts_num].cph_hosts = strdup(value);
2163-
2164- if (pcphosts[cphosts_num].cph_hosts == NULL)
2165- {
2166- /* FAILURE */
2167-
2168- sprintf(log_buffer, "%s: out of memory in strdup(cph_hosts)",
2169- id);
2170-
2171- log_err(-1, id, log_buffer);
2172-
2173- return(0);
2174- }
2175-
2176- value = pnxt; /* now ptr to path */
2177-
2178- while (!isspace(*pnxt))
2179- {
2180- if (*pnxt == '\0')
2181- {
2182- sprintf(log_buffer, "invalid '%s' specification %s: "
2183- "missing destination path",
2184- id,
2185- value);
2186-
2187- log_err(-1, id, log_buffer);
2188-
2189- free(pcphosts[cphosts_num].cph_hosts);
2190-
2191- return(0);
2192- }
2193-
2194- pnxt++;
2195- }
2196-
2197- *pnxt++ = '\0';
2198-
2199- pcphosts[cphosts_num].cph_from = strdup(value);
2200-
2201- if (pcphosts[cphosts_num].cph_from == NULL)
2202- {
2203- sprintf(log_buffer, "%s: out of memory in strdup(cph_from)",
2204- id);
2205-
2206- log_err(-1, id, log_buffer);
2207-
2208- free(pcphosts[cphosts_num].cph_hosts);
2209-
2210- return(0);
2211- }
2212-
2213- pcphosts[cphosts_num].cph_to = strdup(skipwhite(pnxt));
2214-
2215- if (pcphosts[cphosts_num].cph_to == NULL)
2216- {
2217- sprintf(log_buffer, "%s: out of memory in strdup(cph_to)",
2218- id);
2219-
2220- log_err(-1, id, log_buffer);
2221-
2222- free(pcphosts[cphosts_num].cph_hosts);
2223- free(pcphosts[cphosts_num].cph_from);
2224-
2225- return(0);
2226- }
2227-
2228- cphosts_num++;
2229-
2230- return(1);
2231- } /* END usecp() */
2232-
2233-
2234-
2235-
2236-static unsigned long prologalarm(
2237-
2238- char *value) /* I */
2239-
2240- {
2241- int i;
2242-
2243- log_record(
2244- PBSEVENT_SYSTEM,
2245- PBS_EVENTCLASS_SERVER,
2246- "prologalarm",
2247- value);
2248-
2249- i = (int)atoi(value);
2250-
2251- if (i <= 0)
2252- {
2253- return(0); /* error */
2254- }
2255-
2256- pe_alarm_time = (unsigned int)i;
2257-
2258- return(1);
2259- } /* END prologalarm() */
2260-
2261-
2262-
2263-
2264-
2265-static unsigned long setloglevel(
2266-
2267- char *value) /* I */
2268-
2269- {
2270- int i;
2271-
2272- log_record(
2273- PBSEVENT_SYSTEM,
2274- PBS_EVENTCLASS_SERVER,
2275- "setloglevel",
2276- value);
2277-
2278- i = (int)atoi(value);
2279-
2280- if (i < 0)
2281- {
2282- return(0); /* error */
2283- }
2284-
2285- LOGLEVEL = (unsigned int)i;
2286-
2287- return(1);
2288- } /* END setloglevel() */
2289-
2290-
2291-
2292-
2293-
2294-static unsigned long setumask(
2295-
2296- char *value) /* I */
2297-
2298- {
2299- log_record(
2300- PBSEVENT_SYSTEM,
2301- PBS_EVENTCLASS_SERVER,
2302- "setumask",
2303- value);
2304-
2305- strncpy(DEFAULT_UMASK, value, sizeof(DEFAULT_UMASK));
2306-
2307- return(1);
2308- } /* END setumask() */
2309-
2310-
2311-
2312-
2313-static unsigned long setpreexec(
2314-
2315- char *value) /* I */
2316-
2317- {
2318-#if SHELL_USE_ARGV == 0
2319- static char *id = "setpreexec";
2320-#endif
2321- log_record(
2322- PBSEVENT_SYSTEM,
2323- PBS_EVENTCLASS_SERVER,
2324- "setpreexec",
2325- value);
2326-
2327- strncpy(PRE_EXEC, value, sizeof(PRE_EXEC));
2328-
2329-#if SHELL_USE_ARGV == 0
2330- log_err(0, id, "pbs_mom not configured with enable-shell-user-argv option");
2331-#endif
2332-
2333- return(1);
2334- } /* END setpreexec() */
2335-
2336-
2337-static unsigned long setsourceloginbatch(
2338-
2339- char *value) /* I */
2340-
2341- {
2342-
2343- log_record(
2344- PBSEVENT_SYSTEM,
2345- PBS_EVENTCLASS_SERVER,
2346- "setsourceloginbatch",
2347- value);
2348-
2349- if (value[0] != '\0')
2350- {
2351- /* accept various forms of "true", "yes", and "1" */
2352- switch (value[0])
2353- {
2354-
2355- case 't':
2356-
2357- case 'T':
2358-
2359- case 'y':
2360-
2361- case 'Y':
2362-
2363- case '1':
2364-
2365- src_login_batch = TRUE;
2366-
2367- break;
2368-
2369- case 'f':
2370-
2371- case 'F':
2372-
2373- case 'n':
2374-
2375- case 'N':
2376-
2377- case '0':
2378-
2379- src_login_batch = FALSE;
2380-
2381- break;
2382-
2383- default:
2384- sprintf(log_buffer, "Unknown value of %s", value);
2385-
2386- log_record(
2387- PBSEVENT_SYSTEM,
2388- PBS_EVENTCLASS_SERVER,
2389- "setsourceloginbatch",
2390- log_buffer);
2391- break;
2392-
2393- }
2394- }
2395-
2396- return(1);
2397- } /* END setsourceloginbatch() */
2398-
2399-
2400-static unsigned long setsourcelogininteractive(
2401-
2402- char *value) /* I */
2403-
2404- {
2405-
2406- log_record(
2407- PBSEVENT_SYSTEM,
2408- PBS_EVENTCLASS_SERVER,
2409- "setsourcelogininteractive",
2410- value);
2411-
2412- if (value[0] != '\0')
2413- {
2414- /* accept various forms of "true", "yes", and "1" */
2415- switch (value[0])
2416- {
2417-
2418- case 't':
2419-
2420- case 'T':
2421-
2422- case 'y':
2423-
2424- case 'Y':
2425-
2426- case '1':
2427-
2428- src_login_interactive = TRUE;
2429-
2430- break;
2431-
2432- case 'f':
2433-
2434- case 'F':
2435-
2436- case 'n':
2437-
2438- case 'N':
2439-
2440- case '0':
2441-
2442- src_login_interactive = FALSE;
2443-
2444- break;
2445-
2446- default:
2447- sprintf(log_buffer, "Unknown value of %s", value);
2448-
2449- log_record(
2450- PBSEVENT_SYSTEM,
2451- PBS_EVENTCLASS_SERVER,
2452- "setsourcelogininteractive",
2453- log_buffer);
2454- break;
2455-
2456- }
2457- }
2458-
2459- return(1);
2460- } /* END setsourcelogininteractive() */
2461-
2462-
2463-static unsigned long jobstartblocktime(
2464-
2465- char *value) /* I */
2466-
2467- {
2468- int i;
2469-
2470- log_record(
2471- PBSEVENT_SYSTEM,
2472- PBS_EVENTCLASS_SERVER,
2473- "startblocktime",
2474- value);
2475-
2476- i = (int)strtol(value, NULL, 10);
2477-
2478- if ((i < 0) || ((i == 0) && (value[0] != '0')))
2479- {
2480- return(0); /* error */
2481- }
2482-
2483- TJobStartBlockTime = i;
2484-
2485- return(1);
2486- } /* END jobstartblocktime() */
2487-
2488-
2489-
2490-
2491-
2492-static unsigned long setstatusupdatetime(
2493-
2494- char *value) /* I */
2495-
2496- {
2497- int i;
2498-
2499- log_record(
2500- PBSEVENT_SYSTEM,
2501- PBS_EVENTCLASS_SERVER,
2502- "setstateuspdatetime",
2503- value);
2504-
2505- i = (int)strtol(value, NULL, 10);
2506-
2507- if (i < 1)
2508- {
2509- return(0); /* error */
2510- }
2511-
2512- ServerStatUpdateInterval = (unsigned int)i;
2513-
2514- return(1);
2515- } /* END setstatusupdatetime() */
2516-
2517-
2518-
2519-
2520-
2521-static unsigned long setcheckpolltime(
2522-
2523- char *value) /* I */
2524-
2525- {
2526- int i;
2527-
2528- log_record(
2529- PBSEVENT_SYSTEM,
2530- PBS_EVENTCLASS_SERVER,
2531- "setcheckpolltime",
2532- value);
2533-
2534- i = (int)strtol(value, NULL, 10);
2535-
2536- if (i < 1)
2537- {
2538- return(0); /* error */
2539- }
2540-
2541- CheckPollTime = (unsigned int)i;
2542-
2543- return(1);
2544- } /* END setcheckpolltime() */
2545-
2546-
2547-
2548-
2549-/*
2550-** Add static resource or shell escape line from config file.
2551-** This is a support routine for read_config().
2552-*/
2553-
2554-static void add_static(
2555-
2556- char *str, /* I */
2557- char *file, /* I */
2558- int linenum) /* I */
2559-
2560- {
2561- int i;
2562- char name[50];
2563-
2564- struct config_list *cp;
2565-
2566- str = tokcpy(str, name); /* resource name */
2567- str = skipwhite(str); /* resource value */
2568-
2569- /* FORMAT: <ATTR> [!]<VALUE> */
2570-
2571- if (*str == '!') /* shell escape command */
2572- {
2573- /* remove trailing newline */
2574-
2575- rmnl(str);
2576- }
2577- else
2578- {
2579- /* get the value */
2580- i = strlen(str);
2581-
2582- while (--i)
2583- {
2584- /* strip trailing blanks */
2585-
2586- if (!isspace((int)*(str + i)))
2587- break;
2588-
2589- *(str + i) = '\0';
2590- }
2591- }
2592-
2593- cp = (struct config_list *)malloc(sizeof(struct config_list));
2594-
2595- memcheck((char *)cp);
2596-
2597- cp->c_link = config_list;
2598- cp->c.c_name = strdup(name);
2599-
2600- memcheck(cp->c.c_name);
2601-
2602- cp->c.c_u.c_value = strdup(str);
2603-
2604- memcheck(cp->c.c_u.c_value);
2605-
2606- sprintf(log_buffer, "%s[%d] add name %s value %s",
2607- file,
2608- linenum,
2609- name,
2610- str);
2611-
2612- log_record(
2613- PBSEVENT_DEBUG,
2614- 0,
2615- "add_static",
2616- log_buffer);
2617-
2618- config_list = cp;
2619-
2620- return;
2621- } /* END add_static() */
2622-
2623-
2624-
2625-
2626-
2627-static unsigned long setidealload(
2628-
2629- char *value)
2630-
2631- {
2632- char newstr[50] = "ideal_load ";
2633- float val;
2634-
2635- val = atof(value);
2636-
2637- log_record(
2638- PBSEVENT_SYSTEM,
2639- PBS_EVENTCLASS_SERVER,
2640- "ideal_load",
2641- value);
2642-
2643- if (val < 0.0)
2644- {
2645- return(0); /* error */
2646- }
2647-
2648- ideal_load_val = val;
2649-
2650- if (max_load_val < 0.0)
2651- max_load_val = val; /* set a default */
2652-
2653- strcat(newstr, value);
2654-
2655- return(1);
2656- } /* END setidealload() */
2657-
2658-
2659-
2660-
2661-static unsigned long setignwalltime(
2662-
2663- char *value) /* I */
2664-
2665- {
2666- char newstr[50] = "ignwalltime ";
2667-
2668- log_record(
2669- PBSEVENT_SYSTEM,
2670- PBS_EVENTCLASS_SERVER,
2671- "ignwalltime",
2672- value);
2673-
2674- if (!strncasecmp(value, "t", 1) || (value[0] == '1') || !strcasecmp(value, "on"))
2675- {
2676- ignwalltime = 1;
2677- }
2678- else
2679- {
2680- ignwalltime = 0;
2681- }
2682-
2683- strcat(newstr, value);
2684-
2685- /* SUCCESS */
2686-
2687- return(1);
2688- } /* END setignwalltime() */
2689-
2690-
2691-
2692-static unsigned long setignmem(
2693-
2694- char *value) /* I */
2695-
2696- {
2697- log_record(
2698- PBSEVENT_SYSTEM,
2699- PBS_EVENTCLASS_SERVER,
2700- "ignmem",
2701- value);
2702-
2703- if (!strncasecmp(value,"t",1) || (value[0] == '1') || !strcasecmp(value,"on") )
2704- ignmem = 1;
2705- else
2706- ignmem = 0;
2707-
2708- return(1);
2709- } /* END setignmem() */
2710-
2711-
2712-
2713-static unsigned long setigncput(
2714-
2715- char *value) /* I */
2716-
2717- {
2718- log_record(
2719- PBSEVENT_SYSTEM,
2720- PBS_EVENTCLASS_SERVER,
2721- "igncput",
2722- value);
2723-
2724- if (!strncasecmp(value,"t",1) || (value[0] == '1') || !strcasecmp(value,"on") )
2725- igncput = 1;
2726- else
2727- igncput = 0;
2728-
2729- return(1);
2730- }
2731-
2732-
2733-static unsigned long setignvmem(
2734-
2735- char *value) /* I */
2736-
2737- {
2738- char newstr[50] = "setignvmem ";
2739-
2740- log_record(
2741- PBSEVENT_SYSTEM,
2742- PBS_EVENTCLASS_SERVER,
2743- "setignvmem",
2744- value);
2745-
2746- if (!strncasecmp(value, "t", 1) || (value[0] == '1') || !strcasecmp(value, "on"))
2747- {
2748- ignvmem = 1;
2749- }
2750- else
2751- {
2752- ignvmem = 0;
2753- }
2754-
2755- strcat(newstr, value);
2756-
2757- /* SUCCESS */
2758-
2759- return(1);
2760- } /* END setignvmem() */
2761-
2762-
2763-static unsigned long setautoidealload(
2764-
2765- char *value)
2766-
2767- {
2768- log_record(
2769- PBSEVENT_SYSTEM,
2770- PBS_EVENTCLASS_SERVER,
2771- "auto_ideal_load",
2772- value);
2773-
2774- auto_ideal_load = strdup(value);
2775-
2776- /*
2777- add_static(auto_ideal_load,"config",0);
2778-
2779- nconfig++;
2780- */
2781-
2782- return(1);
2783- } /* END setautoidealload() */
2784-
2785-
2786-
2787-
2788-
2789-static unsigned long setallocparcmd(
2790-
2791- char *value) /* I */
2792-
2793- {
2794- log_record(
2795- PBSEVENT_SYSTEM,
2796- PBS_EVENTCLASS_SERVER,
2797- "allocparcmd",
2798- value);
2799-
2800- AllocParCmd = strdup(value);
2801-
2802- return(1);
2803- } /* END setallocparcmd() */
2804-
2805-
2806-
2807-
2808-
2809-static unsigned long setautomaxload(
2810-
2811- char *value)
2812-
2813- {
2814- log_record(
2815- PBSEVENT_SYSTEM,
2816- PBS_EVENTCLASS_SERVER,
2817- "auto_max_load",
2818- value);
2819-
2820- auto_max_load = strdup(value);
2821-
2822- /*
2823- add_static(auto_ideal_load,"config",0);
2824-
2825- nconfig++;
2826- */
2827-
2828- return(1);
2829- } /* END setautomaxload() */
2830-
2831-
2832-
2833-
2834-
2835-static unsigned long setmaxconnecttimeout(
2836-
2837- char *value) /* I */
2838-
2839- {
2840- MaxConnectTimeout = strtol(value, NULL, 10);
2841-
2842- if (MaxConnectTimeout < 0)
2843- {
2844- MaxConnectTimeout = 10000;
2845-
2846- return(0);
2847- }
2848-
2849- return(1);
2850- }
2851-
2852-
2853-
2854-
2855-static unsigned long setnodecheckscript(
2856-
2857- char *value)
2858-
2859- {
2860- char newstr[1024] = "node_check_script ";
2861-
2862- struct stat sbuf;
2863-
2864- log_record(
2865- PBSEVENT_SYSTEM,
2866- PBS_EVENTCLASS_SERVER,
2867- "node_check_script",
2868- value);
2869-
2870- if ((stat(value, &sbuf) == -1) || !(sbuf.st_mode & S_IXUSR))
2871- {
2872- /* FAILURE */
2873-
2874- /* file does not exist or is not executable */
2875-
2876- return(0);
2877- }
2878-
2879- strncpy(PBSNodeCheckPath, value, sizeof(PBSNodeCheckPath));
2880-
2881- strcat(newstr, value);
2882-
2883- /* SUCCESS */
2884-
2885- return(1);
2886- } /* END setnodecheckscript() */
2887-
2888-
2889-
2890-
2891-
2892-static unsigned long setnodecheckinterval(
2893-
2894- char *value)
2895-
2896- {
2897- char newstr[1024] = "node_check_interval ";
2898-
2899- log_record(
2900- PBSEVENT_SYSTEM,
2901- PBS_EVENTCLASS_SERVER,
2902- "node_check_interval",
2903- value);
2904-
2905- PBSNodeCheckInterval = (int)strtol(value, NULL, 10);
2906-
2907- if (strstr(value, "jobstart"))
2908- PBSNodeCheckProlog = 1;
2909-
2910- if (strstr(value, "jobend"))
2911- PBSNodeCheckEpilog = 1;
2912-
2913- strcat(newstr, value);
2914-
2915- return(1);
2916- } /* END setnodecheckinterval() */
2917-
2918-
2919-
2920-
2921-
2922-static unsigned long settimeout(
2923-
2924- char *value)
2925-
2926- {
2927- char newstr[1024];
2928-
2929- log_record(
2930- PBSEVENT_SYSTEM,
2931- PBS_EVENTCLASS_SERVER,
2932- "timeout",
2933- value);
2934-
2935- DIS_tcp_settimeout(strtol(value, NULL, 10));
2936-
2937- snprintf(newstr, sizeof(newstr), "%s %s",
2938- "timeout",
2939- value);
2940-
2941- return(1);
2942- } /* END settimeout() */
2943-
2944-
2945-
2946-
2947-
2948-static unsigned long setmaxload(
2949-
2950- char *value) /* I */
2951-
2952- {
2953- char newstr[50] = "max_load ";
2954- float val;
2955-
2956- val = atof(value);
2957-
2958- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "max_load", value);
2959-
2960- if (val < 0.0)
2961- {
2962- return(0); /* error */
2963- }
2964-
2965- max_load_val = val;
2966-
2967- if (ideal_load_val < 0.0)
2968- ideal_load_val = val;
2969-
2970- strcat(newstr, value);
2971-
2972- return(1);
2973- } /* END max_load() */
2974-
2975-
2976-
2977-
2978-
2979-static unsigned long setlogfilemaxsize(
2980-
2981- char *value) /* I */
2982-
2983- {
2984- log_file_max_size = strtol(value, NULL, 10);
2985-
2986- if (log_file_max_size < 0)
2987- {
2988- log_file_max_size = 0;
2989-
2990- return(0);
2991- }
2992-
2993- return(1);
2994- }
2995-
2996-
2997-
2998-
2999-static unsigned long setlogfilerolldepth(
3000-
3001- char *value) /* I */
3002-
3003- {
3004- log_file_roll_depth = strtol(value, NULL, 10);
3005-
3006- if (log_file_roll_depth < 1)
3007- {
3008- log_file_roll_depth = 1;
3009-
3010- return(0);
3011- }
3012-
3013- return(1);
3014- }
3015-
3016-
3017-
3018-static unsigned long setlogdirectory(
3019-
3020- char *value) /* I */
3021-
3022- {
3023- path_log = strdup(value);
3024-
3025- return(1);
3026- }
3027-
3028-
3029-
3030-
3031-static unsigned long setlogfilesuffix(
3032-
3033- char *value) /* I */
3034-
3035- {
3036- log_init(value, NULL);
3037-
3038- return(1);
3039- }
3040-
3041-
3042-
3043-static unsigned long setlogkeepdays(
3044-
3045- char *value) /* I */
3046-
3047- {
3048- int i;
3049-
3050- i = (int)atoi(value);
3051-
3052- if (i < 0)
3053- {
3054- return(0); /* error */
3055- }
3056-
3057- LOGKEEPDAYS = i;
3058-
3059- return(1);
3060- }
3061-
3062-
3063-
3064-static u_long setvarattr(
3065-
3066- char *value) /* I */
3067-
3068- {
3069- static char *id = "setvarattr";
3070-
3071- struct varattr *pva;
3072- char *ptr;
3073-
3074- pva = calloc(1, sizeof(struct varattr));
3075-
3076- if (pva == NULL)
3077- {
3078- /* FAILURE */
3079-
3080- log_err(errno, id, "no memory");
3081-
3082- return(0);
3083- }
3084-
3085- CLEAR_LINK(pva->va_link);
3086-
3087- /* FORMAT: <TTL> <PATH> */
3088- /* extract TTL */
3089-
3090- ptr = value;
3091-
3092- pva->va_ttl = strtol(ptr, NULL, 10);
3093-
3094- /* step forward to end of TTL */
3095-
3096- while (!isspace(*ptr))
3097- ptr++;
3098-
3099- if (*ptr == '\0')
3100- {
3101- free(pva);
3102-
3103- return(0);
3104- }
3105-
3106- /* skip white space */
3107-
3108- while (isspace(*ptr))
3109- ptr++;
3110-
3111- if (*ptr == '\0')
3112- {
3113- free(pva);
3114-
3115- return(0);
3116- }
3117-
3118- /* preserve command and args */
3119-
3120- pva->va_cmd = strdup(ptr);
3121-
3122- append_link(&mom_varattrs, &pva->va_link, pva);
3123-
3124- /* SUCCESS */
3125-
3126- return(1);
3127- } /* END setvarattr() */
3128-
3129-
3130-
3131-
3132-
3133-static unsigned long setnodefilesuffix(
3134-
3135- char *value) /* I */
3136-
3137- {
3138- char *ptr;
3139-
3140- ptr = strtok(value, ",");
3141-
3142- nodefile_suffix = strdup(ptr);
3143-
3144- ptr = strtok(NULL, ",");
3145-
3146- if (ptr != NULL)
3147- submithost_suffix = strdup(ptr);
3148-
3149- /* SUCCESS */
3150-
3151- return(1);
3152- } /* END setnodexfilesuffix() */
3153-
3154-
3155-
3156-
3157-static unsigned long setmomhost(
3158-
3159- char *value) /* I */
3160-
3161- {
3162- hostname_specified = 1;
3163-
3164- strncpy(mom_host, value, PBS_MAXHOSTNAME); /* remember name */
3165-
3166- /* SUCCESS */
3167-
3168- return(1);
3169- } /* END setmomhost() */
3170-
3171-
3172-static u_long setrreconfig(
3173-
3174- char *Value) /* I */
3175-
3176- {
3177- static char id[] = "setrreconfig";
3178- int enable = -1;
3179-
3180- log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
3181-
3182- if (Value == NULL)
3183- {
3184- /* FAILURE */
3185-
3186- return(0);
3187- }
3188-
3189- /* accept various forms of "true", "yes", and "1" */
3190- switch (Value[0])
3191- {
3192-
3193- case 't':
3194-
3195- case 'T':
3196-
3197- case 'y':
3198-
3199- case 'Y':
3200-
3201- case '1':
3202-
3203- enable = 1;
3204-
3205- break;
3206-
3207- case 'f':
3208-
3209- case 'F':
3210-
3211- case 'n':
3212-
3213- case 'N':
3214-
3215- case '0':
3216-
3217- enable = 0;
3218-
3219- break;
3220-
3221- }
3222-
3223- if (enable != -1)
3224- {
3225- MOMConfigRReconfig = enable;
3226- }
3227-
3228- return(1);
3229- } /* END setrreconfig() */
3230-
3231-
3232-static unsigned long setnospooldirlist(
3233-
3234- char *value) /* I */
3235-
3236- {
3237- char *TokPtr;
3238- char *ptr;
3239-
3240- int index = 0;
3241-
3242- char tmpLine[1024];
3243-
3244- ptr = strtok_r(value, " \t\n:,", &TokPtr);
3245-
3246- while (ptr != NULL)
3247- {
3248- TNoSpoolDirList[index] = strdup(ptr);
3249-
3250- snprintf(tmpLine, sizeof(tmpLine), "added NoSpoolDir[%d] '%s'",
3251- index,
3252- ptr);
3253-
3254- log_record(
3255- PBSEVENT_SYSTEM,
3256- PBS_EVENTCLASS_SERVER,
3257- "setnospooldirlist",
3258- tmpLine);
3259-
3260- index++;
3261-
3262- if (index >= TMAX_NSDCOUNT)
3263- break;
3264-
3265- ptr = strtok_r(NULL, " \t\n:,", &TokPtr);
3266- } /* END while (ptr != NULL) */
3267-
3268- /* SUCCESS */
3269-
3270- return(1);
3271- } /* END setnospooldirlist() */
3272-
3273-
3274-
3275-
3276-static unsigned long setspoolasfinalname(
3277-
3278- char *value) /* I */
3279-
3280- {
3281- log_record(
3282- PBSEVENT_SYSTEM,
3283- PBS_EVENTCLASS_SERVER,
3284- "spoolasfinalname",
3285- value);
3286-
3287- if (!strncasecmp(value,"t",1) || (value[0] == '1') || !strcasecmp(value,"on") )
3288- spoolasfinalname = 1;
3289- else
3290- spoolasfinalname = 0;
3291-
3292- return(1);
3293- } /* END setspoolasfinalname() */
3294-
3295-
3296-
3297-static unsigned long setkilldelay(
3298-
3299- char *value)
3300-
3301- {
3302- log_record(
3303- PBSEVENT_SYSTEM,
3304- PBS_EVENTCLASS_SERVER,
3305- "setkilldelay",
3306- value);
3307-
3308- if ((!strncasecmp(value,"t",1)) ||
3309- (value[0] == '1') ||
3310- (!strcasecmp(value,"on")))
3311- killdelay = 1;
3312- else
3313- killdelay = 0;
3314-
3315- return(1);
3316- } /* END setkilldelay() */
3317-
3318-
3319-
3320-
3321-
3322-static unsigned long setremchkptdirlist(
3323-
3324- char *value) /* I */
3325-
3326- {
3327- char *TokPtr;
3328- char *ptr;
3329-
3330- int index = 0;
3331- char tmpLine[1024];
3332-
3333- while ((TRemChkptDirList[index] != NULL) && (index < TMAX_RCDCOUNT))
3334- {
3335- index++;
3336- }
3337-
3338- if (index >= TMAX_RCDCOUNT)
3339- return (1);
3340-
3341- ptr = strtok_r(value, " \t\n:,", &TokPtr);
3342-
3343- while (ptr != NULL)
3344- {
3345- TRemChkptDirList[index] = strdup(ptr);
3346-
3347- snprintf(tmpLine, sizeof(tmpLine), "added RemChkptDir[%d] '%s'",
3348- index,
3349- ptr);
3350-
3351- log_record(
3352- PBSEVENT_SYSTEM,
3353- PBS_EVENTCLASS_SERVER,
3354- "setremchkptdirlist",
3355- tmpLine);
3356-
3357- index++;
3358-
3359- if (index >= TMAX_RCDCOUNT)
3360- break;
3361-
3362- ptr = strtok_r(NULL, " \t\n:,", &TokPtr);
3363- } /* END while (ptr != NULL) */
3364-
3365- /* SUCCESS */
3366-
3367- return (1);
3368- } /* END setremchkptdirlist() */
3369-
3370-
3371-
3372-
3373-
3374-
3375-void
3376-check_log(void)
3377-
3378- {
3379- last_log_check = time_now;
3380-
3381- /* periodically record the version and loglevel */
3382-
3383- sprintf(log_buffer, msg_info_mom, PACKAGE_VERSION, LOGLEVEL);
3384-
3385- log_event(
3386- PBSEVENT_SYSTEM | PBSEVENT_FORCE,
3387- PBS_EVENTCLASS_SERVER,
3388- msg_daemonname,
3389- log_buffer);
3390-
3391- if (LOGKEEPDAYS > 0)
3392- {
3393- /* remove logs older than log_keep_days */
3394-
3395- snprintf(log_buffer,sizeof(log_buffer),"checking for old pbs_mom logs in dir '%s' (older than %d days)",
3396- path_log,
3397- LOGKEEPDAYS);
3398-
3399- log_event(
3400- PBSEVENT_SYSTEM | PBSEVENT_FORCE,
3401- PBS_EVENTCLASS_SERVER,
3402- msg_daemonname,
3403- log_buffer);
3404-
3405- if (log_remove_old(path_log,(LOGKEEPDAYS * SECS_PER_DAY)) != 0)
3406- {
3407- log_err(-1,"check_log","failure occurred when checking for old pbs_mom logs");
3408- }
3409- }
3410-
3411- if (log_file_max_size <= 0)
3412- {
3413- return;
3414- }
3415-
3416- if (log_size() >= log_file_max_size)
3417- {
3418- log_event(
3419- PBSEVENT_SYSTEM | PBSEVENT_FORCE,
3420- PBS_EVENTCLASS_SERVER,
3421- msg_daemonname,
3422- "Rolling log file");
3423-
3424- log_roll(log_file_roll_depth);
3425- }
3426-
3427- return;
3428- } /* END check_log() */
3429-
3430-
3431-
3432-
3433-
3434-/*
3435-** Open and read the config file. Save information in a linked
3436-** list. After reading the file, create an array, copy the list
3437-** elements to the array and free the list.
3438-*/
3439-
3440-/* NOTE: add new mom config parameters to 'special[]' */
3441-
3442-int read_config(
3443-
3444- char *file) /* I */
3445-
3446- {
3447- static char id[] = "read_config";
3448-
3449- FILE *conf;
3450-
3451- struct stat sb;
3452-
3453- struct config_list *cp;
3454-
3455- struct config *ap;
3456- char line[120];
3457- char name[50];
3458- char *str;
3459- char *ptr;
3460-
3461- int linenum;
3462- int i;
3463-
3464- int IgnConfig = 0;
3465-
3466- int rc;
3467-
3468- int n, list_len;
3469- char *server_list_ptr;
3470- char *tp;
3471-
3472-
3473- if (LOGLEVEL >= 3)
3474- {
3475- sprintf(log_buffer, "updating configuration using file '%s'",
3476- (file != NULL) ? file : "NULL");
3477-
3478- log_record(
3479- PBSEVENT_SYSTEM,
3480- PBS_EVENTCLASS_SERVER,
3481- id,
3482- log_buffer);
3483- }
3484-
3485- for (i = 0;i < mask_num;i++)
3486- {
3487- free(maskclient[i]);
3488- }
3489-
3490- mask_num = 0;
3491-
3492- if (file == NULL)
3493- file = config_file;
3494-
3495- rc = 0;
3496-
3497- if (file[0] == '\0')
3498- {
3499- log_record(
3500- PBSEVENT_SYSTEM,
3501- PBS_EVENTCLASS_SERVER,
3502- id,
3503- "ALERT: no config file specified");
3504-
3505- IgnConfig = 1; /* no config file */
3506- }
3507-
3508- if ((IgnConfig == 0) && (stat(file, &sb) == -1))
3509- {
3510- IgnConfig = 1;
3511-
3512- sprintf(log_buffer, "fstat: %s",
3513- file);
3514-
3515- log_err(errno, id, log_buffer);
3516-
3517- if (config_file_specified != 0)
3518- {
3519- /* file specified and not there, return failure */
3520-
3521- log_record(
3522- PBSEVENT_SYSTEM,
3523- PBS_EVENTCLASS_SERVER,
3524- id,
3525- "ALERT: cannot open config file - no file");
3526-
3527- rc = 1;
3528- }
3529- else
3530- {
3531- /* "config" file not located, return success */
3532-
3533- if (LOGLEVEL >= 3)
3534- {
3535- sprintf(log_buffer, "cannot open file '%s'",
3536- file);
3537-
3538- log_record(
3539- PBSEVENT_SYSTEM,
3540- PBS_EVENTCLASS_SERVER,
3541- id,
3542- log_buffer);
3543- }
3544-
3545- rc = 0;
3546- }
3547- } /* END if ((IgnConfig == 0) && (stat(file,&sb) == -1)) */
3548-
3549- if (IgnConfig == 0)
3550- {
3551-#if !defined(DEBUG) && !defined(NO_SECURITY_CHECK)
3552-
3553- if (chk_file_sec(file, 0, 0, S_IWGRP | S_IWOTH, 1, NULL))
3554- {
3555- /* not authorized to access specified file, return failure */
3556-
3557- log_record(
3558- PBSEVENT_SYSTEM,
3559- PBS_EVENTCLASS_SERVER,
3560- id,
3561- "ALERT: cannot open config file - permissions");
3562-
3563- IgnConfig = 1;
3564-
3565- rc = 1;
3566- }
3567-
3568-#endif /* NO_SECURITY_CHECK */
3569- } /* END if (ignConfig == 0) */
3570-
3571- if (IgnConfig == 0)
3572- {
3573- if ((conf = fopen(file, "r")) == NULL)
3574- {
3575- sprintf(log_buffer, "fopen: %s",
3576- file);
3577-
3578- log_err(errno, id, log_buffer);
3579-
3580- IgnConfig = 1;
3581-
3582- rc = 1;
3583- }
3584- } /* END if (IgnConfig == 0) */
3585-
3586- if (IgnConfig == 0)
3587- {
3588- nconfig = 0;
3589- linenum = 0;
3590-
3591- while (fgets(line, sizeof(line), conf))
3592- {
3593- linenum++;
3594-
3595- if (line[0] == '#') /* comment */
3596- continue;
3597-
3598- if ((ptr = strchr(line, '#')) != NULL)
3599- {
3600- /* allow inline comments */
3601-
3602- *ptr = '\0';
3603- }
3604-
3605- str = skipwhite(line); /* pass over initial whitespace */
3606-
3607- if (*str == '\0')
3608- continue;
3609-
3610- if (LOGLEVEL >= 6)
3611- {
3612- sprintf(log_buffer, "processing config line '%.64s'",
3613- str);
3614-
3615- log_record(
3616- PBSEVENT_SYSTEM,
3617- PBS_EVENTCLASS_SERVER,
3618- id,
3619- log_buffer);
3620- }
3621-
3622- if (*str == '$')
3623- {
3624- /* special command */
3625-
3626- str = tokcpy(++str, name); /* resource name */
3627-
3628- for (i = 0;special[i].name;i++)
3629- {
3630- if (strcasecmp(name, special[i].name) == 0)
3631- break;
3632- } /* END for (i) */
3633-
3634- if (special[i].name == NULL)
3635- {
3636- /* didn't find it */
3637-
3638- sprintf(log_buffer, "special command name %s not found (ignoring line)",
3639- name);
3640-
3641- log_err(-1, id, log_buffer);
3642-
3643- continue;
3644- }
3645-
3646- str = skipwhite(str); /* command param */
3647-
3648- rmnl(str);
3649-
3650- if (special[i].handler(str) == 0)
3651- {
3652- sprintf(log_buffer, "%s[%d] special command %s failed with %s",
3653- file,
3654- linenum,
3655- name,
3656- str);
3657-
3658- log_err(-1, id, log_buffer);
3659- }
3660-
3661- continue;
3662- }
3663-
3664- add_static(str, file, linenum);
3665-
3666- nconfig++;
3667- } /* END while (fgets()) */
3668-
3669- /*
3670- ** Create a new array.
3671- */
3672-
3673- if (config_array != NULL)
3674- {
3675- for (ap = config_array;ap->c_name != NULL;ap++)
3676- {
3677- free(ap->c_name);
3678- free(ap->c_u.c_value);
3679- }
3680-
3681- free(config_array);
3682- }
3683-
3684- config_array = (struct config *)calloc(nconfig + 1, sizeof(struct config));
3685-
3686- memcheck((char *)config_array);
3687-
3688- /*
3689- ** Copy in the new information saved from the file.
3690- */
3691-
3692- for (i = 0, ap = config_array;i < nconfig;i++, ap++)
3693- {
3694- *ap = config_list->c;
3695- cp = config_list->c_link;
3696-
3697- free(config_list); /* don't free name and value strings */
3698- config_list = cp; /* they carry over from the list */
3699- }
3700-
3701- ap->c_name = NULL; /* one extra */
3702-
3703- fclose(conf);
3704- } /* END if (IgnConfig == 0) */
3705-
3706- if (mom_server_count == 0)
3707- {
3708- /* No server names in torque/mom_priv/config. Get names from torque/server_name. */
3709-
3710- server_list_ptr = pbs_get_server_list();
3711- list_len = csv_length(server_list_ptr);
3712-
3713- for (n = 0; n < list_len; n++)
3714- {
3715- tp = csv_nth(server_list_ptr, n);
3716-
3717- if (tp)
3718- {
3719- setpbsserver(tp);
3720- }
3721- }
3722- }
3723-
3724- return(rc);
3725- } /* END read_config() */
3726-
3727-
3728-
3729-
3730-
3731-
3732-/*
3733-** Get an rm_attribute structure from a string. If a NULL is passed
3734-** for the string, use the previously remembered string.
3735-*/
3736-
3737-struct rm_attribute *momgetattr(
3738-
3739- char *str) /* I */
3740-
3741- {
3742- char *id = "momgetattr";
3743-
3744- static char cookie[] = "tag:"; /* rm_attribute to ignore */
3745- static char *hold = NULL;
3746- static char qual[80] = "";
3747- static char valu[4096] = "";
3748-
3749- static struct rm_attribute attr =
3750- {
3751- qual, valu
3752- };
3753-
3754- int level, i;
3755-
3756- if (str == NULL) /* if NULL is passed, use prev value */
3757- str = hold;
3758-
3759- /* FORMAT: ??? */
3760-
3761- do
3762- {
3763- str = skipwhite(str);
3764-
3765- if (*str++ != '[')
3766- {
3767- return(NULL);
3768- }
3769-
3770- str = skipwhite(str); /* copy qualifier */
3771-
3772- str = tokcpy(str, qual);
3773- str = skipwhite(str);
3774-
3775- if (*str++ != '=')
3776- {
3777- return(NULL);
3778- }
3779-
3780- level = 0;
3781-
3782- for (i = 0;*str;str++, i++)
3783- {
3784- if (*str == '[')
3785- {
3786- level++;
3787- }
3788- else if (*str == ']')
3789- {
3790- if (level == 0)
3791- break;
3792-
3793- level--;
3794- }
3795-
3796- valu[i] = *str;
3797- }
3798-
3799- if (*str++ != ']')
3800- {
3801- return(NULL);
3802- }
3803-
3804- valu[i] = '\0';
3805-
3806- if (LOGLEVEL >= 7)
3807- {
3808- sprintf(log_buffer, "found %s = %s",
3809- qual,
3810- valu);
3811-
3812- log_record(
3813- PBSEVENT_JOB,
3814- PBS_EVENTCLASS_JOB,
3815- id,
3816- log_buffer);
3817- }
3818- }
3819- while (strncmp(qual, cookie, sizeof(cookie) - 1) == 0);
3820-
3821- hold = str;
3822-
3823- if (LOGLEVEL >= 5)
3824- {
3825- sprintf(log_buffer, "passing back %s = %s",
3826- qual,
3827- valu);
3828-
3829- log_record(
3830- PBSEVENT_JOB,
3831- PBS_EVENTCLASS_JOB,
3832- id,
3833- log_buffer);
3834- }
3835-
3836- return(&attr);
3837- } /* END momgetattr() */
3838-
3839-
3840-
3841-
3842-
3843-/*
3844-** Check the request against the format of the line read from
3845-** the config file. If it is a static value, there should be
3846-** no params. If it is a shell escape, the parameters (if any)
3847-** should match the command line for the system call.
3848-*/
3849-
3850-char *conf_res(
3851-
3852- char *resline, /* I */
3853- struct rm_attribute *attr) /* I */
3854-
3855- {
3856- char *id = "conf_res";
3857-
3858- char *name[RM_NPARM];
3859- char *value[RM_NPARM];
3860- int used[RM_NPARM]; /* (boolean) */
3861- char param[80], *d;
3862- int i, fd, len;
3863- FILE *child;
3864- char *child_spot;
3865- int child_len;
3866-
3867- if (resline == NULL)
3868- {
3869- return("");
3870- }
3871-
3872- if (resline[0] != '!')
3873- {
3874- /* static value */
3875-
3876- if (attr != NULL)
3877- {
3878- sprintf(ret_string, "? %d",
3879- RM_ERR_BADPARAM);
3880-
3881- return(ret_string);
3882- }
3883-
3884- return(resline);
3885- }
3886-
3887- /*
3888- ** From here on we are going to put together a shell command
3889- ** to do the requestor's bidding. Parameter substitution
3890- ** is the first step.
3891- */
3892-
3893- for (i = 0;i < RM_NPARM;i++)
3894- {
3895- /* remember params */
3896-
3897- if (attr == NULL)
3898- {
3899- /* FAILURE */
3900-
3901- break;
3902- }
3903-
3904- name[i] = strdup(attr->a_qualifier);
3905-
3906- memcheck(name[i]);
3907-
3908- value[i] = strdup(attr->a_value);
3909-
3910- memcheck(value[i]);
3911-
3912- used[i] = 0;
3913-
3914- attr = momgetattr(NULL);
3915- } /* END for (i) */
3916-
3917- if (attr != NULL)
3918- {
3919- /* too many params */
3920- log_err(-1, id, "too many params");
3921-
3922- sprintf(ret_string, "? %d",
3923- RM_ERR_BADPARAM);
3924-
3925- goto done;
3926- }
3927-
3928- name[i] = NULL;
3929-
3930- for (d = ret_string, resline++;*resline;)
3931- {
3932- /* scan command */
3933-
3934- if (*resline == '%')
3935- {
3936- /* possible token */
3937-
3938- char *hold;
3939-
3940- hold = tokcpy(resline + 1, param);
3941-
3942- for (i = 0;name[i];i++)
3943- {
3944- if (strcmp(param, name[i]) == 0)
3945- break;
3946- }
3947-
3948- if (name[i])
3949- {
3950- /* found a match */
3951-
3952- char *x = value[i];
3953-
3954- while (*x)
3955- {
3956- *d++ = *x++;
3957- }
3958-
3959- resline = hold;
3960-
3961- used[i] = 1;
3962- }
3963- else
3964- {
3965- *d++ = *resline++;
3966- }
3967- }
3968- else
3969- {
3970- *d++ = *resline++;
3971- }
3972- }
3973-
3974- for (i = 0;name[i];i++)
3975- {
3976- if (!used[i])
3977- {
3978- /* parameter sent but not used */
3979- log_err(-1, id,
3980- "unused parameters");
3981-
3982- sprintf(ret_string, "? %d",
3983- RM_ERR_BADPARAM);
3984-
3985- goto done;
3986- }
3987- } /* END for (i) */
3988-
3989- *d = '\0';
3990-
3991- DBPRT(("command: %s\n",
3992- ret_string))
3993-
3994- if ((child = popen(ret_string, "r")) == NULL)
3995- {
3996- log_err(errno, id, "popen");
3997-
3998- sprintf(ret_string, "? %d",
3999- RM_ERR_SYSTEM);
4000-
4001- goto done;
4002- }
4003-
4004- fd = fileno(child);
4005-
4006- child_spot = ret_string;
4007- child_len = 0;
4008- child_spot[0] = '\0';
4009-
4010-retryread:
4011-
4012- while ((len = read(fd, child_spot, ret_size - child_len)) > 0)
4013- {
4014- for (i = 0;i < len;i++)
4015- {
4016- if (child_spot[i] == '\n')
4017- break;
4018- }
4019-
4020- if (i < len)
4021- {
4022- /* found newline */
4023-
4024- child_len += i + 1;
4025-
4026- break;
4027- }
4028-
4029- child_len += len;
4030-
4031- child_spot += len;
4032-
4033- checkret(&child_spot, len);
4034- }
4035-
4036- if (len == -1)
4037- {
4038- if (errno == EINTR)
4039- {
4040- goto retryread;
4041- }
4042-
4043- log_err(errno, id, "pipe read");
4044-
4045- sprintf(ret_string, "? %d",
4046- RM_ERR_SYSTEM);
4047-
4048- fclose(child);
4049-
4050- goto done;
4051- }
4052-
4053- pclose(child);
4054-
4055- if (child_len > 0)
4056- ret_string[child_len - 1] = '\0'; /* hack off newline */
4057-
4058-done:
4059-
4060- for (i = 0;name[i] != NULL;i++)
4061- {
4062- /* free up params */
4063-
4064- free(name[i]);
4065- free(value[i]);
4066- } /* END for (i) */
4067-
4068- return(ret_string);
4069- } /* END conf_res() */
4070-
4071-
4072-
4073-
4074-static void catch_abort(
4075-
4076- int sig)
4077-
4078- {
4079-
4080- struct rlimit rlimit;
4081-
4082- /*
4083- * Reset ourselves to the default signal handler to try and
4084- * prevent recursive core dumps.
4085- */
4086-
4087- struct sigaction act;
4088-
4089- sigemptyset(&act.sa_mask);
4090- act.sa_flags = 0;
4091- act.sa_handler = SIG_DFL;
4092-
4093- sigaction(SIGSEGV, &act, NULL);
4094- sigaction(SIGBUS, &act, NULL);
4095- sigaction(SIGFPE, &act, NULL);
4096- sigaction(SIGILL, &act, NULL);
4097- sigaction(SIGTRAP, &act, NULL);
4098- sigaction(SIGSYS, &act, NULL);
4099-
4100- log_err(sig, "mom_main", "Caught fatal core signal");
4101- rlimit.rlim_cur = RLIM_INFINITY;
4102- rlimit.rlim_max = RLIM_INFINITY;
4103-
4104- setrlimit(RLIMIT_CORE, &rlimit);
4105- abort();
4106-
4107- return;
4108- } /* END catch_abort() */
4109-
4110-
4111-
4112-
4113-
4114-static void catch_hup(
4115-
4116- int sig)
4117-
4118- {
4119- sprintf(log_buffer, "caught signal %d",
4120- sig);
4121-
4122- log_record(PBSEVENT_SYSTEM, 0, "catch_hup", "reset");
4123-
4124- call_hup = 1;
4125-
4126- rpp_dbprt = 1 - rpp_dbprt; /* toggle debug prints for RPP */
4127-
4128-
4129- return;
4130- } /* END catch_hup() */
4131-
4132-
4133-
4134-
4135-/*
4136- * Do a restart of resmom.
4137- * Read the last seen config file and
4138- * Clean up and reinit the dependent code.
4139- */
4140-
4141-static void
4142-process_hup(void)
4143-
4144- {
4145- char *id = "process_hup";
4146-
4147- call_hup = 0;
4148- log_record(PBSEVENT_SYSTEM, 0, id, "reset");
4149-
4150- log_close(1);
4151- log_open(log_file, path_log);
4152- log_file_max_size = 0;
4153- log_file_roll_depth = 1;
4154- read_config(NULL);
4155- check_log();
4156- cleanup();
4157-
4158- initialize();
4159-
4160- return;
4161- } /* END process_hup() */
4162-
4163-
4164-
4165-
4166-/*
4167-** Got an alarm call.
4168-** Close all general network connections, clean up and reinit the
4169-** dependent code.
4170-*/
4171-
4172-void toolong(
4173-
4174- int sig)
4175-
4176- {
4177- char *id = "toolong";
4178-
4179- log_record(PBSEVENT_SYSTEM, 0, id, "alarm call");
4180-
4181- if (LOGLEVEL >= 1)
4182- DBPRT(("alarm call\n"))
4183-
4184- return;
4185- } /* END toolong() */
4186-
4187-
4188-
4189-
4190-
4191-
4192-
4193-#ifdef DEBUG
4194-
4195-void log_verbose(
4196-
4197- char *id,
4198- char *buf,
4199- int len)
4200-
4201- {
4202- int i;
4203- char *cp;
4204-
4205- len = MIN(len, 50);
4206-
4207- cp = log_buffer;
4208-
4209- for (i = 0;i < len;i++)
4210- {
4211- int c = buf[i];
4212-
4213- if (isprint(c))
4214- {
4215- *cp++ = c;
4216- }
4217- else
4218- {
4219- sprintf(cp, "(%d)",
4220- c);
4221-
4222- cp += strlen(cp);
4223- }
4224- }
4225-
4226- *cp = '\0';
4227-
4228- log_record(PBSEVENT_DEBUG, 0, id, log_buffer);
4229-
4230- return;
4231- } /* END log_verbose() */
4232-
4233-
4234-#else
4235-#define log_verbose(a, b, c)
4236-#endif
4237-
4238-/*
4239-** See if an IP address matches any names stored as "restricted"
4240-** access hosts. Return 0 if a name matches, 1 if not.
4241-*/
4242-
4243-int bad_restrict(
4244-
4245- u_long ipadd)
4246-
4247- {
4248-
4249- struct hostent *host;
4250-
4251- struct in_addr in;
4252- int i, len1, len2;
4253- char *cp1, *cp2;
4254-
4255- in.s_addr = htonl(ipadd);
4256-
4257- if ((host = gethostbyaddr(
4258- (void *) & in,
4259- sizeof(struct in_addr),
4260- AF_INET)) == NULL)
4261- {
4262- return(1);
4263- }
4264-
4265- len1 = strlen(host->h_name) - 1;
4266-
4267- for (i = 0;i < mask_num;i++)
4268- {
4269- len2 = strlen(maskclient[i]) - 1;
4270-
4271- if (len1 < len2)
4272- continue;
4273-
4274- cp1 = &host->h_name[len1];
4275-
4276- cp2 = &maskclient[i][len2];
4277-
4278- /* check case insensitve */
4279-
4280- while ((len2 >= 0) && (tolower(*cp1) == tolower(*cp2)))
4281- {
4282- cp1--;
4283- cp2--;
4284-
4285- len2--;
4286- } /* END while () */
4287-
4288- if (((len2 == 0) && (*cp2 == '*')) || (len2 == -1))
4289- {
4290- return(0);
4291- }
4292- } /* END for (i) */
4293-
4294- return(1);
4295- } /* END bad_restrict() */
4296-
4297-
4298-/*
4299- * mom_lock - lock out other MOMs from this directory.
4300- */
4301-
4302-static void mom_lock(
4303-
4304- int fds,
4305- int op) /* F_WRLCK or F_UNLCK */
4306-
4307- {
4308-
4309- struct flock flock;
4310-
4311- flock.l_type = op;
4312- flock.l_whence = SEEK_SET;
4313- flock.l_start = 0;
4314- flock.l_len = 0; /* whole file */
4315-
4316- if (fcntl(fds, F_SETLK, &flock) < 0)
4317- {
4318- char tmpPath[256];
4319-
4320- tmpPath[0] = '\0';
4321-
4322- if (getcwd(tmpPath, sizeof(tmpPath)) == NULL)
4323- tmpPath[0] = '\0';
4324-
4325- sprintf(log_buffer, "cannot lock '%s/mom.lock' - another mom running",
4326- (tmpPath[0] != '\0') ? tmpPath : "$MOM_HOME");
4327-
4328- log_err(errno, msg_daemonname, log_buffer);
4329-
4330- fprintf(stderr, "%s\n",
4331- log_buffer);
4332-
4333- exit(1);
4334- }
4335-
4336- return;
4337- } /* END mom_lock() */
4338-
4339-
4340-
4341-/*
4342-** Process a request for the resource monitor. The i/o
4343-** will take place using DIS over a tcp fd or an rpp stream.
4344-*/
4345-
4346-int rm_request(
4347-
4348- int iochan,
4349- int version,
4350- int tcp) /* I */
4351-
4352- {
4353- static char id[] = "rm_request";
4354- char name[100];
4355- char output[BUFSIZ << 2];
4356- int len;
4357- int command, ret;
4358- int restrictrm = 0;
4359- char *curr, *value, *cp, *body;
4360-
4361- struct config *ap;
4362-
4363- struct rm_attribute *attr;
4364-
4365- struct sockaddr_in *addr;
4366- unsigned long ipadd;
4367- u_short port;
4368- void (*close_io) A_((int));
4369- int (*flush_io) A_((int));
4370-
4371- extern struct connection svr_conn[];
4372-
4373- int NotTrusted = 0;
4374-
4375- char *BPtr;
4376- int BSpace;
4377-
4378- errno = 0;
4379- log_buffer[0] = '\0';
4380-
4381- if (tcp)
4382- {
4383- ipadd = svr_conn[iochan].cn_addr;
4384- port = svr_conn[iochan].cn_port;
4385-
4386- close_io = close_conn;
4387- flush_io = DIS_tcp_wflush;
4388- }
4389- else
4390- {
4391- addr = rpp_getaddr(iochan);
4392- ipadd = ntohl(addr->sin_addr.s_addr);
4393- port = ntohs((unsigned short)addr->sin_port);
4394-
4395- close_io = (void(*) A_((int)))rpp_close;
4396- flush_io = rpp_flush;
4397- }
4398-
4399- if (version != RM_PROTOCOL_VER)
4400- {
4401- sprintf(log_buffer, "protocol version %d unknown",
4402- version);
4403-
4404- goto bad;
4405- }
4406-
4407- if (((port_care != FALSE) && (port >= IPPORT_RESERVED)) ||
4408- (tfind(ipadd, &okclients) == NULL))
4409- {
4410- if (bad_restrict(ipadd))
4411- {
4412- sprintf(log_buffer, "bad attempt to connect - unauthorized (port: %d)",
4413- port);
4414-
4415- NotTrusted = 1;
4416-
4417- goto bad;
4418- }
4419-
4420- restrictrm = 1;
4421- }
4422-
4423- /* looks okay, find out what command it is */
4424-
4425- command = disrsi(iochan, &ret);
4426-
4427- if (ret != DIS_SUCCESS)
4428- {
4429- sprintf(log_buffer, "no command %s",
4430- dis_emsg[ret]);
4431-
4432- goto bad;
4433- }
4434-
4435- switch (command)
4436- {
4437- case RM_CMD_CLOSE: /* no response to this */
4438-
4439- close_io(iochan);
4440-
4441- return(1);
4442-
4443- /*NOTREACHED*/
4444-
4445- break;
4446-
4447- case RM_CMD_REQUEST:
4448-
4449- /* query resource data */
4450-
4451- reqnum++;
4452-
4453-
4454- ret = diswsi(iochan, RM_RSP_OK);
4455-
4456- if (ret != DIS_SUCCESS)
4457- {
4458- sprintf(log_buffer, "write request response failed: %s",
4459- dis_emsg[ret]);
4460-
4461- goto bad;
4462- }
4463-
4464- for (;;)
4465- {
4466- cp = disrst(iochan, &ret);
4467-
4468- if (ret == DIS_EOD)
4469- {
4470- break;
4471- }
4472-
4473- if (ret != DIS_SUCCESS)
4474- {
4475- sprintf(log_buffer, "problem with request line: %s",
4476- dis_emsg[ret]);
4477-
4478- goto bad;
4479- }
4480-
4481- curr = skipwhite(cp);
4482-
4483- curr = tokcpy(curr, name);
4484-
4485- if (name[0] == '\0')
4486- {
4487- /* no name */
4488-
4489- sprintf(output, "%s=? %d",
4490- cp,
4491- RM_ERR_UNKNOWN);
4492- }
4493- else
4494- {
4495- if (!strncasecmp(name, "clearjob", strlen("clearjob")))
4496- {
4497- char *ptr = NULL;
4498-
4499- job *pjob = NULL, *pjobnext = NULL;
4500-
4501- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4502- {
4503- ptr = curr + 1;
4504- }
4505-
4506- /* purge job if local */
4507-
4508- if (ptr == NULL)
4509- {
4510- strcpy(output, "invalid clearjob request");
4511- }
4512- else
4513- {
4514- char tmpLine[1024];
4515-
4516- if (!strcasecmp(ptr, "all"))
4517- {
4518- if ((pjob = (job *)GET_NEXT(svr_alljobs)) != NULL)
4519- {
4520- while (pjob != NULL)
4521- {
4522- sprintf(tmpLine, "clearing job %s",
4523- pjob->ji_qs.ji_jobid);
4524-
4525- log_record(PBSEVENT_SYSTEM, 0, id, tmpLine);
4526-
4527- pjobnext = (job *)GET_NEXT(pjob->ji_alljobs);
4528-
4529- job_purge(pjob);
4530-
4531- pjob = pjobnext;
4532-
4533- strcat(output, tmpLine);
4534- strcat(output, "\n");
4535- }
4536- }
4537-
4538- strcat(output, "clear completed");
4539- }
4540- else if ((pjob = find_job(ptr)) != NULL)
4541- {
4542- sprintf(tmpLine, "clearing job %s",
4543- pjob->ji_qs.ji_jobid);
4544-
4545- log_record(PBSEVENT_SYSTEM, 0, id, tmpLine);
4546-
4547- job_purge(pjob);
4548-
4549- strcpy(output, tmpLine);
4550- }
4551- }
4552- }
4553- else if (!strncasecmp(name, "clearmsg", strlen("clearmsg")))
4554- {
4555- /* clear rm messages */
4556-
4557- PBSNodeMsgBuf[0] = '\0';
4558-
4559- strcpy(output, "messages cleared");
4560-
4561- log_record(PBSEVENT_SYSTEM, 0, id, "messages cleared");
4562- }
4563- else if (!strncasecmp(name, "cycle", strlen("cycle")))
4564- {
4565- /* force immediate cycle */
4566-
4567- LastServerUpdateTime = 0;
4568-
4569- strcpy(output, "cycle forced");
4570-
4571- log_record(PBSEVENT_SYSTEM, 0, id, "reporting cycle forced");
4572- }
4573- else if (!strncasecmp(name, "status_update_time", strlen("status_update_time")))
4574- {
4575- /* set or report status_update_time */
4576-
4577- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4578- {
4579- setstatusupdatetime(curr + 1);
4580- }
4581-
4582- sprintf(output, "status_update_time=%d",
4583-
4584- ServerStatUpdateInterval);
4585- }
4586- else if (!strncasecmp(name, "check_poll_time", strlen("check_poll_time")))
4587- {
4588- /* set or report check_poll_time */
4589-
4590- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4591- {
4592- setcheckpolltime(curr + 1);
4593- }
4594-
4595- sprintf(output, "check_poll_time=%d",
4596- CheckPollTime);
4597- }
4598- else if (!strncasecmp(name, "jobstartblocktime", strlen("jobstartblocktime")))
4599- {
4600- /* set or report jobstartblocktime */
4601-
4602- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4603- {
4604- jobstartblocktime(curr + 1);
4605- }
4606-
4607- sprintf(output, "jobstartblocktime=%ld",
4608-
4609- TJobStartBlockTime);
4610- }
4611- else if (!strncasecmp(name, "loglevel", strlen("loglevel")))
4612- {
4613- /* set or report loglevel */
4614-
4615- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4616- {
4617- setloglevel(curr + 1);
4618- }
4619-
4620- sprintf(output, "loglevel=%d",
4621- LOGLEVEL);
4622- }
4623- else if (!strncasecmp(name, "down_on_error", strlen("down_on_error")))
4624- {
4625- /* set or report down_on_error */
4626-
4627- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4628- {
4629- setdownonerror(curr + 1);
4630- }
4631-
4632- sprintf(output, "down_on_error=%d",
4633-
4634- MOMConfigDownOnError);
4635- }
4636- else if (!strncasecmp(name, "enablemomrestart", strlen("enablemomrestart")))
4637- {
4638- /* set or report enablemomrestart */
4639-
4640- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4641- {
4642- setenablemomrestart(curr + 1);
4643- }
4644-
4645- sprintf(output, "enablemomrestart=%d",
4646-
4647- MOMConfigRestart);
4648- }
4649- else if (!strncasecmp(name, "rcpcmd", strlen("rcpcmd")))
4650- {
4651- /* set or report rcp_path and rcp_args */
4652-
4653- if ((*curr == '=') && ((*curr) + 1 != '\0'))
4654- {
4655- setrcpcmd(curr + 1);
4656- }
4657-
4658- sprintf(output, "rcpcmd=%s %s",
4659-
4660- rcp_path, rcp_args);
4661- }
4662- else if (!strncasecmp(name, "version", strlen("version")))
4663- {
4664- /* report version */
4665-
4666- sprintf(output, "version=%s",
4667- PACKAGE_VERSION);
4668- }
4669- else if ((!strncasecmp(name, "configversion", strlen("configversion"))) && (MOMConfigVersion[0] != '\0'))
4670- {
4671- /* report configversion */
4672-
4673- sprintf(output, "configversion=%s",
4674- MOMConfigVersion);
4675- }
4676- else if (!strncasecmp(name, "diag", strlen("diag")))
4677- {
4678- char tmpLine[1024];
4679- char *ptr;
4680-
4681- int rc;
4682- time_t Now;
4683-
4684- job *pjob;
4685-
4686- struct varattr *pva;
4687-
4688- time(&Now);
4689-
4690- ptr = name + strlen("diag");
4691-
4692- verbositylevel = (int)strtol(ptr, NULL, 10);
4693-
4694- output[0] = '\0';
4695-
4696- BPtr = output;
4697- BSpace = sizeof(output);
4698-
4699- sprintf(tmpLine, "\nHost: %s/%s Version: %s PID: %ld\n",
4700- mom_short_name,
4701- mom_host,
4702- PACKAGE_VERSION,
4703- (long)getpid());
4704-
4705- MUStrNCat(&BPtr, &BSpace, tmpLine);
4706-
4707- mom_server_all_diag(&BPtr, &BSpace);
4708-
4709- sprintf(tmpLine, "HomeDirectory: %s\n",
4710- (mom_home != NULL) ? mom_home : "N/A");
4711-
4712- MUStrNCat(&BPtr, &BSpace, tmpLine);
4713-
4714-#ifdef HAVE_SYS_STATVFS_H
4715- {
4716-#include <sys/statvfs.h>
4717-
4718- struct statvfs VFSStat;
4719-
4720- if (statvfs(path_spool, &VFSStat) < 0)
4721- {
4722- MUSNPrintF(&BPtr, &BSpace, "ALERT: cannot stat stdout/stderr spool directory '%s' (errno=%d) %s\n",
4723- path_spool,
4724- errno,
4725- strerror(errno));
4726- }
4727- else
4728- {
4729- if (VFSStat.f_bavail > 0)
4730- {
4731- if (verbositylevel >= 1)
4732- MUSNPrintF(&BPtr, &BSpace, "stdout/stderr spool directory: '%s' (%d blocks available)\n",
4733- path_spool,
4734- VFSStat.f_bavail);
4735- }
4736- else
4737- {
4738- MUSNPrintF(&BPtr, &BSpace, "ALERT: stdout/stderr spool directory '%s' is full\n",
4739- path_spool);
4740- }
4741- }
4742- } /* END BLOCK */
4743-#endif /* HAVE_SYS_STATVFS_H */
4744-
4745- if (MOMConfigVersion[0] != '\0')
4746- {
4747- sprintf(tmpLine, "ConfigVersion: %s\n",
4748- MOMConfigVersion);
4749-
4750- MUStrNCat(&BPtr, &BSpace, tmpLine);
4751- }
4752-
4753- if (verbositylevel >= 3)
4754- {
4755-#if SYSLOG
4756- MUStrNCat(&BPtr, &BSpace, "NOTE: syslog enabled\n");
4757-#else /* SYSLOG */
4758- MUStrNCat(&BPtr, &BSpace, "NOTE: syslog not enabled (use 'configure --enable-syslog' to enable)\n");
4759-#endif /* SYSLOG */
4760- }
4761-
4762- if (verbositylevel >= 3)
4763- {
4764- if (PBSNodeCheckPath[0] != '\0')
4765- {
4766- sprintf(tmpLine, "Node Health Check Script: %s (%d second update interval)\n",
4767- PBSNodeCheckPath,
4768- PBSNodeCheckInterval * ServerStatUpdateInterval);
4769-
4770- MUStrNCat(&BPtr, &BSpace, tmpLine);
4771- }
4772- }
4773-
4774- sprintf(tmpLine, "MOM active: %ld seconds\n",
4775- (long)Now - MOMStartTime);
4776-
4777- MUStrNCat(&BPtr, &BSpace, tmpLine);
4778-
4779- if (verbositylevel >= 1)
4780- {
4781- sprintf(tmpLine, "Check Poll Time: %d seconds\n",
4782- CheckPollTime);
4783-
4784- MUStrNCat(&BPtr, &BSpace, tmpLine);
4785-
4786- sprintf(tmpLine, "Server Update Interval: %d seconds\n",
4787- ServerStatUpdateInterval);
4788-
4789- MUStrNCat(&BPtr, &BSpace, tmpLine);
4790- }
4791-
4792- if (PBSNodeMsgBuf[0] != '\0')
4793- {
4794- sprintf(tmpLine, "MOM Message: %s (use 'momctl -q clearmsg' to clear)\n",
4795- PBSNodeMsgBuf);
4796-
4797- MUStrNCat(&BPtr, &BSpace, tmpLine);
4798- }
4799-
4800- if (MOMUNameMissing[0] != '\0')
4801- {
4802- sprintf(tmpLine, "WARNING: passwd file is corrupt (job requests user '%s' - not found in local passwd file)\n",
4803- MOMUNameMissing);
4804-
4805- MUStrNCat(&BPtr, &BSpace, tmpLine);
4806- }
4807-
4808- if (MOMPrologTimeoutCount > 0)
4809- {
4810- sprintf(tmpLine, "WARNING: %d prolog timeouts (%d seconds) detected since start up - increase $prologalarm or investigate prolog\n",
4811- MOMPrologTimeoutCount,
4812- pe_alarm_time);
4813-
4814- MUStrNCat(&BPtr, &BSpace, tmpLine);
4815- }
4816-
4817- if (MOMPrologFailureCount > 0)
4818- {
4819- sprintf(tmpLine, "WARNING: %d prolog failures detected since start up - investigate prolog\n",
4820- MOMPrologFailureCount);
4821-
4822- MUStrNCat(&BPtr, &BSpace, tmpLine);
4823- }
4824-
4825- sprintf(tmpLine, "LogLevel: %d (use SIGUSR1/SIGUSR2 to adjust)\n",
4826-
4827- LOGLEVEL);
4828-
4829- MUStrNCat(&BPtr, &BSpace, tmpLine);
4830-
4831- if (verbositylevel >= 1)
4832- {
4833-#if RPP
4834- sprintf(tmpLine, "Communication Model: %s\n", "RPP");
4835-#else /* RPP */
4836- sprintf(tmpLine, "Communication Model: %s\n", "TCP");
4837-#endif /* RPP */
4838-
4839- MUStrNCat(&BPtr, &BSpace, tmpLine);
4840-
4841- if ((MOMIsLocked == 1) || (MOMIsPLocked == 1) || (verbositylevel >= 4))
4842- {
4843- sprintf(tmpLine, "MemLocked: %s",
4844- (MOMIsLocked == 0) ? "FALSE" : "TRUE");
4845-
4846- if (MOMIsLocked == 1)
4847- strcat(tmpLine, " (mlock)");
4848-
4849- if (MOMIsPLocked == 1)
4850- strcat(tmpLine, " (plocked)");
4851-
4852- strcat(tmpLine, "\n");
4853-
4854- MUStrNCat(&BPtr, &BSpace, tmpLine);
4855- }
4856- } /* END if (verbositylevel >= 1) */
4857-
4858- if ((verbositylevel >= 1) && (pbs_tcp_timeout > 0))
4859- {
4860- sprintf(tmpLine, "TCP Timeout: %d seconds\n",
4861- (int)pbs_tcp_timeout);
4862-
4863- MUStrNCat(&BPtr, &BSpace, tmpLine);
4864- }
4865-
4866- if (verbositylevel >= 1)
4867- {
4868-
4869- struct stat s;
4870-
4871- int prologfound = 0;
4872-
4873- if (stat(path_prolog, &s) != -1)
4874- {
4875- MUSNPrintF(&BPtr, &BSpace, "Prolog: %s (enabled)\n",
4876- path_prolog);
4877-
4878- prologfound = 1;
4879- }
4880- else if (verbositylevel >= 2)
4881- {
4882- MUSNPrintF(&BPtr, &BSpace, "Prolog: %s (disabled)\n",
4883- path_prolog);
4884- }
4885-
4886- if (stat(path_prologp, &s) != -1)
4887- {
4888- MUSNPrintF(&BPtr, &BSpace, "Parallel Prolog: %s (enabled)\n",
4889- path_prologp);
4890-
4891- prologfound = 1;
4892- }
4893-
4894- if (prologfound == 1)
4895- {
4896- sprintf(tmpLine, "Prolog Alarm Time: %d seconds\n",
4897- pe_alarm_time);
4898-
4899- MUStrNCat(&BPtr, &BSpace, tmpLine);
4900- }
4901- }
4902-
4903- if (verbositylevel >= 2)
4904- {
4905- /* check alarm */
4906-
4907- rc = alarm(alarm_time);
4908-
4909- alarm(rc);
4910-
4911- sprintf(tmpLine, "Alarm Time: %d of %d seconds\n",
4912- rc,
4913- alarm_time);
4914-
4915- MUStrNCat(&BPtr, &BSpace, tmpLine);
4916- }
4917-
4918- if (verbositylevel >= 1)
4919- {
4920- /* display okclient list */
4921-
4922- tmpLine[0] = '\0';
4923-
4924- tlist(okclients, tmpLine, sizeof(tmpLine));
4925-
4926- MUSNPrintF(&BPtr, &BSpace, "Trusted Client List: %s\n",
4927- tmpLine);
4928- }
4929-
4930- if (verbositylevel >= 1)
4931- {
4932- tmpLine[0] = '\0';
4933-
4934- MUSNPrintF(&BPtr, &BSpace, "Copy Command: %s %s\n",
4935- rcp_path,
4936- rcp_args);
4937- }
4938-
4939- /* joblist */
4940-
4941- if ((pjob = (job *)GET_NEXT(svr_alljobs)) == NULL)
4942- {
4943- sprintf(tmpLine, "NOTE: no local jobs detected\n");
4944-
4945- MUStrNCat(&BPtr, &BSpace, tmpLine);
4946- }
4947- else
4948- {
4949- int numvnodes = 0;
4950- task *ptask;
4951- char SIDList[1024];
4952-
4953- char *VPtr; /* job env variable value pointer */
4954-
4955- char *SPtr;
4956- int SSpace;
4957-
4958- for (;pjob != NULL;pjob = (job *)GET_NEXT(pjob->ji_alljobs))
4959- {
4960- SPtr = SIDList;
4961- SSpace = sizeof(SIDList);
4962-
4963- SIDList[0] = '\0';
4964-
4965- for (ptask = (task *)GET_NEXT(pjob->ji_tasks);
4966- ptask != NULL;
4967- ptask = (task *)GET_NEXT(ptask->ti_jobtask))
4968- {
4969- /* only check on tasks that we think should still be around */
4970-
4971- if (ptask->ti_qs.ti_status != TI_STATE_RUNNING)
4972- continue;
4973-
4974- /* NOTE: on linux systems, the session master should have
4975- pid == sessionid */
4976-
4977- MUSNPrintF(&SPtr, &SSpace, "%s%d",
4978- (SIDList[0] != '\0') ? "," : "",
4979- ptask->ti_qs.ti_sid);
4980- } /* END for (task) */
4981-
4982- numvnodes += pjob->ji_numvnod;
4983-
4984- sprintf(tmpLine, "job[%s] state=%s sidlist=%s",
4985- pjob->ji_qs.ji_jobid,
4986- PJobSubState[pjob->ji_qs.ji_substate],
4987- SIDList);
4988-
4989- MUStrNCat(&BPtr, &BSpace, tmpLine);
4990-
4991- if (verbositylevel >= 4)
4992- {
4993- /* report job variables */
4994-
4995- VPtr = get_job_envvar(pjob, "BATCH_PARTITION_ID");
4996-
4997- if (VPtr != NULL)
4998- {
4999- sprintf(tmpLine, " BATCH_PARTITION_ID=%s",
5000- VPtr);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: