]> andersk Git - moira.git/blobdiff - server/qsetup.pc
Fix the logic for old clients to better handle the add_list case.
[moira.git] / server / qsetup.pc
index 90a333aa0e28d8f5b3d40d77357acab3884a24bc..b832e8cbe19f5b495e963834c83b0c6207cd3f1c 100644 (file)
@@ -373,7 +373,7 @@ static const char *mailman_suffixes[] = { "-admin", "-owner", "-request",
 int setup_alis(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int ngid, cnt, mailman, mailman_id;
+  int ngid, cnt, mailman, mailman_id, lid;
   char *name, *desc;
   EXEC SQL END DECLARE SECTION;
   unsigned char *p;
@@ -396,9 +396,7 @@ int setup_alis(struct query *q, char *argv[], client *cl)
 
   if (idx == 1)
     {
-      EXEC SQL BEGIN DECLARE SECTION;
-      int lid = *(int *)argv[0];
-      EXEC SQL END DECLARE SECTION;
+      lid = *(int *)argv[0];
 
       if (acl_access_check(lid, cl))
        return MR_PERM;
@@ -504,15 +502,21 @@ int setup_alis(struct query *q, char *argv[], client *cl)
     {
       /* Client too old to know about the mailman code.
        * Use existing value of mailman boolean in the table.
+       * Don't do this for add_list from an old client, since the row
+       * they're creating won't exist yet, and there's no way for them to
+       * create a list with the mailman bit set, anyway.
        */
-      EXEC SQL SELECT mailman INTO :mailman FROM list WHERE name = :name;
-      if (mailman)
+      if (idx == 1)
        {
-         EXEC SQL SELECT  COUNT(name) INTO :cnt FROM list
-           WHERE (name = :name || '-admin' OR name = :name || '-owner' OR
-                  name = :name || '-request');
-         if (cnt)
-           return MR_EXISTS;
+         EXEC SQL SELECT mailman INTO :mailman FROM list WHERE list_id = :lid;
+         if (mailman)
+           {
+             EXEC SQL SELECT  COUNT(name) INTO :cnt FROM list
+               WHERE (name = :name || '-admin' OR name = :name || '-owner' OR
+                      name = :name || '-request');
+             if (cnt)
+               return MR_EXISTS;
+           }
        }
     }
 
This page took 0.03352 seconds and 4 git commands to generate.