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