[Nut-upsuser] Problem after reboot
Arjen de Korte
nut+users at de-korte.org
Fri Mar 3 12:48:41 UTC 2006
> The reason for "Success" is that the code calls
>
> fatal("getpwnam(%s)", user);
>
> and not
>
> fatalx("getpwnam(%s)", user);
>
> While this fact is not widely documented, the only difference between
> the (badly named) procedures fatal() and fatalx() is that fatal()
> prints an error message based on errno, whereas fatalx() does not. So
> one should only call fatal() in the case of an error condition that
> has actually set errno.
Thanks for this explanation. I also saw your patch on commits. While this
patch will surely help in this particular instance, I would rather see a
more general solution to this. I really think that the fatal() function
should never, ever print ': Success'. It aborts execution prematurely and
as such, 'Success' is probably the opposite of what is going on.
To fix this for all programs using a call to fatal() to bail out, I
propose the following addition to the fatal() function (no diff yet, as
I'm not behind my development machine now):
void fatal(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
- vfatal(fmt, va, 1);
+ vfatal(fmt, va, (errno > 0) ? 1 : 0);
va_end(va);
exit(EXIT_FAILURE);
}
Besides this, we should really try to be more verbose in the error
messages. The error message is not very informative to non-programmers:
getpwnam(nut): Success
since it doesn't really help in locating the problem. I think something in
the line of
error: can't get uid for user 'nut'
would have a better chance of directing the OP to finding the cause of the
driver not being able to start (non existant nut user).
Arjen
More information about the Nut-upsuser
mailing list