]> andersk Git - moira.git/blobdiff - reg_svr/reg_svr.pc
One more 2004 tweak.
[moira.git] / reg_svr / reg_svr.pc
index a293c3b9ab9762e523f81730d2498351b721f15c..43e52e302592d56617046e399f3fffa93ef531a2 100644 (file)
@@ -301,7 +301,7 @@ void RIFO(reg_client *rc, int argc, char **argv)
   char middle[USERS_MIDDLE_SIZE], last[USERS_LAST_SIZE];
   char fullname[USERS_FIRST_SIZE + USERS_MIDDLE_SIZE + USERS_LAST_SIZE];
   char class[USERS_TYPE_SIZE], pin[USERS_PIN_SIZE];
-  int uid, status, secure, sqlstatus;
+  int uid, status, secure, sqlstatus, count;
   EXEC SQL END DECLARE SECTION;
 
   if (rc->uid || argc != 4)
@@ -315,6 +315,8 @@ void RIFO(reg_client *rc, int argc, char **argv)
   ulast = argv[2];
   id = argv[3];
 
+  EXEC SQL SELECT count(login) INTO :count FROM users WHERE clearid = :id;
+
   /* "ORDER BY status" so that if there's both a matching state 0 entry
      and a matching state 3 entry, we'll get the former. */
   EXEC SQL DECLARE csr_id CURSOR FOR
@@ -334,6 +336,14 @@ void RIFO(reg_client *rc, int argc, char **argv)
       strtrim(class);
       strtrim(pin);
 
+      /* It's possible they have both a deleted account and a status 8
+       * account.  We can't compensate for that in the ORDER BY clause
+       * above, so check here.  If they have more than one entry and the
+       * first one we get is deleted, skip it.
+       */
+      if (status == US_DELETED && count > 1)
+       continue;
+
       /* Check names, allowing for the possibility that Moira and the
         user might have them split up differently. eg, Mary/Ann/Singleton
         vs. Mary Ann/Singleton. */
@@ -348,6 +358,9 @@ void RIFO(reg_client *rc, int argc, char **argv)
        continue;
       if (strlen(first) > 3 && strlen(ufirst) < 3)
        continue;
+      if (!*ufirst && !*ulast)
+       continue;
+
       /* Ignore the middle name since Moira doesn't have those reliably */
       break;
     }
@@ -501,10 +514,8 @@ void SPIN(reg_client *rc, int argc, char **argv)
       return;
     }
 
-  /* "ORDER BY status" so that if there's both a matching state 0 entry
-     and a matching state 3 entry, we'll get the former. */
   EXEC SQL SELECT pin INTO :pin FROM users WHERE clearid = :rc->id
-    ORDER BY status;
+    AND status = :rc->user_status;
   strtrim(pin);
   if (strcmp(argv[0], pin) != 0)
     {
This page took 0.121494 seconds and 4 git commands to generate.