]> andersk Git - moira.git/blobdiff - server/qsupport.qc
added sq_save_unique_string
[moira.git] / server / qsupport.qc
index d0cdd4907ffb9a02f22afe02ec876a4b36740a73..c016c232e4b2c7407cc56f9a8651ca6a18e11660 100644 (file)
@@ -6,9 +6,20 @@
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
  *
  *     $Log$
- *     Revision 1.9  1987-08-22 17:41:34  wesommer
- *     More of Mike's changes. 
+ *     Revision 1.11  1987-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.
 
@@ -780,6 +791,81 @@ delete_current_quota(q, argv, cl, access_check)
     return(SMS_SUCCESS);
 ##}
 \f
+/**
+ ** 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
 /**
  ** delete_list_members - called after the delete_list query to clean up
  **                      members table.
@@ -832,7 +918,7 @@ delete_list_members(q, argv)
 ##}
 \f
 /**
- ** grvd_support - Support routine for get_rvd_servers query
+ ** followup_grvd - Support routine for get_rvd_servers query
  **
  ** Inputs:
  **    q     - grvd query structure
@@ -847,7 +933,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;
@@ -885,7 +971,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;
@@ -1136,11 +1222,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
@@ -1156,16 +1243,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
@@ -1176,22 +1262,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"
 
@@ -1238,13 +1339,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
@@ -1260,6 +1366,8 @@ add_user_group(q, argv)
     /* 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 = "members"
 
     /* and we're done */
     return(SMS_SUCCESS);
@@ -1366,20 +1474,31 @@ get_groups_of_all_users(q, argv, action, 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
 
-##  repeat retrieve (login = u.#login, group = l.name, gid = g.#gid)
+##  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);
 ##}
@@ -1408,6 +1527,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
@@ -1431,6 +1552,7 @@ get_all_poboxes(q, argv, action, actarg)
 ##  {
         (*action)(4, targv, actarg);
 ##  }
+##  set lockmode session where readlock = system
 
     return(SMS_SUCCESS);
 ##}
This page took 0.04185 seconds and 4 git commands to generate.