]> andersk Git - moira.git/blobdiff - server/qsetup.pc
Changes for billing_contact column in machine table.
[moira.git] / server / qsetup.pc
index a2b2b89fb7282b3e5d8edebb692724e08cd724b1..11a4da78b7b3f715585d413ed73e73c0249fb489 100644 (file)
@@ -276,12 +276,15 @@ int setup_dclu(struct query *q, char *argv[], client *cl)
  * a -1 there.  Remember that this is also used for ulis, with the indexes
  * at 6 & 7.  Also check that the list name does not contain uppercase
  * characters, control characters, @, or :.
+ *
+ *  Newlines in list descriptions do bad things to the aliases file
+ *  moira generates, so make sure the description doesn't contain any, too.
  */
 
 static int badlistchars[] = {
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^@ - ^O */
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^P - ^_ */
-  1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, /* SPACE - / */
+  1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, /* SPACE - / */
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, /* 0 - ? */
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* @ - O */
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, /* P - _ */
@@ -301,7 +304,7 @@ int setup_alis(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int ngid, cnt;
-  char *name;
+  char *name, *desc;
   EXEC SQL END DECLARE SECTION;
   unsigned char *p;
   int idx, err;
@@ -312,6 +315,13 @@ int setup_alis(struct query *q, char *argv[], client *cl)
     idx = 1;
   name = argv[idx];
 
+  if (q->version == 2)
+    desc = argv[9 + idx];
+  else if (q->version == 3)
+    desc = argv[10 + idx];
+  else if (q->version >= 4)
+    desc = argv[12 + idx];
+
   if (idx == 1)
     {
       EXEC SQL BEGIN DECLARE SECTION;
@@ -328,6 +338,12 @@ int setup_alis(struct query *q, char *argv[], client *cl)
        return MR_BAD_CHAR;
     }
 
+  for (p = (unsigned char *) desc; *p; p++)
+    {
+      if (*p == '\n')
+       return MR_BAD_CHAR;
+    }
+
   /* Check that it doesn't conflict with a pre-existing weirdly-cased
    * name. */
   EXEC SQL SELECT COUNT(name) INTO :cnt FROM list
@@ -399,6 +415,11 @@ int setup_dlis(struct query *q, char *argv[], client *cl)
   if (cnt > 0)
     return MR_IN_USE;
 
+  EXEC SQL SELECT COUNT(name) INTO :cnt FROM list
+    WHERE memacl_id = :id AND memacl_type = 'LIST' AND list_id != :id;
+  if (cnt > 0)
+    return MR_IN_USE;
+
   EXEC SQL SELECT COUNT(name) INTO :cnt FROM servers
     WHERE acl_id = :id AND acl_type = 'LIST';
   if (cnt > 0)
@@ -418,7 +439,8 @@ int setup_dlis(struct query *q, char *argv[], client *cl)
     WHERE z.xmt_type = 'LIST' AND z.xmt_id = :id
     OR z.sub_type = 'LIST' AND z.sub_id = :id
     OR z.iws_type = 'LIST' AND z.iws_id = :id
-    OR z.iui_type = 'LIST' AND z.iui_id = :id;
+    OR z.iui_type = 'LIST' AND z.iui_id = :id
+    OR z.owner_type = 'LIST' and z.owner_id = :id;
   if (cnt > 0)
     return MR_IN_USE;
 
@@ -857,7 +879,7 @@ int setup_ahst(struct query *q, char **argv, client *cl)
   int value, id, ssaddr, smask, shigh, slow, cnt;
   unsigned int saddr, mask, high, low;
   EXEC SQL END DECLARE SECTION;
-  int row;
+  int row, idx;
   struct in_addr addr;
 
   id = *(int *)argv[0];
@@ -872,6 +894,11 @@ int setup_ahst(struct query *q, char **argv, client *cl)
   else
     row = 0;
 
+  if (q->version < 6)
+    idx = 0;
+  else
+    idx = 1;
+
   /* Sanity check name, vendor, model, and os. */
   if ((row == 0 || strcasecmp(argv[1], oldname)) &&
       !hostname_check(argv[row]))
@@ -896,18 +923,18 @@ int setup_ahst(struct query *q, char **argv, client *cl)
     return MR_EXISTS;
 
   /* check address */
-  if (!strcmp(argv[9 + row], "unassigned"))
+  if (!strcmp(argv[9 + row + idx], "unassigned"))
     value = -1;
-  else if (!strcmp(argv[9 + row], "unique"))
+  else if (!strcmp(argv[9 + row + idx], "unique"))
     {
-      if (*(int *)argv[8 + row] == 0)
+      if (*(int *)argv[8 + row + idx] == 0)
        value = -1;
       else
        value = -2;
     }
   else
     {
-      value = ntohl(inet_addr(argv[9 + row]));
+      value = ntohl(inet_addr(argv[9 + row + idx]));
       if (value == -1)
        return MR_ADDRESS;
     }
@@ -918,7 +945,7 @@ int setup_ahst(struct query *q, char **argv, client *cl)
       /*
        * an address or unique was specified.
        */
-      id = *(int *)argv[8 + row];
+      id = *(int *)argv[8 + row + idx];
       EXEC SQL SELECT saddr, mask, high, low INTO :ssaddr, :smask,
        :shigh, :slow FROM subnet WHERE snet_id = :id;
       if (dbms_errno)
@@ -942,7 +969,7 @@ int setup_ahst(struct query *q, char **argv, client *cl)
           * link in an inet_addr() that returns an error for
           * this case.
           */
-         addr.s_addr = inet_addr(argv[9 + row]);
+         addr.s_addr = inet_addr(argv[9 + row + idx]);
          name = inet_ntoa(addr);
          EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine
            WHERE address = :name;
@@ -994,13 +1021,13 @@ int setup_ahst(struct query *q, char **argv, client *cl)
        * we have an address in value. Convert it to a string and store it.
        */
       addr.s_addr = htonl(value);
-      strcpy(argv[9 + row], inet_ntoa(addr));
+      strcpy(argv[9 + row + idx], inet_ntoa(addr));
     }
   else
-    strcpy(argv[9 + row], "unassigned");
+    strcpy(argv[9 + row + idx], "unassigned");
 
   /* status checking */
-  value = atoi(argv[7 + row]);
+  value = atoi(argv[7 + row + idx]);
   if (row == 0 && !(value == 1 || value == 0))
     return MR_TYPE;
   if (row == 1)
This page took 0.038808 seconds and 4 git commands to generate.