Merge lp:~bkerensa/ubuntu/trusty/torque/merge-from-debian into lp:debian/torque

Proposed by Benjamin Kerensa
Status: Needs review
Proposed branch: lp:~bkerensa/ubuntu/trusty/torque/merge-from-debian
Merge into: lp:debian/torque
Diff against target: 24125 lines (+33/-23774)
30 files modified
.pc/CVE-2013-4319.patch/src/server/process_request.c (+0/-1394)
.pc/applied-patches (+0/-7)
.pc/c90string.patch/src/resmom/mom_main.c (+0/-8362)
.pc/c90string.patch/src/server/pbsd_main.c (+0/-3044)
.pc/fix-FTBFS-on-kfreebsd.patch/src/resmom/freebsd5/mom_mach.c (+0/-2432)
.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 (+19/-0)
debian/control (+4/-2)
debian/rules (+2/-1)
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/freebsd5/mom_mach.c (+1/-1)
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/server/process_request.c (+0/-15)
src/tools/xpbsmon/buildindex.src (+0/-1)
src/tools/xpbsmon/entry.tk (+1/-0)
To merge this branch: bzr merge lp:~bkerensa/ubuntu/trusty/torque/merge-from-debian
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+192388@code.launchpad.net

Description of the change

Merge from Debian

To post a comment you must log in.

Unmerged revisions

15. By Benjamin Kerensa

Merge from Debian

14. By Daniel T Chen

Specified multiarch Tcl and Tk locations during configure,
fixing FTBFS.

13. By Adam Conrad

No-change rebuild to drop spurious libsfgcc1 dependency on armhf.

12. By Dominique Belhachemi

* New upstream release
* This version of TORQUE fixes a problem with MOM's seg-faulting.

11. By Dominique Belhachemi

New upstream release

10. By Dominique Belhachemi

* Upload to unstable
* Added tcl85.patch: Fix xpbsmon issue (Closes: #626480)

9. By Jordi Mallach

* Fix paths on "non-standard-dir-perm" overrides.
* Make torque-server Conflict: torque-client (<= 2.4), and
  torque-client-x11 Replace: torque-gui, for smoother upgrade path
  from the Ubuntu packages.
* Explicitly enable RPP.
* Pass --with-rcp=scp so Torque uses scp as remote copy command.
* Build-Depend on openssh-client.
* Add gnu_fixes.patch, disabled for now, to fix builds on the Hurd.
  This patch is a temporary hack. As it is now, the package will build,
  but will most probably not work. The correct fix is to disable quota
  support on this platform.

8. By Dominique Belhachemi

install man pages together with their associated binaries (Closes: #581576)

7. By Matthias Klose

No-change rebuild to fix lpia shared library dependencies.

6. By Morten Kjeldgaard

Fix FTBFS on PPC platform using patch from torqueusers mailing
list (LP: #343601).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed directory '.pc' => '.pc'
=== removed directory '.pc/CVE-2013-4319.patch'
=== removed directory '.pc/CVE-2013-4319.patch/src'
=== removed directory '.pc/CVE-2013-4319.patch/src/server'
=== removed file '.pc/CVE-2013-4319.patch/src/server/process_request.c'
--- .pc/CVE-2013-4319.patch/src/server/process_request.c 2013-10-07 07:09:57 +0000
+++ .pc/CVE-2013-4319.patch/src/server/process_request.c 1970-01-01 00:00:00 +0000
@@ -1,1394 +0,0 @@
1/*
2* OpenPBS (Portable Batch System) v2.3 Software License
3*
4* Copyright (c) 1999-2000 Veridian Information Solutions, Inc.
5* All rights reserved.
6*
7* ---------------------------------------------------------------------------
8* For a license to use or redistribute the OpenPBS software under conditions
9* other than those described below, or to purchase support for this software,
10* please contact Veridian Systems, PBS Products Department ("Licensor") at:
11*
12* www.OpenPBS.org +1 650 967-4675 sales@OpenPBS.org
13* 877 902-4PBS (US toll-free)
14* ---------------------------------------------------------------------------
15*
16* This license covers use of the OpenPBS v2.3 software (the "Software") at
17* your site or location, and, for certain users, redistribution of the
18* Software to other sites and locations. Use and redistribution of
19* OpenPBS v2.3 in source and binary forms, with or without modification,
20* are permitted provided that all of the following conditions are met.
21* After December 31, 2001, only conditions 3-6 must be met:
22*
23* 1. Commercial and/or non-commercial use of the Software is permitted
24* provided a current software registration is on file at www.OpenPBS.org.
25* If use of this software contributes to a publication, product, or
26* service, proper attribution must be given; see www.OpenPBS.org/credit.html
27*
28* 2. Redistribution in any form is only permitted for non-commercial,
29* non-profit purposes. There can be no charge for the Software or any
30* software incorporating the Software. Further, there can be no
31* expectation of revenue generated as a consequence of redistributing
32* the Software.
33*
34* 3. Any Redistribution of source code must retain the above copyright notice
35* and the acknowledgment contained in paragraph 6, this list of conditions
36* and the disclaimer contained in paragraph 7.
37*
38* 4. Any Redistribution in binary form must reproduce the above copyright
39* notice and the acknowledgment contained in paragraph 6, this list of
40* conditions and the disclaimer contained in paragraph 7 in the
41* documentation and/or other materials provided with the distribution.
42*
43* 5. Redistributions in any form must be accompanied by information on how to
44* obtain complete source code for the OpenPBS software and any
45* modifications and/or additions to the OpenPBS software. The source code
46* must either be included in the distribution or be available for no more
47* than the cost of distribution plus a nominal fee, and all modifications
48* and additions to the Software must be freely redistributable by any party
49* (including Licensor) without restriction.
50*
51* 6. All advertising materials mentioning features or use of the Software must
52* display the following acknowledgment:
53*
54* "This product includes software developed by NASA Ames Research Center,
55* Lawrence Livermore National Laboratory, and Veridian Information
56* Solutions, Inc.
57* Visit www.OpenPBS.org for OpenPBS software support,
58* products, and information."
59*
60* 7. DISCLAIMER OF WARRANTY
61*
62* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ANY EXPRESS
63* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
64* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT
65* ARE EXPRESSLY DISCLAIMED.
66*
67* IN NO EVENT SHALL VERIDIAN CORPORATION, ITS AFFILIATED COMPANIES, OR THE
68* U.S. GOVERNMENT OR ANY OF ITS AGENCIES BE LIABLE FOR ANY DIRECT OR INDIRECT,
69* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
70* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
71* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
72* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
73* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
74* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75*
76* This license will be governed by the laws of the Commonwealth of Virginia,
77* without reference to its choice of law rules.
78*/
79
80#include <pbs_config.h> /* the master config generated by configure */
81
82#include <errno.h>
83#include <stdio.h>
84#include <stdlib.h>
85#include <sys/types.h>
86#include <sys/time.h>
87#include <sys/socket.h>
88#include <netinet/in.h>
89#include <memory.h>
90#include <time.h>
91#include <pwd.h>
92#include <sys/param.h>
93#if HAVE_SYS_UCRED_H
94#include <sys/ucred.h>
95#endif
96#if HAVE_SYS_UIO_H
97#include <sys/uio.h>
98#endif
99
100#include "libpbs.h"
101#include "pbs_error.h"
102#include "server_limits.h"
103#include "pbs_nodes.h"
104#include "list_link.h"
105#include "attribute.h"
106#include "pbs_job.h"
107#include "server.h"
108#include "credential.h"
109#include "batch_request.h"
110#include "net_connect.h"
111#include "log.h"
112#include "svrfunc.h"
113#include "pbs_proto.h"
114#include "csv.h"
115
116#ifndef PBS_MOM
117#include "array.h"
118#endif
119
120/*
121 * process_request - this function gets, checks, and invokes the proper
122 * function to deal with a batch request received over the network.
123 *
124 * All data encoding/decoding dependencies are moved to a lower level
125 * routine. That routine must convert
126 * the data received into the internal server structures regardless of
127 * the data structures used by the encode/decode routines. This provides
128 * the "protocol" and "protocol generation tool" freedom to the bulk
129 * of the server.
130 */
131
132/* global data items */
133
134tlist_head svr_requests;
135
136extern struct connection svr_conn[];
137
138extern struct credential conn_credent[PBS_NET_MAX_CONNECTIONS];
139
140extern struct server server;
141extern char server_host[];
142extern tlist_head svr_newjobs;
143extern time_t time_now;
144extern char *msg_err_noqueue;
145extern char *msg_err_malloc;
146extern char *msg_request;
147#ifndef PBS_MOM
148extern char server_name[];
149#endif
150
151extern int LOGLEVEL;
152
153/* private functions local to this file */
154
155static void close_client A_((int sfds));
156static void freebr_manage A_((struct rq_manage *));
157static void freebr_cpyfile A_((struct rq_cpyfile *));
158static void close_quejob A_((int sfds));
159#ifndef PBS_MOM
160static void free_rescrq A_((struct rq_rescq *));
161#endif /* PBS_MOM */
162
163/* END private prototypes */
164
165#ifndef PBS_MOM
166
167extern struct pbsnode *PGetNodeFromAddr(pbs_net_t);
168#endif
169
170/* request processing prototypes */
171void req_quejob(struct batch_request *preq);
172void req_jobcredential(struct batch_request *preq);
173void req_jobscript(struct batch_request *preq);
174void req_rdytocommit(struct batch_request *preq);
175void req_commit(struct batch_request *preq);
176void req_deletejob(struct batch_request *preq);
177void req_holdjob(struct batch_request *preq);
178void req_checkpointjob(struct batch_request *preq);
179void req_messagejob(struct batch_request *preq);
180void req_modifyjob(struct batch_request *preq);
181#ifndef PBS_MOM
182void req_orderjob(struct batch_request *preq);
183void req_rescreserve(struct batch_request *preq);
184void req_rescfree(struct batch_request *preq);
185#endif
186#ifdef PBS_MOM
187void req_rerunjob(struct batch_request *preq);
188#endif
189void req_shutdown(struct batch_request *preq);
190void req_signaljob(struct batch_request *preq);
191void req_mvjobfile(struct batch_request *preq);
192#ifndef PBS_MOM
193void req_stat_node(struct batch_request *preq);
194void req_track(struct batch_request *preq);
195void req_jobobit(struct batch_request *preq);
196void req_stagein(struct batch_request *preq);
197
198void req_deletearray(struct batch_request *preq);
199void req_holdarray(struct batch_request *preq);
200
201#endif
202
203/* END request processing prototypes */
204
205
206#ifdef ENABLE_UNIX_SOCKETS
207#ifndef PBS_MOM
208int get_creds(int sd, char *username, char *hostname)
209 {
210 int nb/*, sync*/;
211 char ctrl[CMSG_SPACE(sizeof(struct ucred))];
212 size_t size;
213
214 struct iovec iov[1];
215
216 struct msghdr msg;
217
218 struct cmsghdr *cmptr;
219 ucreds *credentials;
220
221 struct passwd *cpwd;
222 char dummy;
223
224 msg.msg_name = NULL;
225 msg.msg_namelen = 0;
226 msg.msg_iov = iov;
227 msg.msg_iovlen = 1;
228 msg.msg_control = ctrl;
229 msg.msg_controllen = sizeof(ctrl);
230 msg.msg_flags = 0;
231
232#ifdef LOCAL_CREDS
233 nb = 1;
234
235 if (setsockopt(sd, 0, LOCAL_CREDS, &nb, sizeof(nb)) == -1) return 0;
236
237#else
238#ifdef SO_PASSCRED
239 nb = 1;
240
241 if (setsockopt(sd, SOL_SOCKET, SO_PASSCRED, &nb, sizeof(nb)) == -1)
242 return 0;
243
244#endif
245#endif
246
247 dummy = '\0';
248
249 do
250 {
251 msg.msg_iov->iov_base = (void *) & dummy;
252 msg.msg_iov->iov_len = sizeof(dummy);
253 nb = recvmsg(sd, &msg, 0);
254 }
255 while (nb == -1 && (errno == EINTR || errno == EAGAIN));
256
257 if (nb == -1) return 0;
258
259 if ((unsigned)msg.msg_controllen < sizeof(struct cmsghdr)) return 0;
260
261 cmptr = CMSG_FIRSTHDR(&msg);
262
263#ifndef __NetBSD__
264 size = sizeof(ucreds);
265
266#else
267 if (cmptr->cmsg_len < SOCKCREDSIZE(0)) return 0;
268
269 size = SOCKCREDSIZE(((cred *)CMSG_DATA(cmptr))->sc_ngroups);
270
271#endif
272 if ((unsigned)cmptr->cmsg_len != CMSG_LEN(size)) return 0;
273
274 if (cmptr->cmsg_level != SOL_SOCKET) return 0;
275
276 if (cmptr->cmsg_type != SCM_CREDS) return 0;
277
278 if (!(credentials = (ucreds *)malloc(size))) return 0;
279
280 *credentials = *(ucreds *)CMSG_DATA(cmptr);
281
282 cpwd = getpwuid(SPC_PEER_UID(credentials));
283
284 if (cpwd)
285 strcpy(username, cpwd->pw_name);
286
287 strcpy(hostname, server_name);
288
289 free(credentials);
290
291 return 0;
292 }
293
294#endif
295#endif /* END ENABLE_UNIX_SOCKETS */
296
297
298/*
299 * process_request - process an request from the network:
300 *
301 * - Call function to read in the request and decode it.
302 * - Validate requesting host and user.
303 * - Call function to process request based on type.
304 * That function MUST free the request by calling free_br()
305 */
306
307void process_request(
308
309 int sfds) /* file descriptor (socket) to get request */
310
311 {
312#ifdef PBS_MOM
313 char *id = "process_request";
314#endif
315
316 int rc;
317
318 struct batch_request *request;
319
320 time_now = time(NULL);
321
322 request = alloc_br(0);
323
324 request->rq_conn = sfds;
325
326 /*
327 * Read in the request and decode it to the internal request structure.
328 */
329
330#ifndef PBS_MOM
331
332 if (svr_conn[sfds].cn_active == FromClientDIS)
333 {
334#ifdef ENABLE_UNIX_SOCKETS
335
336 if ((svr_conn[sfds].cn_socktype & PBS_SOCK_UNIX) &&
337 (svr_conn[sfds].cn_authen != PBS_NET_CONN_AUTHENTICATED))
338 {
339 get_creds(sfds, conn_credent[sfds].username, conn_credent[sfds].hostname);
340 }
341
342#endif /* END ENABLE_UNIX_SOCKETS */
343 rc = dis_request_read(sfds, request);
344 }
345 else
346 {
347 LOG_EVENT(
348 PBSEVENT_SYSTEM,
349 PBS_EVENTCLASS_REQUEST,
350 "process_req",
351 "request on invalid type of connection");
352
353 close_conn(sfds);
354
355 free_br(request);
356
357 return;
358 }
359
360#else /* PBS_MOM */
361 rc = dis_request_read(sfds, request);
362
363#endif /* PBS_MOM */
364
365 if (rc == -1)
366 {
367 /* FAILURE */
368
369 /* premature end of file */
370
371 close_client(sfds);
372
373 free_br(request);
374
375 return;
376 }
377
378 if ((rc == PBSE_SYSTEM) || (rc == PBSE_INTERNAL))
379 {
380 /* FAILURE */
381
382 /* read error, likely cannot send reply so just disconnect */
383
384 /* ??? not sure about this ??? */
385
386 close_client(sfds);
387
388 free_br(request);
389
390 return;
391 }
392
393 if (rc > 0)
394 {
395 /* FAILURE */
396
397 /*
398 * request didn't decode, either garbage or unknown
399 * request type, in either case, return reject-reply
400 */
401
402 req_reject(rc, 0, request, NULL, "cannot decode message");
403
404 close_client(sfds);
405
406 return;
407 }
408
409 if (get_connecthost(sfds, request->rq_host, PBS_MAXHOSTNAME) != 0)
410 {
411 char tmpLine[1024];
412
413 sprintf(log_buffer, "%s: %lu",
414 pbse_to_txt(PBSE_BADHOST),
415 get_connectaddr(sfds));
416
417 LOG_EVENT(PBSEVENT_DEBUG, PBS_EVENTCLASS_REQUEST, "", log_buffer);
418
419 snprintf(tmpLine, sizeof(tmpLine), "cannot determine hostname for connection from %lu",
420 get_connectaddr(sfds));
421
422 req_reject(PBSE_BADHOST, 0, request, NULL, tmpLine);
423
424 return;
425 }
426
427 if (LOGLEVEL >= 1)
428 {
429 sprintf(
430 log_buffer,
431 msg_request,
432 reqtype_to_txt(request->rq_type),
433 request->rq_user,
434 request->rq_host,
435 sfds);
436
437 LOG_EVENT(PBSEVENT_DEBUG2, PBS_EVENTCLASS_REQUEST, "", log_buffer);
438 }
439
440 /* is the request from a host acceptable to the server */
441
442#ifndef PBS_MOM
443
444 if (svr_conn[sfds].cn_socktype & PBS_SOCK_UNIX)
445 {
446 strcpy(request->rq_host, server_name);
447 }
448
449 if (server.sv_attr[(int)SRV_ATR_acl_host_enable].at_val.at_long)
450 {
451 /* acl enabled, check it; always allow myself and nodes */
452
453 struct pbsnode *isanode;
454
455 isanode = PGetNodeFromAddr(get_connectaddr(sfds));
456
457 if ((isanode == NULL) &&
458 (strcmp(server_host, request->rq_host) != 0) &&
459 (acl_check(
460 &server.sv_attr[(int)SRV_ATR_acl_hosts],
461 request->rq_host,
462 ACL_Host) == 0))
463 {
464 char tmpLine[1024];
465
466 snprintf(tmpLine, sizeof(tmpLine), "request not authorized from host %s",
467 request->rq_host);
468
469 req_reject(PBSE_BADHOST, 0, request, NULL, tmpLine);
470
471 close_client(sfds);
472
473 return;
474 }
475 }
476
477 /*
478 * determine source (user client or another server) of request.
479 * set the permissions granted to the client
480 */
481
482 if (svr_conn[sfds].cn_authen == PBS_NET_CONN_FROM_PRIVIL)
483 {
484 /* request came from another server */
485
486 request->rq_fromsvr = 1;
487
488 request->rq_perm =
489 ATR_DFLAG_USRD | ATR_DFLAG_USWR |
490 ATR_DFLAG_OPRD | ATR_DFLAG_OPWR |
491 ATR_DFLAG_MGRD | ATR_DFLAG_MGWR |
492 ATR_DFLAG_SvWR;
493 }
494 else
495 {
496 /* request not from another server */
497
498 request->rq_fromsvr = 0;
499
500 /*
501 * Client must be authenticated by an Authenticate User Request, if not,
502 * reject request and close connection. -- The following is retained for
503 * compat with old cmds -- The exception to this is of course the Connect
504 * Request which cannot have been authenticated, because it contains the
505 * needed ticket; so trap it here. Of course, there is no prior
506 * authentication on the Authenticate User request either, but it comes
507 * over a reserved port and appears from another server, hence is
508 * automatically granted authentication.
509 *
510 * The above is only true with inet sockets. With unix domain sockets, the
511 * user creds were read before the first dis_request_read call above.
512 * We automatically granted authentication because we can trust the socket
513 * creds. Authorization is still granted in svr_get_privilege below
514 */
515
516 if (request->rq_type == PBS_BATCH_Connect)
517 {
518 req_connect(request);
519
520 if (svr_conn[sfds].cn_socktype == PBS_SOCK_INET)
521 return;
522
523 }
524
525 if (svr_conn[sfds].cn_socktype & PBS_SOCK_UNIX)
526 {
527 conn_credent[sfds].timestamp = time_now;
528 svr_conn[sfds].cn_authen = PBS_NET_CONN_AUTHENTICATED;
529 }
530
531 if (ENABLE_TRUSTED_AUTH == TRUE)
532 rc = 0; /* bypass the authentication of the user--trust the client completely */
533 else if (svr_conn[sfds].cn_authen != PBS_NET_CONN_AUTHENTICATED)
534 rc = PBSE_BADCRED;
535 else
536 rc = authenticate_user(request, &conn_credent[sfds]);
537
538 if (rc != 0)
539 {
540 req_reject(rc, 0, request, NULL, NULL);
541
542 close_client(sfds);
543
544 return;
545 }
546
547 /*
548 * pbs_mom and checkpoint restart scripts both need the authority to do
549 * alters and releases on checkpointable jobs. Allow manager permission
550 * for root on the jobs execution node.
551 */
552
553 if (((request->rq_type == PBS_BATCH_ModifyJob) ||
554 (request->rq_type == PBS_BATCH_ReleaseJob)) &&
555 (strcmp(request->rq_user, PBS_DEFAULT_ADMIN) == 0))
556 {
557 job *pjob;
558 char *dptr;
559 int skip = FALSE;
560 char short_host[PBS_MAXHOSTNAME+1];
561
562 /* make short host name */
563
564 strcpy(short_host, request->rq_host);
565 if ((dptr = strchr(short_host, '.')) != NULL)
566 {
567 *dptr = '\0';
568 }
569
570 if (((pjob = find_job(request->rq_ind.rq_modify.rq_objname)) != (job *)0) &&
571 (pjob->ji_qs.ji_state == JOB_STATE_RUNNING))
572 {
573
574 if ((pjob->ji_wattr[(int)JOB_ATR_checkpoint].at_flags & ATR_VFLAG_SET) &&
575 ((csv_find_string(pjob->ji_wattr[(int)JOB_ATR_checkpoint].at_val.at_str, "s") != NULL) ||
576 (csv_find_string(pjob->ji_wattr[(int)JOB_ATR_checkpoint].at_val.at_str, "c") != NULL) ||
577 (csv_find_string(pjob->ji_wattr[(int)JOB_ATR_checkpoint].at_val.at_str, "enabled") != NULL)) &&
578 (strstr(pjob->ji_wattr[(int)JOB_ATR_exec_host].at_val.at_str, short_host) != NULL))
579 {
580
581 request->rq_perm = svr_get_privilege(request->rq_user, server_host);
582 skip = TRUE;
583
584 }
585 }
586 if (!skip)
587 {
588 request->rq_perm = svr_get_privilege(request->rq_user, request->rq_host);
589 }
590 }
591 else
592 {
593 request->rq_perm = svr_get_privilege(request->rq_user, request->rq_host);
594 }
595 } /* END else (svr_conn[sfds].cn_authen == PBS_NET_CONN_FROM_PRIVIL) */
596
597 /* if server shutting down, disallow new jobs and new running */
598
599 if (server.sv_attr[(int)SRV_ATR_State].at_val.at_long > SV_STATE_RUN)
600 {
601 switch (request->rq_type)
602 {
603 case PBS_BATCH_AsyrunJob:
604 case PBS_BATCH_JobCred:
605 case PBS_BATCH_MoveJob:
606 case PBS_BATCH_QueueJob:
607 case PBS_BATCH_RunJob:
608 case PBS_BATCH_StageIn:
609 case PBS_BATCH_jobscript:
610
611 req_reject(PBSE_SVRDOWN, 0, request, NULL, NULL);
612
613 return;
614
615 /*NOTREACHED*/
616
617 break;
618 }
619 }
620
621#else /* THIS CODE FOR MOM ONLY */
622
623 {
624 extern tree *okclients;
625
626 extern void mom_server_update_receive_time_by_ip(u_long ipaddr, const char *cmd);
627
628 /* check connecting host against allowed list of ok clients */
629
630 if (LOGLEVEL >= 6)
631 {
632 sprintf(log_buffer, "request type %s from host %s received",
633 reqtype_to_txt(request->rq_type),
634 request->rq_host);
635
636 log_record(
637 PBSEVENT_JOB,
638 PBS_EVENTCLASS_JOB,
639 id,
640 log_buffer);
641 }
642
643 if (!tfind(svr_conn[sfds].cn_addr, &okclients))
644 {
645 sprintf(log_buffer, "request type %s from host %s rejected (host not authorized)",
646 reqtype_to_txt(request->rq_type),
647 request->rq_host);
648
649 log_record(
650 PBSEVENT_JOB,
651 PBS_EVENTCLASS_JOB,
652 id,
653 log_buffer);
654
655 req_reject(PBSE_BADHOST, 0, request, NULL, "request not authorized");
656
657 close_client(sfds);
658
659 return;
660 }
661
662 if (LOGLEVEL >= 3)
663 {
664 sprintf(log_buffer, "request type %s from host %s allowed",
665 reqtype_to_txt(request->rq_type),
666 request->rq_host);
667
668 log_record(
669 PBSEVENT_JOB,
670 PBS_EVENTCLASS_JOB,
671 id,
672 log_buffer);
673 }
674
675 mom_server_update_receive_time_by_ip(svr_conn[sfds].cn_addr, reqtype_to_txt(request->rq_type));
676 } /* END BLOCK */
677
678 request->rq_fromsvr = 1;
679
680 request->rq_perm =
681 ATR_DFLAG_USRD | ATR_DFLAG_USWR |
682 ATR_DFLAG_OPRD | ATR_DFLAG_OPWR |
683 ATR_DFLAG_MGRD | ATR_DFLAG_MGWR |
684 ATR_DFLAG_SvWR | ATR_DFLAG_MOM;
685
686#endif /* END else !PBS_MOM */
687
688 /*
689 * dispatch the request to the correct processing function.
690 * The processing function must call reply_send() to free
691 * the request struture.
692 */
693
694 dispatch_request(sfds, request);
695
696 return;
697 } /* END process_request() */
698
699
700
701
702
703/*
704 * dispatch_request - Determine the request type and invoke the corresponding
705 * function. The function will perform the request action and return the
706 * reply. The function MUST also reply and free the request by calling
707 * reply_send().
708 *
709 * @see process_request() - parent
710 */
711
712void dispatch_request(
713
714 int sfds, /* I */
715 struct batch_request *request) /* I */
716
717 {
718 char *id = "dispatch_request";
719
720 if (LOGLEVEL >= 5)
721 {
722 sprintf(log_buffer,"dispatching request %s on sd=%d",
723 reqtype_to_txt(request->rq_type),
724 sfds);
725
726 log_record(
727 PBSEVENT_JOB,
728 PBS_EVENTCLASS_JOB,
729 id,
730 log_buffer);
731 }
732
733 switch (request->rq_type)
734 {
735 case PBS_BATCH_QueueJob:
736
737 net_add_close_func(sfds, close_quejob);
738
739 req_quejob(request);
740
741 break;
742
743 case PBS_BATCH_JobCred:
744
745 req_jobcredential(request);
746
747 break;
748
749 case PBS_BATCH_jobscript:
750
751 req_jobscript(request);
752
753 break;
754
755 case PBS_BATCH_RdytoCommit:
756
757 req_rdytocommit(request);
758
759 break;
760
761 case PBS_BATCH_Commit:
762
763 req_commit(request);
764
765 net_add_close_func(sfds, (void (*)())0);
766
767 break;
768
769 case PBS_BATCH_DeleteJob:
770
771#ifdef PBS_MOM
772 req_deletejob(request);
773#else
774 /* if this is a server size job delete request, then the request could also be
775 * for an entire array. we check to see if the request object name is an array id.
776 * if so we hand off the the req_deletearray() function. If not we pass along to the
777 * normal req_deltejob() function.
778 */
779
780 if (is_array(request->rq_ind.rq_delete.rq_objname))
781 {
782 req_deletearray(request);
783 }
784 else
785 {
786 req_deletejob(request);
787 }
788
789#endif
790 break;
791
792 case PBS_BATCH_HoldJob:
793#ifdef PBS_MOM
794 req_holdjob(request);
795
796#else
797 if (is_array(request->rq_ind.rq_hold.rq_orig.rq_objname))
798 {
799 req_holdarray(request);
800 }
801 else
802 {
803 req_holdjob(request);
804 }
805
806#endif
807 break;
808
809 case PBS_BATCH_CheckpointJob:
810
811 req_checkpointjob(request);
812
813 break;
814
815#ifndef PBS_MOM
816
817 case PBS_BATCH_LocateJob:
818
819 req_locatejob(request);
820
821 break;
822
823 case PBS_BATCH_Manager:
824
825 req_manager(request);
826
827 break;
828
829#endif /* END !PBS_MOM */
830
831 case PBS_BATCH_MessJob:
832
833 req_messagejob(request);
834
835 break;
836
837 case PBS_BATCH_AsyModifyJob:
838
839 case PBS_BATCH_ModifyJob:
840
841 req_modifyjob(request);
842
843 break;
844
845 case PBS_BATCH_Rerun:
846
847 req_rerunjob(request);
848
849 break;
850
851#ifndef PBS_MOM
852
853 case PBS_BATCH_MoveJob:
854
855 req_movejob(request);
856
857 break;
858
859 case PBS_BATCH_OrderJob:
860
861 req_orderjob(request);
862
863 break;
864
865 case PBS_BATCH_Rescq:
866
867 req_rescq(request);
868
869 break;
870
871 case PBS_BATCH_ReserveResc:
872
873 req_rescreserve(request);
874
875 break;
876
877 case PBS_BATCH_ReleaseResc:
878
879 req_rescfree(request);
880
881 break;
882
883 case PBS_BATCH_ReleaseJob:
884
885 req_releasejob(request);
886
887 break;
888
889 case PBS_BATCH_RunJob:
890
891 case PBS_BATCH_AsyrunJob:
892
893 req_runjob(request);
894
895 break;
896
897 case PBS_BATCH_SelectJobs:
898
899 case PBS_BATCH_SelStat:
900
901 /* handle special 'truncated' keyword */
902
903 if (!strncasecmp(request->rq_ind.rq_status.rq_id, "truncated", strlen("truncated")))
904 req_stat_job(request);
905 else
906 req_selectjobs(request);
907
908 break;
909
910#endif /* !PBS_MOM */
911
912 case PBS_BATCH_Shutdown:
913
914 req_shutdown(request);
915
916 break;
917
918 case PBS_BATCH_SignalJob:
919
920 case PBS_BATCH_AsySignalJob:
921
922 req_signaljob(request);
923
924 break;
925
926 case PBS_BATCH_StatusJob:
927
928 req_stat_job(request);
929
930 break;
931
932 case PBS_BATCH_MvJobFile:
933
934 req_mvjobfile(request);
935
936 break;
937
938#ifndef PBS_MOM /* server only functions */
939
940 case PBS_BATCH_StatusQue:
941
942 req_stat_que(request);
943
944 break;
945
946 case PBS_BATCH_StatusNode:
947
948 req_stat_node(request);
949
950 break;
951
952 case PBS_BATCH_StatusSvr:
953
954 req_stat_svr(request);
955
956 break;
957
958 /* DIAGTODO: handle PBS_BATCH_StatusDiag and define req_stat_diag() */
959
960 case PBS_BATCH_TrackJob:
961
962 req_track(request);
963
964 break;
965
966 case PBS_BATCH_RegistDep:
967
968 req_register(request);
969
970 break;
971
972 case PBS_BATCH_AuthenUser:
973
974 /* determine if user is valid */
975
976 req_authenuser(request);
977
978 break;
979
980 case PBS_BATCH_JobObit:
981
982 req_jobobit(request);
983
984 break;
985
986 case PBS_BATCH_StageIn:
987
988 req_stagein(request);
989
990 break;
991
992#else /* MOM only functions */
993
994 case PBS_BATCH_ReturnFiles:
995
996 req_returnfiles(request);
997
998 break;
999
1000 case PBS_BATCH_CopyFiles:
1001
1002 req_cpyfile(request);
1003
1004 break;
1005
1006 case PBS_BATCH_DelFiles:
1007
1008 req_delfile(request);
1009
1010 break;
1011
1012#endif /* !PBS_MOM */
1013
1014 default:
1015
1016 req_reject(PBSE_UNKREQ, 0, request, NULL, NULL);
1017
1018 close_client(sfds);
1019
1020 break;
1021 } /* END switch (request->rq_type) */
1022
1023 return;
1024 } /* END dispatch_request() */
1025
1026
1027
1028
1029
1030/*
1031 * close_client - close a connection to a client, also "inactivate"
1032 * any outstanding batch requests on that connection.
1033 */
1034
1035static void close_client(
1036
1037 int sfds) /* connection socket */
1038
1039 {
1040
1041 struct batch_request *preq;
1042
1043 close_conn(sfds); /* close the connection */
1044
1045 preq = (struct batch_request *)GET_NEXT(svr_requests);
1046
1047 while (preq != NULL)
1048 {
1049 /* list of outstanding requests */
1050
1051 if (preq->rq_conn == sfds)
1052 preq->rq_conn = -1;
1053
1054 if (preq->rq_orgconn == sfds)
1055 preq->rq_orgconn = -1;
1056
1057 preq = (struct batch_request *)GET_NEXT(preq->rq_link);
1058 }
1059
1060 return;
1061 } /* END close_client() */
1062
1063
1064
1065
1066/*
1067 * alloc_br - allocate and clear a batch_request structure
1068 */
1069
1070struct batch_request *alloc_br(
1071
1072 int type)
1073
1074 {
1075
1076 struct batch_request *req;
1077
1078 req = (struct batch_request *)malloc(sizeof(struct batch_request));
1079
1080 if (req == NULL)
1081 {
1082 log_err(errno, "alloc_br", msg_err_malloc);
1083
1084 return(NULL);
1085 }
1086
1087 memset((void *)req, (int)0, sizeof(struct batch_request));
1088
1089 req->rq_type = type;
1090
1091 CLEAR_LINK(req->rq_link);
1092
1093 req->rq_conn = -1; /* indicate not connected */
1094 req->rq_orgconn = -1; /* indicate not connected */
1095 req->rq_time = time_now;
1096 req->rq_reply.brp_choice = BATCH_REPLY_CHOICE_NULL;
1097 req->rq_noreply = FALSE; /* indicate reply is needed */
1098
1099 append_link(&svr_requests, &req->rq_link, req);
1100
1101 return(req);
1102 }
1103
1104
1105
1106
1107
1108/*
1109 * close_quejob - locate and deal with the new job that was being recevied
1110 * when the net connection closed.
1111 */
1112
1113static void close_quejob(
1114
1115 int sfds)
1116
1117 {
1118 job *pjob;
1119 job *npjob;
1120
1121 pjob = (job *)GET_NEXT(svr_newjobs);
1122
1123 while (pjob != NULL)
1124 {
1125 npjob = GET_NEXT(pjob->ji_alljobs);
1126
1127 if (pjob->ji_qs.ji_un.ji_newt.ji_fromsock == sfds)
1128 {
1129 if (pjob->ji_qs.ji_substate == JOB_SUBSTATE_TRANSICM)
1130 {
1131
1132#ifndef PBS_MOM
1133
1134 if (pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE)
1135 {
1136 /*
1137 * the job was being created here for the first time
1138 * go ahead and enqueue it as QUEUED; otherwise, hold
1139 * it here as TRANSICM until we hear from the sending
1140 * server again to commit.
1141 */
1142
1143 delete_link(&pjob->ji_alljobs);
1144
1145 pjob->ji_qs.ji_state = JOB_STATE_QUEUED;
1146 pjob->ji_qs.ji_substate = JOB_SUBSTATE_QUEUED;
1147
1148 if (svr_enquejob(pjob))
1149 job_abt(&pjob, msg_err_noqueue);
1150 }
1151
1152#endif /* PBS_MOM */
1153
1154 }
1155 else
1156 {
1157 /* else delete the job */
1158
1159 delete_link(&pjob->ji_alljobs);
1160
1161 job_purge(pjob);
1162 }
1163
1164 break;
1165 } /* END if (..) */
1166
1167 pjob = npjob;
1168 }
1169
1170 return;
1171 } /* END close_quejob() */
1172
1173
1174
1175
1176
1177/*
1178 * free_br - free space allocated to a batch_request structure
1179 * including any sub-structures
1180 */
1181
1182void free_br(
1183
1184 struct batch_request *preq)
1185
1186 {
1187 delete_link(&preq->rq_link);
1188
1189 reply_free(&preq->rq_reply);
1190
1191 if (preq->rq_extend)
1192 free(preq->rq_extend);
1193
1194 switch (preq->rq_type)
1195 {
1196 case PBS_BATCH_QueueJob:
1197
1198 free_attrlist(&preq->rq_ind.rq_queuejob.rq_attr);
1199
1200 break;
1201
1202 case PBS_BATCH_JobCred:
1203
1204 if (preq->rq_ind.rq_jobcred.rq_data)
1205 free(preq->rq_ind.rq_jobcred.rq_data);
1206
1207 break;
1208
1209 case PBS_BATCH_MvJobFile:
1210
1211 case PBS_BATCH_jobscript:
1212
1213 if (preq->rq_ind.rq_jobfile.rq_data)
1214 free(preq->rq_ind.rq_jobfile.rq_data);
1215
1216 break;
1217
1218 case PBS_BATCH_HoldJob:
1219
1220 freebr_manage(&preq->rq_ind.rq_hold.rq_orig);
1221
1222 break;
1223
1224 case PBS_BATCH_CheckpointJob:
1225
1226 freebr_manage(&preq->rq_ind.rq_manager);
1227
1228 break;
1229
1230 case PBS_BATCH_MessJob:
1231
1232 if (preq->rq_ind.rq_message.rq_text)
1233 free(preq->rq_ind.rq_message.rq_text);
1234
1235 break;
1236
1237 case PBS_BATCH_ModifyJob:
1238
1239 case PBS_BATCH_AsyModifyJob:
1240
1241 freebr_manage(&preq->rq_ind.rq_modify);
1242
1243 break;
1244
1245 case PBS_BATCH_StatusJob:
1246
1247 case PBS_BATCH_StatusQue:
1248
1249 case PBS_BATCH_StatusNode:
1250
1251 case PBS_BATCH_StatusSvr:
1252 /* DIAGTODO: handle PBS_BATCH_StatusDiag */
1253
1254 free_attrlist(&preq->rq_ind.rq_status.rq_attr);
1255
1256 break;
1257
1258 case PBS_BATCH_JobObit:
1259
1260 free_attrlist(&preq->rq_ind.rq_jobobit.rq_attr);
1261
1262 break;
1263
1264 case PBS_BATCH_CopyFiles:
1265
1266 case PBS_BATCH_DelFiles:
1267
1268 freebr_cpyfile(&preq->rq_ind.rq_cpyfile);
1269
1270 break;
1271
1272#ifndef PBS_MOM /* Server Only */
1273
1274 case PBS_BATCH_Manager:
1275
1276 freebr_manage(&preq->rq_ind.rq_manager);
1277
1278 break;
1279
1280 case PBS_BATCH_ReleaseJob:
1281
1282 freebr_manage(&preq->rq_ind.rq_release);
1283
1284 break;
1285
1286 case PBS_BATCH_Rescq:
1287
1288 free_rescrq(&preq->rq_ind.rq_rescq);
1289
1290 break;
1291
1292 case PBS_BATCH_SelectJobs:
1293
1294 case PBS_BATCH_SelStat:
1295
1296 free_attrlist(&preq->rq_ind.rq_select);
1297
1298 break;
1299
1300 case PBS_BATCH_RunJob:
1301
1302 case PBS_BATCH_AsyrunJob:
1303
1304 if (preq->rq_ind.rq_run.rq_destin)
1305 free(preq->rq_ind.rq_run.rq_destin);
1306
1307 break;
1308
1309#endif /* !PBS_MOM */
1310
1311 default:
1312
1313 /* NO-OP */
1314
1315 break;
1316 } /* END switch (preq->rq_type) */
1317
1318 free(preq);
1319
1320 return;
1321 } /* END free_br() */
1322
1323
1324
1325
1326
1327static void freebr_manage(
1328
1329 struct rq_manage *pmgr)
1330
1331 {
1332 free_attrlist(&pmgr->rq_attr);
1333
1334 return;
1335 } /* END freebr_manage() */
1336
1337
1338
1339
1340static void freebr_cpyfile(
1341
1342 struct rq_cpyfile *pcf)
1343
1344 {
1345
1346 struct rqfpair *ppair;
1347
1348 while ((ppair = (struct rqfpair *)GET_NEXT(pcf->rq_pair)) != NULL)
1349 {
1350 delete_link(&ppair->fp_link);
1351
1352 if (ppair->fp_local != NULL)
1353 free(ppair->fp_local);
1354
1355 if (ppair->fp_rmt != NULL)
1356 free(ppair->fp_rmt);
1357
1358 free(ppair);
1359 }
1360
1361 return;
1362 } /* END freebr_cpyfile() */
1363
1364
1365
1366
1367
1368#ifndef PBS_MOM
1369static void free_rescrq(
1370
1371 struct rq_rescq *pq)
1372
1373 {
1374 int i;
1375
1376 i = pq->rq_num;
1377
1378 while (i--)
1379 {
1380 if (*(pq->rq_list + i) != NULL)
1381 free(*(pq->rq_list + i));
1382 }
1383
1384 if (pq->rq_list != NULL)
1385 free(pq->rq_list);
1386
1387 return;
1388 } /* END free_rescrq() */
1389
1390#endif /* PBS_MOM */
1391
1392/* END process_requests.c */
1393
1394
13950
=== removed file '.pc/applied-patches'
--- .pc/applied-patches 2013-10-10 17:34:01 +0000
+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1freebsd5_manpages.patch
2gnu_fixes.patch
3c90string.patch
4xpbs_xpbsmon_tclIndex.patch
5tcl85.patch
6CVE-2013-4319.patch
7fix-FTBFS-on-kfreebsd.patch
80
=== removed directory '.pc/c90string.patch'
=== removed directory '.pc/c90string.patch/src'
=== removed directory '.pc/c90string.patch/src/resmom'
=== removed file '.pc/c90string.patch/src/resmom/mom_main.c'
--- .pc/c90string.patch/src/resmom/mom_main.c 2011-08-01 20:05:47 +0000
+++ .pc/c90string.patch/src/resmom/mom_main.c 1970-01-01 00:00:00 +0000
@@ -1,8362 +0,0 @@
1/*
2* OpenPBS (Portable Batch System) v2.3 Software License
3*
4* Copyright (c) 1999-2000 Veridian Information Solutions, Inc.
5* All rights reserved.
6*
7* ---------------------------------------------------------------------------
8* For a license to use or redistribute the OpenPBS software under conditions
9* other than those described below, or to purchase support for this software,
10* please contact Veridian Systems, PBS Products Department ("Licensor") at:
11*
12* www.OpenPBS.org +1 650 967-4675 sales@OpenPBS.org
13* 877 902-4PBS (US toll-free)
14* ---------------------------------------------------------------------------
15*
16* This license covers use of the OpenPBS v2.3 software (the "Software") at
17* your site or location, and, for certain users, redistribution of the
18* Software to other sites and locations. Use and redistribution of
19* OpenPBS v2.3 in source and binary forms, with or without modification,
20* are permitted provided that all of the following conditions are met.
21* After December 31, 2001, only conditions 3-6 must be met:
22*
23* 1. Commercial and/or non-commercial use of the Software is permitted
24* provided a current software registration is on file at www.OpenPBS.org.
25* If use of this software contributes to a publication, product, or
26* service, proper attribution must be given; see www.OpenPBS.org/credit.html
27*
28* 2. Redistribution in any form is only permitted for non-commercial,
29* non-profit purposes. There can be no charge for the Software or any
30* software incorporating the Software. Further, there can be no
31* expectation of revenue generated as a consequence of redistributing
32* the Software.
33*
34* 3. Any Redistribution of source code must retain the above copyright notice
35* and the acknowledgment contained in paragraph 6, this list of conditions
36* and the disclaimer contained in paragraph 7.
37*
38* 4. Any Redistribution in binary form must reproduce the above copyright
39* notice and the acknowledgment contained in paragraph 6, this list of
40* conditions and the disclaimer contained in paragraph 7 in the
41* documentation and/or other materials provided with the distribution.
42*
43* 5. Redistributions in any form must be accompanied by information on how to
44* obtain complete source code for the OpenPBS software and any
45* modifications and/or additions to the OpenPBS software. The source code
46* must either be included in the distribution or be available for no more
47* than the cost of distribution plus a nominal fee, and all modifications
48* and additions to the Software must be freely redistributable by any party
49* (including Licensor) without restriction.
50*
51* 6. All advertising materials mentioning features or use of the Software must
52* display the following acknowledgment:
53*
54* "This product includes software developed by NASA Ames Research Center,
55* Lawrence Livermore National Laboratory, and Veridian Information
56* Solutions, Inc.
57* Visit www.OpenPBS.org for OpenPBS software support,
58* products, and information."
59*
60* 7. DISCLAIMER OF WARRANTY
61*
62* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ANY EXPRESS
63* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
64* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT
65* ARE EXPRESSLY DISCLAIMED.
66*
67* IN NO EVENT SHALL VERIDIAN CORPORATION, ITS AFFILIATED COMPANIES, OR THE
68* U.S. GOVERNMENT OR ANY OF ITS AGENCIES BE LIABLE FOR ANY DIRECT OR INDIRECT,
69* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
70* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
71* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
72* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
73* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
74* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75*
76* This license will be governed by the laws of the Commonwealth of Virginia,
77* without reference to its choice of law rules.
78*/
79/*
80 * The entry point function for MOM.
81 */
82
83#include <pbs_config.h> /* the master config generated by configure */
84
85#include <assert.h>
86#include <stdio.h>
87#include <stdlib.h>
88#include <unistd.h>
89#include <stdarg.h>
90
91#ifdef _CRAY
92#include <termios.h>
93#endif /* _CRAY */
94
95#include <pwd.h>
96#include <signal.h>
97#include <string.h>
98#include <ctype.h>
99#include <errno.h>
100#include <fcntl.h>
101#include <time.h>
102#include <limits.h>
103#include <netdb.h>
104#include <grp.h>
105#include <sys/types.h>
106#include <sys/param.h>
107#include <sys/times.h>
108#include <sys/stat.h>
109#if (PLOCK_DAEMONS & 4)
110#include <sys/lock.h>
111#endif /* PLOCK_DAEMONS */
112#include <netinet/in.h>
113#include <sys/socket.h>
114#ifdef _CRAY
115#include <sys/category.h>
116#include <sys/usrv.h>
117#include <sys/sysv.h>
118#endif /* _CRAY */
119#include <sys/time.h>
120#include <sys/resource.h>
121#include <sys/utsname.h>
122#if defined(NTOHL_NEEDS_ARPA_INET_H) && defined(HAVE_ARPA_INET_H)
123#include <arpa/inet.h>
124#endif
125
126
127#include "libpbs.h"
128#include "pbs_ifl.h"
129#include "server_limits.h"
130#include "list_link.h"
131#include "attribute.h"
132#include "resource.h"
133#include "pbs_job.h"
134#include "mom_mach.h"
135#include "mom_func.h"
136#include "svrfunc.h"
137#include "pbs_error.h"
138#include "log.h"
139#include "net_connect.h"
140#include "rpp.h"
141#include "dis.h"
142#include "dis_init.h"
143#include "resmon.h"
144#include "pbs_nodes.h"
145#include "dis.h"
146#include "csv.h"
147#include "utils.h"
148
149#include "mcom.h"
150
151#ifdef NOPOSIXMEMLOCK
152#undef _POSIX_MEMLOCK
153#endif /* NOPOSIXMEMLOCK */
154
155#ifdef _POSIX_MEMLOCK
156#include <sys/mman.h>
157#endif /* _POSIX_MEMLOCK */
158
159#define CHECK_POLL_TIME 45
160#define DEFAULT_SERVER_STAT_UPDATES 45
161
162#define PMAX_PORT 32000
163#define MAX_RESEND_JOBS 512
164#define DUMMY_JOB_PTR 1
165
166/* Global Data Items */
167
168char *program_name;
169int MOMIsLocked = 0;
170int MOMIsPLocked = 0;
171int ServerStatUpdateInterval = DEFAULT_SERVER_STAT_UPDATES;
172int CheckPollTime = CHECK_POLL_TIME;
173int ForceServerUpdate = 0;
174
175int verbositylevel = 0;
176double cputfactor = 1.00;
177unsigned int default_server_port = 0;
178int exiting_tasks = 0;
179float ideal_load_val = -1.0;
180int internal_state = 0;
181/* by default, enforce these policies */
182int ignwalltime = 0;
183int ignmem = 0;
184int igncput = 0;
185int ignvmem = 0;
186int spoolasfinalname = 0;
187int killdelay = 0;
188/* end policies */
189int lockfds = -1;
190time_t loopcnt; /* used for MD5 calc */
191float max_load_val = -1.0;
192int hostname_specified = 0;
193char mom_host[PBS_MAXHOSTNAME + 1];
194char TMOMRejectConn[1024]; /* most recent rejected connection */
195char mom_short_name[PBS_MAXHOSTNAME + 1];
196int num_var_env;
197char *path_epilog;
198char *path_epilogp;
199char *path_epiloguser;
200char *path_epiloguserp;
201char *path_epilogpdel;
202char *path_jobs;
203char *path_prolog;
204char *path_prologp;
205char *path_prologuser;
206char *path_prologuserp;
207char *path_spool;
208char *path_undeliv;
209char *path_aux;
210char *path_server_name;
211char *path_home = PBS_SERVER_HOME;
212char *mom_home;
213extern char *msg_daemonname; /* for logs */
214extern char *msg_info_mom; /* Mom information message */
215extern int pbs_errno;
216gid_t pbsgroup;
217unsigned int pbs_mom_port = 0;
218unsigned int pbs_rm_port = 0;
219tlist_head mom_polljobs; /* jobs that must have resource limits polled */
220tlist_head svr_newjobs; /* jobs being sent to MOM */
221tlist_head svr_alljobs; /* all jobs under MOM's control */
222tlist_head mom_varattrs; /* variable attributes */
223int termin_child = 0; /* boolean - one or more children need to be terminated this iteration */
224time_t time_now = 0;
225time_t last_poll_time = 0;
226extern tlist_head svr_requests;
227
228extern struct var_table vtable; /* see start_exec.c */
229double wallfactor = 1.00;
230long log_file_max_size = 0;
231long log_file_roll_depth = 1;
232
233time_t last_log_check;
234char *nodefile_suffix = NULL; /* suffix to append to each host listed in job host file */
235char *submithost_suffix = NULL; /* suffix to append to submithost for interactive jobs */
236char *TNoSpoolDirList[TMAX_NSDCOUNT];
237char *TRemChkptDirList[TMAX_RCDCOUNT];
238
239job *JobsToResend[MAX_RESEND_JOBS];
240
241char *AllocParCmd = NULL; /* (alloc) */
242
243int src_login_batch = TRUE;
244int src_login_interactive = TRUE;
245
246/* externs */
247
248extern unsigned int pe_alarm_time;
249extern time_t pbs_tcp_timeout;
250extern long MaxConnectTimeout;
251
252char tmpdir_basename[MAXPATHLEN]; /* for $TMPDIR */
253
254char rcp_path[MAXPATHLEN];
255char rcp_args[MAXPATHLEN];
256char xauth_path[MAXPATHLEN];
257
258time_t LastServerUpdateTime = 0; /* NOTE: all servers updated together */
259
260time_t MOMStartTime = 0;
261int MOMPrologTimeoutCount;
262int MOMPrologFailureCount;
263
264char MOMConfigVersion[64];
265char MOMUNameMissing[64];
266
267int MOMConfigDownOnError = 0;
268int MOMConfigRestart = 0;
269int MOMConfigRReconfig = 0;
270long system_ncpus = 0;
271char *auto_ideal_load = NULL;
272char *auto_max_load = NULL;
273
274#define TMAX_JE 64
275
276pjobexec_t TMOMStartInfo[TMAX_JE];
277
278
279/* prototypes */
280
281extern void add_resc_def(char *, char *);
282extern void mom_server_all_diag(char **BPtr, int *BSpace);
283extern void mom_server_update_receive_time(int stream, const char *command_name);
284extern void mom_server_all_init(void);
285extern void mom_server_all_update_stat(void);
286extern int mark_for_resend(job *);
287extern int mom_server_all_check_connection(void);
288extern int mom_server_all_send_state(void);
289extern int mom_server_add(char *name);
290extern int mom_server_count;
291extern int post_epilogue(job *, int);
292extern int mom_checkpoint_init(void);
293extern void mom_checkpoint_check_periodic_timer(job *pjob);
294extern void mom_checkpoint_set_directory_path(char *str);
295
296void prepare_child_tasks_for_delete();
297
298#define PMOMTCPTIMEOUT 60 /* duration in seconds mom TCP requests will block */
299
300
301/* Local Data Items */
302
303static char *log_file = NULL;
304
305enum PMOMStateEnum
306 {
307 MOM_RUN_STATE_RUNNING,
308 MOM_RUN_STATE_EXIT,
309 MOM_RUN_STATE_KILLALL,
310 MOM_RUN_STATE_RESTART,
311 MOM_RUN_STATE_LAST
312 };
313
314static enum PMOMStateEnum mom_run_state;
315
316static int recover = JOB_RECOV_RUNNING;
317static int recover_set = FALSE;
318
319static int call_hup = 0;
320static int nconfig;
321static char *path_log;
322
323struct config_list
324 {
325 struct config c;
326
327 struct config_list *c_link;
328 };
329
330/* NOTE: must adjust RM_NPARM in resmom.h to be larger than number of parameters
331 specified below */
332
333static unsigned long setxauthpath(char *);
334static unsigned long setrcpcmd(char *);
335static unsigned long setpbsclient(char *);
336static unsigned long configversion(char *);
337static unsigned long cputmult(char *);
338static unsigned long setallocparcmd(char *);
339static unsigned long setidealload(char *);
340static unsigned long setignwalltime(char *);
341static unsigned long setignmem(char *);
342static unsigned long setigncput(char *);
343static unsigned long setignvmem(char *);
344static unsigned long setlogevent(char *);
345static unsigned long setloglevel(char *);
346static unsigned long setumask(char *);
347static unsigned long setpreexec(char *);
348static unsigned long setmaxload(char *);
349static unsigned long setenablemomrestart(char *);
350static unsigned long prologalarm(char *);
351static unsigned long restricted(char *);
352static unsigned long jobstartblocktime(char *);
353static unsigned long usecp(char *);
354static unsigned long wallmult(char *);
355static unsigned long setpbsserver(char *);
356static unsigned long setnodecheckscript(char *);
357static unsigned long setnodecheckinterval(char *);
358static unsigned long settimeout(char *);
359extern unsigned long mom_checkpoint_set_checkpoint_interval(char *);
360extern unsigned long mom_checkpoint_set_checkpoint_script(char *);
361extern unsigned long mom_checkpoint_set_restart_script(char *);
362extern unsigned long mom_checkpoint_set_checkpoint_run_exe_name(char *);
363static unsigned long setdownonerror(char *);
364static unsigned long setstatusupdatetime(char *);
365static unsigned long setcheckpolltime(char *);
366static unsigned long settmpdir(char *);
367static unsigned long setlogfilemaxsize(char *);
368static unsigned long setlogfilerolldepth(char *);
369static unsigned long setlogfilesuffix(char *);
370static unsigned long setlogdirectory(char *);
371static unsigned long setlogkeepdays(char *);
372static unsigned long setvarattr(char *);
373static unsigned long setautoidealload(char *);
374static unsigned long setautomaxload(char *);
375static unsigned long setnodefilesuffix(char *);
376static unsigned long setnospooldirlist(char *);
377static unsigned long setmomhost(char *);
378static unsigned long setrreconfig(char *);
379static unsigned long setsourceloginbatch(char *);
380static unsigned long setsourcelogininteractive(char *);
381static unsigned long setspoolasfinalname(char *);
382static unsigned long setremchkptdirlist(char *);
383static unsigned long setmaxconnecttimeout(char *);
384static unsigned long setkilldelay(char *);
385
386
387static struct specials
388 {
389 char *name;
390 u_long(*handler)();
391 } special[] = {
392 { "alloc_par_cmd", setallocparcmd },
393 { "auto_ideal_load", setautoidealload },
394 { "auto_max_load", setautomaxload },
395 { "xauthpath", setxauthpath },
396 { "rcpcmd", setrcpcmd },
397 { "rcp_cmd", setrcpcmd },
398 { "pbsclient", setpbsclient },
399 { "configversion", configversion },
400 { "cputmult", cputmult },
401 { "ideal_load", setidealload },
402 { "ignwalltime", setignwalltime },
403 { "ignmem", setignmem },
404 { "igncput", setigncput },
405 { "ignvmem", setignvmem },
406 { "logevent", setlogevent },
407 { "loglevel", setloglevel },
408 { "max_load", setmaxload },
409 { "enablemomrestart", setenablemomrestart },
410 { "prologalarm", prologalarm },
411 { "restricted", restricted },
412 { "jobstartblocktime", jobstartblocktime },
413 { "usecp", usecp },
414 { "wallmult", wallmult },
415 { "clienthost", setpbsserver }, /* deprecated - use pbsserver */
416 { "pbsserver", setpbsserver },
417 { "node_check_script", setnodecheckscript },
418 { "node_check_interval", setnodecheckinterval },
419 { "timeout", settimeout },
420 { "checkpoint_interval", mom_checkpoint_set_checkpoint_interval },
421 { "checkpoint_script", mom_checkpoint_set_checkpoint_script },
422 { "restart_script", mom_checkpoint_set_restart_script },
423 { "checkpoint_run_exe", mom_checkpoint_set_checkpoint_run_exe_name },
424 { "down_on_error", setdownonerror },
425 { "status_update_time", setstatusupdatetime },
426 { "check_poll_time", setcheckpolltime },
427 { "tmpdir", settmpdir },
428 { "log_directory", setlogdirectory },
429 { "log_file_max_size", setlogfilemaxsize },
430 { "log_file_roll_depth", setlogfilerolldepth },
431 { "log_file_suffix", setlogfilesuffix },
432 { "log_keep_days", setlogkeepdays },
433 { "varattr", setvarattr },
434 { "nodefile_suffix", setnodefilesuffix },
435 { "nospool_dir_list", setnospooldirlist },
436 { "mom_host", setmomhost },
437 { "remote_reconfig", setrreconfig },
438 { "job_output_file_umask", setumask },
439 { "preexec", setpreexec },
440 { "source_login_batch", setsourceloginbatch },
441 { "source_login_interactive", setsourcelogininteractive },
442 { "spool_as_final_name", setspoolasfinalname },
443 { "remote_checkpoint_dirs", setremchkptdirlist },
444 { "max_conn_timeout_micro_sec", setmaxconnecttimeout },
445 { "kill_delay", setkilldelay },
446 { NULL, NULL }
447 };
448
449
450static char *arch(struct rm_attribute *);
451static char *opsys(struct rm_attribute *);
452static char *requname(struct rm_attribute *);
453static char *validuser(struct rm_attribute *);
454static char *reqmsg(struct rm_attribute *);
455char *reqgres(struct rm_attribute *);
456static char *reqstate(struct rm_attribute *);
457static char *getjoblist(struct rm_attribute *);
458static char *reqvarattr(struct rm_attribute *);
459/* static char *nullproc(struct rm_attribute *); */
460
461
462struct config common_config[] =
463 {
464 { "arch", {arch} }, /* machine architecture */
465 { "opsys", {opsys} }, /* operating system */
466 { "uname", {requname} }, /* user name ??? */
467 { "validuser", {validuser} }, /* valid user ??? */
468 { "message", {reqmsg} }, /* message ??? */
469 { "gres", {reqgres} }, /* generic resource (licenses...) */
470 { "state", {reqstate} }, /* state of pbs_mom */
471 { "jobs", {getjoblist} }, /* job list this pbs_mom */
472 { "varattr", {reqvarattr} }, /* ??? */
473 { NULL, {NULL} }
474 };
475
476int LOGLEVEL = 0; /* valid values (0 - 10) */
477int LOGKEEPDAYS = 0; /* days each log file should be kept before deleting */
478int DEBUGMODE = 0;
479int DOBACKGROUND = 1;
480char DEFAULT_UMASK[1024];
481char PRE_EXEC[1024];
482long TJobStartBlockTime = 5; /* seconds to wait for job to launch before backgrounding */
483long TJobStartTimeout = 300; /* seconds to wait for job to launch before purging */
484
485
486char *ret_string;
487int ret_size;
488
489struct config *config_array = NULL;
490
491struct config_list *config_list = NULL;
492sigset_t allsigs;
493int rm_errno;
494unsigned int reqnum = 0; /* the packet number */
495
496int port_care = TRUE; /* secure connecting ports */
497uid_t uid = 0; /* uid we are running with */
498unsigned int alarm_time = 10; /* time before alarm */
499
500extern tree *okclients; /* accept connections from */
501char **maskclient = NULL; /* wildcard connections */
502int mask_num = 0;
503int mask_max = 0;
504u_long localaddr = 0;
505
506char extra_parm[] = "extra parameter(s)";
507char no_parm[] = "required parameter not found";
508char varattr_delimiter[] = ";";
509
510int cphosts_num = 0;
511
512struct cphosts *pcphosts = NULL;
513
514static int config_file_specified = 0;
515static char config_file[_POSIX_PATH_MAX] = "config";
516
517char PBSNodeMsgBuf[1024];
518char PBSNodeCheckPath[1024];
519int PBSNodeCheckInterval;
520int PBSNodeCheckProlog = 0;
521int PBSNodeCheckEpilog = 0;
522static char *MOMExePath = NULL;
523static time_t MOMExeTime = 0;
524
525
526/* sync w/#define JOB_SUBSTATE_XXX (in include/pbs_job.h)*/
527
528const char *PJobSubState[] =
529 {
530 "TRANSIN", /* Transit in, wait for commit */
531 "TRANSICM", /* Transit in, wait for commit */
532 "TRNOUT", /* transiting job outbound */
533 "TRNOUTCM", /* transiting outbound, rdy to commit */
534 "SUBSTATE04",
535 "SUBSTATE05",
536 "SUBSTATE06",
537 "SUBSTATE07",
538 "SUBSTATE08",
539 "SUBSTATE09",
540 "QUEUED", /* job queued and ready for selection */
541 "PRESTAGEIN", /* job queued, has files to stage in */
542 "SUBSTATE12",
543 "SYNCRES", /* job waiting on sync start ready */
544 "STAGEIN", /* job staging in files then wait */
545 "STAGEGO", /* job staging in files and then run */
546 "STAGECMP", /* job stage in complete */
547 "SUBSTATE17",
548 "SUBSTATE18",
549 "SUBSTATE19",
550 "HELD", /* job held - user or operator */
551 "SYNCHOLD", /* job held - waiting on sync regist */
552 "DEPNHOLD", /* job held - waiting on dependency */
553 "SUBSTATE23",
554 "SUBSTATE24",
555 "SUBSTATE25",
556 "SUBSTATE26",
557 "SUBSTATE27",
558 "SUBSTATE28",
559 "SUBSTATE29",
560 "WAITING", /* job waiting on execution time */
561 "SUBSTATE31",
562 "SUBSTATE32",
563 "SUBSTATE33",
564 "SUBSTATE34",
565 "SUBSTATE35",
566 "SUBSTATE36",
567 "STAGEFAIL", /* job held - file stage in failed */
568 "SUBSTATE38",
569 "SUBSTATE39",
570 "PRERUN", /* job sent to MOM to run */
571 "STARTING", /* final job start initiated */
572 "RUNNING", /* job running */
573 "SUSPEND", /* job suspended, CRAY only */
574 "SUBSTATE44",
575 "SUBSTATE45",
576 "SUBSTATE46",
577 "SUBSTATE47",
578 "SUBSTATE48",
579 "SUBSTATE49",
580 "EXITING", /* Start of job exiting processing */
581 "STAGEOUT", /* job staging out (other) files */
582 "STAGEDEL", /* job deleteing staged out files */
583 "EXITED", /* job exit processing completed */
584 "ABORT", /* job is being aborted by server */
585 "SUBSTATE55",
586 "SUBSTATE56",
587 "PREOBIT", /* preobit job status */
588 "OBIT", /* (MOM) job obit notice sent */
589 "COMPLETED",
590 "RERUN", /* job is rerun, recover output stage */
591 "RERUN1", /* job is rerun, stageout phase */
592 "RERUN2", /* job is rerun, delete files stage */
593 "RERUN3", /* job is rerun, mom delete job */
594 "RETSTD", /* job has checkpoint file, return stdout / stderr files to server
595 * spool dir so that job can be restarted
596 */
597 NULL
598 };
599
600
601/* sync w/#define IS_XXX */
602
603const char *PBSServerCmds[] =
604 {
605 "NULL",
606 "HELLO",
607 "CLUSTER_ADDRS",
608 "UPDATE",
609 "STATUS",
610 NULL
611 };
612
613
614/*
615** These routines are in the "dependent" code.
616*/
617
618extern void dep_initialize A_((void));
619extern void dep_cleanup A_((void));
620
621/* External Functions */
622
623extern void catch_child A_((int));
624extern void init_abort_jobs A_((int));
625extern void scan_for_exiting();
626extern void scan_for_terminated();
627extern int TMomCheckJobChild(pjobexec_t *, int, int *, int *);
628extern int TMomFinalizeJob3(pjobexec_t *, int, int, int *);
629extern void exec_bail(job *, int);
630extern void check_state(int);
631extern void DIS_tcp_funcs();
632
633
634/* Local public functions */
635
636static void stop_me A_((int));
637static void PBSAdjustLogLevel A_((int));
638int TMOMScanForStarting(void);
639
640
641/* Local private functions */
642
643void check_log A_((void));
644
645
646
647
648
649char *nullproc(
650
651 struct rm_attribute *attrib)
652
653 {
654 char *id = "nullproc";
655
656 log_err(-1,id,"should not be called");
657
658 return(NULL);
659 } /* END nullproc() */
660
661
662
663
664static char *arch(
665
666 struct rm_attribute *attrib) /* I */
667
668 {
669 char *id = "arch";
670
671 struct config *cp;
672
673 if (attrib != NULL)
674 {
675 log_err(-1, id, extra_parm);
676
677 rm_errno = RM_ERR_BADPARAM;
678
679 return(NULL);
680 }
681
682 if (config_array == NULL)
683 {
684 return(PBS_MACH);
685 }
686
687 /* locate arch string */
688
689 for (cp = config_array;cp->c_name != NULL;cp++)
690 {
691 if (cp->c_u.c_value == NULL)
692 continue;
693
694 if (strcmp(cp->c_name, "arch"))
695 continue;
696
697 return(cp->c_u.c_value);
698 } /* END for (cp) */
699
700 return(PBS_MACH);
701 } /* END arch() */
702
703
704
705
706static char *opsys(
707
708 struct rm_attribute *attrib) /* I */
709
710 {
711 char *id = "opsys";
712
713 struct config *cp;
714
715 if (attrib != NULL)
716 {
717 log_err(-1, id, extra_parm);
718
719 rm_errno = RM_ERR_BADPARAM;
720
721 return(NULL);
722 }
723
724 if (config_array == NULL)
725 {
726 return(PBS_MACH);
727 }
728
729 /* locate opsys string */
730
731 for (cp = config_array;cp->c_name != NULL;cp++)
732 {
733 if (cp->c_u.c_value == NULL)
734 continue;
735
736 if (strcmp(cp->c_name, "opsys"))
737 continue;
738
739 return(cp->c_u.c_value);
740 } /* END for (cp) */
741
742 return(PBS_MACH);
743 } /* END opsys() */
744
745
746
747
748
749char *
750getuname(void)
751
752 {
753
754 struct utsname n;
755 static char *name = NULL;
756
757 if (name == NULL)
758 {
759 if (uname(&n) == -1)
760 {
761 return(NULL);
762 }
763
764 sprintf(ret_string, "%s %s %s %s %s",
765
766 n.sysname,
767 n.nodename,
768 n.release,
769 n.version,
770 n.machine);
771
772 name = strdup(ret_string);
773 } /* END if (name == NULL) */
774
775 return(name);
776 } /* END getuname() */
777
778
779
780
781static char *reqmsg(
782
783 struct rm_attribute *attrib)
784
785 {
786 char *id = "reqmsg";
787
788 if (attrib != NULL)
789 {
790 log_err(-1, id, extra_parm);
791
792 rm_errno = RM_ERR_BADPARAM;
793
794 return(NULL);
795 }
796
797 return(PBSNodeMsgBuf);
798 } /* END reqmsg() */
799
800
801
802
803static char *getjoblist(
804
805 struct rm_attribute *attrib) /* I */
806
807 {
808 static char *list = NULL;
809 static int listlen = 0;
810 job *pjob;
811 int firstjob = 1;
812
813 if (list == NULL)
814 {
815 if ((list = calloc(BUFSIZ + 50, sizeof(char)))==NULL)
816 {
817 /* FAILURE - cannot alloc memory */
818
819 fprintf(stderr,"ERROR: could not calloc!\n");
820
821 /* since memory cannot be allocated, report no jobs */
822
823 return (" ");
824 }
825
826 listlen = BUFSIZ;
827 }
828
829 *list = '\0'; /* reset the list */
830
831 if ((pjob = (job *)GET_NEXT(svr_alljobs)) == NULL)
832 {
833 /* no jobs - return space character */
834
835 return(" ");
836 }
837
838 for (;pjob != NULL;pjob = (job *)GET_NEXT(pjob->ji_alljobs))
839 {
840 if (!firstjob)
841 strcat(list, " ");
842
843 strcat(list, pjob->ji_qs.ji_jobid);
844
845 if ((int)strlen(list) >= listlen)
846 {
847 char *tmpList;
848
849 listlen += BUFSIZ;
850
851 tmpList = realloc(list,listlen);
852
853 if (tmpList == NULL)
854 {
855 /* FAILURE - cannot alloc memory */
856
857 fprintf(stderr,"ERROR: could not realloc!\n");
858
859 /* since memory cannot be allocated, report no jobs */
860
861 return(" ");
862 }
863
864 list = tmpList;
865 }
866
867 firstjob = 0;
868 } /* END for (pjob) */
869
870 if (list[0] == '\0')
871 {
872 /* no jobs - return space character */
873
874 strcat(list, " ");
875 }
876
877 return(list);
878 } /* END getjoblist() */
879
880
881
882
883#define TMAX_VARBUF 65536
884
885static char *reqvarattr(
886
887 struct rm_attribute *attrib) /* I */
888
889 {
890 static char id[] = "reqvarattr";
891
892 static char *list = NULL, *child_spot;
893 static int listlen = 0;
894
895 struct varattr *pva;
896 int fd, len, child_len;
897 int first_line;
898 FILE *child;
899
900 char *ptr;
901 char *ptr2;
902
903 char tmpBuf[TMAX_VARBUF + 1];
904
905 if (list == NULL)
906 {
907 list = calloc(BUFSIZ + 1024, sizeof(char));
908
909 if (list == NULL)
910 {
911 /* FAILURE - cannot alloc memory */
912
913 log_err(errno,id,"cannot alloc memory");
914
915 return(" ");
916 }
917
918 listlen = BUFSIZ;
919 }
920
921 *list = '\0'; /* reset the list */
922
923 if ((pva = (struct varattr *)GET_NEXT(mom_varattrs)) == NULL)
924 {
925 return(" ");
926 }
927
928 for (;pva != NULL;pva = (struct varattr *)GET_NEXT(pva->va_link))
929 {
930 /* loop for each $varattr parameter */
931
932 if ((pva->va_lasttime == 0) || (time_now >= (pva->va_ttl + pva->va_lasttime)))
933 {
934 if ((pva->va_ttl == -1) && (pva->va_lasttime != 0))
935 {
936 if (pva->va_value[0] != '\0')
937 {
938 if (*list != '\0')
939 strcat(list, varattr_delimiter);
940
941 strcat(list, pva->va_value);
942 }
943
944 if ((int)strlen(list) >= listlen)
945 {
946 listlen += BUFSIZ;
947
948 list = realloc(list, listlen);
949
950 if (list == NULL)
951 {
952 log_err(errno,id,"cannot alloc memory");
953
954 return(" ");
955 }
956 }
957
958 continue; /* ttl of -1 is only run once */
959 }
960
961 /* TTL is satisfied, reload value */
962
963 pva->va_lasttime = time_now;
964
965 if (pva->va_value == NULL)
966 pva->va_value = calloc(TMAX_VARBUF, sizeof(char));
967
968 /* execute script and get a new value */
969
970 if ((child = popen(pva->va_cmd, "r")) == NULL)
971 {
972 sprintf(pva->va_value, "error: %d %s",
973 errno,
974 strerror(errno));
975 }
976 else
977 {
978 fd = fileno(child);
979
980 child_spot = tmpBuf;
981 child_len = 0;
982 child_spot[0] = '\0';
983
984retryread:
985
986 while ((len = read(fd, child_spot, TMAX_VARBUF - child_len)) > 0)
987 {
988 child_len += len;
989 child_spot += len;
990
991 if (child_len >= TMAX_VARBUF - 1)
992 break;
993 } /* END while ((len = read() > 0) */
994
995 if (len == -1)
996 {
997 /* FAILURE - cannot read var script output */
998
999 if (errno == EINTR)
1000 goto retryread;
1001
1002 log_err(errno, id, "pipe read");
1003
1004 sprintf(pva->va_value, "? %d",
1005 RM_ERR_SYSTEM);
1006
1007 pclose(child);
1008
1009 continue;
1010 }
1011
1012 /* SUCCESS */
1013
1014 pclose(child);
1015
1016 tmpBuf[child_len] = '\0';
1017
1018 /* Transfer returned data into var value field */
1019
1020 first_line = TRUE;
1021
1022 ptr = strtok(tmpBuf,"\n;");
1023
1024 ptr2 = pva->va_value;
1025
1026 ptr2[0] = '\0';
1027
1028 /*
1029 * OUTPUT FORMAT: Take what script gives us.
1030 * Script should output 1 or more lines of Name=value1+value2+...
1031 */
1032
1033 while (ptr != NULL)
1034 {
1035 if (!first_line)
1036 strcat(ptr2,varattr_delimiter);
1037
1038 strcat(ptr2,ptr);
1039
1040 first_line = FALSE;
1041
1042 ptr = strtok(NULL,"\n;");
1043 } /* END while (ptr != NULL) */
1044 } /* END else ((child = popen(pva->va_cmd,"r")) == NULL) */
1045 } /* END if ((pva->va_lasttime == 0) || ...) */
1046
1047 if (pva->va_value[0] != '\0')
1048 {
1049 if (*list != '\0')
1050 strcat(list, varattr_delimiter);
1051
1052 strcat(list, pva->va_value);
1053 }
1054
1055 if ((int)strlen(list) >= listlen)
1056 {
1057 listlen += BUFSIZ;
1058 list = realloc(list, listlen);
1059
1060 if (list == NULL)
1061 {
1062 log_err(errno,id,"cannot alloc memory");
1063
1064 return(" ");
1065 }
1066 }
1067 } /* END for (pva) */
1068
1069 if (list[0] == '\0')
1070 strcat(list, " ");
1071
1072 return(list);
1073 } /* END reqvarattr() */
1074
1075
1076
1077
1078
1079char *reqgres(
1080
1081 struct rm_attribute *attrib) /* I (ignored) */
1082
1083 {
1084 char *id = "reqgres";
1085
1086 struct config *cp;
1087
1088 static char GResBuf[1024];
1089 char tmpLine[1024];
1090
1091 int sindex;
1092
1093 if (attrib != NULL)
1094 {
1095 log_err(-1, id, extra_parm);
1096
1097 rm_errno = RM_ERR_BADPARAM;
1098
1099 return(NULL);
1100 }
1101
1102 /* build gres string */
1103
1104 /* FORMAT: <GRES>:<VALUE>[+<GRES>:<VALUE>]... */
1105
1106 GResBuf[0] = '\0';
1107
1108 if (config_array == NULL)
1109 {
1110 return(GResBuf);
1111 }
1112
1113 for (cp = config_array;cp->c_name != NULL;cp++)
1114 {
1115 if (cp->c_u.c_value == NULL)
1116 continue;
1117
1118 /* verify parameter is not special */
1119
1120 for (sindex = 0;sindex < RM_NPARM;sindex++)
1121 {
1122 if (special[sindex].name == NULL)
1123 break;
1124
1125 if (!strcmp(special[sindex].name, cp->c_name))
1126 break;
1127 } /* END for (sindex) */
1128
1129 if ((sindex < RM_NPARM) &&
1130 (special[sindex].name != NULL) &&
1131 (!strcmp(special[sindex].name, cp->c_name)))
1132 {
1133 /* specified parameter is special parameter */
1134
1135 continue;
1136 }
1137
1138 /* verify parameter is not common */
1139
1140 for (sindex = 0;sindex < RM_NPARM;sindex++)
1141 {
1142 if (common_config[sindex].c_name == NULL)
1143 break;
1144
1145 if (!strcmp(common_config[sindex].c_name, cp->c_name))
1146 break;
1147 } /* END for (sindex) */
1148
1149 if ((sindex < RM_NPARM) &&
1150 (common_config[sindex].c_name != NULL) &&
1151 !strcmp(common_config[sindex].c_name, cp->c_name) &&
1152 strcmp(common_config[sindex].c_name, "gres"))
1153 {
1154 /* specified parameter is common parameter */
1155
1156 continue;
1157 }
1158
1159 if (!strncmp(cp->c_name, "size", strlen("size")))
1160 continue;
1161
1162 if (GResBuf[0] != '\0')
1163 strncat(GResBuf, "+", 1024);
1164
1165 snprintf(tmpLine, 1024, "%s:%s",
1166 cp->c_name,
1167 cp->c_u.c_value);
1168
1169 strncat(GResBuf, tmpLine, (sizeof(GResBuf) - strlen(GResBuf) - 1));
1170 } /* END for (cp) */
1171
1172 return(GResBuf);
1173 } /* END reqgres() */
1174
1175
1176
1177
1178static char *reqstate(
1179
1180 struct rm_attribute *attrib) /* I (ignored) */
1181
1182 {
1183 static char state[1024];
1184
1185 if ((internal_state & INUSE_DOWN) && (MOMConfigDownOnError != 0))
1186 strcpy(state, "down");
1187 else if (internal_state & INUSE_BUSY)
1188 strcpy(state, "busy");
1189 else
1190 strcpy(state, "free");
1191
1192 return(state);
1193 } /* END reqstate() */
1194
1195
1196
1197
1198static char *requname(
1199
1200 struct rm_attribute *attrib)
1201
1202 {
1203 char *id = "uname";
1204 char *cp;
1205
1206 if (attrib != NULL)
1207 {
1208 log_err(-1, id, extra_parm);
1209
1210 rm_errno = RM_ERR_BADPARAM;
1211
1212 return(NULL);
1213 }
1214
1215 cp = getuname();
1216
1217 return(cp);
1218 } /* END requname() */
1219
1220
1221
1222
1223
1224static char *validuser(
1225
1226 struct rm_attribute *attrib)
1227
1228 {
1229 char *id = "valid_user";
1230
1231 struct passwd *p;
1232
1233 if ((attrib == NULL) || (attrib->a_value == NULL))
1234 {
1235 log_err(-1, id, no_parm);
1236 rm_errno = RM_ERR_NOPARAM;
1237
1238 return(NULL);
1239 }
1240
1241 p = getpwnam(attrib->a_value);
1242
1243 if (p != NULL)
1244 {
1245 return("yes");
1246 }
1247
1248 return("no");
1249 } /* END validuser() */
1250
1251
1252
1253
1254
1255char *loadave(
1256
1257 struct rm_attribute *attrib)
1258
1259 {
1260 char *id = "loadave";
1261 static char ret_string[20];
1262 double la;
1263
1264 if (attrib)
1265 {
1266 log_err(-1, id, extra_parm);
1267
1268 rm_errno = RM_ERR_BADPARAM;
1269
1270 return(NULL);
1271 }
1272
1273 if (get_la(&la) != 0)
1274 {
1275 rm_errno = RM_ERR_SYSTEM;
1276
1277 return(NULL);
1278 }
1279
1280 sprintf(ret_string, "%.2f",
1281
1282 la);
1283
1284 return(ret_string);
1285 } /* END loadave() */
1286
1287
1288
1289
1290
1291/*
1292** Search the array of resources read from the config files.
1293*/
1294
1295struct config *rm_search(
1296
1297 struct config *where, /* I */
1298 char *what) /* I */
1299
1300 {
1301
1302 struct config *cp;
1303
1304 if (where == NULL || what == NULL)
1305 {
1306 return NULL;
1307 }
1308
1309 for (cp = where;cp->c_name != NULL;cp++)
1310 {
1311 if (strcmp(cp->c_name, what) == 0)
1312 {
1313 return(cp);
1314 }
1315 } /* END for (cp) */
1316
1317 return(NULL);
1318 } /* END rm_search() */
1319
1320
1321
1322
1323
1324/*
1325** Search the various resource lists.
1326*/
1327
1328char *dependent(
1329
1330 char *res, /* I */
1331 struct rm_attribute *attr) /* I */
1332
1333 {
1334
1335 struct config *ap;
1336
1337 extern struct config standard_config[];
1338
1339 extern struct config dependent_config[];
1340
1341 ap = rm_search(common_config, res);
1342
1343 if (ap != NULL)
1344 {
1345 return(ap->c_u.c_func(attr));
1346 }
1347
1348 ap = rm_search(standard_config, res);
1349
1350 if (ap != NULL)
1351 {
1352 return(ap->c_u.c_func(attr));
1353 }
1354
1355 ap = rm_search(dependent_config, res);
1356
1357 if (ap != NULL)
1358 {
1359 return(ap->c_u.c_func(attr));
1360 }
1361
1362 rm_errno = RM_ERR_UNKNOWN;
1363
1364 return(NULL);
1365 } /* END dependent() */
1366
1367
1368
1369
1370
1371
1372void
1373DIS_rpp_reset(void)
1374
1375 {
1376 if (dis_getc != rpp_getc)
1377 {
1378 dis_getc = rpp_getc;
1379 dis_puts = (int (*) A_((int, const char *, size_t)))rpp_write;
1380 dis_gets = (int (*) A_((int, char *, size_t)))rpp_read;
1381 disr_skip = (int (*) A_((int, size_t)))rpp_skip;
1382
1383 disr_commit = rpp_rcommit;
1384 disw_commit = rpp_wcommit;
1385 }
1386
1387 return;
1388 } /* END DIS_rpp_reset() */
1389
1390
1391
1392
1393
1394/*
1395** Initialize standard resource array
1396*/
1397
1398void
1399initialize(void)
1400
1401 {
1402 char *id = "initialize";
1403
1404 log_record(PBSEVENT_SYSTEM, 0, id, "independent");
1405
1406 dep_initialize();
1407
1408 return;
1409 }
1410
1411
1412
1413
1414void
1415cleanup(void)
1416
1417 {
1418 dep_cleanup();
1419
1420 return;
1421 }
1422
1423
1424
1425
1426/*
1427** Clean up after a signal.
1428*/
1429
1430void die(
1431
1432 int sig)
1433
1434 {
1435 char *id = "die";
1436
1437 if (sig > 0)
1438 {
1439 sprintf(log_buffer, "caught signal %d",
1440 sig);
1441
1442 log_record(PBSEVENT_SYSTEM, 0, id, log_buffer);
1443 }
1444 else
1445 {
1446 log_record(PBSEVENT_SYSTEM, 0, id, "abnormal termination");
1447 }
1448
1449 cleanup();
1450
1451 log_close(1);
1452
1453 exit(1);
1454 } /* END die() */
1455
1456
1457
1458
1459/*
1460** Check for fatal memory allocation error.
1461*/
1462
1463void memcheck(
1464
1465 char *buf)
1466
1467 {
1468 if (buf != NULL)
1469 {
1470 return;
1471 }
1472
1473 log_err(-1, "memcheck", "memory allocation failed");
1474
1475 die(0);
1476
1477 return;
1478 } /* END memcheck() */
1479
1480
1481
1482
1483
1484/*
1485** Check the ret_string buffer to make sure that there is
1486** enought room starting at *spot to hold len characters more.
1487** If not, realloc the buffer and make *spot point to
1488** the corresponding place that it used to point to in
1489** the old buffer.
1490*/
1491
1492void checkret(
1493
1494 char **spot,
1495 int len)
1496
1497 {
1498 char *id = "checkret";
1499 char *hold;
1500
1501 if ((*spot - ret_string) < (ret_size - len))
1502 {
1503 return;
1504 }
1505
1506 ret_size += len * 2; /* new buf size */
1507
1508 sprintf(log_buffer, "size increased to %d",
1509 ret_size);
1510
1511 log_record(PBSEVENT_SYSTEM, 0, id, log_buffer);
1512
1513 hold = realloc(ret_string, ret_size); /* new buf */
1514
1515 memcheck(hold);
1516
1517 *spot = *spot - ret_string + hold; /* new spot in buf */
1518
1519 ret_string = hold;
1520
1521 return;
1522 } /* END checkret() */
1523
1524
1525
1526
1527
1528char *skipwhite(
1529
1530 char *str)
1531
1532 {
1533 for (;*str;str++)
1534 {
1535 if (!isspace(*str))
1536 break;
1537 }
1538
1539 return(str);
1540 }
1541
1542
1543
1544
1545
1546char *tokcpy(
1547
1548 char *str,
1549 char *tok)
1550
1551 {
1552 for (;*str;str++, tok++)
1553 {
1554 if (!isalnum(*str) && *str != ':' && *str != '_')
1555 break;
1556
1557 *tok = *str;
1558 } /* END tokcpy() */
1559
1560 *tok = '\0';
1561
1562 return(str);
1563 } /* END tokcpy() */
1564
1565
1566
1567
1568void rmnl(
1569
1570 char *str)
1571
1572 {
1573 int i;
1574
1575 i = strlen(str);
1576
1577 while (--i)
1578 {
1579 if ((*(str + i) != '\n') && !isspace((int)*(str + i)))
1580 break;
1581
1582 *(str + i) = '\0';
1583 }
1584
1585 return;
1586 }
1587
1588
1589
1590
1591
1592u_long addclient(
1593
1594 char *name) /* I */
1595
1596 {
1597 static char id[] = "addclient";
1598
1599 struct hostent *host;
1600
1601 struct in_addr saddr;
1602 u_long ipaddr;
1603
1604 /* FIXME: must be able to retry failed lookups later */
1605
1606 if ((host = gethostbyname(name)) == NULL)
1607 {
1608 sprintf(log_buffer, "host %s not found",
1609 name);
1610
1611 log_err(-1, id, log_buffer);
1612
1613 return(0);
1614 }
1615
1616 memcpy(&saddr, host->h_addr, host->h_length);
1617
1618 ipaddr = ntohl(saddr.s_addr);
1619
1620 tinsert(ipaddr, NULL, &okclients);
1621
1622 return(ipaddr);
1623 } /* END addclient() */
1624
1625
1626
1627
1628
1629static u_long setpbsclient(
1630
1631 char *value) /* I */
1632
1633 {
1634 u_long rc;
1635
1636 if ((value == NULL) || (value[0] == '\0'))
1637 {
1638 /* FAILURE */
1639
1640 return(1);
1641 }
1642
1643 rc = addclient(value);
1644
1645 if (rc != 0)
1646 {
1647 /* FAILURE */
1648
1649 return(1);
1650 }
1651
1652 return(0);
1653 } /* END setpbsclient() */
1654
1655
1656
1657
1658/* FIXME: we need to handle a non-default port number */
1659
1660static u_long setpbsserver(
1661
1662 char *value) /* I */
1663
1664 {
1665 static char id[] = "setpbsserver";
1666
1667 if ((value == NULL) || (*value == '\0'))
1668 {
1669 return(1); /* FAILURE - nothing specified */
1670 }
1671
1672 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value);
1673
1674
1675 return(mom_server_add(value));
1676 } /* END setpbsserver() */
1677
1678
1679
1680
1681static u_long settmpdir(
1682
1683 char *Value)
1684
1685 {
1686 static char id[] = "settmpdir";
1687
1688 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1689
1690 if (*Value != '/')
1691 {
1692 log_err(-1, id, "tmpdir must be a full path");
1693
1694 return(0);
1695 }
1696
1697 strncpy(tmpdir_basename, Value, sizeof(tmpdir_basename));
1698
1699 return(1);
1700 }
1701
1702static u_long setxauthpath(
1703
1704 char *Value)
1705
1706 {
1707 static char id[] = "setxauthpath";
1708
1709 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1710
1711 if (*Value != '/')
1712 {
1713 log_err(-1, id, "xauthpath must be a full path");
1714
1715 return(0);
1716 }
1717
1718 strncpy(xauth_path, Value, sizeof(xauth_path));
1719
1720 return(1);
1721 }
1722
1723
1724
1725
1726
1727static u_long setrcpcmd(
1728
1729 char *Value) /* I */
1730
1731 {
1732 static char id[] = "rcpcmd";
1733 static char *ptr;
1734
1735 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1736
1737 if (*Value != '/')
1738 {
1739 log_err(-1, id, "rcpcmd must be a full path");
1740
1741 /* FAILURE */
1742
1743 return(0);
1744 }
1745
1746 strncpy(rcp_path, Value, sizeof(rcp_path));
1747
1748 strcpy(rcp_args, "");
1749
1750 if ((ptr = strchr(rcp_path, ' ')) != NULL)
1751 {
1752 *ptr = '\0';
1753
1754 if (*(ptr + 1) != '\0')
1755 {
1756 strncpy(rcp_args, ptr + 1, sizeof(rcp_args));
1757 }
1758 }
1759
1760 /* SUCCESS */
1761
1762 return(1);
1763 } /* END setrcpcmd() */
1764
1765
1766
1767
1768
1769static u_long setlogevent(
1770
1771 char *value)
1772
1773 {
1774 char *bad;
1775
1776 *log_event_mask = strtol(value, &bad, 0);
1777
1778 if ((*bad == '\0') || isspace((int)*bad))
1779 {
1780 return(1);
1781 }
1782
1783 return(0);
1784 } /* END setlogevent() */
1785
1786
1787
1788
1789
1790/* NOTE: maskclient is global */
1791
1792static u_long restricted(
1793
1794 char *name)
1795
1796 {
1797 static char id[] = "restricted";
1798
1799 char **tmpMaskClient;
1800
1801 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, name);
1802
1803 if (mask_max == 0)
1804 {
1805 if ((maskclient = (char **)calloc(4, sizeof(char *))) == NULL)
1806 {
1807 /* FAILURE - cannot alloc memory */
1808
1809 log_err(errno,id,"cannot alloc memory");
1810
1811 return(-1);
1812 }
1813
1814 mask_max = 4;
1815 }
1816
1817 maskclient[mask_num] = strdup(name);
1818
1819 if (maskclient[mask_num] == NULL)
1820 {
1821 /* FAILURE - cannot alloc memory */
1822
1823 log_err(errno,id,"cannot alloc memory");
1824
1825 return(-1);
1826 }
1827
1828 mask_num++;
1829
1830 if (mask_num == mask_max)
1831 {
1832 mask_max *= 2;
1833
1834 tmpMaskClient = (char **)realloc(
1835 maskclient,
1836 mask_max * sizeof(char *));
1837
1838 if (tmpMaskClient == NULL)
1839 {
1840 /* FAILURE - cannot alloc memory */
1841
1842 log_err(errno,id,"cannot alloc memory");
1843
1844 return(-1);
1845 }
1846
1847 maskclient = tmpMaskClient;
1848 }
1849
1850 /* SUCCESS */
1851
1852 return(1);
1853 } /* END restricted() */
1854
1855
1856
1857
1858
1859static u_long configversion(
1860
1861 char *Value) /* I */
1862
1863 {
1864 static char id[] = "configversion";
1865
1866 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1867
1868 if (Value == NULL)
1869 {
1870 /* FAILURE */
1871
1872 return(0);
1873 }
1874
1875 strncpy(MOMConfigVersion, Value, sizeof(MOMConfigVersion));
1876
1877 /* SUCCESS */
1878
1879 return(1);
1880 } /* END configversion() */
1881
1882
1883
1884
1885
1886static u_long setdownonerror(
1887
1888 char *Value) /* I */
1889
1890 {
1891 static char id[] = "setdownonerror";
1892 int enable = -1;
1893
1894 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1895
1896 if (Value == NULL)
1897 {
1898 /* FAILURE */
1899
1900 return(0);
1901 }
1902
1903 /* accept various forms of "true", "yes", and "1" */
1904 switch (Value[0])
1905 {
1906
1907 case 't':
1908
1909 case 'T':
1910
1911 case 'y':
1912
1913 case 'Y':
1914
1915 case '1':
1916
1917 enable = 1;
1918
1919 break;
1920
1921 case 'f':
1922
1923 case 'F':
1924
1925 case 'n':
1926
1927 case 'N':
1928
1929 case '0':
1930
1931 enable = 0;
1932
1933 break;
1934
1935 }
1936
1937 if (enable != -1)
1938 {
1939 MOMConfigDownOnError = enable;
1940 }
1941
1942 return(1);
1943 } /* END setdownonerror() */
1944
1945
1946static u_long setenablemomrestart(
1947
1948 char *Value) /* I */
1949
1950 {
1951 static char id[] = "setenablemomrestart";
1952 int enable = -1;
1953
1954 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
1955
1956 if (Value == NULL)
1957 {
1958 /* FAILURE */
1959
1960 return(0);
1961 }
1962
1963 /* accept various forms of "true", "yes", and "1" */
1964 switch (Value[0])
1965 {
1966
1967 case 't':
1968
1969 case 'T':
1970
1971 case 'y':
1972
1973 case 'Y':
1974
1975 case '1':
1976
1977 enable = 1;
1978
1979 break;
1980
1981 case 'f':
1982
1983 case 'F':
1984
1985 case 'n':
1986
1987 case 'N':
1988
1989 case '0':
1990
1991 enable = 0;
1992
1993 break;
1994
1995 }
1996
1997 if (enable != -1)
1998 {
1999 MOMConfigRestart = enable;
2000 }
2001
2002 return(1);
2003 } /* END setenablemomrestart() */
2004
2005
2006
2007
2008static u_long cputmult(
2009
2010 char *value) /* I */
2011
2012 {
2013 static char id[] = "cputmult";
2014
2015 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value);
2016
2017 if ((cputfactor = atof(value)) == 0.0)
2018 {
2019 return(0); /* error */
2020 }
2021
2022 return(1);
2023 } /* END cputmult() */
2024
2025
2026
2027
2028
2029static u_long wallmult(
2030
2031 char *value)
2032
2033 {
2034 static char id[] = "wallmult";
2035
2036 double tmpD;
2037
2038 if (value == NULL)
2039 {
2040 /* FAILURE */
2041
2042 return(0);
2043 }
2044
2045 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, value);
2046
2047 tmpD = atof(value);
2048
2049 if ((tmpD == 0.0) && (value[0] != '\0'))
2050 {
2051 /* FAILURE */
2052
2053 return(0);
2054 }
2055
2056 /* SUCCESS */
2057
2058 wallfactor = tmpD;
2059
2060 return(1);
2061 } /* END wallmult() */
2062
2063
2064
2065
2066static u_long usecp(
2067
2068 char *value) /* I */
2069
2070 {
2071 char *pnxt;
2072 static int cphosts_max = 0;
2073
2074 struct cphosts *newp = NULL;
2075
2076 static char *id = "usecp";
2077
2078 /* FORMAT: <HOST>:<FROM> <TO> */
2079
2080 /*
2081 * HvB and Willem added this for logging purpose
2082 */
2083
2084 log_record(
2085 PBSEVENT_SYSTEM,
2086 PBS_EVENTCLASS_SERVER,
2087 id,
2088 value);
2089
2090 if (cphosts_max == 0)
2091 {
2092 pcphosts = malloc(2 * sizeof(struct cphosts));
2093
2094 if (pcphosts == NULL)
2095 {
2096 sprintf(log_buffer, "%s: out of memory while allocating pcphosts",
2097 id);
2098
2099 log_err(-1, id, log_buffer);
2100
2101 return(0);
2102 }
2103
2104 cphosts_max = 2;
2105 }
2106 else if (cphosts_max == cphosts_num)
2107 {
2108 newp = realloc(
2109 pcphosts,
2110 (cphosts_max + 2) * sizeof(struct cphosts));
2111
2112 if (newp == NULL)
2113 {
2114 /* FAILURE */
2115
2116 sprintf(log_buffer,"%s: out of memory while reallocating pcphosts",
2117 id);
2118
2119 log_err(-1,id,log_buffer);
2120
2121 return(0);
2122 }
2123
2124 pcphosts = newp;
2125
2126 cphosts_max += 2;
2127 }
2128
2129 pnxt = strchr(value, (int)':');
2130
2131 if (pnxt == NULL)
2132 {
2133 /* request failed */
2134
2135 sprintf(log_buffer, "invalid host specification: %s",
2136 value);
2137
2138 log_err(-1, id, log_buffer);
2139
2140 return(0);
2141 }
2142
2143 *pnxt++ = '\0';
2144
2145 pcphosts[cphosts_num].cph_hosts = strdup(value);
2146
2147 if (pcphosts[cphosts_num].cph_hosts == NULL)
2148 {
2149 /* FAILURE */
2150
2151 sprintf(log_buffer, "%s: out of memory in strdup(cph_hosts)",
2152 id);
2153
2154 log_err(-1, id, log_buffer);
2155
2156 return(0);
2157 }
2158
2159 value = pnxt; /* now ptr to path */
2160
2161 while (!isspace(*pnxt))
2162 {
2163 if (*pnxt == '\0')
2164 {
2165 sprintf(log_buffer, "invalid '%s' specification %s: "
2166 "missing destination path",
2167 id,
2168 value);
2169
2170 log_err(-1, id, log_buffer);
2171
2172 free(pcphosts[cphosts_num].cph_hosts);
2173
2174 return(0);
2175 }
2176
2177 pnxt++;
2178 }
2179
2180 *pnxt++ = '\0';
2181
2182 pcphosts[cphosts_num].cph_from = strdup(value);
2183
2184 if (pcphosts[cphosts_num].cph_from == NULL)
2185 {
2186 sprintf(log_buffer, "%s: out of memory in strdup(cph_from)",
2187 id);
2188
2189 log_err(-1, id, log_buffer);
2190
2191 free(pcphosts[cphosts_num].cph_hosts);
2192
2193 return(0);
2194 }
2195
2196 pcphosts[cphosts_num].cph_to = strdup(skipwhite(pnxt));
2197
2198 if (pcphosts[cphosts_num].cph_to == NULL)
2199 {
2200 sprintf(log_buffer, "%s: out of memory in strdup(cph_to)",
2201 id);
2202
2203 log_err(-1, id, log_buffer);
2204
2205 free(pcphosts[cphosts_num].cph_hosts);
2206 free(pcphosts[cphosts_num].cph_from);
2207
2208 return(0);
2209 }
2210
2211 cphosts_num++;
2212
2213 return(1);
2214 } /* END usecp() */
2215
2216
2217
2218
2219static unsigned long prologalarm(
2220
2221 char *value) /* I */
2222
2223 {
2224 int i;
2225
2226 log_record(
2227 PBSEVENT_SYSTEM,
2228 PBS_EVENTCLASS_SERVER,
2229 "prologalarm",
2230 value);
2231
2232 i = (int)atoi(value);
2233
2234 if (i <= 0)
2235 {
2236 return(0); /* error */
2237 }
2238
2239 pe_alarm_time = (unsigned int)i;
2240
2241 return(1);
2242 } /* END prologalarm() */
2243
2244
2245
2246
2247
2248static unsigned long setloglevel(
2249
2250 char *value) /* I */
2251
2252 {
2253 int i;
2254
2255 log_record(
2256 PBSEVENT_SYSTEM,
2257 PBS_EVENTCLASS_SERVER,
2258 "setloglevel",
2259 value);
2260
2261 i = (int)atoi(value);
2262
2263 if (i < 0)
2264 {
2265 return(0); /* error */
2266 }
2267
2268 LOGLEVEL = (unsigned int)i;
2269
2270 return(1);
2271 } /* END setloglevel() */
2272
2273
2274
2275
2276
2277static unsigned long setumask(
2278
2279 char *value) /* I */
2280
2281 {
2282 log_record(
2283 PBSEVENT_SYSTEM,
2284 PBS_EVENTCLASS_SERVER,
2285 "setumask",
2286 value);
2287
2288 strncpy(DEFAULT_UMASK, value, sizeof(DEFAULT_UMASK));
2289
2290 return(1);
2291 } /* END setumask() */
2292
2293
2294
2295
2296static unsigned long setpreexec(
2297
2298 char *value) /* I */
2299
2300 {
2301#if SHELL_USE_ARGV == 0
2302 static char *id = "setpreexec";
2303#endif
2304 log_record(
2305 PBSEVENT_SYSTEM,
2306 PBS_EVENTCLASS_SERVER,
2307 "setpreexec",
2308 value);
2309
2310 strncpy(PRE_EXEC, value, sizeof(PRE_EXEC));
2311
2312#if SHELL_USE_ARGV == 0
2313 log_err(0, id, "pbs_mom not configured with enable-shell-user-argv option");
2314#endif
2315
2316 return(1);
2317 } /* END setpreexec() */
2318
2319
2320static unsigned long setsourceloginbatch(
2321
2322 char *value) /* I */
2323
2324 {
2325
2326 log_record(
2327 PBSEVENT_SYSTEM,
2328 PBS_EVENTCLASS_SERVER,
2329 "setsourceloginbatch",
2330 value);
2331
2332 if (value[0] != '\0')
2333 {
2334 /* accept various forms of "true", "yes", and "1" */
2335 switch (value[0])
2336 {
2337
2338 case 't':
2339
2340 case 'T':
2341
2342 case 'y':
2343
2344 case 'Y':
2345
2346 case '1':
2347
2348 src_login_batch = TRUE;
2349
2350 break;
2351
2352 case 'f':
2353
2354 case 'F':
2355
2356 case 'n':
2357
2358 case 'N':
2359
2360 case '0':
2361
2362 src_login_batch = FALSE;
2363
2364 break;
2365
2366 default:
2367 sprintf(log_buffer, "Unknown value of %s", value);
2368
2369 log_record(
2370 PBSEVENT_SYSTEM,
2371 PBS_EVENTCLASS_SERVER,
2372 "setsourceloginbatch",
2373 log_buffer);
2374 break;
2375
2376 }
2377 }
2378
2379 return(1);
2380 } /* END setsourceloginbatch() */
2381
2382
2383static unsigned long setsourcelogininteractive(
2384
2385 char *value) /* I */
2386
2387 {
2388
2389 log_record(
2390 PBSEVENT_SYSTEM,
2391 PBS_EVENTCLASS_SERVER,
2392 "setsourcelogininteractive",
2393 value);
2394
2395 if (value[0] != '\0')
2396 {
2397 /* accept various forms of "true", "yes", and "1" */
2398 switch (value[0])
2399 {
2400
2401 case 't':
2402
2403 case 'T':
2404
2405 case 'y':
2406
2407 case 'Y':
2408
2409 case '1':
2410
2411 src_login_interactive = TRUE;
2412
2413 break;
2414
2415 case 'f':
2416
2417 case 'F':
2418
2419 case 'n':
2420
2421 case 'N':
2422
2423 case '0':
2424
2425 src_login_interactive = FALSE;
2426
2427 break;
2428
2429 default:
2430 sprintf(log_buffer, "Unknown value of %s", value);
2431
2432 log_record(
2433 PBSEVENT_SYSTEM,
2434 PBS_EVENTCLASS_SERVER,
2435 "setsourcelogininteractive",
2436 log_buffer);
2437 break;
2438
2439 }
2440 }
2441
2442 return(1);
2443 } /* END setsourcelogininteractive() */
2444
2445
2446static unsigned long jobstartblocktime(
2447
2448 char *value) /* I */
2449
2450 {
2451 int i;
2452
2453 log_record(
2454 PBSEVENT_SYSTEM,
2455 PBS_EVENTCLASS_SERVER,
2456 "startblocktime",
2457 value);
2458
2459 i = (int)strtol(value, NULL, 10);
2460
2461 if ((i < 0) || ((i == 0) && (value[0] != '0')))
2462 {
2463 return(0); /* error */
2464 }
2465
2466 TJobStartBlockTime = i;
2467
2468 return(1);
2469 } /* END jobstartblocktime() */
2470
2471
2472
2473
2474
2475static unsigned long setstatusupdatetime(
2476
2477 char *value) /* I */
2478
2479 {
2480 int i;
2481
2482 log_record(
2483 PBSEVENT_SYSTEM,
2484 PBS_EVENTCLASS_SERVER,
2485 "setstateuspdatetime",
2486 value);
2487
2488 i = (int)strtol(value, NULL, 10);
2489
2490 if (i < 1)
2491 {
2492 return(0); /* error */
2493 }
2494
2495 ServerStatUpdateInterval = (unsigned int)i;
2496
2497 return(1);
2498 } /* END setstatusupdatetime() */
2499
2500
2501
2502
2503
2504static unsigned long setcheckpolltime(
2505
2506 char *value) /* I */
2507
2508 {
2509 int i;
2510
2511 log_record(
2512 PBSEVENT_SYSTEM,
2513 PBS_EVENTCLASS_SERVER,
2514 "setcheckpolltime",
2515 value);
2516
2517 i = (int)strtol(value, NULL, 10);
2518
2519 if (i < 1)
2520 {
2521 return(0); /* error */
2522 }
2523
2524 CheckPollTime = (unsigned int)i;
2525
2526 return(1);
2527 } /* END setcheckpolltime() */
2528
2529
2530
2531
2532/*
2533** Add static resource or shell escape line from config file.
2534** This is a support routine for read_config().
2535*/
2536
2537static void add_static(
2538
2539 char *str, /* I */
2540 char *file, /* I */
2541 int linenum) /* I */
2542
2543 {
2544 int i;
2545 char name[50];
2546
2547 struct config_list *cp;
2548
2549 str = tokcpy(str, name); /* resource name */
2550 str = skipwhite(str); /* resource value */
2551
2552 /* FORMAT: <ATTR> [!]<VALUE> */
2553
2554 if (*str == '!') /* shell escape command */
2555 {
2556 /* remove trailing newline */
2557
2558 rmnl(str);
2559 }
2560 else
2561 {
2562 /* get the value */
2563 i = strlen(str);
2564
2565 while (--i)
2566 {
2567 /* strip trailing blanks */
2568
2569 if (!isspace((int)*(str + i)))
2570 break;
2571
2572 *(str + i) = '\0';
2573 }
2574 }
2575
2576 cp = (struct config_list *)malloc(sizeof(struct config_list));
2577
2578 memcheck((char *)cp);
2579
2580 cp->c_link = config_list;
2581 cp->c.c_name = strdup(name);
2582
2583 memcheck(cp->c.c_name);
2584
2585 cp->c.c_u.c_value = strdup(str);
2586
2587 memcheck(cp->c.c_u.c_value);
2588
2589 sprintf(log_buffer, "%s[%d] add name %s value %s",
2590 file,
2591 linenum,
2592 name,
2593 str);
2594
2595 log_record(
2596 PBSEVENT_DEBUG,
2597 0,
2598 "add_static",
2599 log_buffer);
2600
2601 config_list = cp;
2602
2603 return;
2604 } /* END add_static() */
2605
2606
2607
2608
2609
2610static unsigned long setidealload(
2611
2612 char *value)
2613
2614 {
2615 char newstr[50] = "ideal_load ";
2616 float val;
2617
2618 val = atof(value);
2619
2620 log_record(
2621 PBSEVENT_SYSTEM,
2622 PBS_EVENTCLASS_SERVER,
2623 "ideal_load",
2624 value);
2625
2626 if (val < 0.0)
2627 {
2628 return(0); /* error */
2629 }
2630
2631 ideal_load_val = val;
2632
2633 if (max_load_val < 0.0)
2634 max_load_val = val; /* set a default */
2635
2636 strcat(newstr, value);
2637
2638 return(1);
2639 } /* END setidealload() */
2640
2641
2642
2643
2644static unsigned long setignwalltime(
2645
2646 char *value) /* I */
2647
2648 {
2649 char newstr[50] = "ignwalltime ";
2650
2651 log_record(
2652 PBSEVENT_SYSTEM,
2653 PBS_EVENTCLASS_SERVER,
2654 "ignwalltime",
2655 value);
2656
2657 if (!strncasecmp(value, "t", 1) || (value[0] == '1') || !strcasecmp(value, "on"))
2658 {
2659 ignwalltime = 1;
2660 }
2661 else
2662 {
2663 ignwalltime = 0;
2664 }
2665
2666 strcat(newstr, value);
2667
2668 /* SUCCESS */
2669
2670 return(1);
2671 } /* END setignwalltime() */
2672
2673
2674
2675static unsigned long setignmem(
2676
2677 char *value) /* I */
2678
2679 {
2680 log_record(
2681 PBSEVENT_SYSTEM,
2682 PBS_EVENTCLASS_SERVER,
2683 "ignmem",
2684 value);
2685
2686 if (!strncasecmp(value,"t",1) || (value[0] == '1') || !strcasecmp(value,"on") )
2687 ignmem = 1;
2688 else
2689 ignmem = 0;
2690
2691 return(1);
2692 } /* END setignmem() */
2693
2694
2695
2696static unsigned long setigncput(
2697
2698 char *value) /* I */
2699
2700 {
2701 log_record(
2702 PBSEVENT_SYSTEM,
2703 PBS_EVENTCLASS_SERVER,
2704 "igncput",
2705 value);
2706
2707 if (!strncasecmp(value,"t",1) || (value[0] == '1') || !strcasecmp(value,"on") )
2708 igncput = 1;
2709 else
2710 igncput = 0;
2711
2712 return(1);
2713 }
2714
2715
2716static unsigned long setignvmem(
2717
2718 char *value) /* I */
2719
2720 {
2721 char newstr[50] = "setignvmem ";
2722
2723 log_record(
2724 PBSEVENT_SYSTEM,
2725 PBS_EVENTCLASS_SERVER,
2726 "setignvmem",
2727 value);
2728
2729 if (!strncasecmp(value, "t", 1) || (value[0] == '1') || !strcasecmp(value, "on"))
2730 {
2731 ignvmem = 1;
2732 }
2733 else
2734 {
2735 ignvmem = 0;
2736 }
2737
2738 strcat(newstr, value);
2739
2740 /* SUCCESS */
2741
2742 return(1);
2743 } /* END setignvmem() */
2744
2745
2746static unsigned long setautoidealload(
2747
2748 char *value)
2749
2750 {
2751 log_record(
2752 PBSEVENT_SYSTEM,
2753 PBS_EVENTCLASS_SERVER,
2754 "auto_ideal_load",
2755 value);
2756
2757 auto_ideal_load = strdup(value);
2758
2759 /*
2760 add_static(auto_ideal_load,"config",0);
2761
2762 nconfig++;
2763 */
2764
2765 return(1);
2766 } /* END setautoidealload() */
2767
2768
2769
2770
2771
2772static unsigned long setallocparcmd(
2773
2774 char *value) /* I */
2775
2776 {
2777 log_record(
2778 PBSEVENT_SYSTEM,
2779 PBS_EVENTCLASS_SERVER,
2780 "allocparcmd",
2781 value);
2782
2783 AllocParCmd = strdup(value);
2784
2785 return(1);
2786 } /* END setallocparcmd() */
2787
2788
2789
2790
2791
2792static unsigned long setautomaxload(
2793
2794 char *value)
2795
2796 {
2797 log_record(
2798 PBSEVENT_SYSTEM,
2799 PBS_EVENTCLASS_SERVER,
2800 "auto_max_load",
2801 value);
2802
2803 auto_max_load = strdup(value);
2804
2805 /*
2806 add_static(auto_ideal_load,"config",0);
2807
2808 nconfig++;
2809 */
2810
2811 return(1);
2812 } /* END setautomaxload() */
2813
2814
2815
2816
2817
2818static unsigned long setmaxconnecttimeout(
2819
2820 char *value) /* I */
2821
2822 {
2823 MaxConnectTimeout = strtol(value, NULL, 10);
2824
2825 if (MaxConnectTimeout < 0)
2826 {
2827 MaxConnectTimeout = 10000;
2828
2829 return(0);
2830 }
2831
2832 return(1);
2833 }
2834
2835
2836
2837
2838static unsigned long setnodecheckscript(
2839
2840 char *value)
2841
2842 {
2843 char newstr[1024] = "node_check_script ";
2844
2845 struct stat sbuf;
2846
2847 log_record(
2848 PBSEVENT_SYSTEM,
2849 PBS_EVENTCLASS_SERVER,
2850 "node_check_script",
2851 value);
2852
2853 if ((stat(value, &sbuf) == -1) || !(sbuf.st_mode & S_IXUSR))
2854 {
2855 /* FAILURE */
2856
2857 /* file does not exist or is not executable */
2858
2859 return(0);
2860 }
2861
2862 strncpy(PBSNodeCheckPath, value, sizeof(PBSNodeCheckPath));
2863
2864 strcat(newstr, value);
2865
2866 /* SUCCESS */
2867
2868 return(1);
2869 } /* END setnodecheckscript() */
2870
2871
2872
2873
2874
2875static unsigned long setnodecheckinterval(
2876
2877 char *value)
2878
2879 {
2880 char newstr[1024] = "node_check_interval ";
2881
2882 log_record(
2883 PBSEVENT_SYSTEM,
2884 PBS_EVENTCLASS_SERVER,
2885 "node_check_interval",
2886 value);
2887
2888 PBSNodeCheckInterval = (int)strtol(value, NULL, 10);
2889
2890 if (strstr(value, "jobstart"))
2891 PBSNodeCheckProlog = 1;
2892
2893 if (strstr(value, "jobend"))
2894 PBSNodeCheckEpilog = 1;
2895
2896 strcat(newstr, value);
2897
2898 return(1);
2899 } /* END setnodecheckinterval() */
2900
2901
2902
2903
2904
2905static unsigned long settimeout(
2906
2907 char *value)
2908
2909 {
2910 char newstr[1024];
2911
2912 log_record(
2913 PBSEVENT_SYSTEM,
2914 PBS_EVENTCLASS_SERVER,
2915 "timeout",
2916 value);
2917
2918 DIS_tcp_settimeout(strtol(value, NULL, 10));
2919
2920 snprintf(newstr, sizeof(newstr), "%s %s",
2921 "timeout",
2922 value);
2923
2924 return(1);
2925 } /* END settimeout() */
2926
2927
2928
2929
2930
2931static unsigned long setmaxload(
2932
2933 char *value) /* I */
2934
2935 {
2936 char newstr[50] = "max_load ";
2937 float val;
2938
2939 val = atof(value);
2940
2941 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, "max_load", value);
2942
2943 if (val < 0.0)
2944 {
2945 return(0); /* error */
2946 }
2947
2948 max_load_val = val;
2949
2950 if (ideal_load_val < 0.0)
2951 ideal_load_val = val;
2952
2953 strcat(newstr, value);
2954
2955 return(1);
2956 } /* END max_load() */
2957
2958
2959
2960
2961
2962static unsigned long setlogfilemaxsize(
2963
2964 char *value) /* I */
2965
2966 {
2967 log_file_max_size = strtol(value, NULL, 10);
2968
2969 if (log_file_max_size < 0)
2970 {
2971 log_file_max_size = 0;
2972
2973 return(0);
2974 }
2975
2976 return(1);
2977 }
2978
2979
2980
2981
2982static unsigned long setlogfilerolldepth(
2983
2984 char *value) /* I */
2985
2986 {
2987 log_file_roll_depth = strtol(value, NULL, 10);
2988
2989 if (log_file_roll_depth < 1)
2990 {
2991 log_file_roll_depth = 1;
2992
2993 return(0);
2994 }
2995
2996 return(1);
2997 }
2998
2999
3000
3001static unsigned long setlogdirectory(
3002
3003 char *value) /* I */
3004
3005 {
3006 path_log = strdup(value);
3007
3008 return(1);
3009 }
3010
3011
3012
3013
3014static unsigned long setlogfilesuffix(
3015
3016 char *value) /* I */
3017
3018 {
3019 log_init(value, NULL);
3020
3021 return(1);
3022 }
3023
3024
3025
3026static unsigned long setlogkeepdays(
3027
3028 char *value) /* I */
3029
3030 {
3031 int i;
3032
3033 i = (int)atoi(value);
3034
3035 if (i < 0)
3036 {
3037 return(0); /* error */
3038 }
3039
3040 LOGKEEPDAYS = i;
3041
3042 return(1);
3043 }
3044
3045
3046
3047static u_long setvarattr(
3048
3049 char *value) /* I */
3050
3051 {
3052 static char *id = "setvarattr";
3053
3054 struct varattr *pva;
3055 char *ptr;
3056
3057 pva = calloc(1, sizeof(struct varattr));
3058
3059 if (pva == NULL)
3060 {
3061 /* FAILURE */
3062
3063 log_err(errno, id, "no memory");
3064
3065 return(0);
3066 }
3067
3068 CLEAR_LINK(pva->va_link);
3069
3070 /* FORMAT: <TTL> <PATH> */
3071 /* extract TTL */
3072
3073 ptr = value;
3074
3075 pva->va_ttl = strtol(ptr, NULL, 10);
3076
3077 /* step forward to end of TTL */
3078
3079 while (!isspace(*ptr))
3080 ptr++;
3081
3082 if (*ptr == '\0')
3083 {
3084 free(pva);
3085
3086 return(0);
3087 }
3088
3089 /* skip white space */
3090
3091 while (isspace(*ptr))
3092 ptr++;
3093
3094 if (*ptr == '\0')
3095 {
3096 free(pva);
3097
3098 return(0);
3099 }
3100
3101 /* preserve command and args */
3102
3103 pva->va_cmd = strdup(ptr);
3104
3105 append_link(&mom_varattrs, &pva->va_link, pva);
3106
3107 /* SUCCESS */
3108
3109 return(1);
3110 } /* END setvarattr() */
3111
3112
3113
3114
3115
3116static unsigned long setnodefilesuffix(
3117
3118 char *value) /* I */
3119
3120 {
3121 char *ptr;
3122
3123 ptr = strtok(value, ",");
3124
3125 nodefile_suffix = strdup(ptr);
3126
3127 ptr = strtok(NULL, ",");
3128
3129 if (ptr != NULL)
3130 submithost_suffix = strdup(ptr);
3131
3132 /* SUCCESS */
3133
3134 return(1);
3135 } /* END setnodexfilesuffix() */
3136
3137
3138
3139
3140static unsigned long setmomhost(
3141
3142 char *value) /* I */
3143
3144 {
3145 hostname_specified = 1;
3146
3147 strncpy(mom_host, value, PBS_MAXHOSTNAME); /* remember name */
3148
3149 /* SUCCESS */
3150
3151 return(1);
3152 } /* END setmomhost() */
3153
3154
3155static u_long setrreconfig(
3156
3157 char *Value) /* I */
3158
3159 {
3160 static char id[] = "setrreconfig";
3161 int enable = -1;
3162
3163 log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, Value);
3164
3165 if (Value == NULL)
3166 {
3167 /* FAILURE */
3168
3169 return(0);
3170 }
3171
3172 /* accept various forms of "true", "yes", and "1" */
3173 switch (Value[0])
3174 {
3175
3176 case 't':
3177
3178 case 'T':
3179
3180 case 'y':
3181
3182 case 'Y':
3183
3184 case '1':
3185
3186 enable = 1;
3187
3188 break;
3189
3190 case 'f':
3191
3192 case 'F':
3193
3194 case 'n':
3195
3196 case 'N':
3197
3198 case '0':
3199
3200 enable = 0;
3201
3202 break;
3203
3204 }
3205
3206 if (enable != -1)
3207 {
3208 MOMConfigRReconfig = enable;
3209 }
3210
3211 return(1);
3212 } /* END setrreconfig() */
3213
3214
3215static unsigned long setnospooldirlist(
3216
3217 char *value) /* I */
3218
3219 {
3220 char *TokPtr;
3221 char *ptr;
3222
3223 int index = 0;
3224
3225 char tmpLine[1024];
3226
3227 ptr = strtok_r(value, " \t\n:,", &TokPtr);
3228
3229 while (ptr != NULL)
3230 {
3231 TNoSpoolDirList[index] = strdup(ptr);
3232
3233 snprintf(tmpLine, sizeof(tmpLine), "added NoSpoolDir[%d] '%s'",
3234 index,
3235 ptr);
3236
3237 log_record(
3238 PBSEVENT_SYSTEM,
3239 PBS_EVENTCLASS_SERVER,
3240 "setnospooldirlist",
3241 tmpLine);
3242
3243 index++;
3244
3245 if (index >= TMAX_NSDCOUNT)
3246 break;
3247
3248 ptr = strtok_r(NULL, " \t\n:,", &TokPtr);
3249 } /* END while (ptr != NULL) */
3250
3251 /* SUCCESS */
3252
3253 return(1);
3254 } /* END setnospooldirlist() */
3255
3256
3257
3258
3259static unsigned long setspoolasfinalname(
3260
3261 char *value) /* I */
3262
3263 {
3264 log_record(
3265 PBSEVENT_SYSTEM,
3266 PBS_EVENTCLASS_SERVER,
3267 "spoolasfinalname",
3268 value);
3269
3270 if (!strncasecmp(value,"t",1) || (value[0] == '1') || !strcasecmp(value,"on") )
3271 spoolasfinalname = 1;
3272 else
3273 spoolasfinalname = 0;
3274
3275 return(1);
3276 } /* END setspoolasfinalname() */
3277
3278
3279
3280static unsigned long setkilldelay(
3281
3282 char *value)
3283
3284 {
3285 log_record(
3286 PBSEVENT_SYSTEM,
3287 PBS_EVENTCLASS_SERVER,
3288 "setkilldelay",
3289 value);
3290
3291 if ((!strncasecmp(value,"t",1)) ||
3292 (value[0] == '1') ||
3293 (!strcasecmp(value,"on")))
3294 killdelay = 1;
3295 else
3296 killdelay = 0;
3297
3298 return(1);
3299 } /* END setkilldelay() */
3300
3301
3302
3303
3304
3305static unsigned long setremchkptdirlist(
3306
3307 char *value) /* I */
3308
3309 {
3310 char *TokPtr;
3311 char *ptr;
3312
3313 int index = 0;
3314 char tmpLine[1024];
3315
3316 while ((TRemChkptDirList[index] != NULL) && (index < TMAX_RCDCOUNT))
3317 {
3318 index++;
3319 }
3320
3321 if (index >= TMAX_RCDCOUNT)
3322 return (1);
3323
3324 ptr = strtok_r(value, " \t\n:,", &TokPtr);
3325
3326 while (ptr != NULL)
3327 {
3328 TRemChkptDirList[index] = strdup(ptr);
3329
3330 snprintf(tmpLine, sizeof(tmpLine), "added RemChkptDir[%d] '%s'",
3331 index,
3332 ptr);
3333
3334 log_record(
3335 PBSEVENT_SYSTEM,
3336 PBS_EVENTCLASS_SERVER,
3337 "setremchkptdirlist",
3338 tmpLine);
3339
3340 index++;
3341
3342 if (index >= TMAX_RCDCOUNT)
3343 break;
3344
3345 ptr = strtok_r(NULL, " \t\n:,", &TokPtr);
3346 } /* END while (ptr != NULL) */
3347
3348 /* SUCCESS */
3349
3350 return (1);
3351 } /* END setremchkptdirlist() */
3352
3353
3354
3355
3356
3357
3358void
3359check_log(void)
3360
3361 {
3362 last_log_check = time_now;
3363
3364 /* periodically record the version and loglevel */
3365
3366 sprintf(log_buffer, msg_info_mom, PACKAGE_VERSION, LOGLEVEL);
3367
3368 log_event(
3369 PBSEVENT_SYSTEM | PBSEVENT_FORCE,
3370 PBS_EVENTCLASS_SERVER,
3371 msg_daemonname,
3372 log_buffer);
3373
3374 if (LOGKEEPDAYS > 0)
3375 {
3376 /* remove logs older than log_keep_days */
3377
3378 snprintf(log_buffer,sizeof(log_buffer),"checking for old pbs_mom logs in dir '%s' (older than %d days)",
3379 path_log,
3380 LOGKEEPDAYS);
3381
3382 log_event(
3383 PBSEVENT_SYSTEM | PBSEVENT_FORCE,
3384 PBS_EVENTCLASS_SERVER,
3385 msg_daemonname,
3386 log_buffer);
3387
3388 if (log_remove_old(path_log,(LOGKEEPDAYS * SECS_PER_DAY)) != 0)
3389 {
3390 log_err(-1,"check_log","failure occurred when checking for old pbs_mom logs");
3391 }
3392 }
3393
3394 if (log_file_max_size <= 0)
3395 {
3396 return;
3397 }
3398
3399 if (log_size() >= log_file_max_size)
3400 {
3401 log_event(
3402 PBSEVENT_SYSTEM | PBSEVENT_FORCE,
3403 PBS_EVENTCLASS_SERVER,
3404 msg_daemonname,
3405 "Rolling log file");
3406
3407 log_roll(log_file_roll_depth);
3408 }
3409
3410 return;
3411 } /* END check_log() */
3412
3413
3414
3415
3416
3417/*
3418** Open and read the config file. Save information in a linked
3419** list. After reading the file, create an array, copy the list
3420** elements to the array and free the list.
3421*/
3422
3423/* NOTE: add new mom config parameters to 'special[]' */
3424
3425int read_config(
3426
3427 char *file) /* I */
3428
3429 {
3430 static char id[] = "read_config";
3431
3432 FILE *conf;
3433
3434 struct stat sb;
3435
3436 struct config_list *cp;
3437
3438 struct config *ap;
3439 char line[120];
3440 char name[50];
3441 char *str;
3442 char *ptr;
3443
3444 int linenum;
3445 int i;
3446
3447 int IgnConfig = 0;
3448
3449 int rc;
3450
3451 int n, list_len;
3452 char *server_list_ptr;
3453 char *tp;
3454
3455
3456 if (LOGLEVEL >= 3)
3457 {
3458 sprintf(log_buffer, "updating configuration using file '%s'",
3459 (file != NULL) ? file : "NULL");
3460
3461 log_record(
3462 PBSEVENT_SYSTEM,
3463 PBS_EVENTCLASS_SERVER,
3464 id,
3465 log_buffer);
3466 }
3467
3468 for (i = 0;i < mask_num;i++)
3469 {
3470 free(maskclient[i]);
3471 }
3472
3473 mask_num = 0;
3474
3475 if (file == NULL)
3476 file = config_file;
3477
3478 rc = 0;
3479
3480 if (file[0] == '\0')
3481 {
3482 log_record(
3483 PBSEVENT_SYSTEM,
3484 PBS_EVENTCLASS_SERVER,
3485 id,
3486 "ALERT: no config file specified");
3487
3488 IgnConfig = 1; /* no config file */
3489 }
3490
3491 if ((IgnConfig == 0) && (stat(file, &sb) == -1))
3492 {
3493 IgnConfig = 1;
3494
3495 sprintf(log_buffer, "fstat: %s",
3496 file);
3497
3498 log_err(errno, id, log_buffer);
3499
3500 if (config_file_specified != 0)
3501 {
3502 /* file specified and not there, return failure */
3503
3504 log_record(
3505 PBSEVENT_SYSTEM,
3506 PBS_EVENTCLASS_SERVER,
3507 id,
3508 "ALERT: cannot open config file - no file");
3509
3510 rc = 1;
3511 }
3512 else
3513 {
3514 /* "config" file not located, return success */
3515
3516 if (LOGLEVEL >= 3)
3517 {
3518 sprintf(log_buffer, "cannot open file '%s'",
3519 file);
3520
3521 log_record(
3522 PBSEVENT_SYSTEM,
3523 PBS_EVENTCLASS_SERVER,
3524 id,
3525 log_buffer);
3526 }
3527
3528 rc = 0;
3529 }
3530 } /* END if ((IgnConfig == 0) && (stat(file,&sb) == -1)) */
3531
3532 if (IgnConfig == 0)
3533 {
3534#if !defined(DEBUG) && !defined(NO_SECURITY_CHECK)
3535
3536 if (chk_file_sec(file, 0, 0, S_IWGRP | S_IWOTH, 1, NULL))
3537 {
3538 /* not authorized to access specified file, return failure */
3539
3540 log_record(
3541 PBSEVENT_SYSTEM,
3542 PBS_EVENTCLASS_SERVER,
3543 id,
3544 "ALERT: cannot open config file - permissions");
3545
3546 IgnConfig = 1;
3547
3548 rc = 1;
3549 }
3550
3551#endif /* NO_SECURITY_CHECK */
3552 } /* END if (ignConfig == 0) */
3553
3554 if (IgnConfig == 0)
3555 {
3556 if ((conf = fopen(file, "r")) == NULL)
3557 {
3558 sprintf(log_buffer, "fopen: %s",
3559 file);
3560
3561 log_err(errno, id, log_buffer);
3562
3563 IgnConfig = 1;
3564
3565 rc = 1;
3566 }
3567 } /* END if (IgnConfig == 0) */
3568
3569 if (IgnConfig == 0)
3570 {
3571 nconfig = 0;
3572 linenum = 0;
3573
3574 while (fgets(line, sizeof(line), conf))
3575 {
3576 linenum++;
3577
3578 if (line[0] == '#') /* comment */
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: