]> andersk Git - moira.git/blobdiff - server/qsupport.qc
separate access check from setup routine.
[moira.git] / server / qsupport.qc
index 3d8e43e69bb0647f00fe8beb2b742861cf0adb03..f28dc8a0f1622eb151f7c6f2a1c2a08580754da9 100644 (file)
@@ -6,10 +6,39 @@
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
  *
  *     $Log$
- *     Revision 1.12  1987-08-29 00:05:54  mike
- *     Fixed bug in check_nfs.
- *     Added code to upcasify machine names in validate_id.
+ *     Revision 1.18  1988-01-14 12:00:38  mar
+ *     separate access check from setup routine.
+ *     make get_query_need be more paranoid
  *
+Revision 1.17  88/01/04  12:09:00  mar
+fixup pobox access checking & make id assignment more paranoid (wesommer)
+
+Revision 1.16  87/11/12  18:16:56  wesommer
+Add support for delete_user_by_uid.
+Fix access_pop.
+Check a few return codes.
+
+Revision 1.15  87/09/11  15:31:58  wesommer
+add_user_group modified to side-effect the time for tbs for groups as 
+well as the other things.
+
+Revision 1.15  87/09/10  22:44:49  wesommer
+One more table needs to be modified when adding the user-group.
+
+Revision 1.14  87/09/04  17:50:03  mike
+Renamed delete_list_members to followup_delete_list.  New routine removes
+list from maillists and groups tables in addition to the members table.
+
+Added routines validate_label and validate_label_2 used in validating
+filesys labels for get_filesys and delete_filesys respectively.
+
+Revision 1.13  87/09/01  16:24:01  wesommer
+A list should be considered modified if its acl changes.
+
+Revision 1.12  87/08/29  00:05:54  mike
+Fixed bug in check_nfs.
+Added code to upcasify machine names in validate_id.
+
 Revision 1.11  87/08/28  14:55:45  mike
 Modified delete_locker to require only one argument, the login name.
 Modified get_groups_of_all_users and get_all_poboxes to disable INGRES
@@ -123,14 +152,15 @@ access_pop(q, argv, cl)
 ##  int exists;
 
     if (!bcmp(q->name, "add_pobox", 10) && !bcmp(argv[1], "POP", 4)) {
+       box = argv[3];
+       if (strcmp(cl->kname.name, box) != 0) return SMS_PERM;
+       
        users_id = *(int *)argv[0];
        mach_id = *(int *)argv[2];
-       box = argv[3];
+           
 ##      range of p is pobox
 ##      repeat retrieve (exists = any(p.#box where p.#users_id = @users_id
-##                                   and p.type = "POP" 
-##                                   and p.#mach_id = @mach_id
-##                                   and p.#box = @box))
+##                                   and p.type = "POP"))
        if (exists) return(SMS_EXISTS);
     }
 
@@ -226,19 +256,15 @@ access_maillist(q, argv, cl)
  **
  **/
 
-setup_add_group(q, argv, cl, access_check)
+setup_add_group(q, argv, cl)
     struct query *q;
     char *argv[];
     client *cl;
-    int access_check;
 ##{
 ##  int ngid;
 ##  int exists;
-    int status;
-
-    status = access_list(q, argv, cl);
-
-    if (status != SMS_SUCCESS || access_check) return(status);
+##  int rowcount;
+       int status;
 
 ##  range of g is groups
 ##  range of v is values
@@ -250,7 +276,9 @@ setup_add_group(q, argv, cl, access_check)
     }
 
 ##  repeat replace v (value = @ngid) where v.name = "gid"
-    return(SMS_SUCCESS);
+##  inquire_equel (rowcount = "rowcount")
+    if (rowcount != 1) return SMS_INGRES_ERR;
+    else return(SMS_SUCCESS);
 ##}
 \f
 /**
@@ -266,17 +294,14 @@ setup_add_group(q, argv, cl, access_check)
  **
  **/
 
-setup_add_user(q, argv, cl, access_check)
+setup_add_user(q, argv, cl)
     struct query *q;
     register char *argv[];
     client *cl;
-    int access_check;
 ##{
 ##  int nuid;
 ##  int exists;
 
-    if (access_check) return(SMS_SUCCESS);
-
     if (!bcmp(argv[1], "#", 2)) {
 ##      range of u is users
 ##      range of v is values
@@ -529,6 +554,7 @@ set_list_modtime_by_id(q, argv)
 
     list_id = *(int *)argv[0];
 ##  repeat replace list (modtime = "now") where list.#list_id = @list_id
+##  repeat replace list (modtime = "now") where list.#acl_id = @list_id
     return(SMS_SUCCESS);
 ##}
 
@@ -568,6 +594,7 @@ followup_amtl(q, argv)
     list_id = *(int *)argv[0];
 
 ##  repeat replace list (modtime = "now") where list.#list_id = @list_id
+##  repeat replace list (modtime = "now") where list.#acl_id = @list_id
 
     /* if query is not amtl or if member_type is not LIST then return */
     if (bcmp(q->shortname, "amtl", 4) || bcmp(argv[1], "LIST", 4)) 
@@ -772,19 +799,16 @@ add_new_quota(q, argv)
     return(SMS_SUCCESS);
 ##}
 
-delete_current_quota(q, argv, cl, access_check)
+delete_current_quota(q, argv, cl)
     struct query *q;
     register char *argv[];
     client *cl;
-    int access_check;
 ##{
 ##  int mach_id;
 ##  int users_id;
 ##  char *device;
 ##  int quota;
 
-    if (access_check) return(SMS_SUCCESS);
-
     mach_id = *(int *)argv[0];
     device = argv[1];
     users_id = *(int *)argv[2];
@@ -876,8 +900,9 @@ followup_usha(q, argv)
 ##}
 \f
 /**
- ** delete_list_members - called after the delete_list query to clean up
- **                      members table.
+ ** followup_delete_list - called after the delete_list query to clean up
+ **                       members table; also deletes list from maillist
+ **                        and groups tables.
  **
  ** Inputs: argv[0] - list_id
  **
@@ -887,7 +912,7 @@ followup_usha(q, argv)
  **
  **/
 
-delete_list_members(q, argv)
+followup_delete_list(q, argv)
     struct query *q;
     register char *argv[];
 ##{
@@ -922,6 +947,8 @@ delete_list_members(q, argv)
     sq_destroy(sq);
 
 ##  repeat delete m where m.#list_id = @list_id
+##  repeat delete maillists where maillists.#list_id = @list_id
+##  repeat delete groups where groups.#list_id = @list_id
 
     return(SMS_SUCCESS);
 ##}
@@ -1034,11 +1061,15 @@ set_next_object_id(object)
     char *object;
 ##{
 ##  char *name;
+##  int rowcount;
 
-    name = object;
+       name = object;
 ##  range of v is values
 ##  repeat replace v (value = v.value + 1) where v.#name = @name
-    return(SMS_SUCCESS);
+##      inquire_equel (rowcount = "rowcount")
+    if (rowcount != 1)
+       return SMS_INGRES_ERR;
+    else return(SMS_SUCCESS);
 ##}
 
 /**
@@ -1068,7 +1099,8 @@ get_query_need(q, argv, action, actarg)
     last_get_time = argv[1];
     table = q1->rtable;
 
-    if (q1->type != RETRIEVE) return(SMS_NO_MATCH);
+    if (q1 == NULL || q1->type != RETRIEVE || table == NULL)
+       return(SMS_NO_MATCH);
 
 ##  range of tbs is tblstats
 ##  repeat retrieve (need = any(tbs.modtime where tbs.#table = @table and
@@ -1371,10 +1403,13 @@ add_user_group(q, argv)
 ##      repeat retrieve (exists = any(g.#gid where g.#gid = @gid))
     }
 ##  repeat replace v (value = @gid) where v.name = "gid"
-
     /* add list to group table */
 ##  repeat append groups (#list_id = @list_id, ltid = list.tid, #gid = @gid)
 ##      where list.#list_id = @list_id
+
+##  repeat replace tbs (modtime = "now", appends = tbs.appends + 1)
+##             where tbs.table = "groups"
+
 ##  repeat replace tbs (modtime = "now", appends = tbs.appends + 1)
 ##         where tbs.table = "members"
 
@@ -1728,8 +1763,13 @@ validate_id(argv, vo)
        for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
     namefield = vo->namefield;
     idfield = vo->idfield;
-##  retrieve (id = table.idfield) where table.namefield = name
-##  inquire_equel (rowcount = "rowcount")
+    if (!bcmp(namefield, "uid", 4)) {
+##    retrieve (id = table.idfield) where table.namefield = int4(name)
+##    inquire_equel (rowcount = "rowcount")
+    } else {
+##    retrieve (id = table.idfield) where table.namefield = name
+##    inquire_equel (rowcount = "rowcount")
+    }
     if (rowcount != 1) return(vo->error);
     *(int *)argv[vo->index] = id;
     return(SMS_EXISTS);
@@ -1752,6 +1792,29 @@ validate_name(argv, vo)
     return ((rowcount == 1) ? SMS_EXISTS : vo->error);
 ##}
 
+/* Special validation routine for get_filesys */
+validate_label(q, argv)
+    struct query *q;
+    char *argv[];
+{
+    register char *label;
+    register char *c;
+
+    label = argv[0];
+    c = (char *)index(label, '*');
+    if (c == label) return(SMS_NOT_UNIQUE);
+    return(SMS_SUCCESS);
+}
+
+/* Special validation routine for delete_filesys */
+validate_label_2(q, argv)
+    struct query *q;
+    char *argv[];
+{
+    if (index(argv[0], '*') != 0) return(SMS_NOT_UNIQUE);
+    return(SMS_SUCCESS);
+}
+
 validate_date(argv, vo)
     char *argv[];
     struct valobj *vo;
This page took 0.045435 seconds and 4 git commands to generate.