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