]> andersk Git - moira.git/blobdiff - afssync/sync.pc
Handle null instance KERBEROS list members.
[moira.git] / afssync / sync.pc
index 0ed44c886a71dd5d1c1b39fd403cb0e9db72dba6..677bc1859dfe0b43df21ea495c83c305c0ccc011 100644 (file)
@@ -161,7 +161,7 @@ do_groups()
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char name[33], string[129];
-    int gid, id, lid, hide, ustatus;
+    int gid, id, lid, hide, ustatus, root_flag;
     EXEC SQL END DECLARE SECTION;
 
     long status, pos;
@@ -260,19 +260,28 @@ do_groups()
                    FROM strings WHERE string_id = :id;
 
                aid = 0;
+               root_flag = 0;
                strtrim(string);
 
-               if (p = (char *)index(string, '@')) {
+               if (p = strchr(string, '@')) 
+                 {
                    *p = 0;
-                   if (strcmp(p+1, "ATHENA.MIT.EDU")) aid = -1;
-               } else aid = -1;
-
-               if ((p = (char *)index(string, '.')) && (p-string) < 9 &&
-                   !strcmp(p+1, "root"))
-               {
+                   if (strcmp(p+1, "ATHENA.MIT.EDU")) 
+                     aid = -1;
+                 } 
+               else aid = -1;
+
+               p = strchr(string, '.');
+               if ((!p) && (strlen(string) < 9))
+                 strcpy(name, string);
+               else if ((p-string) < 9 && !strcmp(p+1, "root"))
+                 {
                    strncpy(name, string, p-string);
                    name[p-string] = 0;
-               } else aid = -1;
+                   root_flag = 1;
+                 }
+               else
+                 aid = -1;
 
                if (aid == 0) {
                    EXEC SQL DECLARE k_cursor2 CURSOR FOR
@@ -281,10 +290,18 @@ do_groups()
                        WHERE login = :name
                        ORDER BY unix_uid;
                    EXEC SQL OPEN k_cursor2;
-                   while (1) {
-                       if (sqlca.sqlcode) break;
-                       EXEC SQL FETCH k_cursor2 INTO :lid, :ustatus;
-                       if (ustatus==1 || ustatus==2) aid = lid+65536;
+                   while (1) 
+                   {
+                     if (sqlca.sqlcode) 
+                       break;
+                     EXEC SQL FETCH k_cursor2 INTO :lid, :ustatus;
+                     if (ustatus==1 || ustatus==2)
+                         {
+                           if (root_flag == 1)
+                             aid = lid+65536;
+                           else
+                             aid = lid;
+                         }
                    }
                    EXEC SQL CLOSE k_cursor2;
                }
This page took 0.8563 seconds and 4 git commands to generate.