"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
else
{
rc->suggestions = find_usernames(first, middle, last);
else
{
rc->suggestions = find_usernames(first, middle, last);
+ if (!rc->suggestions && errno)
{
com_err(whoami, errno, "in RIFO");
{
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));
EXEC SQL SELECT COUNT(login) INTO :count FROM users
WHERE login = :username;
if (sqlca.sqlcode)
EXEC SQL SELECT COUNT(login) INTO :count FROM users
WHERE login = :username;
if (sqlca.sqlcode)
+ {
+ errno = MR_DBMS_ERR;
+ return NULL;
+ }
if (count == 0)
{
EXEC SQL SELECT COUNT(name) INTO :count FROM list
WHERE name = :username;
if (sqlca.sqlcode)
if (count == 0)
{
EXEC SQL SELECT COUNT(name) INTO :count FROM list
WHERE name = :username;
if (sqlca.sqlcode)
+ {
+ errno = MR_DBMS_ERR;
+ return NULL;
+ }
}
if (count == 0)
{
EXEC SQL SELECT COUNT(label) INTO :count FROM filesys
WHERE label = :username;
if (sqlca.sqlcode)
}
if (count == 0)
{
EXEC SQL SELECT COUNT(label) INTO :count FROM filesys
WHERE label = :username;
if (sqlca.sqlcode)
+ {
+ errno = MR_DBMS_ERR;
+ return NULL;
+ }
+ /* 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;