source: trunk/third/moira/incremental/afs/afs.c @ 25547

Revision 25547, 19.0 KB checked in by jdreed, 12 years ago (diff)
In moira: * Re-snapshot moira at r4081, to pick up client changes for lockers of type 'SITE'
Line 
1/* $Id: afs.c 4079 2012-05-23 22:42:25Z jweiss $
2 *
3 * Do AFS incremental updates
4 *
5 * Copyright (C) 1989,1992 by the Massachusetts Institute of Technology
6 * for copying and distribution information, please see the file
7 * <mit-copyright.h>.
8 */
9
10#include <moira.h>
11#include <moira_site.h>
12#include <moira_schema.h>
13
14#include <stdio.h>
15#include <stdlib.h>
16#include <sys/resource.h>
17#include <sys/types.h>
18#include <sys/utsname.h>
19#include <sys/file.h>
20#include <string.h>
21#include <unistd.h>
22
23#include <com_err.h>
24#ifdef HAVE_KRB4
25#include <krb.h>
26#endif
27#include <krb5.h>
28
29#include <afs/param.h>
30#include <afs/cellconfig.h>
31#include <afs/venus.h>
32#include <afs/ptclient.h>
33#include <afs/pterror.h>
34
35/* Cheesy test for determining AFS more recent than 3.4a */
36#ifndef AFSCONF_CLIENTNAME
37#include <afs/dirpath.h>
38#define AFSCONF_CLIENTNAME AFSDIR_CLIENT_ETC_DIRPATH
39#endif
40
41#define STOP_FILE "/moira/afs/noafs"
42#define file_exists(file) (access((file), F_OK) == 0)
43
44RCSID("$HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/incremental/afs/afs.c $ $Id: afs.c 4079 2012-05-23 22:42:25Z jweiss $");
45
46char *whoami;
47
48/* Main stub routines */
49void do_user(char **before, int beforec, char **after, int afterc);
50void do_list(char **before, int beforec, char **after, int afterc);
51void do_member(char **before, int beforec, char **after, int afterc);
52void do_filesys(char **before, int beforec, char **after, int afterc);
53void do_quota(char **before, int beforec, char **after, int afterc);
54
55/* Support stub routines */
56void run_cmd(char *cmd);
57int add_user_lists(int ac, char **av, void *user);
58int add_list_members(int ac, char **av, void  *group);
59int check_user(int ac, char **av, void *ustate);
60void edit_group(int op, char *group, char *type, char *member);
61int pr_try();
62void check_afs(void);
63int moira_connect(void);
64int moira_disconnect(void);
65
66/* libprot.a routines */
67extern int pr_Initialize();
68extern int pr_CreateUser();
69extern int pr_CreateGroup();
70extern int pr_DeleteByID();
71extern int pr_ChangeEntry();
72extern int pr_SetFieldsEntry();
73extern int pr_AddToGroup();
74extern int pr_RemoveUserFromGroup();
75extern int pr_SIdToName();
76
77static char tbl_buf[1024];
78static struct member {
79  int op;
80  char list[LIST_NAME_SIZE];
81  char type[IMEMBERS_MEMBER_TYPE_SIZE];
82  char member[MAX_FIELD_WIDTH];
83  struct member *next;
84} *member_head = NULL;
85
86static int mr_connections = 0;
87
88int main(int argc, char **argv)
89{
90  int beforec, afterc, i;
91  char *table, **before, **after;
92  struct rlimit rl;
93
94  getrlimit(RLIMIT_NOFILE, &rl);
95  for (i = rl.rlim_cur; i > 2; i--)
96    close(i);
97
98  whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]);
99
100  table = argv[1];
101  beforec = atoi(argv[2]);
102  before = &argv[4];
103  afterc = atoi(argv[3]);
104  after = &argv[4 + beforec];
105
106  setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
107
108  strcpy(tbl_buf, table);
109  strcat(tbl_buf, " (");
110  for (i = 0; i < beforec; i++)
111    {
112      if (i > 0)
113        strcat(tbl_buf, ",");
114      strcat(tbl_buf, before[i]);
115    }
116  strcat(tbl_buf, ")->(");
117  for (i = 0; i < afterc; i++)
118    {
119      if (i > 0)
120        strcat(tbl_buf, ",");
121      strcat(tbl_buf, after[i]);
122    }
123  strcat(tbl_buf, ")");
124
125  initialize_sms_error_table();
126  initialize_krb_error_table();
127
128  if (!strcmp(table, "users"))
129    do_user(before, beforec, after, afterc);
130  else if (!strcmp(table, "list"))
131    do_list(before, beforec, after, afterc);
132  else if (!strcmp(table, "imembers"))
133    do_member(before, beforec, after, afterc);
134  else if (!strcmp(table, "filesys"))
135    do_filesys(before, beforec, after, afterc);
136  else if (!strcmp(table, "quota"))
137    do_quota(before, beforec, after, afterc);
138
139  exit(0);
140}
141
142
143void do_user(char **before, int beforec, char **after, int afterc)
144{
145  int astate, bstate, auid, buid, code;
146  char *av[2];
147
148  auid = buid = astate = bstate = 0;
149  if (afterc > U_STATE)
150    astate = atoi(after[U_STATE]);
151  if (beforec > U_STATE)
152    bstate = atoi(before[U_STATE]);
153  if (afterc > U_UID)
154    auid = atoi(after[U_UID]);
155  if (beforec > U_UID)
156    buid = atoi(before[U_UID]);
157
158  /* We consider "half-registered" users to be active */
159  if (astate == 2)
160    astate = 1;
161  if (bstate == 2)
162    bstate = 1;
163
164  if (astate != 1 && bstate != 1)               /* inactive user */
165    return;
166
167  if (astate == bstate && auid == buid &&
168      !strcmp(before[U_NAME], after[U_NAME]))
169    /* No AFS related attributes have changed */
170    return;
171
172  if (astate == bstate)
173    {
174      /* Only a modify has to be done */
175      com_err(whoami, 0, "Changing user %s (uid %d) to %s (uid %d)",
176              before[U_NAME], buid, after[U_NAME], auid);
177
178      code = pr_try(pr_ChangeEntry, before[U_NAME], after[U_NAME], &auid, "");
179      if (code)
180        {
181          critical_alert(whoami, "incremental",
182                         "Couldn't change user %s (id %d) to %s (id %d): %s",
183                         before[U_NAME], buid, after[U_NAME], auid,
184                         error_message(code));
185        }
186      return;
187    }
188  if (bstate == 1)
189    {
190      com_err(whoami, 0, "Deleting user %s (uid %d)",
191              before[U_NAME], buid);
192
193      code = pr_try(pr_DeleteByID, buid);
194      if (code && code != PRNOENT)
195        {
196          critical_alert(whoami, "incremental", "Couldn't delete user %s (id %d): %s",
197                         before[U_NAME], buid, error_message(code));
198        }
199      return;
200    }
201  if (astate == 1)
202    {
203      com_err(whoami, 0, "%s user %s (uid %d)",
204              ((bstate != 0) ? "Reactivating" : "Creating"),
205              after[U_NAME], auid);
206
207      code = pr_try(pr_CreateUser, after[U_NAME], &auid);
208      /* if we get PRIDEXIST, it's only an error if the username
209         doesn't match (otherwise it just means the user was deleted
210         from Moira but not AFS */
211      if (code == PRIDEXIST)
212        {
213          char ename[PR_MAXNAMELEN];
214
215          if (pr_try(pr_SIdToName, auid, ename) == 0 &&
216              !strcmp(after[U_NAME], ename))
217            return;
218        }
219      if (code)
220        {
221          critical_alert(whoami, "incremental", "Couldn't create user %s (id %d): %s",
222                         after[U_NAME], auid, error_message(code));
223          return;
224        }
225
226      if (bstate != 0)
227        {
228          /* Reactivating a user; get his group list */
229          code = moira_connect();
230          if (code)
231            {
232              critical_alert(whoami, "incremental", "Error contacting Moira server "
233                             "to retrieve grouplist of user %s: %s",
234                             after[U_NAME], error_message(code));
235              return;
236            }
237          av[0] = "ruser";
238          av[1] = after[U_NAME];
239          code = mr_query("get_lists_of_member", 2, av, add_user_lists,
240                          after[U_NAME]);
241          if (code && code != MR_NO_MATCH)
242            {
243              critical_alert(whoami, "incremental",
244                             "Couldn't retrieve membership of user %s: %s",
245                             after[U_NAME], error_message(code));
246            }
247          moira_disconnect();
248        }
249      return;
250    }
251}
252
253
254void do_list(char **before, int beforec, char **after, int afterc)
255{
256  int agid, bgid;
257  int ahide, bhide;
258  int code, id;
259  char g1[PR_MAXNAMELEN], g2[PR_MAXNAMELEN];
260  char *av[2];
261
262  agid = bgid = 0;
263  if (beforec > L_GID && atoi(before[L_ACTIVE]) && atoi(before[L_GROUP]))
264    {
265      bgid = atoi(before[L_GID]);
266      bhide = atoi(before[L_HIDDEN]);
267    }
268  if (afterc > L_GID && atoi(after[L_ACTIVE]) && atoi(after[L_GROUP]))
269    {
270      agid = atoi(after[L_GID]);
271      ahide = atoi(after[L_HIDDEN]);
272    }
273
274  if (agid == 0 && bgid == 0)                   /* Not active groups */
275    return;
276
277  if (agid && bgid)
278    {
279      if (strcmp(after[L_NAME], before[L_NAME]))
280        {
281          /* Only a modify is required */
282          strcpy(g1, "system:");
283          strcpy(g2, "system:");
284          strcat(g1, before[L_NAME]);
285          strcat(g2, after[L_NAME]);
286          id = -agid;
287
288          com_err(whoami, 0, "Changing group %s (gid %d) to %s (gid %d)",
289                  before[L_NAME], bgid, after[L_NAME], agid);
290
291          code = pr_try(pr_ChangeEntry, g1, g2, &id, "");
292          if (code)
293            {
294              critical_alert(whoami, "incremental", "Couldn't change group %s (id %d) "
295                             "to %s (id %d): %s", before[L_NAME], -bgid,
296                             after[L_NAME], -agid, error_message(code));
297            }
298        }
299      if (ahide != bhide)
300        {
301          com_err(whoami, 0, "Making group %s (gid %d) %s", after[L_NAME],
302                  agid, (ahide ? "hidden" : "visible"));
303          code = pr_try(pr_SetFieldsEntry, -agid, PR_SF_ALLBITS,
304                        (ahide ? PRP_STATUS_ANY : PRP_GROUP_DEFAULT) >>
305                        PRIVATE_SHIFT, 0 /*ngroups*/, 0 /*nusers*/);
306          if (code)
307            {
308              critical_alert(whoami, "incremental",
309                             "Couldn't set flags of group %s: %s",
310                             after[L_NAME], error_message(code));
311            }
312        }
313      return;
314    }
315  if (bgid)
316    {
317      com_err(whoami, 0, "Deleting group %s (gid %d)", before[L_NAME], bgid);
318      code = pr_try(pr_DeleteByID, -bgid);
319      if (code && code != PRNOENT)
320        {
321          critical_alert(whoami, "incremental",
322                         "Couldn't delete group %s (id %d): %s",
323                         before[L_NAME], -bgid, error_message(code));
324        }
325      return;
326    }
327  if (agid)
328    {
329      strcpy(g1, "system:");
330      strcat(g1, after[L_NAME]);
331      strcpy(g2, "system:administrators");
332      id = -agid;
333      com_err(whoami, 0, "Creating %s group %s (gid %d)",
334              (ahide ? "hidden" : "visible"), after[L_NAME], agid);
335      code = pr_try(pr_CreateGroup, g1, g2, &id);
336      if (code == PRIDEXIST)
337        {
338          char ename[PR_MAXNAMELEN];
339
340          if (pr_try(pr_SIdToName, -agid, ename) == 0 && !strcmp(g1, ename))
341            return;
342        }
343      if (code)
344        {
345          critical_alert(whoami, "incremental", "Couldn't create group %s (id %d): %s",
346                         after[L_NAME], id, error_message(code));
347          return;
348        }
349      if (ahide)
350        {
351          code = pr_try(pr_SetFieldsEntry, -agid, PR_SF_ALLBITS,
352                        (ahide ? PRP_STATUS_ANY : PRP_GROUP_DEFAULT) >>
353                        PRIVATE_SHIFT, 0 /*ngroups*/, 0 /*nusers*/);
354          if (code)
355            {
356              critical_alert(whoami, "incremental",
357                             "Couldn't set flags of group %s: %s",
358                             after[L_NAME], error_message(code));
359            }
360        }
361
362      /* We need to make sure the group is properly populated */
363      if (beforec < L_ACTIVE)
364        return;
365
366      code = moira_connect();
367      if (code)
368        {
369          critical_alert(whoami, "incremental",
370                         "Error contacting Moira server to resolve %s: %s",
371                         after[L_NAME], error_message(code));
372          return;
373        }
374      av[0] = after[L_NAME];
375      code = mr_query("get_end_members_of_list", 1, av,
376                      add_list_members, after[L_NAME]);
377      if (code)
378        {
379          critical_alert(whoami, "incremental",
380                         "Couldn't retrieve full membership of list %s: %s",
381                         after[L_NAME], error_message(code));
382        }
383      moira_disconnect();
384      return;
385    }
386}
387
388
389
390#define LM_EXTRA_ACTIVE   (LM_END)
391#define LM_EXTRA_PUBLIC   (LM_END+1)
392#define LM_EXTRA_HIDDEN   (LM_END+2)
393#define LM_EXTRA_MAILLIST (LM_END+3)
394#define LM_EXTRA_GROUP    (LM_END+4)
395#define LM_EXTRA_GID      (LM_END+5)
396#define LM_EXTRA_END      (LM_END+6)
397
398void do_member(char **before, int beforec, char **after, int afterc)
399{
400  if (afterc)
401    {
402      if (afterc < LM_EXTRA_END)
403        return;
404      else
405        {
406          if (!atoi(after[LM_EXTRA_ACTIVE]) || !atoi(after[LM_EXTRA_GROUP]))
407            return;
408        }
409
410      edit_group(1, after[LM_LIST], after[LM_TYPE], after[LM_MEMBER]);
411    }
412  else if (beforec)
413    {
414      if (beforec < LM_EXTRA_END)
415        return;
416      else
417        {
418          if (!atoi(before[LM_EXTRA_ACTIVE]) || !atoi(before[LM_EXTRA_GROUP]))
419            return;
420        }
421      edit_group(0, before[LM_LIST], before[LM_TYPE], before[LM_MEMBER]);
422    }
423}
424
425
426void do_filesys(char **before, int beforec, char **after, int afterc)
427{
428  char cmd[1024];
429  int acreate, atype, bcreate, btype, fsltypelen, fsnamelen;
430  char *tmp;
431
432  if (afterc < FS_CREATE)
433    atype = acreate = 0;
434  else
435    {
436      atype = !strcmp(after[FS_TYPE], "AFS");
437      acreate = atoi(after[FS_CREATE]);
438      /* If the lockername ends in ".lockertype" strip that.
439       * eg.  the SITE locker "foo.site" becomes just "foo"
440       */
441      fsltypelen = strlen(after[FS_L_TYPE]);
442      fsnamelen = strlen(after[FS_NAME]);
443      tmp = (after[FS_NAME] + fsnamelen - fsltypelen);
444      if (!strcasecmp(tmp, after[FS_L_TYPE]) && *(tmp-1) == '.')
445        *(tmp-1) = '\0';
446    }
447
448  if (beforec < FS_CREATE)
449    {
450      if (acreate == 0 || atype == 0)
451        return;
452
453      /* new locker creation */
454      sprintf(cmd, "%s/perl -I%s %s/afs_create.pl %s %s %s %s %s %s",
455              BIN_DIR, BIN_DIR, BIN_DIR,
456              after[FS_NAME], after[FS_L_TYPE], after[FS_MACHINE],
457              after[FS_PACK], after[FS_OWNER], after[FS_OWNERS]);
458      run_cmd(cmd);
459      return;
460    }
461  else
462    {
463      /* If the lockername ends in ".lockertype" strip that.
464       * eg.  the SITE locker "foo.site" becomes just "foo"
465       */
466      fsltypelen = strlen(before[FS_L_TYPE]);
467      fsnamelen = strlen(before[FS_NAME]);
468      tmp = (before[FS_NAME] + fsnamelen - fsltypelen);
469      if (!strcasecmp(tmp, before[FS_L_TYPE]) && *(tmp-1) == '.')
470        *(tmp-1) = '\0';
471    }
472
473  btype = !strcmp(before[FS_TYPE], "AFS");
474  bcreate = atoi(before[FS_CREATE]);
475  if (afterc < FS_CREATE)
476    {
477      if (btype && bcreate)
478        critical_alert(whoami, "incremental", "Cannot delete AFS filesystem %s: "
479                       "Operation not supported", before[FS_NAME]);
480      return;
481    }
482
483  if (!acreate)
484    return;
485
486  /* Are we dealing with AFS lockers (could be type ERR lockers) */
487  if (!atype && !btype)
488    {
489      if (strcmp(before[FS_TYPE], "ERR") || strcmp(after[FS_TYPE], "ERR"))
490        return;
491    }
492
493  /* By now, we know we are simply changing AFS filesystem attributes.
494   * Operations supported:
495   *    Name change:  rename/remount
496   *    Path change:  remount
497   *    Type change:  ERR<-->AFS
498   */
499
500#if 0
501  if (strcmp(before[FS_OWNER], after[FS_OWNER]) ||
502      strcmp(before[FS_OWNERS], after[FS_OWNERS]))
503    {
504      critical_alert(whoami, "incremental",
505                     "Cannot change ownership of filesystem %s: Operation not yet supported",
506                     after[FS_NAME]);
507    }
508#endif
509
510  sprintf(cmd, "%s/perl -I%s %s/afs_rename.pl %s %s %s %s %s %s %s %s %s %s",
511          BIN_DIR, BIN_DIR, BIN_DIR,
512          before[FS_NAME], before[FS_MACHINE], before[FS_TYPE],
513          before[FS_L_TYPE], before[FS_PACK],
514          after[FS_NAME], after[FS_MACHINE], after[FS_TYPE],
515          after[FS_L_TYPE], after[FS_PACK]);
516  run_cmd(cmd);
517}
518
519
520void do_quota(char **before, int beforec, char **after, int afterc)
521{
522  char cmd[1024];
523
524  if (afterc < Q_DIRECTORY || strcmp("ANY", after[Q_TYPE]) ||
525      strncmp("/afs/", after[Q_DIRECTORY], 5))
526    return;
527
528  sprintf(cmd, "%s/perl -I%s %s/afs_quota.pl %s %s",
529          BIN_DIR, BIN_DIR, BIN_DIR,
530          after[Q_DIRECTORY], after[Q_QUOTA]);
531  run_cmd(cmd);
532  return;
533}
534
535
536void run_cmd(char *cmd)
537{
538  int success=0, tries=0;
539
540  check_afs();
541
542  while (success == 0 && tries < 2)
543    {
544      if (tries++)
545        sleep(90);
546      com_err(whoami, 0, "Executing command: %s", cmd);
547      if (system(cmd) == 0)
548        success++;
549    }
550  if (!success)
551    critical_alert(whoami, "incremental", "failed command: %s", cmd);
552}
553
554
555int add_user_lists(int ac, char **av, void *user)
556{
557  if (atoi(av[L_ACTIVE]) && atoi(av[L_GROUP]))  /* active group ? */
558    edit_group(1, av[L_NAME], "USER", user);
559  return 0;
560}
561
562
563int add_list_members(int ac, char **av, void *group)
564{
565  edit_group(1, group, av[0], av[1]);
566  return 0;
567}
568
569int check_user(int ac, char **av, void *ustate)
570{
571  *(int *)ustate = atoi(av[U_STATE]);
572  return 0;
573}
574
575
576void edit_group(int op, char *group, char *type, char *member)
577{
578  char *p = 0;
579  char buf[PR_MAXNAMELEN];
580  int code, ustate;
581  static char *local_realm = NULL;
582  struct member *m;
583  krb5_context context = NULL;
584
585  /* The following KERBEROS code allows for the use of entities
586   * user@foreign_cell.
587   */
588  if (!local_realm)
589    {
590      code = krb5_init_context(&context);
591      if (code)
592        goto out;
593
594      code = krb5_get_default_realm(context, &local_realm);
595      if (code)
596        goto out;
597    }
598
599  if (!strcmp(type, "KERBEROS"))
600    {
601      p = strchr(member, '@');
602      if (p && !strcasecmp(p+1, local_realm))
603        *p = 0;
604    }
605  else if (strcmp(type, "USER"))
606    return;                                     /* invalid type */
607
608  /* Cannot risk doing another query during a callback */
609  /* We could do this simply for type USER, but eventually this may also
610   * dynamically add KERBEROS types to the prdb, and we will need to do
611   * a query to look up the uid of the null-instance user */
612  if (mr_connections)
613    {
614      m = malloc(sizeof(struct member));
615      if (!m)
616        {
617          critical_alert(whoami, "incremental", "Out of memory");
618          exit(1);
619        }
620      m->op = op;
621      strcpy(m->list, group);
622      strcpy(m->type, type);
623      strcpy(m->member, member);
624      m->next = member_head;
625      member_head = m;
626      return;
627    }
628
629  strcpy(buf, "system:");
630  strcat(buf, group);
631  com_err(whoami, 0, "%s %s %s group %s", (op ? "Adding" : "Removing"), member,
632          (op ? "to" : "from"), group);
633  code = pr_try(op ? pr_AddToGroup : pr_RemoveUserFromGroup, member, buf);
634  if (code)
635    {
636      if (op==1 && code == PRIDEXIST)
637        return; /* Already added */
638
639      if (code == PRNOENT)
640        {                       /* Something is missing */
641          if (op == 0)
642            return;                     /* Already deleted */
643          if (!strcmp(type, "KERBEROS"))        /* Special instances; ok */
644            return;
645
646          /* Check whether the member being added is an active user */
647          code = moira_connect();
648          if (!code)
649            {
650              code = mr_query("get_user_by_login", 1, &member,
651                              check_user, (char *) &ustate);
652            }
653          if (code)
654            {
655              critical_alert(whoami, "incremental", "Error contacting Moira server "
656                             "to lookup user %s: %s", member,
657                             error_message(code));
658            }
659
660          /* We don't use moira_disconnect()
661           * because we may already be in the routine.
662           */
663          mr_disconnect();
664          mr_connections--;
665
666          if (!code && ustate!=1 && ustate!=2)
667            return; /* inactive user */
668          code = PRNOENT;
669        }
670
671    out:
672      if (context)
673        krb5_free_context(context);
674      if (local_realm)
675        free(local_realm);
676
677      critical_alert(whoami, "incremental", "Couldn't %s %s %s %s: %s",
678                     op ? "add" : "remove", member,
679                     op ? "to" : "from", buf,
680                     error_message(code));
681    }
682}
683
684
685int pr_try(int (*fn)(), char *a1, char *a2, char *a3, char *a4, char *a5,
686            char *a6, char *a7, char *a8)
687{
688  static int initd = 0;
689  int code;
690  int tries = 0;
691
692  check_afs();
693
694  if (initd)
695    code = pr_Initialize(0, AFSCONF_CLIENTNAME, 0);
696  else
697    {
698      code = 0;
699      initd = 1;
700    }
701  if (!code)
702    code = pr_Initialize(1, AFSCONF_CLIENTNAME, 0);
703  if (code)
704    {
705      critical_alert(whoami, "incremental", "Couldn't initialize libprot: %s",
706                     error_message(code));
707      return code;
708    }
709
710  sleep(1);                                     /* give ptserver room */
711
712  while ((code = (*fn)(a1, a2, a3, a4, a5, a6, a7, a8)))
713    {
714      if (++tries > 2)
715        break;          /* 3 tries */
716
717      if (code == UNOQUORUM)
718        sleep(90);
719      else if (code == PRPERM)
720        system("/usr/bin/aklog");
721      else
722        sleep(15);
723
724      /* Re-initialize the prdb connection */
725      code = pr_Initialize(0, AFSCONF_CLIENTNAME, 0);
726      if (!code)
727        code = pr_Initialize(1, AFSCONF_CLIENTNAME, 0);
728      if (code)
729        {
730          critical_alert(whoami, "incremental", "Couldn't re-initialize libprot: %s",
731                         error_message(code));
732          initd = 0;                            /* we lost */
733          break;
734        }
735    }
736  return code;
737}
738
739
740void check_afs(void)
741{
742  int i;
743
744  for (i = 0; file_exists(STOP_FILE); i++)
745    {
746      if (i > 30)
747        {
748          critical_alert(whoami, "incremental",
749                         "AFS incremental failed (%s exists): %s",
750                         STOP_FILE, tbl_buf);
751          exit(1);
752        }
753      sleep(60);
754    }
755}
756
757
758int moira_connect(void)
759{
760  int code;
761
762  if (!mr_connections++)
763    {
764      struct utsname uts;
765      uname(&uts);
766      code = mr_connect(uts.nodename);
767      if (!code)
768        code = mr_krb5_auth("afs.incr");
769      return code;
770    }
771  return 0;
772}
773
774int moira_disconnect(void)
775{
776  struct member *m;
777
778  if (!--mr_connections)
779    {
780      mr_disconnect();
781      while ((m = member_head))
782        {
783          edit_group(m->op, m->list, m->type, m->member);
784          member_head = m->next;
785          free(m);
786        }
787    }
788  return 0;
789}
Note: See TracBrowser for help on using the repository browser.