You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Surya prakash Verma <su...@tataelxsi.co.in.INVALID> on 2020/03/12 05:05:28 UTC
DNS Name Resolution Issue
Hello All,
I am trying to test DNS Name resolution but observed issue of file opening fails while running.
After debugging we have observed fails at following code:
stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); in libs/libc/netdb/lib_dnsaddserver.c.
We have analyzed the issue and observed trying to open resolv.conf in "at" mode but There is no such mode as "at" in C programming.
So We have experimented with "a+" "w+" etc but these did not work because of the "resolv.conf" file resides in /etc directory in ROMFS,
ROMFS supports only "r" mode.
So modified the code as mentioned below.
stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); must be changed to
stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "r");
With this change it is working properly.
Kindly confirm our understanding.
Thanks & Regards,
Surya
________________________________
Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient of this message , or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited. Email transmission cannot be guaranteed to be secure or error-free, as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender, therefore, does not accept liability for any errors, omissions or contaminations in the contents of this message which might have occurred as a result of email transmission. If verification is required, please request for a hard-copy version.
________________________________
Re: DNS Name Resolution Issue
Posted by Nathan Hartman <ha...@gmail.com>.
On Thu, Mar 12, 2020 at 11:33 AM Gregory Nutt <sp...@gmail.com> wrote:
> >> We have analyzed the issue and observed trying to open resolv.conf in "at" mode but There is no such mode as "at" in C programming.
> >> So We have experimented with "a+" "w+" etc but these did not work because of the "resolv.conf" file resides in /etc directory in ROMFS,
> >> ROMFS supports only "r" mode.
> >> So modified the code as mentioned below.
> >> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); must be changed to
> >> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "r");
> >>
> >> With this change it is working properly.
> > Perhaps the original author intended "a+" (open for append/update)?
> > However, if the file is never written to, only read from, then "r" is
> > correct.
> >
> > Just for completeness I looked through all other instances of fopen()
> > calls in nuttx and apps. This appears to be the only one with an
> > illegal mode string.
>
> It is just some dumb typo of unknown origin at this point. The
> /etc/resolve.conf logic has obviously never been built or tested so some
> compile issues or odd behavior is not unexpected.
>
> What is needed is a PR.
I created PR 558:
https://github.com/apache/incubator-nuttx/pull/558
Cheers,
Nathan
Re: DNS Name Resolution Issue
Posted by Gregory Nutt <sp...@gmail.com>.
>> We have analyzed the issue and observed trying to open resolv.conf in "at" mode but There is no such mode as "at" in C programming.
>> So We have experimented with "a+" "w+" etc but these did not work because of the "resolv.conf" file resides in /etc directory in ROMFS,
>> ROMFS supports only "r" mode.
>> So modified the code as mentioned below.
>> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); must be changed to
>> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "r");
>>
>> With this change it is working properly.
> Perhaps the original author intended "a+" (open for append/update)?
> However, if the file is never written to, only read from, then "r" is
> correct.
>
> Just for completeness I looked through all other instances of fopen()
> calls in nuttx and apps. This appears to be the only one with an
> illegal mode string.
It is just some dumb typo of unknown origin at this point. The
/etc/resolve.conf logic has obviously never been built or tested so some
compile issues or odd behavior is not unexpected.
What is needed is a PR.
Re: DNS Name Resolution Issue
Posted by Nathan Hartman <ha...@gmail.com>.
On Thu, Mar 12, 2020 at 1:05 AM Surya prakash Verma
<su...@tataelxsi.co.in.invalid> wrote:
> We have analyzed the issue and observed trying to open resolv.conf in "at" mode but There is no such mode as "at" in C programming.
> So We have experimented with "a+" "w+" etc but these did not work because of the "resolv.conf" file resides in /etc directory in ROMFS,
> ROMFS supports only "r" mode.
> So modified the code as mentioned below.
> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); must be changed to
> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "r");
>
> With this change it is working properly.
Perhaps the original author intended "a+" (open for append/update)?
However, if the file is never written to, only read from, then "r" is
correct.
Just for completeness I looked through all other instances of fopen()
calls in nuttx and apps. This appears to be the only one with an
illegal mode string.
Cheers,
Nathan
Re: DNS Name Resolution Issue
Posted by Gregory Nutt <sp...@gmail.com>.
> That seems like a correct analysis. Can you please submit a PR to
https://github.com/apache/incubator-nuttx ?
Sorry, that should have been https://github.com/apache/incubator-nuttx-apps/
Re: DNS Name Resolution Issue
Posted by Gregory Nutt <sp...@gmail.com>.
> I am trying to test DNS Name resolution but observed issue of file opening fails while running.
>
> After debugging we have observed fails at following code:
> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); in libs/libc/netdb/lib_dnsaddserver.c.
>
> We have analyzed the issue and observed trying to open resolv.conf in "at" mode but There is no such mode as "at" in C programming.
> So We have experimented with "a+" "w+" etc but these did not work because of the "resolv.conf" file resides in /etc directory in ROMFS,
> ROMFS supports only "r" mode.
> So modified the code as mentioned below.
> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "at"); must be changed to
> stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "r");
>
> With this change it is working properly.
>
> Kindly confirm our understanding.
That seems like a correct analysis. Can you please submit a PR to
https://github.com/apache/incubator-nuttx ?