[1644] in Moira

home help back first fref pref prev next nref lref last post

dbck support for memacls

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Sun Aug 13 06:24:18 2000

Message-Id: <200008131024.GAA07574@hodge-podge.mit.edu>
To: moiradev@MIT.EDU
Date: Sun, 13 Aug 2000 06:24:15 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>

	This patch implements the same checking we do for list owners
for list memacls.  The only interesting bit is in the new function
fix_list_memacl().  For fix_list_acl(), we make the list selfowned in
the event that it has a bad acl entry.  For memacls, I decided the
correct behavior was to set the memacl to NONE, since the lists owner
can still set an appropriate membership acl if one is desired.

Garry

Index: dbck.h
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/dbck/dbck.h,v
retrieving revision 1.12
diff -c -r1.12 dbck.h
*** dbck.h	2000/01/13 01:39:45	1.12
--- dbck.h	2000/08/13 10:08:40
***************
*** 69,76 ****
--- 69,78 ----
  struct list {
    char name[LIST_NAME_SIZE];
    char acl_type;
+   char memacl_type;
    int list_id;
    int acl_id;
+   int memacl_id;
    int modby;
    int members;
  };
Index: phase1.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/dbck/phase1.pc,v
retrieving revision 1.11
diff -c -r1.11 phase1.pc
*** phase1.pc	2000/03/23 07:50:15	1.11
--- phase1.pc	2000/08/13 10:10:16
***************
*** 703,719 ****
      out_of_mem("loading lists");
  
    EXEC SQL DECLARE csr108 CURSOR FOR
!     SELECT list_id, name, acl_id, acl_type, modby  FROM list
      ORDER BY list_id;
    EXEC SQL OPEN csr108;
    while (1)
      {
        EXEC SQL BEGIN DECLARE SECTION;
!       int list_id, acl_id, modby;
        char name[LIST_NAME_SIZE], acl_type[LIST_ACL_TYPE_SIZE];
        EXEC SQL END DECLARE SECTION;
  
!       EXEC SQL FETCH csr108 INTO :list_id, :name, :acl_id, :acl_type, :modby;
        if (sqlca.sqlcode)
  	break;
        l = malloc(sizeof(struct list));
--- 703,722 ----
      out_of_mem("loading lists");
  
    EXEC SQL DECLARE csr108 CURSOR FOR
!     SELECT list_id, name, acl_id, acl_type, memacl_id, memacl_type, modby
!     FROM list
      ORDER BY list_id;
    EXEC SQL OPEN csr108;
    while (1)
      {
        EXEC SQL BEGIN DECLARE SECTION;
!       int list_id, acl_id, memacl_id, modby;
        char name[LIST_NAME_SIZE], acl_type[LIST_ACL_TYPE_SIZE];
+       char memacl_type[LIST_ACL_TYPE_SIZE];
        EXEC SQL END DECLARE SECTION;
  
!       EXEC SQL FETCH csr108 INTO :list_id, :name, :acl_id, :acl_type, 
! 	:memacl_id, :memacl_type, :modby;
        if (sqlca.sqlcode)
  	break;
        l = malloc(sizeof(struct list));
***************
*** 722,727 ****
--- 725,732 ----
        strcpy(l->name, strtrim(name));
        l->acl_type = acl_type[0];
        l->acl_id = acl_id;
+       l->memacl_type = memacl_type[0];
+       l->memacl_id = memacl_id;
        l->list_id = list_id;
        l->modby = modby;
        l->members = 0;
Index: phase2.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/dbck/phase2.pc,v
retrieving revision 1.18
diff -c -r1.18 phase2.pc
*** phase2.pc	2000/03/23 07:50:15	1.18
--- phase2.pc	2000/08/13 10:20:15
***************
*** 49,54 ****
--- 49,55 ----
  int show_svc(void *id);
  void list_check(int id, void *list, void *hint);
  void fix_list_acl(int id);
+ void fix_list_memacl(int id);
  int show_member_list(void *id);
  int show_mem_user(void *id);
  int show_mem_list(void *id);
***************
*** 870,875 ****
--- 871,907 ----
  	}
        break;
      }
+ 
+   switch (l->memacl_type)
+     {
+     case 'L':
+       if (!hash_lookup(lists, l->memacl_id))
+ 	{
+ 	  printf("List %s has bad LIST memacl %d\n", l->name, l->memacl_id);
+ 	  if (single_fix("Patch", 1))
+ 	    fix_list_memacl(l->list_id);
+ 	}
+       break;
+     case 'U':
+       if (!hash_lookup(users, l->memacl_id))
+ 	{
+ 	  printf("List %s has bad USER acl %d\n", l->name, l->memacl_id);
+ 	  if (single_fix("Patch", 1))
+ 	    fix_list_memacl(l->list_id);
+ 	}
+       break;
+     case 'K':
+       l->memacl_id = maybe_fixup_unref_string(l->memacl_id, id, l->name,
+ 					      "list", "memacl_id", "list_id");
+ 	  if (!l->memacl_id)
+ 	    {
+ 	      printf("List %s has bad KERBEROS acl %d\n", l->name, 
+ 		     l->memacl_id);
+ 	      if (single_fix("Patch", 1))
+ 		fix_list_memacl(l->list_id);
+ 	    }
+ 	  break;
+     }
  }
  
  void fix_list_acl(int id)
***************
*** 879,884 ****
--- 911,932 ----
    EXEC SQL END DECLARE SECTION;
  
    EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
+     WHERE list_id = :iid;
+   rowcount = sqlca.sqlerrd[2];
+   if (rowcount > 0)
+     printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
+   else
+     printf("Not fixed\n");
+   modified("list");
+ }
+ 
+ void fix_list_memacl(int id)
+ {
+   EXEC SQL BEGIN DECLARE SECTION;
+   int rowcount, iid = (int)id;
+   EXEC SQL END DECLARE SECTION;
+ 
+   EXEC SQL UPDATE list SET memacl_id = 0, memacl_type = 'NONE'
      WHERE list_id = :iid;
    rowcount = sqlca.sqlerrd[2];
    if (rowcount > 0)

home help back first fref pref prev next nref lref last post