]>
Commit | Line | Data |
---|---|---|
fb8809f4 | 1 | /* $Header$ |
2 | * | |
3 | * Do AFS incremental updates | |
4 | * | |
60c22e5f | 5 | * Copyright (C) 1989,1992 by the Massachusetts Institute of Technology |
fb8809f4 | 6 | * for copying and distribution information, please see the file |
7 | * <mit-copyright.h>. | |
8 | */ | |
9 | ||
16838ad1 | 10 | #include <stdio.h> |
60c22e5f | 11 | #include <sys/types.h> |
12 | #include <sys/file.h> | |
13 | #include <strings.h> | |
14 | ||
d1be2e3a | 15 | #include <krb.h> |
2ce085d2 | 16 | #include <moira.h> |
17 | #include <moira_site.h> | |
f633445d | 18 | |
60c22e5f | 19 | #include <afs/param.h> |
20 | #include <afs/cellconfig.h> | |
21 | #include <afs/venus.h> | |
22 | #include <afs/ptclient.h> | |
23 | #include <afs/pterror.h> | |
fb8809f4 | 24 | |
d1be2e3a | 25 | #define STOP_FILE "/moira/afs/noafs" |
60c22e5f | 26 | #define file_exists(file) (access((file), F_OK) == 0) |
fb8809f4 | 27 | |
16838ad1 | 28 | #if defined(vax) && !defined(__STDC__) |
29 | #define volatile | |
30 | #endif | |
31 | ||
fb8809f4 | 32 | char *whoami; |
33 | ||
eb63ae5f | 34 | /* Main stub routines */ |
35 | int do_user(); | |
36 | int do_list(); | |
37 | int do_member(); | |
38 | int do_filesys(); | |
39 | int do_quota(); | |
40 | ||
41 | /* Support stub routines */ | |
42 | int run_cmd(); | |
43 | int add_user_lists(); | |
44 | int get_members(); | |
45 | int edit_group(); | |
46 | int pr_try(); | |
47 | int check_afs(); | |
48 | ||
49 | /* libprot.a routines */ | |
50 | extern long pr_Initialize(); | |
51 | extern long pr_CreateUser(); | |
52 | extern long pr_CreateGroup(); | |
53 | extern long pr_DeleteByID(); | |
54 | extern long pr_ChangeEntry(); | |
55 | extern long pr_SetFieldsEntry(); | |
56 | extern long pr_AddToGroup(); | |
57 | extern long pr_RemoveUserFromGroup(); | |
58 | ||
59 | static char tbl_buf[1024]; | |
60 | ||
fb8809f4 | 61 | main(argc, argv) |
62 | char **argv; | |
63 | int argc; | |
64 | { | |
a7fdf2de | 65 | int beforec, afterc, i; |
fb8809f4 | 66 | char *table, **before, **after; |
67 | ||
a7fdf2de | 68 | for (i = getdtablesize() - 1; i > 2; i--) |
69 | close(i); | |
70 | ||
fb8809f4 | 71 | table = argv[1]; |
72 | beforec = atoi(argv[2]); | |
73 | before = &argv[4]; | |
74 | afterc = atoi(argv[3]); | |
75 | after = &argv[4 + beforec]; | |
48c9cd1f | 76 | whoami = argv[0]; |
f10e3ca2 | 77 | |
eb63ae5f | 78 | setlinebuf(stdout); |
79 | ||
80 | strcpy(tbl_buf, table); | |
81 | strcat(tbl_buf, " ("); | |
810d12a7 | 82 | for (i = 0; i < beforec; i++) { |
83 | if (i > 0) | |
eb63ae5f | 84 | strcat(tbl_buf, ","); |
85 | strcat(tbl_buf, before[i]); | |
810d12a7 | 86 | } |
eb63ae5f | 87 | strcat(tbl_buf, ")->("); |
810d12a7 | 88 | for (i = 0; i < afterc; i++) { |
89 | if (i > 0) | |
eb63ae5f | 90 | strcat(tbl_buf, ","); |
91 | strcat(tbl_buf, after[i]); | |
810d12a7 | 92 | } |
eb63ae5f | 93 | strcat(tbl_buf, ")"); |
d1be2e3a | 94 | #ifdef DEBUG |
eb63ae5f | 95 | printf("%s\n", tbl_buf); |
810d12a7 | 96 | #endif |
97 | ||
fb8809f4 | 98 | initialize_sms_error_table(); |
99 | initialize_krb_error_table(); | |
100 | ||
101 | if (!strcmp(table, "users")) { | |
102 | do_user(before, beforec, after, afterc); | |
103 | } else if (!strcmp(table, "list")) { | |
104 | do_list(before, beforec, after, afterc); | |
105 | } else if (!strcmp(table, "members")) { | |
106 | do_member(before, beforec, after, afterc); | |
107 | } else if (!strcmp(table, "filesys")) { | |
108 | do_filesys(before, beforec, after, afterc); | |
1f377b55 | 109 | } else if (!strcmp(table, "quota")) { |
fb8809f4 | 110 | do_quota(before, beforec, after, afterc); |
111 | } | |
fb8809f4 | 112 | exit(0); |
113 | } | |
114 | ||
115 | ||
fb8809f4 | 116 | do_user(before, beforec, after, afterc) |
117 | char **before; | |
118 | int beforec; | |
119 | char **after; | |
120 | int afterc; | |
121 | { | |
eb63ae5f | 122 | int astate, bstate, auid, buid, code; |
9b273918 | 123 | char hostname[64]; |
124 | char *av[2]; | |
60c22e5f | 125 | |
126 | auid = buid = astate = bstate = 0; | |
127 | if (afterc > U_STATE) astate = atoi(after[U_STATE]); | |
128 | if (beforec > U_STATE) bstate = atoi(before[U_STATE]); | |
129 | if (afterc > U_UID) auid = atoi(after[U_UID]); | |
130 | if (beforec > U_UID) buid = atoi(before[U_UID]); | |
131 | ||
132 | /* We consider "half-registered" users to be active */ | |
810d12a7 | 133 | if (astate == 2) astate = 1; |
134 | if (bstate == 2) bstate = 1; | |
fb8809f4 | 135 | |
60c22e5f | 136 | if (astate != 1 && bstate != 1) /* inactive user */ |
fb8809f4 | 137 | return; |
60c22e5f | 138 | |
139 | if (astate == bstate && auid == buid && | |
140 | !strcmp(before[U_NAME], after[U_NAME])) | |
141 | /* No AFS related attributes have changed */ | |
fb8809f4 | 142 | return; |
fb8809f4 | 143 | |
60c22e5f | 144 | if (astate == bstate) { |
145 | /* Only a modify has to be done */ | |
eb63ae5f | 146 | code = pr_try(pr_ChangeEntry, before[U_NAME], after[U_NAME], auid, ""); |
60c22e5f | 147 | if (code) { |
148 | critical_alert("incremental", | |
149 | "Couldn't change user %s (id %d) to %s (id %d): %s", | |
150 | before[U_NAME], buid, after[U_NAME], auid, | |
151 | error_message(code)); | |
152 | } | |
153 | return; | |
154 | } | |
155 | if (bstate == 1) { | |
eb63ae5f | 156 | code = pr_try(pr_DeleteByID, buid); |
60c22e5f | 157 | if (code && code != PRNOENT) { |
158 | critical_alert("incremental", | |
159 | "Couldn't delete user %s (id %d): %s", | |
160 | before[U_NAME], buid, error_message(code)); | |
161 | } | |
162 | return; | |
163 | } | |
164 | if (astate == 1) { | |
eb63ae5f | 165 | code = pr_try(pr_CreateUser, after[U_NAME], &auid); |
60c22e5f | 166 | if (code) { |
167 | critical_alert("incremental", | |
168 | "Couldn't create user %s (id %d): %s", | |
169 | after[U_NAME], auid, error_message(code)); | |
96786144 | 170 | return; |
60c22e5f | 171 | } |
2dbcb756 | 172 | |
9b273918 | 173 | if (beforec) { |
174 | /* Reactivating a user; get his group list */ | |
175 | gethostname(hostname, sizeof(hostname)); | |
176 | code = mr_connect(hostname); | |
177 | if (!code) code = mr_auth("afs.incr"); | |
178 | if (code) { | |
179 | critical_alert("incremental", | |
180 | "Error contacting Moira server to retrieve grouplist of user %s: %s", | |
181 | after[U_NAME], error_message(code)); | |
182 | return; | |
183 | } | |
2dbcb756 | 184 | av[0] = "ruser"; |
9b273918 | 185 | av[1] = after[U_NAME]; |
186 | code = mr_query("get_lists_of_member", 2, av, | |
187 | add_user_lists, after[U_NAME]); | |
b80d6d78 | 188 | if (code && code != MR_NO_MATCH) |
9b273918 | 189 | critical_alert("incremental", |
190 | "Couldn't retrieve membership of user %s: %s", | |
191 | after[U_NAME], error_message(code)); | |
192 | mr_disconnect(); | |
193 | } | |
60c22e5f | 194 | return; |
fb8809f4 | 195 | } |
196 | } | |
197 | ||
198 | ||
fb8809f4 | 199 | do_list(before, beforec, after, afterc) |
200 | char **before; | |
201 | int beforec; | |
202 | char **after; | |
203 | int afterc; | |
204 | { | |
8ec23c21 | 205 | register int agid, bgid; |
eb63ae5f | 206 | int ahide, bhide; |
60c22e5f | 207 | long code, id; |
ed9a5300 | 208 | char hostname[64]; |
60c22e5f | 209 | char g1[PR_MAXNAMELEN], g2[PR_MAXNAMELEN]; |
ed9a5300 | 210 | char *av[2]; |
fb8809f4 | 211 | |
60c22e5f | 212 | agid = bgid = 0; |
8ec23c21 | 213 | if (beforec > L_GID && atoi(before[L_ACTIVE]) && atoi(before[L_GROUP])) { |
60c22e5f | 214 | bgid = atoi(before[L_GID]); |
8ec23c21 | 215 | bhide = atoi(before[L_HIDDEN]); |
216 | } | |
217 | if (afterc > L_GID && atoi(after[L_ACTIVE]) && atoi(after[L_GROUP])) { | |
60c22e5f | 218 | agid = atoi(after[L_GID]); |
8ec23c21 | 219 | ahide = atoi(after[L_HIDDEN]); |
220 | } | |
fb8809f4 | 221 | |
60c22e5f | 222 | if (agid == 0 && bgid == 0) /* Not active groups */ |
223 | return; | |
60c22e5f | 224 | |
60c22e5f | 225 | if (agid && bgid) { |
8ec23c21 | 226 | if (strcmp(after[L_NAME], before[L_NAME])) { |
227 | /* Only a modify is required */ | |
228 | strcpy(g1, "system:"); | |
229 | strcpy(g2, "system:"); | |
230 | strcat(g1, before[L_NAME]); | |
231 | strcat(g2, after[L_NAME]); | |
eb63ae5f | 232 | code = pr_try(pr_ChangeEntry, g1, g2, -agid, ""); |
8ec23c21 | 233 | if (code) { |
234 | critical_alert("incremental", | |
235 | "Couldn't change group %s (id %d) to %s (id %d): %s", | |
236 | before[L_NAME], -bgid, after[L_NAME], -agid, | |
237 | error_message(code)); | |
238 | } | |
239 | } | |
240 | if (ahide != bhide) { | |
eb63ae5f | 241 | code = pr_try(pr_SetFieldsEntry, -agid, PR_SF_ALLBITS, |
242 | (ahide ? PRP_STATUS_ANY : PRP_GROUP_DEFAULT) >>PRIVATE_SHIFT, | |
243 | 0 /*ngroups*/, 0 /*nusers*/); | |
8ec23c21 | 244 | if (code) { |
245 | critical_alert("incremental", | |
246 | "Couldn't set flags of group %s: %s", | |
247 | after[L_NAME], error_message(code)); | |
248 | } | |
60c22e5f | 249 | } |
fb8809f4 | 250 | return; |
251 | } | |
60c22e5f | 252 | if (bgid) { |
eb63ae5f | 253 | code = pr_try(pr_DeleteByID, -bgid); |
60c22e5f | 254 | if (code && code != PRNOENT) { |
255 | critical_alert("incremental", | |
256 | "Couldn't delete group %s (id %d): %s", | |
257 | before[L_NAME], -bgid, error_message(code)); | |
258 | } | |
fb8809f4 | 259 | return; |
260 | } | |
60c22e5f | 261 | if (agid) { |
262 | strcpy(g1, "system:"); | |
263 | strcat(g1, after[L_NAME]); | |
264 | strcpy(g2, "system:administrators"); | |
265 | id = -agid; | |
eb63ae5f | 266 | code = pr_try(pr_CreateGroup, g1, g2, &id); |
60c22e5f | 267 | if (code) { |
268 | critical_alert("incremental", | |
269 | "Couldn't create group %s (id %d): %s", | |
ed9a5300 | 270 | after[L_NAME], id, error_message(code)); |
60c22e5f | 271 | return; |
272 | } | |
8ec23c21 | 273 | if (ahide) { |
eb63ae5f | 274 | code = pr_try(pr_SetFieldsEntry, -agid, PR_SF_ALLBITS, |
275 | (ahide ? PRP_STATUS_ANY : PRP_GROUP_DEFAULT) >>PRIVATE_SHIFT, | |
276 | 0 /*ngroups*/, 0 /*nusers*/); | |
8ec23c21 | 277 | if (code) { |
278 | critical_alert("incremental", | |
279 | "Couldn't set flags of group %s: %s", | |
280 | after[L_NAME], error_message(code)); | |
281 | } | |
282 | } | |
60c22e5f | 283 | |
284 | /* We need to make sure the group is properly populated */ | |
285 | if (beforec < L_ACTIVE || atoi(before[L_ACTIVE]) == 0) return; | |
286 | ||
ed9a5300 | 287 | gethostname(hostname, sizeof(hostname)); |
288 | code = mr_connect(hostname); | |
289 | if (!code) code = mr_auth("afs.incr"); | |
290 | if (code) { | |
291 | critical_alert("incremental", | |
292 | "Error contacting Moira server to resolve %s: %s", | |
293 | after[L_NAME], error_message(code)); | |
294 | return; | |
295 | } | |
296 | av[0] = "LIST"; | |
297 | av[1] = after[L_NAME]; | |
298 | get_members(2, av, after[L_NAME]); | |
299 | ||
300 | mr_disconnect(); | |
301 | return; | |
60c22e5f | 302 | } |
fb8809f4 | 303 | } |
304 | ||
305 | ||
306 | do_member(before, beforec, after, afterc) | |
307 | char **before; | |
308 | int beforec; | |
309 | char **after; | |
310 | int afterc; | |
311 | { | |
60c22e5f | 312 | int code; |
313 | char *p; | |
314 | ||
bd70a79d | 315 | if ((beforec < 4 || !atoi(before[LM_END])) && |
316 | (afterc < 4 || !atoi(after[LM_END]))) | |
fb8809f4 | 317 | return; |
60c22e5f | 318 | |
ed9a5300 | 319 | if (afterc) |
320 | edit_group(1, after[LM_LIST], after[LM_TYPE], after[LM_MEMBER]); | |
321 | if (beforec) | |
e9f07a3b | 322 | edit_group(0, before[LM_LIST], before[LM_TYPE], before[LM_MEMBER]); |
ed9a5300 | 323 | } |
324 | ||
325 | ||
eb63ae5f | 326 | do_filesys(before, beforec, after, afterc) |
327 | char **before; | |
328 | int beforec; | |
329 | char **after; | |
330 | int afterc; | |
331 | { | |
332 | char cmd[1024]; | |
89e513d9 | 333 | int acreate, atype, btype; |
334 | ||
335 | if (afterc < FS_CREATE) { | |
336 | atype = acreate = 0; | |
337 | } else { | |
338 | atype = !strcmp(after[FS_TYPE], "AFS"); | |
339 | acreate = atoi(after[FS_CREATE]); | |
340 | } | |
341 | ||
eb63ae5f | 342 | if (beforec < FS_CREATE) { |
89e513d9 | 343 | if (acreate == 0 || atype == 0) return; |
eb63ae5f | 344 | |
345 | /* new locker creation */ | |
346 | sprintf(cmd, "%s/perl -I%s %s/afs_create.pl %s %s %s %s %s %s", | |
347 | BIN_DIR, BIN_DIR, BIN_DIR, | |
348 | after[FS_NAME], after[FS_L_TYPE], after[FS_MACHINE], | |
349 | after[FS_PACK], after[FS_OWNER], after[FS_OWNERS]); | |
350 | run_cmd(cmd); | |
351 | return; | |
352 | } | |
89e513d9 | 353 | |
89e513d9 | 354 | btype = !strcmp(before[FS_TYPE], "AFS"); |
eb63ae5f | 355 | if (afterc < FS_CREATE) { |
89e513d9 | 356 | if (btype) |
eb63ae5f | 357 | critical_alert("incremental", |
3b1e9c5f | 358 | "Cannot delete AFS filesystem %s: Operation not supported", |
eb63ae5f | 359 | before[FS_NAME]); |
360 | return; | |
eb63ae5f | 361 | } |
3b1e9c5f | 362 | |
363 | if (!acreate) | |
364 | return; | |
365 | ||
366 | /* Are we dealing with AFS lockers (could be type ERR lockers) */ | |
367 | if (!atype && !btype) | |
368 | if (strcmp(before[FS_TYPE], "ERR") || strcmp(after[FS_TYPE], "ERR")) | |
369 | return; | |
370 | ||
371 | /* By now, we know we are simply changing AFS filesystem attributes. | |
372 | * Operations supported: | |
373 | * Name change: rename/remount | |
374 | * Path change: remount | |
375 | * Type change: ERR<-->AFS | |
376 | */ | |
377 | ||
378 | if (strcmp(before[FS_OWNER], after[FS_OWNER]) || | |
3ae9c0f3 | 379 | strcmp(before[FS_OWNERS], after[FS_OWNERS])) |
3b1e9c5f | 380 | { |
381 | critical_alert("incremental", | |
382 | "Cannot change ownership of filesystem %s: Operation not yet supported", | |
383 | after[FS_NAME]); | |
384 | } | |
385 | ||
386 | sprintf(cmd, "%s/perl -I%s %s/afs_rename.pl %s %s %s %s %s %s %s %s %s %s", | |
387 | BIN_DIR, BIN_DIR, BIN_DIR, | |
3ae9c0f3 | 388 | before[FS_NAME], before[FS_MACHINE], before[FS_TYPE], |
3b1e9c5f | 389 | before[FS_L_TYPE], before[FS_PACK], |
3ae9c0f3 | 390 | after[FS_NAME], after[FS_MACHINE], after[FS_TYPE], |
3b1e9c5f | 391 | after[FS_L_TYPE], after[FS_PACK]); |
392 | run_cmd(cmd); | |
eb63ae5f | 393 | } |
394 | ||
395 | ||
396 | do_quota(before, beforec, after, afterc) | |
397 | char **before; | |
398 | int beforec; | |
399 | char **after; | |
400 | int afterc; | |
401 | { | |
402 | char cmd[1024]; | |
403 | ||
404 | if (afterc < Q_DIRECTORY || strcmp("ANY", after[Q_TYPE]) || | |
405 | strncmp("/afs/", after[Q_DIRECTORY], 5)) | |
406 | return; | |
407 | ||
408 | sprintf(cmd, "%s/perl -I%s %s/afs_quota.pl %s %s", | |
409 | BIN_DIR, BIN_DIR, BIN_DIR, | |
410 | after[Q_DIRECTORY], after[Q_QUOTA]); | |
411 | run_cmd(cmd); | |
412 | return; | |
413 | } | |
414 | ||
415 | ||
416 | run_cmd(cmd) | |
417 | char *cmd; | |
418 | { | |
419 | int success=0, tries=0; | |
420 | ||
421 | check_afs(); | |
422 | ||
423 | while (success == 0 && tries < 2) { | |
424 | if (tries++) | |
425 | sleep(90); | |
426 | com_err(whoami, 0, "Executing command: %s", cmd); | |
427 | if (system(cmd) == 0) | |
428 | success++; | |
429 | } | |
430 | if (!success) | |
431 | critical_alert("incremental", "failed command: %s", cmd); | |
432 | } | |
433 | ||
434 | ||
435 | add_user_lists(ac, av, user) | |
436 | int ac; | |
437 | char *av[]; | |
438 | char *user; | |
439 | { | |
440 | if (atoi(av[5])) | |
441 | edit_group(1, av[0], "USER", user); | |
442 | } | |
443 | ||
444 | ||
ed9a5300 | 445 | get_members(ac, av, group) |
446 | int ac; | |
447 | char *av[]; | |
448 | char *group; | |
449 | { | |
450 | int code=0; | |
451 | ||
452 | if (strcmp(av[0], "LIST")) { | |
ed9a5300 | 453 | edit_group(1, group, av[0], av[1]); |
454 | } else { | |
cdd40d28 | 455 | code = mr_query("get_end_members_of_list", 1, &av[1], |
456 | get_members, group); | |
ed9a5300 | 457 | if (code) |
458 | critical_alert("incremental", | |
459 | "Couldn't retrieve full membership of %s: %s", | |
460 | group, error_message(code)); | |
461 | } | |
462 | return code; | |
463 | } | |
464 | ||
465 | ||
466 | edit_group(op, group, type, member) | |
467 | int op; | |
468 | char *group; | |
469 | char *type; | |
470 | char *member; | |
471 | { | |
472 | char *p = 0; | |
473 | char buf[PR_MAXNAMELEN]; | |
ed9a5300 | 474 | int code; |
d1be2e3a | 475 | static char local_realm[REALM_SZ+1] = ""; |
ed9a5300 | 476 | |
60c22e5f | 477 | /* The following KERBEROS code allows for the use of entities |
478 | * user@foreign_cell. | |
479 | */ | |
d1be2e3a | 480 | if (!local_realm[0]) |
481 | krb_get_lrealm(local_realm, 1); | |
ed9a5300 | 482 | if (!strcmp(type, "KERBEROS")) { |
483 | p = index(member, '@'); | |
d1be2e3a | 484 | if (p && !strcasecmp(p+1, local_realm)) |
60c22e5f | 485 | *p = 0; |
ed9a5300 | 486 | } else if (strcmp(type, "USER")) |
487 | return; /* invalid type */ | |
60c22e5f | 488 | |
ed9a5300 | 489 | strcpy(buf, "system:"); |
490 | strcat(buf, group); | |
eb63ae5f | 491 | code=pr_try(op ? pr_AddToGroup : pr_RemoveUserFromGroup, member, buf); |
ed9a5300 | 492 | if (code) { |
493 | if (op==0 && code == PRNOENT) return; | |
494 | if (op==1 && code == PRIDEXIST) return; | |
495 | if (strcmp(type, "KERBEROS") || code != PRNOENT) { | |
60c22e5f | 496 | critical_alert("incremental", |
ed9a5300 | 497 | "Couldn't %s %s %s %s: %s", |
498 | op ? "add" : "remove", member, | |
499 | op ? "to" : "from", buf, | |
60c22e5f | 500 | error_message(code)); |
60c22e5f | 501 | } |
57bc9f26 | 502 | } |
fb8809f4 | 503 | } |
504 | ||
505 | ||
eb63ae5f | 506 | long pr_try(fn, a1, a2, a3, a4, a5, a6, a7, a8) |
507 | long (*fn)(); | |
508 | char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; | |
fb8809f4 | 509 | { |
eb63ae5f | 510 | static int initd=0; |
16838ad1 | 511 | volatile register long code; |
eb63ae5f | 512 | register int tries = 0; |
513 | #ifdef DEBUG | |
514 | char fname[64]; | |
515 | #endif | |
516 | ||
517 | check_afs(); | |
60c22e5f | 518 | |
eb63ae5f | 519 | if (!initd) { |
520 | code=pr_Initialize(1, AFSCONF_CLIENTNAME, 0); | |
521 | if (code) { | |
522 | critical_alert("incremental", "Couldn't initialize libprot: %s", | |
523 | error_message(code)); | |
60c22e5f | 524 | return; |
eb63ae5f | 525 | } |
526 | initd = 1; | |
9b9540a1 | 527 | } |
16838ad1 | 528 | sleep(1); /* give ptserver room */ |
9b9540a1 | 529 | |
eb63ae5f | 530 | while (code = (*fn)(a1, a2, a3, a4, a5, a6, a7, a8)) { |
531 | #ifdef DEBUG | |
532 | long t; | |
533 | t = time(0); | |
534 | if (fn == pr_AddToGroup) strcpy(fname, "pr_AddToGroup"); | |
535 | else if (fn == pr_RemoveUserFromGroup) | |
536 | strcpy(fname, "pr_RemoveUserFromGroup"); | |
537 | else if (fn == pr_CreateUser) strcpy(fname, "pr_CreateUser"); | |
538 | else if (fn == pr_CreateGroup) strcpy(fname, "pr_CreateGroup"); | |
539 | else if (fn == pr_DeleteByID) strcpy(fname, "pr_DeleteByID"); | |
540 | else if (fn == pr_ChangeEntry) strcpy(fname, "pr_ChangeEntry"); | |
541 | else if (fn == pr_SetFieldsEntry) strcpy(fname, "pr_SetFieldsEntry"); | |
542 | else if (fn == pr_AddToGroup) strcpy(fname, "pr_AddToGroup"); | |
16838ad1 | 543 | else |
eb63ae5f | 544 | sprintf(fname, "pr_??? (0x%08x)", (long)fn); |
eb63ae5f | 545 | |
16838ad1 | 546 | com_err(whoami, code, "- %s failed (try %d @%u)", fname, tries+1, t); |
eb63ae5f | 547 | #endif |
16838ad1 | 548 | if (++tries > 2) break; /* 3 tries */ |
549 | ||
550 | if (code == UNOQUORUM) sleep(90); | |
551 | else sleep(15); | |
552 | ||
553 | /* Re-initialize the prdb connection */ | |
554 | code=pr_Initialize(0, AFSCONF_CLIENTNAME, 0); | |
555 | if (!code) code=pr_Initialize(1, AFSCONF_CLIENTNAME, 0); | |
556 | if (code) { | |
557 | critical_alert("incremental", "Couldn't re-initialize libprot: %s", | |
558 | error_message(code)); | |
559 | initd = 0; /* we lost */ | |
560 | break; | |
561 | } | |
9b9540a1 | 562 | } |
eb63ae5f | 563 | return code; |
fb8809f4 | 564 | } |
565 | ||
566 | ||
eb63ae5f | 567 | check_afs() |
fb8809f4 | 568 | { |
eb63ae5f | 569 | int i; |
570 | ||
571 | for (i=0; file_exists(STOP_FILE); i++) { | |
572 | if (i > 30) { | |
573 | critical_alert("incremental", | |
574 | "AFS incremental failed (%s exists): %s", | |
575 | STOP_FILE, tbl_buf); | |
576 | exit(1); | |
577 | } | |
578 | sleep(60); | |
579 | } | |
fb8809f4 | 580 | } |