[Dnsmasq-discuss] dnsmasq --test > output to stderr

Simon Kelley simon at thekelleys.org.uk
Thu Mar 24 20:37:13 UTC 2022



On 24/03/2022 09:03, Ercolino de Spiacico wrote:
>> The relevant code looks like:
>>
>>   if (testmode)
>>      {
>>        fprintf(stderr, "dnsmasq: %s.\n", _("syntax check OK"));
>>        exit(0);
>>      }
>>
>> So it's not an accident, but the reason it's like that is rather lost 
>> in the mists of time.
>>
>> Can you take advantage of the fact that the exit code is zero when the 
>> test passes, but non-zero if there's an error?
> 
> My ideal scenario would be to suppress the OK and print out any 
> descriptive error (whatever dnsmasq tells me), so it's not just it 
> worked or it didn't. I can try to use the exit code but I can only think 
> of very clumsy ways to extract error messages only...
> 
> 
> Out of curiosity is there an interest in correcting this the OK message 
> to stdout?

Easy to do. The usual consideration applies: will it break existing 
usage? The man page just promises an exit code, it doesn't say anything 
about messages.

If the test fails, the error message gets sent to stderr and logged, 
which seems reasonable. I envisage the main use if this is to test an 
new configuration before stopping the existing instance, on the grounds 
that it's sensible not to kill your DNS until you are fairly sure that 
the new config will in fact come up.

It's not obvious to me that sending the "ok" message to stdout is in 
fact the correct thing to do.


Simon.

> 
> Thanks
> 
> 
> 
> 
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss
> 



More information about the Dnsmasq-discuss mailing list