]> andersk Git - moira.git/commitdiff
find_usernames returns NULL either for "can't suggest a username" or
authordanw <danw>
Tue, 25 Aug 1998 15:52:48 +0000 (15:52 +0000)
committerdanw <danw>
Tue, 25 Aug 1998 15:52:48 +0000 (15:52 +0000)
"an error occurred". make sure it sets or unsets errno appropriately and
check errno as well as the return value when calling it. fixes [1185] in
moira / [1519] in moira-admin

reg_svr/reg_svr.pc

index 0841bfbef23cfbebc2dcd7e96002d03a14cfbc86..bbfcdad1bb435bbe24928cf27e496e0c6dad73f5 100644 (file)
@@ -407,10 +407,10 @@ void RIFO(reg_client *rc, int argc, char **argv)
   else
     {
       rc->suggestions = find_usernames(first, middle, last);
-      if (!rc->suggestions)
+      if (!rc->suggestions && errno)
        {
          com_err(whoami, errno, "in RIFO");
-         reply(rc, INTERNAL_ERROR, "INIT", "c", NULL, "Out of memory");
+         reply(rc, INTERNAL_ERROR, "INIT", "c", NULL, error_message(errno));
          return;
        }
     }
@@ -737,20 +737,29 @@ char *find_usernames(char *first, char *middle, char *last)
       EXEC SQL SELECT COUNT(login) INTO :count FROM users
        WHERE login = :username;
       if (sqlca.sqlcode)
-       return NULL;
+       {
+         errno = MR_DBMS_ERR;
+         return NULL;
+       }
       if (count == 0)
        {
          EXEC SQL SELECT COUNT(name) INTO :count FROM list
            WHERE name = :username;
          if (sqlca.sqlcode)
-           return NULL;
+           {
+             errno = MR_DBMS_ERR;
+             return NULL;
+           }
        }
       if (count == 0)
        {
          EXEC SQL SELECT COUNT(label) INTO :count FROM filesys
            WHERE label = :username;
          if (sqlca.sqlcode)
-           return NULL;
+           {
+             errno = MR_DBMS_ERR;
+             return NULL;
+           }
        }
 
       if (count == 0)
@@ -775,6 +784,9 @@ char *find_usernames(char *first, char *middle, char *last)
       ;
     }
 
+  /* unames will be NULL if we couldn't suggest a username. Clear
+     errno so the caller can distinguish this from an error case. */
+  errno = 0;
   return unames;
 }
 
This page took 0.043021 seconds and 5 git commands to generate.