]> andersk Git - moira.git/blobdiff - server/qsupport.qc
update for use with new com_err library
[moira.git] / server / qsupport.qc
index ad0070fdedbaf14d09816d5f196f27b24c6a0f3f..ad4f988f763a3f9723fa4926a9cb6e945af75359 100644 (file)
@@ -20,6 +20,7 @@ static char *rcsid_qsupport_qc = "$Header$";
 
 
 extern char *whoami, *strsave();
+extern int ingres_errno, sms_errcode;
 
 
 /* Specialized Access Routines */
@@ -731,8 +732,8 @@ setup_ufil(q, argv)
 ##}
 
 
-/* setup_dfil: free any quota records associated with a filesystem
- * when it is deleted.
+/* setup_dfil: free any quota records and fsgroup info associated with
+ * a filesystem when it is deleted.  Also adjust the allocation numbers.
  */
 
 setup_dfil(q, argv, cl)
@@ -750,6 +751,8 @@ setup_dfil(q, argv, cl)
 ##     where n.nfsphys_id = fs.phys_id and fs.filsys_id = @id
 
 ##  repeat delete q where q.filsys_id = @id
+##  repeat delete fsgroup where fsgroup.filsys_id = @id
+##  repeat delete fsgroup where fsgroup.group_id = @id
     return(SMS_SUCCESS);
 ##}
 
@@ -1254,6 +1257,11 @@ followup_glin(q, sq, v, action, actarg, cl)
                strcpy(name, "???");
        } else if (!strcmp(type, "USER")) {
 ##         repeat retrieve (name = users.login) where users.users_id = @id
+##         inquire_equel(rowcount = "rowcount")
+           if (rowcount != 1)
+               strcpy(name, "???");
+       } else if (!strcmp(type, "KERBEROS")) {
+##         repeat retrieve (name = strings.string) where strings.string_id = @id
 ##         inquire_equel(rowcount = "rowcount")
            if (rowcount != 1)
                strcpy(name, "???");
@@ -1396,6 +1404,11 @@ followup_gzcl(q, sq, v, action, actarg, cl)
                  strcpy(name, "???");
            } else if (!strcmp(argv[i], "USER")) {
 ##             repeat retrieve (name = users.login) where users.users_id = @id
+##             inquire_equel(rowcount = "rowcount")
+               if (rowcount != 1)
+                 strcpy(name, "???");
+           } else if (!strcmp(argv[i], "KERBEROS")) {
+##             repeat retrieve (name = strings.string) where strings.string_id = @id
 ##             inquire_equel(rowcount = "rowcount")
                if (rowcount != 1)
                  strcpy(name, "???");
@@ -1457,6 +1470,11 @@ followup_gsha(q, sq, v, action, actarg, cl)
              strcpy(name, "???");
        } else if (!strcmp(argv[1], "USER")) {
 ##         repeat retrieve (name = users.login) where users.users_id = @id
+##         inquire_equel(rowcount = "rowcount")
+           if (rowcount != 1)
+             strcpy(name, "???");
+       } else if (!strcmp(argv[1], "KERBEROS")) {
+##         repeat retrieve (name = strings.string) where strings.string_id = @id
 ##         inquire_equel(rowcount = "rowcount")
            if (rowcount != 1)
              strcpy(name, "???");
@@ -1598,6 +1616,12 @@ get_list_info(q, aargv, cl, action, actarg)
        } else if (!strcmp(acl_type, "USER")) {
 ##         repeat retrieve (acl_name = users.#login)
 ##             where users.users_id = @acl_id
+##         inquire_equel(rowcount = "rowcount")
+           if (rowcount != 1)
+               strcpy(acl_name, "???");
+       } else if (!strcmp(acl_type, "KERBEROS")) {
+##         repeat retrieve (acl_name = strings.string)
+##             where strings.string_id = @acl_id
 ##         inquire_equel(rowcount = "rowcount")
            if (rowcount != 1)
                strcpy(acl_name, "???");
@@ -1646,7 +1670,8 @@ int get_ace_use(q, argv, cl, action, actarg)
 
     atype = argv[0];
     aid = *(int *)argv[1];
-    if (!strcmp(atype, "LIST") || !strcmp(atype, "USER")) {
+    if (!strcmp(atype, "LIST") || !strcmp(atype, "USER") ||
+       !strcmp(atype, "KERBEROS")) {
        return(get_ace_internal(atype, aid, action, actarg));
     }
 
@@ -1690,6 +1715,28 @@ int get_ace_use(q, argv, cl, action, actarg)
          found++;
     }
 
+    if (!strcmp(atype, "RKERBERO")) {
+##     range of m is members
+##     repeat retrieve (listid = m.list_id)
+##             where m.member_type = "KERBEROS" and m.member_id = @aid {
+           sq_save_data(sq, listid);
+##     }
+       /* get all the list_id's of containing lists */
+       while (sq_get_data(sq, &id)) {
+##         repeat retrieve (listid = m.list_id)
+##             where m.member_type = "LIST" and m.member_id = @id {
+             sq_save_unique_data(sq, listid);
+##         }
+         }
+       /* now process each one */
+       while (sq_get_data(sq, &id)) {
+           if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+             found++;
+       }
+       if (get_ace_internal("KERBEROS", aid, action, actarg) == SMS_SUCCESS)
+         found++;
+    }
+
     sq_destroy(sq);    
     if (!found) return(SMS_NO_MATCH);
     return(SMS_SUCCESS);
@@ -1795,7 +1842,8 @@ int get_lists_of_member(q, argv, cl, action, actarg)
     aid = *(int *)argv[1];
     if (!strcmp(atype, "LIST") ||
        !strcmp(atype, "USER") ||
-       !strcmp(atype, "STRING")) {
+       !strcmp(atype, "STRING") ||
+       !strcmp(atype, "KERBEROS")) {
       return(glom_internal(atype, aid, action, actarg));
     }
 
@@ -1861,6 +1909,28 @@ int get_lists_of_member(q, argv, cl, action, actarg)
          found++;
     }
 
+    if (!strcmp(atype, "RKERBERO")) {
+##     range of m is members
+##     repeat retrieve (listid = m.list_id)
+##             where m.member_type = "KERBEROS" and m.member_id = @aid {
+           sq_save_data(sq, listid);
+##     }
+       /* get all the list_id's of containing lists */
+       while (sq_get_data(sq, &id)) {
+##         repeat retrieve (listid = m.list_id)
+##             where m.member_type = "LIST" and m.member_id = @id {
+             sq_save_unique_data(sq, listid);
+##         }
+         }
+       /* now process each one */
+       while (sq_get_data(sq, &id)) {
+           if (glom_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+             found++;
+       }
+       if (glom_internal("KERBEROS", aid, action, actarg) == SMS_SUCCESS)
+         found++;
+    }
+
 ##  repeat replace tblstats (retrieves = tblstats.retrieves + 1)
 ##     where tblstats.#table = "members"
     sq_destroy(sq);    
@@ -1971,6 +2041,15 @@ get_members_of_list(q, argv, cl, action, actarg)
 ##             where m.#list_id = @list_id and m.member_type = "STRING"
 ##                   and m.member_id = strings.string_id
 ##             sort by #member_name
+##  {
+        (*action)(2, targv, actarg);
+##  }
+
+    targv[0] = "KERBEROS";
+##  repeat retrieve (member_name = strings.string)
+##             where m.#list_id = @list_id and m.member_type = "KERBEROS"
+##                   and m.member_id = strings.string_id
+##             sort by #member_name
 ##  {
         (*action)(2, targv, actarg);
 ##  }
@@ -2165,14 +2244,14 @@ register_user(q, argv, cl)
 
     /* check new login name */
 ##  repeat retrieve (flag = any(u.#login where u.#login = @login))
-    if (flag)
-      return(SMS_IN_USE);
+    if (ingres_errno) return(sms_errcode);
+    if (flag) return(SMS_IN_USE);
 ##  repeat retrieve (flag = any(l.#name where l.#name = @login))
-    if (flag)
-      return(SMS_IN_USE);
+    if (ingres_errno) return(sms_errcode);
+    if (flag) return(SMS_IN_USE);
 ##  repeat retrieve (flag = any(filesys.#label where filesys.#label = @login))
-    if (flag)
-      return(SMS_IN_USE);
+    if (ingres_errno) return(sms_errcode);
+    if (flag) return(SMS_IN_USE);
     com_err(whoami, 0, "new login name OK");
 
     /* choose place for pobox, put in mid */
@@ -2341,6 +2420,7 @@ validate_row(q, argv, v)
     /* look for the record */
 ##  range of rvar is table
 ##  retrieve (rowcount = count(rvar.name where qual))
+    if (ingres_errno) return(sms_errcode);
     if (rowcount == 0) return(SMS_NO_MATCH);
     if (rowcount > 1) return(SMS_NOT_UNIQUE);
     return(SMS_EXISTS);
@@ -2407,6 +2487,9 @@ validate_fields(q, argv, vo, n)
            status = SMS_EXISTS;
            break;
 
+       case V_LOCK:
+           status = lock_table(vo);
+           break;
        }
 
        if (status != SMS_EXISTS) return(status);
@@ -2471,9 +2554,11 @@ validate_id(argv, vo)
     idfield = vo->idfield;
     if (!strcmp(namefield, "uid")) {
 ##    retrieve (id = table.idfield) where table.namefield = int4(name)
+      if (ingres_errno) return(sms_errcode);
 ##    inquire_equel (rowcount = "rowcount")
     } else {
 ##    retrieve (id = table.idfield) where table.namefield = name
+      if (ingres_errno) return(sms_errcode);
 ##    inquire_equel (rowcount = "rowcount")
     }
     if (rowcount != 1) return(vo->error);
@@ -2501,6 +2586,7 @@ validate_name(argv, vo)
     }
 ##  retrieve (rowcount = countu(table.namefield 
 ##            where table.namefield = name))
+    if (ingres_errno) return(sms_errcode);
     return ((rowcount == 1) ? SMS_EXISTS : vo->error);
 ##}
 
@@ -2544,12 +2630,14 @@ struct valobj *vo;
        if (!strcmp(argv[vo->index], argv[vo->index - 1]))
          return(SMS_EXISTS);
 ##     retrieve (id = any(table.namefield where table.namefield = name))
+       if (ingres_errno) return(sms_errcode);
        if (id)
          return(vo->error);
        else
          return(SMS_EXISTS);
     }
 ##  retrieve (id = table.idfield) where table.namefield = name
+    if (ingres_errno) return(sms_errcode);
     if (id == -1 || id == *(int *)argv[vo->index - 1])
       return(SMS_EXISTS);
     else
@@ -2579,6 +2667,7 @@ validate_type(argv, vo)
 ##  repeat retrieve (exists = any(a.trans where a.name = @typename and
 ##                                   a.type = "TYPE" and
 ##                                   a.trans = @value))
+    if (ingres_errno) return(sms_errcode);
     return (exists ? SMS_EXISTS : vo->error);
 ##}
 
@@ -2606,6 +2695,7 @@ validate_typedata(q, argv, vo)
     /* get corresponding data type associated with field type name */
 ##  repeat retrieve (data_type = alias.trans) 
 ##         where alias.#name = @field_type and alias.type = "TYPEDATA"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel (rowcount = "rowcount")
     if (rowcount != 1) return(SMS_TYPE);
 
@@ -2669,6 +2759,26 @@ validate_typedata(q, argv, vo)
 ##}
 
 
+/* Lock the table named by the validation object */
+
+lock_table(vo)
+struct valobj *vo;
+##{
+##  char *table, *idfield;
+##  int rowcount;
+
+    table = vo->table;
+    idfield = vo->idfield;
+##  replace table (modtime = "now") where table.idfield = 0
+    if (ingres_errno) return(sms_errcode);
+##  inquire_equel (rowcount = "rowcount")
+    if (rowcount != 1)
+      return(vo->error);
+    else
+      return(SMS_EXISTS);
+##}
+
+
 /* This looks up a login name and returns the SMS internal ID.  It is used
  * by authenticate to put the users_id in the client structure.
  */
This page took 0.043828 seconds and 4 git commands to generate.