[1841] in Moira

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

change to winad.gen

daemon@ATHENA.MIT.EDU (Qing Dong)
Fri Aug 10 15:25:20 2001

Message-Id: <200108101925.PAA27109@melbourne-city-street.mit.edu>
Date: Fri, 10 Aug 2001 15:25:18 -0400
To: moiradev@mit.edu
From: Qing Dong <dongq@MIT.EDU>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

I made changes to winad.pc to include container info. Also change
all the blank field to "NONE". 

Thanks. 

Qing
 
Index: winad.pc
===================================================================
RCS file:
\\dongq-afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/gen/
winad.pc,v
retrieving revision 1.3
diff -c -r1.3 winad.pc
*** winad.pc	2001/07/20 21:15:31	1.3
--- winad.pc	2001/08/10 19:22:18
***************
*** 32,37 ****
--- 32,38 ----
  int do_user(void);
  int do_groups(void);
  int do_groupmembership(void);
+ int do_containers(void);
  
  int main(int argc, char **argv)
  {
***************
*** 53,58 ****
--- 54,60 ----
    changed = do_user();
    changed += do_groups();
    changed += do_groupmembership();
+   changed += do_containers();
   
    if (!changed)
    {
***************
*** 137,144 ****
          }
          else
          {
!           strcpy(type, "");
!           strcpy(name, "");
          }
  
          EXEC SQL CLOSE f_cursor;
--- 139,146 ----
          }
          else
          {
!           strcpy(type, "NONE");
!           strcpy(name, "NONE");
          }
  
          EXEC SQL CLOSE f_cursor;
***************
*** 159,166 ****
          }
          else
          {
!           strcpy(type, "");
!           strcpy(name, "");
          }
        }
    
--- 161,168 ----
          }
          else
          {
!           strcpy(type, "NONE");
!           strcpy(name, "NONE");
          }
        }
    
***************
*** 229,235 ****
        strtrim(acltype);
  
        
!       strcpy(aclname, "");
        if (strcmp(acltype, "LIST") == 0)
        {
          EXEC SQL SELECT name into :aclname
--- 231,237 ----
        strtrim(acltype);
  
        
!       strcpy(aclname, "NONE");
        if (strcmp(acltype, "LIST") == 0)
        {
          EXEC SQL SELECT name into :aclname
***************
*** 367,369 ****
--- 369,455 ----
    fix_file(foutf);
    return 1;
  }
+ 
+ int do_containers(void)
+ {
+   FILE *fout;
+   char foutf[MAXPATHLEN];
+   char foutft[MAXPATHLEN];
+   EXEC SQL BEGIN DECLARE SECTION;
+   char container_name[CONTAINERS_NAME_SIZE];
+   char acl_type[CONTAINERS_ACL_TYPE_SIZE];
+   char acl_name[STRINGS_STRING_SIZE];
+   char description[CONTAINERS_DESCRIPTION_SIZE];
+   int cnt_id;
+   int acl_id;
+   EXEC SQL END DECLARE SECTION;
+ 
+   sprintf(foutf, "%s/wincontainer.db", winad_dir);
+   sprintf(foutft, "%s~", foutf);
+ 
+   fout = fopen(foutft, "w");
+   if (!fout)
+   {
+     perror("cannot open wincontainer.db for write");
+     exit(MR_OCONFIG);
+   }
+ 
+   EXEC SQL DECLARE container_cursor CURSOR FOR
+     SELECT name, cnt_id, acl_type, acl_id, description
+     FROM containers
+     ORDER BY cnt_id, name;
+   EXEC SQL OPEN container_cursor;
+   while (1)
+     {
+       EXEC SQL FETCH container_cursor INTO :container_name, :cnt_id, 
+       :acl_type, :acl_id, :description ;
+       
+       if (sqlca.sqlcode)
+ 	      break;
+       
+       strtrim(container_name);
+       strtrim(acl_type);
+       strtrim(description);
+ 
+       strcpy(acl_name, "NONE");
+       if (strcmp(acl_type, "LIST") == 0)
+       {
+         EXEC SQL SELECT name into :acl_name
+         FROM list
+         WHERE list_id = :acl_id;
+       }
+       else if (strcmp(acl_type, "USER") == 0)
+       {
+         EXEC SQL SELECT login into :acl_name
+         FROM users
+         WHERE users_id = :acl_id;
+       }
+       else if (strcmp(acl_type, "KERBEROS") == 0)
+       {
+         EXEC SQL SELECT string into :acl_name
+         FROM strings
+         WHERE string_id = :acl_id;
+       }
+       
+       strtrim(acl_name);
+        
+       fprintf(fout, "%d,%s,%s,%s,%s\n",
+ 		    cnt_id, container_name, acl_type, acl_name,
+         description);
+ 	}
+   if (sqlca.sqlcode < 0)
+     db_error(sqlca.sqlcode);
+ 
+   EXEC SQL CLOSE container_cursor;
+   EXEC SQL COMMIT;
+ 
+   if (fclose(fout))
+   {
+     fprintf(stderr, "Unsuccessful file close of wincontainer.db\n");
+     exit(MR_CCONFIG);
+   }
+ 
+   fix_file(foutf);
+   return 1;
+ }
+ 



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