]> andersk Git - moira.git/blobdiff - server/qsupport.qc
added users_id & entity to client structure; query counters as globals
[moira.git] / server / qsupport.qc
index bf8ee99ab9d209f4f9b651a53464be0567aee4d1..f28dc8a0f1622eb151f7c6f2a1c2a08580754da9 100644 (file)
@@ -6,9 +6,56 @@
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
  *
  *     $Log$
- *     Revision 1.8  1987-08-18 15:05:20  wesommer
- *     Fixed definition of add_locker.
+ *     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
+table locking.
+
+Revision 1.10  87/08/25  15:56:54  mike
+- Fixed bugs in get_groups_of_all_users
+- Added tblstats updates to add_user_group
+- Added routines: add_hostaccess (ashi), delete_hostaccess (dshi),
+  followup_ushp, and followup_usha
+
+Revision 1.9  87/08/22  17:41:34  wesommer
+More of Mike's changes. 
+
+Revision 1.8  87/08/18  15:05:20  wesommer
+Fixed definition of add_locker.
+
 Revision 1.7  87/08/04  01:49:41  wesommer
 Rearranged messages.
 
@@ -105,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);
     }
 
@@ -168,6 +216,37 @@ access_list(q, argv, cl)
     return(SMS_SUCCESS);
 ##}
 
+/**
+ ** access_maillist - access_list + disallow adding user-group to maillists
+ **
+ ** Inputs:
+ **   argv[0] - list_id
+ **
+ **/
+
+access_maillist(q, argv, cl)
+    struct query *q;
+    char *argv[];
+    client *cl;
+##{
+##  int list_id;
+##  int exists;
+##  char list_name[32];
+    int status;
+
+    status = access_list(q, argv, cl);
+    if (status != SMS_SUCCESS) return(status);
+    if (bcmp(q->name, "add_maillist", 12)) return(status);
+
+    list_id = *(int *)argv[0];
+##  range of g is groups
+##  repeat retrieve (exists = any(g.#list_id where g.#list_id = @list_id))
+    if (!exists) return(SMS_SUCCESS);
+##  repeat retrieve (list_name = list.name) where list.#list_id = @list_id
+##  repeat retrieve (exists = any(users.login where users.login = @list_name))
+    return ((exists) ? SMS_USER_GROUP : SMS_SUCCESS);
+##}
+
 /**
  ** Setup routine for add_group
  **
@@ -177,19 +256,15 @@ access_list(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
@@ -201,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
 /**
@@ -217,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
@@ -411,12 +485,14 @@ setup_update_filesys(q, argv)
 ##  int rowcount;
 ##  char dir[32];
     char caccess;
+    register int status;
     register char *cp1;
     register char *cp2;
 
     caccess = (isupper(*access)) ? tolower(*access) : *access;
     if (caccess != 'r' && caccess != 'w') return(SMS_FILESYS_ACCESS);
 
+    status = SMS_NFS;
 ##  range of np is nfsphys
 ##  retrieve (dir = np.#dir) where np.#mach_id = mach_id
 ##  {
@@ -426,10 +502,13 @@ setup_update_filesys(q, argv)
             if (*cp1++ != *cp2) break;
             cp2++;
         }
-        if (*cp2 == 0) return(SMS_SUCCESS);
+        if (*cp2 == 0) {
+            status = SMS_SUCCESS;
+##           endretrieve
+        }
 ##  }
 
-    return(SMS_NFS);
+    return(status);
 ##}
 \f
 /* Followup Routines */
@@ -475,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);
 ##}
 
@@ -488,12 +568,126 @@ set_finger_modtime(q, argv)
 ##  repeat replace f (modtime = "now") where f.#users_id = @users_id
     return(SMS_SUCCESS);
 ##}
+\f
+/**
+ ** followup_amtl - followup for amtl and dmfl; when adding a list 
+ **                 member to a maillist, add list to maillist table,
+ **                 unless list is a user-group.
+ **                 Then set_list_modtime_by_id.
+ **
+ ** Inputs:
+ **   argv[0] - list_id
+ **   argv[1] - member_type
+ **   argv[2] - member_id
+ **
+ **/
+
+followup_amtl(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int list_id;
+##  int member_id;
+##  int exists;
+##  char list_name[33];
+
+    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)) 
+       return(SMS_SUCCESS);
+
+    member_id = *(int *)argv[2];
+##  range of l is list
+##  range of ml is maillists
+##  range of g is groups
+
+    /* is parent list a mailing list? */
+##  repeat retrieve (exists = any(ml.#list_id where ml.#list_id=@list_id))
+
+    /* if not then return */
+    if (!exists) return(SMS_SUCCESS);
+
+    /* is member_list a user-group? */
+    /* is it a group? */
+##  repeat retrieve (exists = any(g.#list_id where g.#list_id = @member_id))
+    if (exists) {
+       /* get list_name */
+##      repeat retrieve (list_name = l.#name) where l.#list_id = @member_id
+       /* is list_name a username? */
+##      repeat retrieve (exists = any(users.login 
+##                                   where users.login = @list_name))
+       /* yes, return error */
+       if (exists) return(SMS_USER_GROUP);
+    }
+
+    /* list is not a user-group; add list to maillist table */
+##  repeat append maillists (#list_id = @member_id, ltid = l.tid)
+##         where l.#list_id = @member_id
+
+    return(SMS_SUCCESS);
+##}
+\f
+/**
+ ** followup_add_pobox
+ ** followup_delete_pobox - followup routines for pobox queries
+ **
+ ** Description:
+ **   add_pobox: set pobox creation time
+ **              increment pop usage in serverhosts
+ **
+ **   delete_pobox: decrement pop usage in serverhosts
+ **
+ **/
+
+followup_add_pobox(q, argv)
+    struct query *q;
+    char *argv[];
+{
+    set_pobox_creation(q, argv);
+    set_pop_usage(q, argv, 1);
+    return(SMS_SUCCESS);
+}
+
+followup_delete_pobox(q, argv)
+    struct query *q;
+    char *argv[];
+{
+    set_pop_usage(q, argv, -1);
+    return(SMS_SUCCESS);
+}
+
+set_pobox_creation(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int users_id;
+##  int mach_id;
+##  char *type;
+##  char *box;
+
+    users_id = *(int *)argv[0];
+    type = argv[1];
+    mach_id = *(int *)argv[2];
+    box = argv[3];
+
+##  range of p is pobox
+##  repeat replace p (created = "now") 
+##         where p.#users_id = @users_id and p.#type = @type and
+##               p.#mach_id = @mach_id and p.#box = @box
+
+    return (SMS_SUCCESS);
+##}
 
 /**
  ** set_pop_usage - incr/decr usage count for pop server in serverhosts talbe
  **
  ** Inputs:
  **   q->name - "add_pobox" or "delete_pobox"
+ **   argv[1] - type
  **   argv[2] - mach_id
  **
  ** Description:
@@ -501,25 +695,71 @@ set_finger_modtime(q, argv)
  **
  **/
 
-set_pop_usage(q, argv)
+set_pop_usage(q, argv, count)
     struct query *q;
     char *argv[];
 ##{
 ##  int mach_id;
+##  int n;
+
+    if (bcmp(argv[1], "POP", 3)) return(SMS_SUCCESS);
 
     mach_id = *(int *)argv[2];
+    n = count;
+
 ##  range of sh is serverhosts
+##  repeat replace sh (value1 = sh.value1 + @n)
+##         where sh.service = "pop" and sh.#mach_id = @mach_id
 
-    if (!bcmp(q->name, "add_pobox", 10)) {
-##      repeat replace sh (value1 = sh.value1 + 1)
-##             where sh.service = "pop" and sh.#mach_id = @mach_id
-    } else if (!bcmp(q->name, "delete_pobox", 13)) {
+    return(SMS_SUCCESS);
+##}
+
+/**
+ ** delete_user_poboxes - delete all poboxes for a user
+ **
+ ** Inputs:
+ **   argv[0] - users_id
+ **
+ **/
+
+delete_user_poboxes(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int users_id;
+##  int n;
+##  int mach_id;
+    register int i;
+    int mach_ids[10];
+
+    users_id = *(int *)argv[0];
+
+    /* get machine ids for pop server(s) on which the user currently exists */
+##  range of p is pobox
+    i = 0;
+##  repeat retrieve (mach_id = p.#mach_id) 
+##         where p.#users_id = @users_id and p.type = "POP"
+##  {
+        mach_ids[i++] = mach_id;
+        if (i == 10) {
+##           endretrieve
+        }
+##  }
+
+    /* decrement counts on serverhost entries */
+##  range of sh is serverhosts
+    while (--i >= 0) {
+       mach_id = mach_ids[i];
 ##      repeat replace sh (value1 = sh.value1 - 1)
 ##             where sh.service = "pop" and sh.#mach_id = @mach_id
     }
 
+    /* delete user's poboxes */
+##  repeat delete p where p.#users_id = @users_id
+
     return(SMS_SUCCESS);
 ##}
+
 \f
 /**
  ** add_new_quota
@@ -559,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];
@@ -588,8 +825,84 @@ delete_current_quota(q, argv, cl, access_check)
 ##}
 \f
 /**
- ** delete_list_members - called after the delete_list query to clean up
- **                      members table.
+ ** add_hostaccess - create entry in hostaccess table upon adding a new
+ **                  machine to the serverhosts table where service =
+ **                  "hostaccess".
+ **
+ ** Inputs:
+ **   argv[0] - service
+ **   argv[1] - mach_id
+ **
+ **/
+
+add_hostaccess(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int mach_id;
+
+    /* only work with service = "hostaccess" */
+    if (bcmp(argv[0], "hostaccess", 10)) return(SMS_SUCCESS);
+
+    mach_id = *(int *)argv[1];
+##  repeat append hostaccess (#mach_id = @mach_id, status = 0)
+##  repeat replace tblstats (modtime = "now", appends = tblstats.appends + 1)
+##         where tblstats.table = "hostaccess"
+    return(SMS_SUCCESS);
+##}
+
+/* followup to delete_server_host_info */
+
+delete_hostaccess(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int mach_id;
+
+    /* only work with service = "hostaccess" */
+    if (bcmp(argv[0], "hostaccess", 10)) return(SMS_SUCCESS);
+
+    mach_id = *(int *)argv[1];
+##  repeat delete hostaccess where hostaccess.#mach_id = @mach_id
+##  repeat replace tblstats (modtime = "now", deletes = tblstats.deletes + 1)
+##         where tblstats.table = "hostaccess"
+    return(SMS_SUCCESS);
+##}
+
+followup_ushp(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int mach_id;
+##  int status;
+
+    mach_id = *(int *)argv[0];
+##  range of ha is hostaccess
+##  repeat retrieve (status = ha.#status) where ha.#mach_id = @mach_id
+    status |= 1;
+##  repeat replace ha (#status = @status) where ha.#mach_id = @mach_id
+    return(SMS_SUCCESS);
+##}
+
+followup_usha(q, argv)
+    struct query *q;
+    char *argv[];
+##{
+##  int mach_id;
+##  int status;
+
+    mach_id = *(int *)argv[0];
+##  range of ha is hostaccess
+##  repeat retrieve (status = ha.#status) where ha.#mach_id = @mach_id
+    status |= 2;
+##  repeat replace ha (#status = @status) where ha.#mach_id = @mach_id
+    return(SMS_SUCCESS);
+##}
+\f
+/**
+ ** 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
  **
@@ -599,7 +912,7 @@ delete_current_quota(q, argv, cl, access_check)
  **
  **/
 
-delete_list_members(q, argv)
+followup_delete_list(q, argv)
     struct query *q;
     register char *argv[];
 ##{
@@ -634,12 +947,14 @@ 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);
 ##}
 \f
 /**
- ** grvd_support - Support routine for get_rvd_servers query
+ ** followup_grvd - Support routine for get_rvd_servers query
  **
  ** Inputs:
  **    q     - grvd query structure
@@ -654,7 +969,7 @@ delete_list_members(q, argv)
  **
  **/
 
-grvd_support(q, sq, v, action, actarg)
+followup_grvd(q, sq, v, action, actarg)
     struct query *q;
     struct save_queue *sq;
     struct validate *v;
@@ -692,7 +1007,7 @@ grvd_support(q, sq, v, action, actarg)
     return(SMS_SUCCESS);
 ##}
 
-gars_support(q, sq, v, action, actarg)
+followup_gars(q, sq, v, action, actarg)
     struct query *q;
     struct save_queue *sq;
     struct validate *v;
@@ -746,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);
 ##}
 
 /**
@@ -780,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
@@ -943,11 +1263,12 @@ add_locker(q, argv)
  **
  ** Inputs:
  **   argv[0] - users_id
- **   argv[1] - machine_id
- **   argv[2] - device
- **   argv[3] - quota
  ** 
  ** Description:
+ **   - get login name from users_id
+ **   - get filesys entry from login
+ **   - use filesys.mach_id and filesys.name to determine machine/device
+ **     pair for nfsphys and nfsquota
  **   - delete filesys entry (label=<login>)
  **   - decrement allocated in nfsphys by quota
  **   - delete nfsquota entry
@@ -963,16 +1284,15 @@ delete_locker(q, argv)
 ##{
 ##  int users_id;
 ##  int mach_id;
-##  char *device;
 ##  int quota;
 ##  int rowcount;
 ##  char login[9];
+##  char lname[64];
+##  char ndev[32];
+    register char *c;
 
     /* copy arguments */
     users_id = *(int *)argv[0];
-    mach_id = *(int *)argv[1];
-    device = argv[2];
-    sscanf(argv[3], "%d", &quota);
 
 ##  range of u is users
 ##  range of f is filesys
@@ -983,22 +1303,37 @@ delete_locker(q, argv)
     /* get login name */
 ##  repeat retrieve (login = u.#login) where u.#users_id = @users_id
 
-    /* delete the filesys entry */
-##  repeat delete f where f.label = @login
+    /* get mach_id and locker name from filesys entry; then delete it */
+##  repeat retrieve (mach_id = f.#mach_id, lname = f.#name)
+##         where f.#label = @login
 ##  inquire_equel (rowcount = "rowcount")
     if (rowcount == 0) return(SMS_FILESYS);
+##  repeat delete f where f.#label = @login
+
+    /* get prefix directory */
+    c = (char *)rindex(lname, '/');
+    *c = 0;
+
+    /* get nfs device */
+##  repeat retrieve (ndev = np.device) 
+##         where np.#mach_id = @mach_id and np.dir = @lname
+
+    /* get quota from nfsquota entry; then delete entry */
+##  repeat retrieve (quota = nq.#quota)
+##         where nq.#mach_id = @mach_id and nq.#device = @ndev and
+##               nq.#users_id = @users_id
+##  repeat delete nq where nq.#mach_id = @mach_id and nq.#device = @ndev and
+##                  nq.#users_id = @users_id
+
+    /* decrement nfsphys.allocated */
+##  repeat replace np (allocated = np.allocated - @quota)
+##         where np.#mach_id = @mach_id and np.#device = @ndev
+
+    /* adjust table statistics */
 ##  repeat replace tbs (deletes = tbs.deletes + 1, modtime = "now")
 ##             where tbs.table = "filesys"
-
-    /* decrement usage count in nfsphys table */
-##  replace np (#allocated = np.#allocated - quota) 
-##         where np.#mach_id = mach_id and np.#device = device
 ##  repeat replace tbs (updates = tbs.updates + 1, modtime = "now")
 ##             where tbs.table = "nfsphys"
-
-    /* delete nfsquota entry */
-##  delete nq where nq.#users_id = users_id and nq.#mach_id = mach_id and
-##                  nq.#device = device
 ##  repeat replace tbs (deletes = tbs.deletes + 1, modtime = "now")
 ##             where tbs.table = "nfsquota"
 
@@ -1045,13 +1380,18 @@ add_user_group(q, argv)
 ##  repeat replace values (value = @list_id) where values.name = "list_id"
 
     /* create the list */
+##  range of tbs is tblstats
 ##  repeat append list (name = @login, #list_id = @list_id, flags = 1,
 ##                      desc = "User Group", acl_id = @list_id,
 ##                     expdate = "today" + "5 years", modtime = "now")
+##  repeat replace tbs (modtime = "now", appends = tbs.appends + 1)
+##         where tbs.table = "list"
 
     /* add user to list */
 ##  repeat append members (#list_id = @list_id, member_type = "USER",
 ##                        member_id = @users_id)
+##  repeat replace tbs (modtime = "now", appends = tbs.appends + 1)
+##         where tbs.table = "members"
 
     /* get new gid */
 ##  range of g is groups
@@ -1063,11 +1403,16 @@ 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"
+
     /* and we're done */
     return(SMS_SUCCESS);
 ##}
@@ -1163,6 +1508,44 @@ get_groups_of_user(q, argv, action, actarg)
 
     return ((rowcount = 0) ? SMS_NO_MATCH : SMS_SUCCESS);
 ##}
+
+get_groups_of_all_users(q, argv, action, actarg)
+    struct query *q;
+    char *argv[];
+    int (*action)();
+    int actarg;
+##{
+##  char login[9];
+##  char group[33];
+##  char gid[11];
+    char *targv[3];
+##  int errorno;
+
+    targv[0] = login;
+    targv[1] = group;
+    targv[2] = gid;
+
+##  range of u is users
+##  range of l is list
+##  range of m is members
+##  range of g is groups
+
+##  set lockmode session where readlock = nolock
+
+##  repeat retrieve (login = u.#login, group = l.name, gid = text(g.#gid))
+##         where m.member_type = "USER" and m.member_id = u.users_id and
+##               u.status != 0 and m.list_id = g.list_id and
+##               g.ltid = l.tid
+##         sort by #login, #group
+##  {
+        (*action)(3, targv, actarg);
+##  }
+
+##  inquire_equel (errorno = "errorno")
+##  set lockmode session where readlock = system
+
+    return((errorno) ? SMS_INGRES_ERR : SMS_SUCCESS);
+##}
 \f
 /**
  ** get_all_poboxes - optimized query for retrieval of all poboxes
@@ -1188,6 +1571,8 @@ get_all_poboxes(q, argv, action, actarg)
     targv[3] = box;
 
     targv[1] = "LOCAL";
+
+##  set lockmode session where readlock = nolock
 ##  range of p is pobox
 ##  repeat retrieve (login=users.#login, machine = #machine.name, box=p.#box)
 ##             where p.type = "LOCAL" and p.users_id = users.users_id
@@ -1208,6 +1593,56 @@ get_all_poboxes(q, argv, action, actarg)
 ##  repeat retrieve (login=users.#login, machine=strings.string, box=p.#box)
 ##             where p.type = "FOREIGN" and p.users_id = users.users_id
 ##                   and p.mach_id = strings.string_id
+##  {
+        (*action)(4, targv, actarg);
+##  }
+##  set lockmode session where readlock = system
+
+    return(SMS_SUCCESS);
+##}
+
+get_new_poboxes(q, argv, action, actarg)
+    struct query *q;
+    char *argv[];
+    int (*action)();
+    int actarg;
+##{
+##  char *created;
+##  char login[9];
+##  char machine[129];
+##  char box[129];
+    char *targv[4];
+
+    created = argv[0];
+
+    targv[0] = login;
+    targv[2] = machine;
+    targv[3] = box;
+
+    targv[1] = "LOCAL";
+##  range of p is pobox
+##  repeat retrieve (login=users.#login, machine = #machine.name, box=p.#box)
+##             where p.type = "LOCAL" and p.users_id = users.users_id
+##                   and p.mach_id = #machine.mach_id and
+##                   p.#created > @created
+##  {
+        (*action)(4, targv, actarg);
+##  }
+
+    targv[1] = "POP";
+##  repeat retrieve (login=users.#login, machine = #machine.name, box=p.#box)
+##             where p.type = "POP" and p.users_id = users.users_id
+##                   and p.mach_id = #machine.mach_id and
+##                   p.#created > @created
+##  {
+        (*action)(4, targv, actarg);
+##  }
+
+    targv[1] = "FOREIGN";
+##  repeat retrieve (login=users.#login, machine=strings.string, box=p.#box)
+##             where p.type = "FOREIGN" and p.users_id = users.users_id
+##                   and p.mach_id = strings.string_id and
+##                   p.#created > @created
 ##  {
         (*action)(4, targv, actarg);
 ##  }
@@ -1319,13 +1754,22 @@ validate_id(argv, vo)
 ##  char *idfield;
 ##  int id;
 ##  int rowcount;
+    register char *c;
 
     name = argv[vo->index];
     table = vo->table;
+    /* minor kludge to upcasify machine names */
+    if (!bcmp(table, "machine", 7))
+       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);
@@ -1348,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;
@@ -1399,6 +1866,7 @@ validate_typedata(q, argv, vo)
 ##  int id;
 ##  int refc;
 ##  int rowcount;
+    register char *c;
 
     /* get named object */
     name = argv[vo->index];
@@ -1428,6 +1896,7 @@ validate_typedata(q, argv, vo)
 
     } else if (!strcmp(data_type, "machine")) {
        /* MACHINE */
+       for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
 ##      repeat retrieve (id = machine.mach_id) where machine.#name = @name
 ##      inquire_equel (rowcount = "rowcount")
        if (rowcount != 1) return(SMS_MACHINE);
This page took 0.157624 seconds and 4 git commands to generate.