]> andersk Git - moira.git/blobdiff - server/qsupport.qc
documented optional servername on connect command
[moira.git] / server / qsupport.qc
index bb7a011a55ba54e4865366196c063a5cc48c9da7..f7a0aeb494f107f20addc6796c9bc11f7a5b1c3e 100644 (file)
@@ -4,6 +4,8 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  *
  */
 
@@ -11,6 +13,7 @@
 static char *rcsid_qsupport_qc = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include "query.h"
 #include "sms_server.h"
 #include <ctype.h>
@@ -69,7 +72,8 @@ access_login(q, argv, cl)
  * Inputs: argv[0] - list_id
  *         q - query name
  *         argv[2] - member ID (only for queries "amtl" and  "dmfl")
- *         cl - client name
+ *         argv[7] - group IID (only for query "ulis")
+ *          cl - client name
  *
  * - check that client is a member of the access control list
  * - OR, if the query is add_member_to_list or delete_member_from_list
@@ -81,14 +85,14 @@ access_list(q, argv, cl)
     char *argv[];
     client *cl;
 ##{
-##  int list_id, acl_id, flags, rowcount;
+##  int list_id, acl_id, flags, rowcount, gid;
 ##  char acl_type[9];
     char *client_type;
     int client_id, status;
 
     list_id = *(int *)argv[0];
 ##  repeat retrieve (acl_id = list.#acl_id, acl_type = list.#acl_type,
-##                  flags = list.#public) 
+##                  gid = list.#gid, flags = list.#public) 
 ##        where list.#list_id = @list_id
 ##  inquire_equel(rowcount = "rowcount")
     if (rowcount != 1)
@@ -102,6 +106,11 @@ access_list(q, argv, cl)
     if ((!strcmp("amtl", q->shortname) || !strcmp("dmfl", q->shortname)) &&
        (flags && !strcmp("USER", argv[1]))) {
        if (*(int *)argv[2] == client_id) return(SMS_SUCCESS);
+    /* if update_list, don't allow them to change the GID */
+    } else if (!strcmp("ulis", q->shortname)) {
+       if ((!strcmp(argv[7], UNIQUE_GID) && (gid != -1)) ||
+           (strcmp(argv[7], UNIQUE_GID) && (gid != atoi(argv[7]))))
+         return(SMS_PERM);
     }
 
     /* check for client in access control list */
@@ -206,7 +215,7 @@ access_member(q, argv, cl)
       return(access_visible_list(q, &argv[1], cl));
 
     if (!strcmp(argv[0], "USER") || !strcmp(argv[0], "RUSER")) {
-       if (!strcmp(cl->kname.name, argv[1]))
+       if (cl->users_id == *(int *)argv[1])
          return(SMS_SUCCESS);
     }
 
@@ -345,6 +354,12 @@ int setup_dusr(q, argv)
 ##  int flag, id;
 
     id = *(int *)argv[0];
+
+    /* For now, only allow users to be deleted if their status is 0 */
+##  repeat retrieve (flag = u.status) where u.users_id = @id
+    if (flag != 0)
+      return(SMS_IN_USE);
+
 ##  repeat delete nfsquota where nfsquota.users_id = @id
 ##  repeat retrieve (flag = any(members.member_id where members.member_id=@id
 ##                      and members.member_type = "USER"))
@@ -377,18 +392,18 @@ int setup_spop(q, argv)
 struct query *q;
 char **argv;
 ##{
-##  int id, flag;
+##  int id, mid, flag;
 ##  char type[9];
 
     id = *(int *)argv[0];
-##  repeat retrieve (type = u.potype, flag = any(machine.name
-##                                     where machine.mach_id = u.pop_id 
-##                                             and u.pop_id != 0
-##                                             and u.users_id = @id))
+##  repeat retrieve (type = u.potype, mid = u.pop_id,
+##                  flag = any(machine.name where machine.mach_id = u.pop_id 
+##                                  and u.pop_id != 0 and u.users_id = @id))
+##     where u.users_id = @id
     if (!flag)
       return(SMS_MACHINE);
-    if (strcmp(type, "POP"))
-      set_pop_usage(id, 1);
+    if (strcmp(strtrim(type), "POP"))
+      set_pop_usage(mid, 1);
     return(SMS_SUCCESS);
 ##}
 
@@ -406,7 +421,7 @@ char **argv;
 ##  repeat retrieve (type = u.potype, id = u.pop_id)
 ##             where u.users_id = @user
 
-    if (strcmp(type, "POP"))
+    if (!strcmp(strtrim(type), "POP"))
       set_pop_usage(id, -1);
     return(SMS_SUCCESS);
 ##}
@@ -437,6 +452,9 @@ int setup_dmac(q, argv)
 ##  repeat retrieve (flag = any(hostaccess.mach_id where hostaccess.mach_id=@id))
     if (flag)
        return(SMS_IN_USE);
+##  repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
+    if (flag)
+       return(SMS_IN_USE);
 
 ##  repeat delete mcmap where mcmap.mach_id = @id
     return(SMS_SUCCESS);
@@ -525,7 +543,7 @@ int setup_dlis(q, argv)
     if (flag)
        return(SMS_IN_USE);
 ##  repeat retrieve (flag = any(list.name where list.acl_id=@id and
-##                     list.acl_type = "LIST"))
+##                     list.acl_type = "LIST" and list.list_id != @id))
     if (flag)
        return(SMS_IN_USE);
 ##  repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
@@ -644,14 +662,18 @@ setup_afil(q, argv)
 }
 
 
+/* Verify the arguments, depending on the FStype.  Also, if this is an
+ * NFS filesystem, then update any quotas for that filesystem to reflect
+ * the new phys_id.
+ */
+
 setup_ufil(q, argv)
     struct query *q;
     char *argv[];
-{
-    char *type;
-    int mach_id;
-    char *name;
-    char *access;  
+##{
+    int mach_id, status;
+    char *type, *name, *access;  
+##  int fid;
 
     type = argv[2];
     mach_id = *(int *)argv[3];
@@ -659,11 +681,14 @@ setup_ufil(q, argv)
     access = argv[6];
     var_phys_id = 0;
 
-    if (!strcmp(type, "NFS"))
-       return (check_nfs(mach_id, name, access));
-    else
-       return(SMS_SUCCESS);
-}
+    if (!strcmp(type, "NFS")) {
+       status = check_nfs(mach_id, name, access);
+       fid = *(int *)argv[0];
+##     replace nfsquota (phys_id = var_phys_id) where nfsquota.filsys_id = fid
+       return(status);
+    } else
+      return(SMS_SUCCESS);
+##}
 
 
 /* Find the NFS physical partition that the named directory is on.
@@ -866,25 +891,24 @@ set_pobox_modtime(q, argv, cl)
 ##}
 
 
-/* Sets the modtime on a machine record.  The machine name is in argv[0].
- * This routine is different from the generic set_modtime in that the
- * name is uppercased first.
+/* Like set_modtime, but uppercases the name first.
  */
 
-set_mach_modtime(q, argv, cl)
+set_uppercase_modtime(q, argv, cl)
     struct query *q;
     char **argv;
     client *cl;
 ##{
-##  char *host, *entity;
+##  char *name, *entity, *table;
 ##  int who;
 
     entity = cl->entity;
     who = cl->users_id;
+    table = q->rtable;
+    name = argv[0];
 
-    host = argv[0];
-##  repeat replace m (modtime = "now", modby = @who, modwith = @entity)
-##      where m.name = uppercase(@host)
+##  replace table (modtime = "now", modby = who, modwith = entity)
+##      where table.#name = uppercase(name)
     return(SMS_SUCCESS);
 ##}
 
@@ -1205,7 +1229,7 @@ followup_glin(q, sq, v, action, actarg, cl)
 
     idx = 8;
     if (!strcmp(q->shortname, "gsin"))
-      idx = 11;
+      idx = 12;
 
     while (sq_get_data(sq, &argv)) {
        sms_trim_args(q->vcnt, argv);
@@ -1478,7 +1502,7 @@ int set_pobox(q, argv, cl)
 
 ##  repeat retrieve (id = users.pop_id, potype = users.#potype)
 ##             where users.users_id = @user
-    if (!strcmp(potype, "POP"))
+    if (!strcmp(strtrim(potype), "POP"))
       set_pop_usage(id, -1);
 
     if (!strcmp(argv[1], "POP")) {
@@ -2143,7 +2167,7 @@ register_user(q, argv, cl)
 ##  repeat retrieve (flag = any(u.#login where u.#login = @login))
     if (flag)
       return(SMS_IN_USE);
-##  repeat retrieve (flag = any(l.name where l.name = @login))
+##  repeat retrieve (flag = any(l.#name where l.#name = @login))
     if (flag)
       return(SMS_IN_USE);
 ##  repeat retrieve (flag = any(filesys.#name where filesys.#name = @login))
@@ -2219,7 +2243,8 @@ register_user(q, argv, cl)
       return(SMS_NO_ID);
 ##  repeat append filesys (filsys_id = values.value, phys_id = @pid,
 ##                        label = @login, type = "NFS", mach_id = @m_id,
-##                        name = @directory + @login, mount = "/mit/" + @login,
+##                        name = @directory + "/" + @login,
+##                        mount = "/mit/" + @login,
 ##                        access = "w", comments = "User Locker",
 ##                        owner = @users_id, owners = @list_id, createflg = 1,
 ##                        lockertype = "HOMEDIR", modtime = "now",
@@ -2229,7 +2254,7 @@ register_user(q, argv, cl)
     if (rowcount != 1)
       return(SMS_INTERNAL);
     com_err(whoami, 0, "filesys created on mach %d in %s/%s", m_id,
-           trim(directory), login);
+           directory, login);
 
     /* set quota */
 ##  repeat retrieve (quota = values.value) where values.name = "def_quota"
@@ -2237,8 +2262,8 @@ register_user(q, argv, cl)
     if (rowcount != 1)
       return(SMS_NO_QUOTA);
 ##  repeat append nfsquota (#users_id = @users_id, filsys_id = values.value,
-##                         #quota = @quota, modtime = "now", modby = @who,
-##                         modwith = @entity)
+##                         #quota = @quota, phys_id = @pid, modtime = "now",
+##                         modby = @who, modwith = @entity)
 ##     where values.name = "filsys_id"
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
@@ -2251,6 +2276,11 @@ register_user(q, argv, cl)
       return(SMS_INTERNAL);
     com_err(whoami, 0, "quota of %d assigned", quota);
 
+##  repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
+##     where tblstats.table = "users"
+##  repeat replace tblstats (appends = tblstats.appends + 1, modtime = "now")
+##     where tblstats.table = "list" or tblstats.table = "filesys" or
+##           tblstats.table = "nfsquota"
     return(SMS_SUCCESS);
 ##}
 
@@ -2304,7 +2334,7 @@ validate_row(q, argv, v)
     table = q->rtable;
     name = v->field;
 
-    if (log_flags & LOG_RES)
+    if (log_flags & LOG_VALID)
        /* tell the logfile what we're doing */
        com_err(whoami, 0, "validating row: %s", qual);
     
@@ -2327,48 +2357,48 @@ validate_fields(q, argv, vo, n)
     while (--n >= 0) {
        switch (vo->type) {
        case V_NAME:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating %s in %s: %s", 
                    vo->namefield, vo->table, argv[vo->index]);
            status = validate_name(argv, vo);
            break;
 
        case V_ID:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating %s in %s: %s", 
                    vo->idfield, vo->table, argv[vo->index]);
            status = validate_id(argv, vo);
            break;
 
        case V_DATE:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating date: %s", argv[vo->index]);
            status = validate_date(argv, vo);
            break;
 
        case V_TYPE:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating %s type: %s",
                    vo->table, argv[vo->index]);
            status = validate_type(argv, vo);
            break;
 
        case V_TYPEDATA:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating typed data (%s): %s",
                    argv[vo->index - 1], argv[vo->index]);
            status = validate_typedata(q, argv, vo);
            break;
 
        case V_RENAME:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating rename %s in %s",
                        argv[vo->index], vo->table);
            status = validate_rename(argv, vo);
            break;
 
        case V_CHAR:
-           if (log_flags & LOG_RES)
+           if (log_flags & LOG_VALID)
              com_err(whoami, 0, "validating chars: %s", argv[vo->index]);
            status = validate_chars(argv[vo->index]);
            break;
@@ -2389,7 +2419,7 @@ validate_fields(q, argv, vo, n)
 
 /* validate_chars: verify that there are no illegal characters in
  * the string.  Legal characters are printing chars other than 
- * ", *, ?, [ and ].
+ * ", *, ?, \, [ and ].
  */
 static int illegalchars[] = {
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^@ - ^O */
@@ -2397,7 +2427,7 @@ static int illegalchars[] = {
     0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* SPACE - / */
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0 - ? */
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, /* P - _ */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, /* P - _ */
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* p - ^? */
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -2598,8 +2628,9 @@ validate_typedata(q, argv, vo)
             * values.[idfield] for the id.
             */
            if (vo->idfield && !strcmp(argv[0], argv[vo->index])) {
+               set_next_object_id(q->validate->object_id, q->rtable);
                name = vo->idfield;
-##             repeat retrieve (id = values.value+1) where values.#name = @name
+##             repeat retrieve (id = values.value) where values.#name = @name
 ##             inquire_equel(rowcount = "rowcount")
                if (rowcount != 1) return(SMS_LIST);
            } else
@@ -2667,6 +2698,4 @@ char *name;
 
 sanity_check_database()
 ##{
-##  replace servers (inprogress = 0)
-##  replace serverhosts (inprogress = 0)
 ##}
This page took 0.049897 seconds and 4 git commands to generate.