[SSSD] [PATCH] 1371-Missing resolv.conf should be non-fatal
Jakub Hrozek
jhrozek at redhat.com
Fri Sep 7 12:02:39 UTC 2012
On Fri, Sep 07, 2012 at 12:41:30PM +0200, Michal Židek wrote:
> On 09/07/2012 05:53 AM, Ariel Barria wrote:
> >Patch sent for review.
> >
> >https://fedorahosted.org/sssd/ticket/1371
> >
> >
> >_______________________________________________
> >sssd-devel mailing list
> >sssd-devel at lists.fedorahosted.org
> >https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
>
> Hi Ariel,
>
> I have not tested your patch, but I see some problems in it.
> Do not set errno variable explicitly to 0. It is not how it is ment
> to be used.
Actually, it might be beneficial to clear errno in some cases. stat(2)
is probably not one of them as it only sets errno in an error condition.
Here is a nice summary on the errno checking:
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=6619179
> Also ENOENT is not the only possible error, we
> should check for the other errors as well. Also do not clear
> the return value of stat.
>
> The check should look something like:
>
> ret = stat( ... );
> if (ret != 0) {
I would also assign the errno value to ret immediatelly to avoid
rewriting errno with another DEBUG call for instance.
> if (errno == ENOENT) {
> /* resolv.conf not found. This is the reason for this patch ...*/;
> } else {
> /* ... but we must check for other errors as well
> (the error msg here can be more general) */
> }
> } else {
> /* Here is everything OK */
> }
More information about the sssd-devel
mailing list