]> andersk Git - moira.git/blobdiff - gen/winad.pc
Command line printer manipulation client, and build goo.
[moira.git] / gen / winad.pc
index 0db5020b643d84e36303b7aa3145d955f7e2f35e..48582d8ad6bb1fb6fe9547bb4876acabbcf38611 100644 (file)
@@ -86,6 +86,8 @@ int do_user(void)
   int users_id, unix_uid, status;
   char type[FILESYS_TYPE_SIZE];
   char name[FILESYS_NAME_SIZE];
+  char homedir[USERS_WINHOMEDIR_SIZE];
+  char profiledir[USERS_WINPROFILEDIR_SIZE];
   int fid;
   EXEC SQL END DECLARE SECTION;
 
@@ -100,75 +102,97 @@ int do_user(void)
   }
 
   EXEC SQL DECLARE u_cursor CURSOR FOR
-    SELECT users_id, login, unix_uid, status, clearid
+    SELECT users_id, login, unix_uid, status, clearid, winhomedir,
+    winprofiledir
     FROM users
     ORDER BY users_id;
   EXEC SQL OPEN u_cursor;
   while (1)
     {
       EXEC SQL FETCH u_cursor INTO :users_id, :login, :unix_uid, :status,
-:mit_id;
+:mit_id, :homedir, :profiledir;
       if (sqlca.sqlcode)
              break;
       strtrim(login);
       strtrim(mit_id);
-      
-      EXEC SQL SELECT filsys_id into :fid
-        FROM filesys
-        WHERE lockertype = 'HOMEDIR' 
-        AND label = :login
-        AND type = 'FSGROUP';
+      strtrim(homedir);
+      strtrim(profiledir);
+
+      if (strcmp(mit_id, "") == 0)
+       strcpy(mit_id, "0");
+
+      if (strcasecmp(homedir, "[AFS]") == 0 || strcasecmp(profiledir,
+                                                         "[AFS]") == 0)
+       {
+         EXEC SQL SELECT filsys_id into :fid
+           FROM filesys
+           WHERE lockertype = 'HOMEDIR' 
+           AND label = :login
+           AND type = 'FSGROUP';
+         
+         if (sqlca.sqlcode == 0)
+           {
+             EXEC SQL DECLARE f_cursor CURSOR FOR
+               SELECT type, name 
+               FROM filesys a, fsgroup b
+               WHERE a.filsys_id=b.filsys_id 
+               AND b.group_id=:fid
+               ORDER by key;
+             
+             EXEC SQL OPEN f_cursor;
+             
+             EXEC SQL FETCH f_cursor INTO :type, :name;
+             
+             if (sqlca.sqlcode == 0)
+               {
+                 strtrim(type);
+                 strtrim(name);
+               }
+             else
+               {
+                 strcpy(type, "NONE");
+                 strcpy(name, "NONE");
+               }
+             
+             EXEC SQL CLOSE f_cursor;
+           }
+
+         else
+           {
+             EXEC SQL SELECT type, name into :type, :name
+               FROM filesys
+               WHERE lockertype = 'HOMEDIR' 
+               AND label=:login;
+             
+             if (sqlca.sqlcode == 0)
+               {
+                 strtrim(type);
+                 strtrim(name);
+               }
+             else
+               {
+                 strcpy(type, "NONE");
+                 strcpy(name, "NONE");
+               }
+           }
+         if (strcasecmp(type, "AFS") != 0)
+           strcpy(name, "[LOCAL]");
 
-      if (sqlca.sqlcode == 0)
-      {
-        EXEC SQL DECLARE f_cursor CURSOR FOR
-          SELECT type, name 
-          FROM filesys a, fsgroup b
-          WHERE a.filsys_id=b.filsys_id 
-          AND b.group_id=:fid
-          ORDER by key;
-      
-        EXEC SQL OPEN f_cursor;
-      
-        EXEC SQL FETCH f_cursor INTO :type, :name;
-
-        if (sqlca.sqlcode == 0)
-        {
-          strtrim(type);
-          strtrim(name);
-        }
-        else
-        {
-          strcpy(type, "NONE");
-          strcpy(name, "NONE");
-        }
-
-        EXEC SQL CLOSE f_cursor;
-      }
-       
+       }
 
-      else
-      {
-        EXEC SQL SELECT type, name into :type, :name
-          FROM filesys
-          WHERE lockertype = 'HOMEDIR' 
-          AND label=:login;
-
-        if (sqlca.sqlcode == 0)
-        {
-          strtrim(type);
-          strtrim(name);
-        }
-        else
-        {
-          strcpy(type, "NONE");
-          strcpy(name, "NONE");
-        }
-      }
+      if (strcasecmp(homedir, "[AFS]") == 0)
+       strcpy(homedir, name);
+
+      if (strcasecmp(profiledir, "[AFS]") == 0)
+       {
+         strcpy(profiledir, name);
+         if (strcasecmp(name, "[LOCAL]"))
+           strcat(profiledir, "/.winprofile");
+       }
   
       fprintf(fout, "%d %s %d %d %s %s %s\n",
                      users_id, login, unix_uid, status, mit_id, 
-          type, name);
+             homedir, profiledir);
     }
   
   if (sqlca.sqlcode < 0)
@@ -198,7 +222,7 @@ int do_groups(void)
   char acltype[LIST_ACL_TYPE_SIZE];
   int aclid;
   char aclname[STRINGS_STRING_SIZE];
-  int list_id, active, maillist, grouplist;
+  int list_id, active, publicflg, hidden, maillist, grouplist;
   EXEC SQL END DECLARE SECTION;
 
   sprintf(foutf, "%s/wingroup.db", winad_dir);
@@ -212,16 +236,15 @@ int do_groups(void)
   }
 
   EXEC SQL DECLARE l_cursor CURSOR FOR
-    SELECT list_id, name, active, maillist, grouplist, description,
-acl_type, acl_id
+    SELECT list_id, name, active, publicflg, hidden, maillist,
+    grouplist, description, acl_type, acl_id
     FROM list
     ORDER BY list_id;
   EXEC SQL OPEN l_cursor;
   while (1)
     {
-      EXEC SQL FETCH l_cursor INTO :list_id, :listname, :active, :maillist,
-:grouplist,
-            :description, :acltype, :aclid;
+      EXEC SQL FETCH l_cursor INTO :list_id, :listname, :active, :publicflg,
+       :hidden, :maillist, :grouplist, :description, :acltype, :aclid;
       
       if (sqlca.sqlcode)
              break;
@@ -253,9 +276,9 @@ acl_type, acl_id
       
       strtrim(aclname);
        
-      fprintf(fout, "%d %s %d %d %d %s %s %s\n",
-                   list_id, listname, active, maillist, grouplist, acltype, aclname,
-description);
+      fprintf(fout, "%d %s %d %d %d %d %d %s %s %s\n",
+                   list_id, listname, active, publicflg, hidden, maillist,
+             grouplist, acltype, aclname, description);
        }
 
   if (sqlca.sqlcode < 0)
@@ -352,8 +375,29 @@ int do_groupmembership(void)
         db_error(sqlca.sqlcode);
 
       EXEC SQL CLOSE csr002;
+
+      /* get all the machines */
+      EXEC SQL DECLARE csr003 CURSOR FOR
+       SELECT i.member_type, m.name
+       FROM machine m, imembers i
+       WHERE i.list_id = :list_id AND i.member_type = 'MACHINE'
+       AND i.member_id = m.mach_id
+       ORDER BY m.name;
+
+      EXEC SQL OPEN csr003;
+      while (1)
+       {
+         EXEC SQL FETCH csr003 into :member_type, :member_name;
+         if (sqlca.sqlcode)
+           break;
+         fprintf(fout, "%d %s %s\n", list_id, member_type, member_name);
        }
 
+      if (sqlca.sqlcode < 0)
+       db_error(sqlca.sqlcode);
+       EXEC SQL CLOSE csr003;
+    }
+
   if (sqlca.sqlcode < 0)
     db_error(sqlca.sqlcode);
 
This page took 0.040446 seconds and 4 git commands to generate.