]> andersk Git - moira.git/blobdiff - server/qsupport.qc
punt unused function followup_amtl; have add_member_to_list and
[moira.git] / server / qsupport.qc
index 5b95b7feefc3c1a9abbf546c11c0f9a3defa0280..c300eb2977236f9eaf5b2bbc9caae9bee3d00b96 100644 (file)
@@ -386,8 +386,9 @@ int setup_dusr(q, argv)
 ##                     hostaccess.acl_type = "USER"))
     if (flag)
        return(SMS_IN_USE);
-    else
-       return(SMS_SUCCESS);
+    if (ingres_errno)
+       return(sms_errcode);
+    return(SMS_SUCCESS);
 ##}
 
 
@@ -426,6 +427,7 @@ char **argv;
     user = *(int *)argv[0];
 ##  repeat retrieve (type = u.potype, id = u.pop_id)
 ##             where u.users_id = @user
+    if (ingres_errno) return(sms_errcode);
 
     if (!strcmp(strtrim(type), "POP"))
       set_pop_usage(id, -1);
@@ -466,6 +468,7 @@ int setup_dmac(q, argv)
        return(SMS_IN_USE);
 
 ##  repeat delete mcmap where mcmap.mach_id = @id
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -487,8 +490,9 @@ int setup_dclu(q, argv)
 ##  repeat retrieve (flag = any(svc.clu_id where svc.clu_id=@id))
     if (flag)
        return(SMS_IN_USE);
-    else
-       return(SMS_SUCCESS);
+    if (ingres_errno)
+       return(sms_errcode);
+    return(SMS_SUCCESS);
 ##}
 
 
@@ -517,6 +521,7 @@ char **argv;
            if (set_next_object_id("gid", "list"))
              return(SMS_INGRES_ERR);
 ##         repeat retrieve (ngid = values.value) where values.name = "gid"
+           if (ingres_errno) return(sms_errcode);
            sprintf(argv[idx], "%d", ngid);
        } else {
            strcpy(argv[idx], "-1");
@@ -570,8 +575,9 @@ int setup_dlis(q, argv)
 ##                   zephyr.iui_type = "LIST" and zephyr.iui_id = @id))
     if (flag)
         return(SMS_IN_USE);
-    else
-       return(SMS_SUCCESS);
+    if (ingres_errno)
+       return(sms_errcode);
+    return(SMS_SUCCESS);
 ##}
 
 
@@ -594,8 +600,9 @@ int setup_dsin(q, argv)
 ##  repeat retrieve (flag = servers.inprogress) where servers.#name = @name
     if (flag)
        return(SMS_IN_USE);
-    else
-       return(SMS_SUCCESS);
+    if (ingres_errno)
+       return(sms_errcode);
+    return(SMS_SUCCESS);
 ##}
 
 
@@ -616,8 +623,9 @@ int setup_dshi(q, argv)
 ##     where serverhosts.service=uppercase(@name) and serverhosts.mach_id=@id
     if (flag)
        return(SMS_IN_USE);
-    else
-       return(SMS_SUCCESS);
+    if (ingres_errno)
+       return(sms_errcode);
+    return(SMS_SUCCESS);
 ##}
 
 
@@ -694,6 +702,7 @@ setup_ufil(q, argv)
        status = check_nfs(mach_id, name, access);
        fid = *(int *)argv[0];
 ##     replace nfsquota (phys_id = var_phys_id) where nfsquota.filsys_id = fid
+       if (ingres_errno) return(sms_errcode);
        return(status);
     } else
       return(SMS_SUCCESS);
@@ -735,7 +744,8 @@ setup_ufil(q, argv)
 ##           endretrieve
         }
 ##  }
-
+    if (ingres_errno)
+       return(sms_errcode);
     return(status);
 ##}
 
@@ -761,6 +771,7 @@ setup_dfil(q, argv, cl)
 ##  repeat delete q where q.filsys_id = @id
 ##  repeat delete fsgroup where fsgroup.filsys_id = @id
 ##  repeat delete fsgroup where fsgroup.group_id = @id
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -780,6 +791,8 @@ setup_dnfp(q, argv, cl)
 ##  repeat retrieve (exists = any(filesys.label where filesys.phys_id = @id))
     if (exists)
       return(SMS_IN_USE);
+    if (ingres_errno)
+      return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -804,6 +817,7 @@ setup_dnfq(q, argv, cl)
 ##     q.filsys_id = @fs
 ##  repeat replace nfsphys (allocated = nfsphys.allocated - @quota)
 ##     where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -845,8 +859,9 @@ client *cl;
 ##     replace v (value = id) where v.#name = "strings_id"
 ##     append to strings (string_id = id, string = name)
     }
+    if (ingres_errno) return(sms_errcode);
     *(int *)argv[1] = id;
-    return(0);
+    return(SMS_SUCCESS);
 ##}
 
 
@@ -1149,6 +1164,7 @@ followup_fix_modby(q, sq, v, action, actarg, cl)
        free(argv);
     }
     sq_destroy(sq);
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -1361,53 +1377,6 @@ followup_glin(q, sq, v, action, actarg, cl)
 ##}
 
 
-/** followup_amtl - followup for amtl and dmfl; when adding a list 
- **                 member to a maillist, make member list a maillist also
- **                 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, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
-##{
-##  int list_id;
-##  int member_id;
-##  int exists, who;
-##  char *entity;
-
-    list_id = *(int *)argv[0];
-    entity = cl->entity;
-    who = cl->client_id;
-
-##  range of l is list
-##  repeat replace l (modtime = "now", modby = @who, modwith = @entity)
-##      where l.#list_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];
-
-    /* is parent list a mailing list? */
-##  repeat retrieve (exists = l.maillist) where l.#list_id=@list_id
-    if (!exists)
-       return(SMS_SUCCESS);
-
-    /* list is not a user-group; add list to maillist table */
-##  repeat replace l (maillist = 1) where l.#list_id = @member_id
-    return(SMS_SUCCESS);
-##}
-
-
 /* followup_gnfq: Fix the directory name & modby fields
  *   argv[0] = filsys_id
  *   argv[2] = ascii(quota)
@@ -1490,6 +1459,7 @@ followup_anfq(q, argv, cl)
 ##     where nq.filsys_id = @fs and nq.users_id = @user
 ##  repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
 ##     where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -1661,6 +1631,7 @@ int set_pobox(q, argv, cl)
 
 ##  repeat retrieve (id = users.pop_id, potype = users.#potype)
 ##             where users.users_id = @user
+    if (ingres_errno) return(sms_errcode);
     if (!strcmp(strtrim(potype), "POP"))
       set_pop_usage(id, -1);
 
@@ -1673,6 +1644,8 @@ int set_pobox(q, argv, cl)
 ##             where users.users_id = @user
        set_pop_usage(id, 1);
     } else if (!strcmp(argv[1], "SMTP")) {
+       if (index(box, '/') || index(box, '|'))
+         return(SMS_BAD_CHAR);
 ##      range of s is strings
 ##      repeat retrieve (id = s.string_id) where s.string = @box
 ##      inquire_equel (rowcount = "rowcount")
@@ -1692,6 +1665,7 @@ int set_pobox(q, argv, cl)
     set_pobox_modtime(q, argv, cl);
 ##  repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
 ##     where tblstats.#table = "users"
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -1792,6 +1766,7 @@ get_list_info(q, aargv, cl, action, actarg)
     }
 
     sq_destroy(sq);
+    if (ingres_errno) return(sms_errcode);
 ##  repeat replace tblstats (retrieves = tblstats.retrieves + 1)
 ##     where tblstats.#table = "list"
 
@@ -1810,8 +1785,8 @@ int add_member_to_list(q, argv, cl)
     char **argv;
     client *cl;
 ##{
-##  int id, lid, mid, exists, error;
-##  char *mtype, dtype[9];
+##  int id, lid, mid, exists, error, who;
+##  char *mtype, dtype[9], buf[256], *entity;
     int ancestors[MAXLISTDEPTH], acount, a;
     int descendants[MAXLISTDEPTH], dcount, d;
     char *dtypes[MAXLISTDEPTH];
@@ -1826,6 +1801,12 @@ int add_member_to_list(q, argv, cl)
 ##                        and m.direct = 1))
     if (exists)
       return(SMS_EXISTS);
+    if (!strcasecmp(mtype, "STRING")) {
+##     repeat retrieve (buf = strings.string) where strings.string_id = @mid
+       if (index(buf, '/') || index(buf, '|'))
+         return(SMS_BAD_CHAR);
+    }
+
     ancestors[0] = lid;
     acount = 1;
 ##  repeat retrieve (id = m.list_id)
@@ -1908,6 +1889,11 @@ int add_member_to_list(q, argv, cl)
            }
        }
     }
+    lid = *(int *)argv[0];
+    entity = cl->entity;
+    who = cl->client_id;
+##  repeat replace list (modtime = "now", modby = @who, modwith = @entity)
+##      where list.#list_id = @lid
     if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
@@ -1921,8 +1907,8 @@ int delete_member_from_list(q, argv, cl)
     char **argv;
     client *cl;
 ##{
-##  int id, lid, mid, cnt, exists, error;
-##  char *mtype, dtype[9];
+##  int id, lid, mid, cnt, exists, error, who;
+##  char *mtype, dtype[9], *entity;
     int ancestors[MAXLISTDEPTH], acount, a;
     int descendants[MAXLISTDEPTH], dcount, d;
     char *dtypes[MAXLISTDEPTH];
@@ -2006,11 +1992,16 @@ int delete_member_from_list(q, argv, cl)
 ##                 m.member_type = mtype
            } else {
 ##             replace m (ref_count = m.ref_count-1)
-##                 where m.list_id = lid and m.member_idn = mid and
+##                 where m.list_id = lid and m.member_id = mid and
 ##                 m.member_type = mtype
            }
        }
     }
+    lid = *(int *)argv[0];
+    entity = cl->entity;
+    who = cl->client_id;
+##  repeat replace list (modtime = "now", modby = @who, modwith = @entity)
+##      where list.#list_id = @lid
     if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
@@ -2089,6 +2080,7 @@ int get_ace_use(q, argv, cl, action, actarg)
     }
 
     sq_destroy(sq);    
+    if (ingres_errno) return(sms_errcode);
     if (!found) return(SMS_NO_MATCH);
     return(SMS_SUCCESS);
 ##}
@@ -2235,6 +2227,7 @@ int get_lists_of_member(q, argv, cl, action, actarg)
 ##    }
     }
 
+    if (ingres_errno) return(sms_errcode);
     if (!found) return(SMS_NO_MATCH);
     return(SMS_SUCCESS);
 ##}
@@ -2292,6 +2285,7 @@ get_members_of_list(q, argv, cl, action, actarg)
 ##  {
         (*action)(2, targv, actarg);
 ##  }
+    if (ingres_errno) return(sms_errcode);
 
     targv[0] = "LIST";
 ##  repeat retrieve (member_name = list.name)
@@ -2301,6 +2295,7 @@ get_members_of_list(q, argv, cl, action, actarg)
 ##  {
         (*action)(2, targv, actarg);
 ##  }
+    if (ingres_errno) return(sms_errcode);
 
     targv[0] = "STRING";
 ##  repeat retrieve (member_name = strings.string)
@@ -2310,6 +2305,7 @@ get_members_of_list(q, argv, cl, action, actarg)
 ##  {
         (*action)(2, targv, actarg);
 ##  }
+    if (ingres_errno) return(sms_errcode);
 
     targv[0] = "KERBEROS";
 ##  repeat retrieve (member_name = strings.string)
@@ -2319,6 +2315,7 @@ get_members_of_list(q, argv, cl, action, actarg)
 ##  {
         (*action)(2, targv, actarg);
 ##  }
+    if (ingres_errno) return(sms_errcode);
 
     return(SMS_SUCCESS);
 ##}
@@ -2343,6 +2340,7 @@ int count_members_of_list(q, argv, cl, action, actarg)
 ##  repeat retrieve (ct = count(imembers.list_id
 ##                             where imembers.list_id = @list and
 ##                                   imembers.direct = 1))
+    if (ingres_errno) return(sms_errcode);
     sprintf(countbuf, "%d", ct);
     (*action)(1, rargv, actarg);
     return(SMS_SUCCESS);
@@ -2411,6 +2409,7 @@ int qualified_get(q, argv, action, actarg, start, range, field, flags)
 ##  retrieve (name = rvar.rfield) where qual {
        (*action)(1, rargv, actarg);
 ##  }
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount")
 ##  repeat replace tblstats (retrieves = tblstats.retrieves + 1)
 ##     where tblstats.#table = @rtbl
@@ -2458,6 +2457,7 @@ int qualified_get_serverhost(q, argv, cl, action, actarg)
 ##  retrieve (sname = sh.service, mname = machine.name) where qual {
        (*action)(2, rargv, actarg);
 ##  }
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount")
 ##  repeat replace tblstats (retrieves = tblstats.retrieves + 1)
 ##     where tblstats.#table = "serverhosts"
@@ -2524,6 +2524,7 @@ register_user(q, argv, cl)
 ##  repeat retrieve (mid = sh.mach_id, machname = m.name)
 ##    where sh.service = "POP" and m.mach_id = sh.mach_id and
 ##     sh.value2 - sh.value1 = max(sh.value2-sh.value1 where sh.service="POP")
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount == 0)
       return(SMS_NO_POBOX);
@@ -2537,6 +2538,7 @@ register_user(q, argv, cl)
 ##                   pmodwith=@entity)
 ##     where u.#users_id = @users_id
 ##  inquire_equel(rowcount = "rowcount");
+    if (ingres_errno) return(sms_errcode);
     if (rowcount != 1)
       return(SMS_INTERNAL);
     set_pop_usage(mid, 1);
@@ -2550,6 +2552,7 @@ register_user(q, argv, cl)
     if (set_next_object_id("list_id", "list"))
       return(SMS_NO_ID);
 ##  repeat retrieve (list_id = values.value) where values.name = "list_id"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_INTERNAL);
@@ -2560,6 +2563,7 @@ register_user(q, argv, cl)
 ##                     acl_type = "USER", acl_id = @users_id, modtime = "now",
 ##                     modby = @who, modwith = @entity)
 ##     where values.name = "gid"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_INTERNAL);
@@ -2571,10 +2575,11 @@ register_user(q, argv, cl)
     incremental_clear_before();
 ##  repeat append imembers (#list_id = @list_id, member_type = "USER",
 ##                        member_id = @users_id, ref_count = 1, direct = 1)
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_INTERNAL);
-    incremental_after("members", 0, argv);
+    incremental_after("members", 0, aargv);
     com_err(whoami, 0, "group list created");
 
     /* decide where to put filesystem */
@@ -2591,6 +2596,7 @@ register_user(q, argv, cl)
            m_id = mid;
        }
 ##  }
+    if (ingres_errno) return(sms_errcode);
     if (maxsize == 0)
       return(SMS_NO_FILESYS);
 
@@ -2607,6 +2613,7 @@ register_user(q, argv, cl)
 ##                        lockertype = "HOMEDIR", modtime = "now",
 ##                        modby = @who, modwith = @entity)
 ##     where values.name = "filsys_id"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_INTERNAL);
@@ -2618,6 +2625,7 @@ register_user(q, argv, cl)
 
     /* set quota */
 ##  repeat retrieve (quota = values.value) where values.name = "def_quota"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_NO_QUOTA);
@@ -2626,26 +2634,30 @@ register_user(q, argv, cl)
 ##                         #quota = @quota, phys_id = @pid, modtime = "now",
 ##                         modby = @who, modwith = @entity)
 ##     where values.name = "filsys_id"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_INTERNAL);
 ##  repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
 ##     where nfsphys.nfsphys_id = filesys.#phys_id and
 ##           filesys.filsys_id = values.value and values.name = "filsys_id"
+    if (ingres_errno) return(sms_errcode);
 ##  inquire_equel(rowcount = "rowcount");
     if (rowcount != 1)
       return(SMS_INTERNAL);
     aargv[0] = login;
     aargv[1] = login;
     sprintf(buffer, "nq.users_id = %d and nq.filsys_id = values.value and values.name = \"filsys_id\"", users_id);
-    incremental_after("nfsquota", buffer, argv);
+    incremental_after("nfsquota", buffer, aargv);
     com_err(whoami, 0, "quota of %d assigned", quota);
+    if (ingres_errno) return(sms_errcode);
 
 ##  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"
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -2673,6 +2685,7 @@ int count;
 ##  repeat replace sh (value1 = sh.value1 + @n)
 ##         where sh.service = "POP" and sh.#mach_id = @mach_id
 
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 ##}
 
@@ -2782,6 +2795,7 @@ validate_fields(q, argv, vo, n)
        vo++;
     }
 
+    if (ingres_errno) return(sms_errcode);
     return(SMS_SUCCESS);
 }
 
This page took 0.063109 seconds and 4 git commands to generate.