Re: [PATCH] new applet gethostbyname
Hi Eial ! You are not right. It is not the same behavior! what is the difference then? Thats what we are talking about ! On one hand, simple IP lookup using libc function (gethostbyname), on the other hand, full DNS query (like host command). You can find the IP address of a name with less code, correct, but this uses the libc implementation of the resolver and does not the same kind of work a DNS client does. So the decision is first, which kind of work you need - In your case: Simple IP address lookup with libc function. are you talking about dnsip? dnsip is an example of a full DNS query program like the host command from bind. My explanation decision was more general, not specific to an implementation. In case you would need a full fledged DNS query (seperate from libc implementation), Laurent would be right. I don't think you are able to write a full DNS query with less code. so both ping and nslookup have full fledged DNS query? ping ? Does ping use/need a full dns query? As far as I know does ping only use simple ip lookup, and then send out network packages to those addresses (ICMP or UDP) nslookup, I ought yes, it shall do a full dns query (bypassing libc implementation). ... but I have not looked into current code. So please keep in mind: Things tend to look different if viewed from a more global point, and you need to use the correct language to describe your problem, otherwise anybody will misunderstand something and complain or point you in a wrong direction. I've done that very clear, but still I'll retry: You mixed up two different things. Simple IP lookup (what seams to be the right thing for you), and the host command (implementing it for Busybox) on the other side. The host command IS NOT simple IP lookup, it is full DNS query. IMO that was your mixture, leading to lengthy discussion. The complaining was due to using the name 'host' for an applet which just does simple IP lookup, as that name is the name of a full DNS query command ... and mixing those would confuse others. So a 'getent hosts' applet seams to be the right thing for your job ... if it is included in Busybox. IMO a good idea due to general usability / function of getent for scripting purposes, but not my decision. I have two system, on each I need to run a script which queries me for a hostname, that hostname needs to be converted to ip, what applet should I use that will give me the ip without the need for output parsing? Currently there is none in Busybox (without parsing of output). I'm using a slightly patched version of ipcalc applet to do the job of gethostbyname :-) ... have posted a patch for this about two years ago, but it has not bean accepted. Beside this, Busybox has nslookup. What is wrong with that? Only different output format? In case you complain because the many information it displays: What about an option for nslookup, lets say -s (for short) to display only single line of output (if only one address returned from query)? Just as an unverified idea. What about this? as said before, I have two distinct systems in which nslookup gives two distinct outputs. that is why nslookup isn't good. Please post example of different output, including version of Busybox of the two systems. Let as see why output is different. maybe adding -S switch for nslookup is a good idea but that is not what I've intended to begin with. It was just an idea of a way we could go, in case you want a full DNS query (not only simple IP lookup). Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Harald, On 07/08/2012 09:24 AM, ra...@gmx.de wrote: Thats what we are talking about ! On one hand, simple IP lookup using libc function (gethostbyname), on the other hand, full DNS query (like host command). I thought we've finished the getent vs host discussion. dnsip is an example of a full DNS query program like the host command from bind. My explanation decision was more general, not specific to an implementation. doesn't getaddrinfo provides that? ping ? Does ping use/need a full dns query? As far as I know does ping only use simple ip lookup, and then send out network packages to those addresses (ICMP or UDP) when enabling fancy output in ping, one can see the ip of the pinged machine. The complaining was due to using the name 'host' for an applet which just does simple IP lookup, as that name is the name of a full DNS query command ... and mixing those would confuse others. but we closed that issue. Currently there is none in Busybox (without parsing of output). that is why I've wrote the applet in the first place. I'm using a slightly patched version of ipcalc applet to do the job of gethostbyname :-) ... have posted a patch for this about two years ago, but it has not bean accepted. I see. Please post example of different output, including version of Busybox of the two systems. Let as see why output is different. system 1: nslookup skynet Server: 10.200.10.20 Address:10.200.10.20#53 Name: skynet Address: 10.200.10.20 system 2: nslookup skynet Server:10.200.10.20 Address 1: 10.200.10.20 skynet Name: skynet Address 1: 10.200.10.20 skynet It was just an idea of a way we could go, in case you want a full DNS query (not only simple IP lookup). we need a decision on this. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! I thought we've finished the getent vs host discussion. dnsip is an example of a full DNS query program like the host command from bind. My explanation decision was more general, not specific to an implementation. doesn't getaddrinfo provides that? It looks to me, you still mix up some information. Here we talked about a DNS query program (e.g. host or dnsip) and now you are asking about the libc function getaddrinfo. I'm not sure if I understand, what are you asking? getaddrinfo is a libc function of the same family as gethostbyname. ping ? Does ping use/need a full dns query? As far as I know does ping only use simple ip lookup, and then send out network packages to those addresses (ICMP or UDP) when enabling fancy output in ping, one can see the ip of the pinged machine. Providing the IP address does not mean it contain explicit DNS query code. The code of ping uses simple IP lookup (that is the libc function). In addition to showing up that information ping send's out network packages to measure round trip time. No good candidate, as it produces extra network traffic if you only want to get your IP address. Currently there is none in Busybox (without parsing of output). that is why I've wrote the applet in the first place. Sure, but there are many people who do not like to clutter the Busybox binary with many applets that not of wide spread interest or at least modeled after an widely used upstream package. So your chance to get a simple applet named 'gethostbyname' into Busybox is really low. It only gets better, if you hit a wider amount of users need. system 1: nslookup skynet Server: 10.200.10.20 Address:10.200.10.20#53 Name: skynet Address: 10.200.10.20 system 2: nslookup skynet Server:10.200.10.20 Address 1: 10.200.10.20 skynet Name: skynet Address 1: 10.200.10.20 skynet You forgot to post the versions of Busybox. Looks to me your System 1 uses an older version of Busybox. As far as I know newer versions of Busybox corrected / extended the output of nslookup to allow for multiple addresses. Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Harald, On 07/08/2012 12:34 PM, ra...@gmx.de wrote: It looks to me, you still mix up some information. Here we talked about a DNS query program (e.g. host or dnsip) and now you are asking about the libc function getaddrinfo. I'm not sure if I understand, what are you asking? getaddrinfo is a libc function of the same family as gethostbyname. we've agreed in an off list mail thread that getent is the right course of action here, why does dnsip should change it? Providing the IP address does not mean it contain explicit DNS query code. The code of ping uses simple IP lookup (that is the libc function). In addition to showing up that information ping send's out network packages to measure round trip time. No good candidate, as it produces extra network traffic if you only want to get your IP address. I still fail to see the issue, why this is different then previously decided? Sure, but there are many people who do not like to clutter the Busybox binary with many applets that not of wide spread interest or at least modeled after an widely used upstream package. I have no problem with that. So your chance to get a simple applet named 'gethostbyname' into Busybox is really low. It only gets better, if you hit a wider amount of users need. I'm not in it for the sole notion of getting an applet into busybox, I've encountered a strange issue and found a solution, as I like to help others, I've decided to offer the applet to the community, if the community doesn't want my applet, that is ok, I have no problems with that. You forgot to post the versions of Busybox. Looks to me your System 1 uses an older version of Busybox. As far as I know newer versions of Busybox corrected / extended the output of nslookup to allow for multiple addresses. both use the same busybox 1.19.2 Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Eial Czerwacki wrote: system 1: nslookup skynet Server: 10.200.10.20 Address:10.200.10.20#53 Name: skynet Address: 10.200.10.20 system 2: nslookup skynet Server:10.200.10.20 Address 1: 10.200.10.20 skynet Name: skynet Address 1: 10.200.10.20 skynet both use the same busybox 1.19.2 Looking at the source busybox-1.19.2/networking/nslookup.c it's simply not possible that the output of system 1 comes from busybox 1.19.2. By the way, the applet nslookup is misleading, because it uses getaddrinfo instead of a DNS query. As a consequence, there are even answers from non existing DNS-servers. # nslookup localhost 0.0.0.0 Server:0.0.0.0 Address 1: 0.0.0.0 Name: localhost Address 1: 127.0.0.1 localhost Ralf ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! we've agreed in an off list mail thread that getent is the right course of action here, why does dnsip should change it? It was Laurent who mentioned dnsip. You mixed only things and I tried to clarify this. I still fail to see the issue, why this is different then previously decided? ping is not a candidate to just query an IP address. Completely different purpose - don't use it for this purpose if you do not understand why! I'm not in it for the sole notion of getting an applet into busybox, I've encountered a strange issue and found a solution, as I like to help others, I've decided to offer the applet to the community, if the community doesn't want my applet, that is ok, I have no problems with that. You mixed things up and mentioned to add your applet with optional name 'host'. Giving an applet of your function this name is wrong. This is what I wanted to clarify and why. In addition I wanted to help you finding the info of the mentioned getent command. That's all. You forgot to post the versions of Busybox. Looks to me your System 1 uses an older version of Busybox. As far as I know newer versions of Busybox corrected / extended the output of nslookup to allow for multiple addresses. both use the same busybox 1.19.2 Whops! This looks not very well. May be you detected a bug? Same version shell give comparable output. There seams to be definitly something wrong, especially that '#53'. Try to find the reason. Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Ralf, On 07/08/2012 01:27 PM, Ralf Friedl wrote: Looking at the source busybox-1.19.2/networking/nslookup.c it's simply not possible that the output of system 1 comes from busybox 1.19.2. but still I do see two distinct outputs on the same busybox. By the way, the applet nslookup is misleading, because it uses getaddrinfo instead of a DNS query. As a consequence, there are even answers from non existing DNS-servers. # nslookup localhost 0.0.0.0 Server:0.0.0.0 Address 1: 0.0.0.0 Name: localhost Address 1: 127.0.0.1 localhost Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Harald, On 07/08/2012 01:33 PM, ra...@gmx.de wrote: It was Laurent who mentioned dnsip. You mixed only things and I tried to clarify this. indeed but I don't think that is it relevant anymore. ping is not a candidate to just query an IP address. Completely different purpose - don't use it for this purpose if you do not understand why! agreed, that is why I didn't used ping from the beginning, I've just mentioned ping as an example. You mixed things up and mentioned to add your applet with optional name 'host'. Giving an applet of your function this name is wrong. This is what I wanted to clarify and why. In addition I wanted to help you finding the info of the mentioned getent command. That's all. look at the mailing thread, I've addressed it already (hint: going the getent way) Whops! This looks not very well. May be you detected a bug? Same version shell give comparable output. There seams to be definitly something wrong, especially that '#53'. Try to find the reason. my bed it on dhcp server config, as I cannot force someone to config his server in a different way, I cannot use nslookup. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Ralf ! By the way, the applet nslookup is misleading, because it uses getaddrinfo instead of a DNS query. As a consequence, there are even answers from non existing DNS-servers. Whops ... so Busybox nslookup does the job of 'getent hosts' (or one of its alikes) ... and not a separate DNS query as expected. Hence nslookup shall definitely provide the information required by Eial and may be a candidate for a '-s' short output format extension (which may be a useful scripting extension). Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Eial Czerwacki wrote: On 07/08/2012 01:27 PM, Ralf Friedl wrote: Looking at the source busybox-1.19.2/networking/nslookup.c it's simply not possible that the output of system 1 comes from busybox 1.19.2. but still I do see two distinct outputs on the same busybox. Please verify that it is really the same busybox. Call busybox to get the version information, and busybox nslookup skynet to get the output. Ralf ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! my bed it on dhcp server config, as I cannot force someone to config his server in a different way, I cannot use nslookup. Different DHCP server config shall not give different nslookup output if device is configured for same IP address. So there is usually something wrong. I think it's best to find the reason for this difference and to fix it. Otherwise nslookup does the job you wanted, as Ralf mentioned. It differs only in output format. So don't try to add different applet for nearly same operation. If only output format matters, add on option to control output format. More likely this gets accepted then a new applet (if for general scripting purpose). Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/08/2012 01:57 PM, Ralf Friedl wrote: Eial Czerwacki wrote: On 07/08/2012 01:27 PM, Ralf Friedl wrote: Looking at the source busybox-1.19.2/networking/nslookup.c it's simply not possible that the output of system 1 comes from busybox 1.19.2. but still I do see two distinct outputs on the same busybox. Please verify that it is really the same busybox. Call busybox to get the version information, and busybox nslookup skynet to get the output. Ralf same usb mass storage device on two different systems Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Harald Becker wrote: By the way, the applet nslookup is misleading, because it uses getaddrinfo instead of a DNS query. As a consequence, there are even answers from non existing DNS-servers. Whops ... so Busybox nslookup does the job of 'getent hosts' (or one of its alikes) ... and not a separate DNS query as expected. When I wrote that, I assumed that it would only return answers from an /etc/hosts lookup. But it seems that the attempt to set an alternate DNS-Server is not effective with busybox 1.19.3 and uClibc-0.9.29: # nslookup www.google.com 0.0.0.0 Server:0.0.0.0 Address 1: 0.0.0.0 Name: www.google.com Address 1: 173.194.35.176 muc03s02-in-f16.1e100.net Address 2: 173.194.35.177 muc03s02-in-f17.1e100.net Address 3: 173.194.35.178 muc03s02-in-f18.1e100.net Address 4: 173.194.35.179 muc03s02-in-f19.1e100.net Address 5: 173.194.35.180 muc03s02-in-f20.1e100.net Ralf ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Harald, On 07/08/2012 02:04 PM, ra...@gmx.de wrote: Different DHCP server config shall not give different nslookup output if device is configured for same IP address. So there is usually something wrong. I think it's best to find the reason for this difference and to fix it. Otherwise nslookup does the job you wanted, as Ralf mentioned. It differs only in output format. So don't try to add different applet for nearly same operation. If only output format matters, add on option to control output format. More likely this gets accepted then a new applet (if for general scripting purpose). nslookup is not a valid option currently. I cannot take in account all possible outputs. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! nslookup is not a valid option currently. I cannot take in account all possible outputs. You shall not consider different outputs, you shall fix the bug here (or at least help to fix). It is not correct that you receive different output format. With correct output nslookup shall give the information you requested. You only need to pick the info from output. So there is an applet that contains the code to query the information you want. Adding an option to to nslookup to change output format for easy scripting shall definitely be considered. So go two steps: 1. Fix problem of different output of nslookup 2. Add option (e.g. -s) to nslookup applet to produce a simpler output format for easy script usage I think there will be many users who agree with this and will vote to add this option to Busybox main line (or at least do not complain). Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Eial Czerwacki wrote: On 07/08/2012 01:57 PM, Ralf Friedl wrote: Eial Czerwacki wrote: On 07/08/2012 01:27 PM, Ralf Friedl wrote: Looking at the source busybox-1.19.2/networking/nslookup.c it's simply not possible that the output of system 1 comes from busybox 1.19.2. but still I do see two distinct outputs on the same busybox. Please verify that it is really the same busybox. Call busybox to get the version information, and busybox nslookup skynet to get the output. same usb mass storage device on two different systems What I don't understand is why you even consider some kB significant if you have an USB storage device. So it seems that you don't want to do what I suggested. If it is the same binary, as you write, I'm sure you would find that you get the same output in both cases. Well, if it's not important for you why you get different outputs from supposedly the same program, and prefer to blame it on the DHCP server, or the phase of the moon, I don't see why it should be more important to other people. I'll give you one last advice anyway. The output of your system 1 looks exactly like the output from bind-utils nslookup. So it seems that your system 1 uses a different nslookup program. Ralf ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Ralf, On 07/08/2012 03:25 PM, Ralf Friedl wrote: What I don't understand is why you even consider some kB significant if you have an USB storage device. the fact that I use USB storage device doesn't means that I have plenty of room, I have very limited root for the actual boot system. why I cannot use more room, because my boss said so, these are the limitation. So it seems that you don't want to do what I suggested. if your suggestion is to use dnsip, than again, not an option. If it is the same binary, as you write, I'm sure you would find that you get the same output in both cases. I'm sure you are sure but in reality that is not the case, I get different outputs. Well, if it's not important for you why you get different outputs from supposedly the same program, and prefer to blame it on the DHCP server, or the phase of the moon, I don't see why it should be more important to other people. I've found a problem and come up with a solution, I've decided on my free time to pitch it to the community so don't be disrespectful because I'm pretty sure that you would not want some to disrespect you. as I don't know what is the issue and the systems most probably differ on the server side but not on the client side, I tend to I'll give you one last advice anyway. The output of your system 1 looks exactly like the output from bind-utils nslookup. So it seems that your system 1 uses a different nslookup program. again, you are not listening... Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
It was Laurent who mentioned dnsip. And I did for a reason. (Time for a little rant.) The root of the problem here is that historically, there were different mechanisms used to perform human-readable name - IP address resolution. DNS was one of them, and ended up being the most widely used (for good reason: it is, by definition, distributed), but it was not the first. Other mechanisms were, for instance, Sun's NIS and NIS+. I don't know who the culprit is - I want to accuse GNU as usual, but I don't think they're the only one at fault here, because the idiocy made it into the standard: *somebody* thought that it would be a good idea to unify all the naming protocols under a unique interface that would hide all the details, and include that interface into the libc. That interface was gethostbyname(). It was later replaced by getaddrinfo(), which suffers from the exact same problems - although Single Unix v4's getaddrinfo() page acknowledges that it is often implemented via DNS now: see http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html So, there is only *one* standard, libc-provided, interface, for name resolution, and that is gethostbyname(), or now getaddrinfo(). And you cannot be sure that it uses DNS: it all depends on your machine and network configuration. It could use NIS on some architecture, or even some Active Directory-based WINS resolution if the network is mostly Microsoft-administered. On most systems, getaddrinfo() will first look up the /etc/hosts file (which is an old legacy interface for naming, and it is widely accepted that the naming scheme in /etc/hosts should be compatible with DNS, but it is, strictly speaking, not DNS), and then fall back on DNS resolution if /etc/hosts doesn't give an answer. GNU calls this system NSS, Name Service Switch, and on GNU systems, getaddrinfo()'s behaviour is configured via the /etc/nsswitch.conf file. The usual /etc/nsswitch.conf will just contain order hosts, bind, which means lookup /etc/hosts first and DNS second. The problem with NSS is that it's useless. Everybody uses DNS now. People who use NIS know they use NIS and use NIS tools for name resolution. People who use WINS use Microsoft tools - and generally also use DNS. Programmers use getaddrinfo() expecting to access DNS and nothing else. NSS is a bloated compatibility layer that just gets in the way; getaddrinfo() is a *horrible* API to access DNS, because it has to be very generic (to handle every possible name service under the sun) and can't focus on the interesting details of DNS - for instance, it is totally synchronous by nature, with no way of specifying a timeout except via a previous alarm() call. And there is *no* standard API that means do a simple DNS query, just bypass NSS. Every libc, even the uClibc, has to implement some minimal NSS into getaddrinfo() - if only to allow /etc/hosts resolution. There is no standard libc hook for DNS resolution, even if the internals of getaddrinfo() have to perform it. So applications needing pure DNS access have to implement DNS resolution themselves. This is obviously hard work, so a few DNS resolution libraries exist out there. The most common is BIND's own libresolv; good luck trying to use this in an embedded system. Another one is djbdns' client library, which I have successfully made work on several embedded systems, with a very small memory footprint and disk usage. The dnsip utility I mentioned is based on this library, and that is why I mentioned it: it's a small tool that performs a full-fledged DNS query. Comparatively, the host command, which does the same, needs BIND's libresolv, with a much bigger memory and disk footprint. Note that busybox nslookup cheats, and if busybox host were to be implemented, it would most likely cheat too: busybox nslookup doesn't perform DNS resolution, it performs NSS resolution, via the only API it has access to: getaddrinfo(). And even if it was not cheating, it would be a very bad idea to use nslookup anyway: http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/nslookup-flaws.html explains all the problems there are with BIND's original nslookup design and implementation as far as DNS diagnostics are concerned. The only way for busybox not to cheat and really implement DNS tools would be to integrate a complete DNS client library into it. I think it would be outside the scope of busybox, though; let busybox do what it can with NSS resolution, and use real, external DNS tools if you need to do DNS. I have written a complete embeddable DNS client library (inspired by the djbdns client library but with better APIs), and plan to release it when it's at least a bit documented. I can send it to anyone who wants to work with DNS, but don't be delusional: if a static 27 kB binary is too big for you, then just don't try to do proper DNS, and stick to your libc's NSS. -- Laurent ___ busybox mailing list
Re: [PATCH] new applet gethostbyname
On Sun, 2012-07-08 at 08:22 +0300, Eial Czerwacki wrote: On 07/05/2012 06:41 PM, Paul Smith wrote: If you can use a getent applet instead, and one is created and added to busybox, that would be better for everyone of course. Cheers! offering me to use a applet that isn't even in busybox, weights 27kb where again size does matters when my small applet does the same in a fraction of the size is not logical. Sorry if what I wrote wasn't clear. I wasn't suggesting you would use the getent program. That's why I write applet (i.e., busybox applet) above, not program. as I've said is previous mail, I'll think on how I can create a getent applet and pitch it up instead. That's what I meant by my comment. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/08/2012 04:01 PM, Paul Smith wrote: On Sun, 2012-07-08 at 08:22 +0300, Eial Czerwacki wrote: On 07/05/2012 06:41 PM, Paul Smith wrote: If you can use a getent applet instead, and one is created and added to busybox, that would be better for everyone of course. Cheers! offering me to use a applet that isn't even in busybox, weights 27kb where again size does matters when my small applet does the same in a fraction of the size is not logical. Sorry if what I wrote wasn't clear. I wasn't suggesting you would use the getent program. That's why I write applet (i.e., busybox applet) above, not program. as I've said is previous mail, I'll think on how I can create a getent applet and pitch it up instead. That's what I meant by my comment. cool :) ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Laurent ! Quick fix, major absolutely correct: /etc/nsswitch contains line: hosts: files dns /etc/host.conf contains: order hosts, bind ... which usually doubles something? Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
as I've said is previous mail, I'll think on how I can create a getent applet and pitch it up instead. That's what I meant by my comment. cool :) cool, yes ... but as Ralf mentioned, we already have that applet, with just a different output format: nslookup (accepting it does NSS lookup and not not DNS lookup) ... so we have no need to add another applet. ... and again: The difference of nslookup output is unintentional and ought to be a bug, either in usage or in Busybox. So Eial shall try to fix that flaw first. Thereafter format of output (and possible short option) can be discussed. Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Paul ! The nslookup program does not do NSS lookup. We are talking about Busybox nslookup. As Ralf mentioned it does NSS lookup. If the busybox version of nslookup uses nsswitch.conf / ... then it's not correct Sure ... Ralf told this already ... The Busybox nslookup is claiming to do DNS lookup but does NSS ... so the current Busybox nslookup does what upstream 'getent hosts' is providing. Also getent does a lot more than just show hostnames. As I said before it's a command line interface to all the get*ent() functions in libc so in addition to hostnames it can be used to look up passwd entries, group entries, etc. A getent applet in busybox WOULD be very useful. Full ack! Are you able to provide a new getent applet (deleting the current nslookup)? (Sorry currently can't do development work due to personal/health restrictions). Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On Sun, Jul 08, 2012 at 05:36:08PM +0200, ra...@gmx.de wrote: Full ack! Are you able to provide a new getent applet (deleting the current nslookup)? (Sorry currently can't do development work due to personal/health restrictions). I question the benefit of deleting a utility that some people might be using, even if it's doing slightly the wrong thing. If anybody wants the real nslookup behavior, DNS is a pretty trivial protocol and it should be easy to add a correct applet at the same time instead of just removing the incorrect one. Parsing and treating resolv.conf properly is actually probably the bulk of the work; sending, receiving, and printing the DNS result is completely trivial. Rich ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Rich ! On Sun, Jul 08, 2012 at 05:36:08PM +0200, ra...@gmx.de wrote: Full ack! Are you able to provide a new getent applet (deleting the current nslookup)? (Sorry currently can't do development work due to personal/health restrictions). I question the benefit of deleting a utility that some people might be using, even if it's doing slightly the wrong thing. Sorry, I expressed it wrong. so let me clarify: Change delete the current nslookup to making current nslookup a proposal for removement / replacement, what was my intention. If anybody wants the real nslookup behavior, DNS is a pretty trivial protocol and it should be easy to add a correct applet at the same time instead of just removing the incorrect one. As it seams to me that nslookup is a dieing command and it is more and more replaced by the host command, we should create a host command applet for Busybox in this case (IMO) ... or add dnsip? ... otherwise correct. Replacing wrong applet with correctly working code is better then simply removing. I based my decision of removal on the assumption that no one is willing to add a full DNS query directly to Busybox (instead using e.g. dnsip - like mentioned by Laurent). Parsing and treating resolv.conf properly is actually probably the bulk of the work; sending, receiving, and printing the DNS result is completely trivial. Fine, looks a bit to me, as you are pointing up to create a full version of a host command to Busybox ... pretty nice ;-) Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Quick fix, major absolutely correct: /etc/nsswitch contains line: hosts: files dns /etc/host.conf contains: order hosts, bind Ah, yes, I confused the syntaxes, sorry about that. /etc/nsswitch.conf indeed contains something like hosts: files dns to configure NSS. The thing is that libresolv, the BIND DNS client library, *also* adds a compatibility layer to /etc/hosts, in case someone doesn't want to use NSS *but* still wants a /etc/hosts file for local DNS definitions. /etc/host.conf is a configuration file for the libresolv, and order hosts, bind means that DNS queries will first be answered using the data in /etc/hosts if possible, and fall back on real DNS mechanisms otherwise. Compatibility layer on compatibility layer! Conclusion: for direct DNS access, use the djbdns command-line tools, the djbdns client library, or my client library. Less bloat, less complexity, better interfaces. :P -- Laurent ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/05/2012 06:41 PM, Paul Smith wrote: On Thu, 2012-07-05 at 17:13 +0300, Eial Czerwacki wrote: On 07/05/2012 02:03 PM, Laurent Bercot wrote: but these bins are large, my applet adds at most 3kb to the total size. My statically linked dnsip applet is 27 kB. This does not qualify as large by any means on a full-fledged Unix platform (even an embedded one), especially compared to the BIND host binary. for me it does, way to big when one can get the same behavior in a fraction of the size. That's fine but you have to understand that just because adding a new custom applet like this to busybox would be the best for your specific environment that doesn't mean it's the best for everyone else, or for the busybox project as a whole. If it ends up that you need this particular gethostbyname applet as written previously then probably you should keep it locally and continue to patch it into your personal version of busybox. If you can use a getent applet instead, and one is created and added to busybox, that would be better for everyone of course. Cheers! I've encountered a problem under busybox in which I wasn't able to get a the ip of a machine in an exact manner on different systems, I've wrote a applet that solves it and I've pitched it up to the community, as busybox should be size optimized. offering me to use a applet that isn't even in busybox, weights 27kb where again size does matters when my small applet does the same in a fraction of the size is not logical. it is like you'll want to add -vvv to lspci and I'd advise you to use a statically linked full lspci. as I've said is previous mail, I'll think on how I can create a getent applet and pitch it up instead. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Harald, You are not right. It is not the same behavior! what is the difference then? You can find the IP address of a name with less code, correct, but this uses the libc implementation of the resolver and does not the same kind of work a DNS client does. So the decision is first, which kind of work you need - In your case: Simple IP address lookup with libc function. are you talking about dnsip? In case you would need a full fledged DNS query (seperate from libc implementation), Laurent would be right. I don't think you are able to write a full DNS query with less code. so both ping and nslookup have full fledged DNS query? So please keep in mind: Things tend to look different if viewed from a more global point, and you need to use the correct language to describe your problem, otherwise anybody will misunderstand something and complain or point you in a wrong direction. I've done that very clear, but still I'll retry: I have two system, on each I need to run a script which queries me for a hostname, that hostname needs to be converted to ip, what applet should I use that will give me the ip without the need for output parsing? Beside this, Busybox has nslookup. What is wrong with that? Only different output format? In case you complain because the many information it displays: What about an option for nslookup, lets say -s (for short) to display only single line of output (if only one address returned from query)? Just as an unverified idea. What about this? as said before, I have two distinct systems in which nslookup gives two distinct outputs. that is why nslookup isn't good. I cannot be more clear then that. maybe adding -S switch for nslookup is a good idea but that is not what I've intended to begin with. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
but these bins are large, my applet adds at most 3kb to the total size. My statically linked dnsip applet is 27 kB. This does not qualify as large by any means on a full-fledged Unix platform (even an embedded one), especially compared to the BIND host binary. You really have to figure out exactly what behaviour you need, and then choose the tool that fulfills your goal. -- Laurent ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/05/2012 02:03 PM, Laurent Bercot wrote: but these bins are large, my applet adds at most 3kb to the total size. My statically linked dnsip applet is 27 kB. This does not qualify as large by any means on a full-fledged Unix platform (even an embedded one), especially compared to the BIND host binary. You really have to figure out exactly what behaviour you need, and then choose the tool that fulfills your goal. for me it does, way to big when one can get the same behavior in a fraction of the size. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On Thu, 2012-07-05 at 17:13 +0300, Eial Czerwacki wrote: On 07/05/2012 02:03 PM, Laurent Bercot wrote: but these bins are large, my applet adds at most 3kb to the total size. My statically linked dnsip applet is 27 kB. This does not qualify as large by any means on a full-fledged Unix platform (even an embedded one), especially compared to the BIND host binary. for me it does, way to big when one can get the same behavior in a fraction of the size. That's fine but you have to understand that just because adding a new custom applet like this to busybox would be the best for your specific environment that doesn't mean it's the best for everyone else, or for the busybox project as a whole. If it ends up that you need this particular gethostbyname applet as written previously then probably you should keep it locally and continue to patch it into your personal version of busybox. If you can use a getent applet instead, and one is created and added to busybox, that would be better for everyone of course. Cheers! ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hello Harald, No ! In glibc gethostbyname (getaddrinfo is a different entry to same functionality) uses the nsswitch and usually checks the local addresses first (if not configured differently). Only the host command from bind ignores local addresses. $ host NAME -- only query DNS for NAME $ getent hosts NAME -- check /etc/hosts then queries DNS (if nsswitch not configured differently) in that case I think that keeping it the host format is the right thing to do. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On Wed, 2012-07-04 at 08:07 +0300, Eial Czerwacki wrote: does getent needs a valid host file in the system? after viewing both host and getent I'm sure that host is exactly what I've implemented. I don't think it is a good idea to base the implementation on getent. I didn't see your implementation in detail, but if it uses gethostbyname() or gethostent() etc. functions in GLIBC, then it IS NOT the standard host(1) utility. The host(1) utility communicates via the network to the current DNS server in /etc/resolv.conf (or the server specified on the host(1) command line, if given) and does hostname lookups directly from the DNS server. Consider this: if you do have a hostname in your /etc/hosts file but it doesn't exist in the DNS server, then host(1) will _not_ resolve the hostname. getent(1) will. Similarly, if you have a hostname in /etc/hosts which maps to a different IP address than that same hostname does on the DNS server, then host(1) will show the DNS server's IP address, NOT the one in /etc/hosts, regardless of the contents of nsswitch.conf etc. If you want to have a command-line interface to the get*ent() functions like getpwent(), getgrent(), gethostent(), gethostbyname(), etc., then the getent(1) utility is the (only, that I'm aware of) right answer. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Paul! I'm not sure what you mean by emulated functions. Busybox emulates the functionality of the standard getent functions for passwd, shadow, group and gshadow files to bypass the usual need of nsswitch and it's need of extra libraries. This behavior of Busybox may be configured during build of Busybox binary. This emulation may be a good thing on systems that do not provide the get*ent functions or does otherwise not behave the same way. They all handle nsswitch.conf etc. Not all libraries/systems have nsswitch functionality or honor nsswitch.conf. Perhaps there's something about the Busybox environment which makes this less than ideal? The problem is the extra need for nsswitch libraries. Think of statically linking with a single binary and no extra libraries. In this case bypassing the nsswitch (not using get*ent functions) is a good thing and helps to minimize space requirement. On a standard glibc based system I use nsswitch functionality and there is no emulation of the mentioned functions. -- Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/04/2012 09:00 AM, Paul Smith wrote: On Wed, 2012-07-04 at 08:07 +0300, Eial Czerwacki wrote: I didn't see your implementation in detail, but if it uses gethostbyname() or gethostent() etc. functions in GLIBC, then it IS NOT the standard host(1) utility. The host(1) utility communicates via the network to the current DNS server in /etc/resolv.conf (or the server specified on the host(1) command line, if given) and does hostname lookups directly from the DNS server. Consider this: if you do have a hostname in your /etc/hosts file but it doesn't exist in the DNS server, then host(1) will _not_ resolve the hostname. getent(1) will. Similarly, if you have a hostname in /etc/hosts which maps to a different IP address than that same hostname does on the DNS server, then host(1) will show the DNS server's IP address, NOT the one in /etc/hosts, regardless of the contents of nsswitch.conf etc. If you want to have a command-line interface to the get*ent() functions like getpwent(), getgrent(), gethostent(), gethostbyname(), etc., then the getent(1) utility is the (only, that I'm aware of) right answer. that is right but assuming /etc/hosts parsing is added, how can we be sure that there isn't any changes in file format? also, adding such parser most probably will increase the size of the bin, on the other hand, it is possible to add a config switch that enables /etc/hosts parsing support if it is needed. for my example, /etc/hosts parsing is not needed and I do need every bit of space. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! in that case I think that keeping it the host format is the right thing to do. It does not depend on the output format, it depends on how you query the IP address. The host command only queries the remote DNS server and does NOT use local libc functions for name query. That is you directly send network packets to DNS server and parse server responses. On the other side this functionality is provided by the glibc library (resolver) hidden behind functions like gethostbyname or getaddrinfo, so you do not need manual DNS server query ... and then (if you use such functions) you shall model your output/applet after the 'getent hosts' command. -- Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hello Harald, It does not depend on the output format, it depends on how you query the IP address. The host command only queries the remote DNS server and does NOT use local libc functions for name query. That is you directly send network packets to DNS server and parse server responses. On the other side this functionality is provided by the glibc library (resolver) hidden behind functions like gethostbyname or getaddrinfo, so you do not need manual DNS server query ... and then (if you use such functions) you shall model your output/applet after the 'getent hosts' command. as said before, my needs are bound to getting the ip using dns as my usb drive imaeg is closed in the matter that I don't want edit the hosts file all the time. so the big modification where should be either in gethostbyname or getaddrinfo to be able to take /etc/hosts in account? Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On Wed, 2012-07-04 at 09:14 +0300, Eial Czerwacki wrote: that is right but assuming /etc/hosts parsing is added, how can we be sure that there isn't any changes in file format? I don't understand what you mean. There's no need to add parsing for /etc/hosts to anything. The library already has that parsing code; it's all embedded under the gethostbyname() function. Since you're already invoking gethostbyname() you're already paying for the overhead of the code that parses the /etc/hosts file. in that case I think that keeping it the host format is the right thing to do. The right thing to do in what sense? The right thing to do for your environment? Obviously only you can decide whether you'd rather have the host(1) or getent(1) applets. Both are useful, in different contexts. The getent(1) utility is useful for all sorts of scripting needs. It's far and away the most likely to be useful in a normal Busybox environment. The lucky thing is it's also simpler to write and will result in much less code added to Busybox. The host(1) utility is really mainly useful when you're debugging DNS problems and/or servers. It's not so useful for general scripting because the IP address you get back from it might not be the same IP address as some program you invoke (ping or ssh or telnet or whatever for example) would use for that same hostname, which can be confusing. Also as far as I'm aware there's no standard C runtime function which you can use to implement host(1), so you'll have to recreate a significant chunk of the DNS server access code, which WOULD be a lot of work and a lot of new, somewhat complex code added to Busybox. My suspicion is that the Busybox maintainers would be leery of accepting this and might suggest you just go get the real host(1) application from BIND and use that instead. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/04/2012 10:02 AM, Paul Smith wrote: I don't understand what you mean. There's no need to add parsing for /etc/hosts to anything. The library already has that parsing code; it's all embedded under the gethostbyname() function. Since you're already invoking gethostbyname() you're already paying for the overhead of the code that parses the /etc/hosts file. The right thing to do in what sense? The right thing to do for your environment? Obviously only you can decide whether you'd rather have the host(1) or getent(1) applets. Both are useful, in different contexts. The getent(1) utility is useful for all sorts of scripting needs. It's far and away the most likely to be useful in a normal Busybox environment. The lucky thing is it's also simpler to write and will result in much less code added to Busybox. The host(1) utility is really mainly useful when you're debugging DNS problems and/or servers. It's not so useful for general scripting because the IP address you get back from it might not be the same IP address as some program you invoke (ping or ssh or telnet or whatever for example) would use for that same hostname, which can be confusing. Also as far as I'm aware there's no standard C runtime function which you can use to implement host(1), so you'll have to recreate a significant chunk of the DNS server access code, which WOULD be a lot of work and a lot of new, somewhat complex code added to Busybox. My suspicion is that the Busybox maintainers would be leery of accepting this and might suggest you just go get the real host(1) application from BIND and use that instead. there is something that I miss in understanding the issue so I need to understand it first. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/04/2012 10:18 AM, Eial Czerwacki wrote: On 07/04/2012 10:02 AM, Paul Smith wrote: I don't understand what you mean. There's no need to add parsing for /etc/hosts to anything. The library already has that parsing code; it's all embedded under the gethostbyname() function. Since you're already invoking gethostbyname() you're already paying for the overhead of the code that parses the /etc/hosts file. The right thing to do in what sense? The right thing to do for your environment? Obviously only you can decide whether you'd rather have the host(1) or getent(1) applets. Both are useful, in different contexts. The getent(1) utility is useful for all sorts of scripting needs. It's far and away the most likely to be useful in a normal Busybox environment. The lucky thing is it's also simpler to write and will result in much less code added to Busybox. The host(1) utility is really mainly useful when you're debugging DNS problems and/or servers. It's not so useful for general scripting because the IP address you get back from it might not be the same IP address as some program you invoke (ping or ssh or telnet or whatever for example) would use for that same hostname, which can be confusing. Also as far as I'm aware there's no standard C runtime function which you can use to implement host(1), so you'll have to recreate a significant chunk of the DNS server access code, which WOULD be a lot of work and a lot of new, somewhat complex code added to Busybox. My suspicion is that the Busybox maintainers would be leery of accepting this and might suggest you just go get the real host(1) application from BIND and use that instead. after understanding what Paul and Harald meant, I'll rewrite the patch and post it later on. Thanks of the clarification guys. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
as said before, my needs are bound to getting the ip using dns as my usb drive imaeg is closed in the matter that I don't want edit the hosts file all the time. You don't have to have *only* busybox on your embedded box. Functionality that is not (yet) implemented in busybox can sometimes be found elsewhere. You could download and compile djbdns ( http://cr.yp.to/djbdns.html ) (you don't need to bother with daemontools and ucspi-tcp if all you want is a command line DNS client) and just keep the dnsip binary, which does exactly what you want. The binary is quite small. Guys, please remember that the point of busybox is to provide lightweight implementations of stuff that is only available as a GNU noodle plate. When lightweight implementations already exist, adding an applet to busybox isn't so important. -- Laurent ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/04/2012 10:57 AM, Laurent Bercot wrote: You don't have to have *only* busybox on your embedded box. Functionality that is not (yet) implemented in busybox can sometimes be found elsewhere. You could download and compile djbdns ( http://cr.yp.to/djbdns.html ) (you don't need to bother with daemontools and ucspi-tcp if all you want is a command line DNS client) and just keep the dnsip binary, which does exactly what you want. The binary is quite small. Guys, please remember that the point of busybox is to provide lightweight implementations of stuff that is only available as a GNU noodle plate. When lightweight implementations already exist, adding an applet to busybox isn't so important. but these bins are large, my applet adds at most 3kb to the total size. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hello Baruch, On 07/03/2012 12:11 PM, Baruch Siach wrote: Hi Eial, On Tue, Jul 03, 2012 at 10:57:50AM +0300, Eial Czerwacki wrote: I'd like to propose a new applet, gethostbyname. all this applet does is to get a host name and return the first ip address. IMHO, this applet should be called 'host', just like the similarly named BIND utility. ok, will change the name [snip] +int gethostbyname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int gethostbyname_main(int argc, char **argv) { +struct hostent *tmp = 0; + +if (argc 2) { +bb_show_usage(); +} + +tmp = gethostbyname(argv[1]); gethostbyname() is obsolete. Please use either current POSIX standard getaddrinfo() or INET_resolve() from libbb. baruch ok, will work on this and resend the patch. Thanks for the pointers. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/03/2012 05:39 PM, Joshua Judson Rosen wrote: On 2012-07-03 05:11, Baruch Siach wrote: Hi Eial, On Tue, Jul 03, 2012 at 10:57:50AM +0300, Eial Czerwacki wrote: I'd like to propose a new applet, gethostbyname. all this applet does is to get a host name and return the first ip address. IMHO, this applet should be called 'host', just like the similarly named BIND utility. No, they're different things: BIND's `host' utility specifically queries DNS--and only DNS: it doesn't resolve names via /etc/hosts, NIS, mDNS, etc. gethostbyname() uses whatever resolver backends are available in libc (i.e.: nsswitch). So it might be a good idea for Eial to model this new applet on glibc's getent command (both in name and behaviour). Joshua, I cannot find any reference to glibc's getent command, can you point me to such reference? ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
So it might be a good idea for Eial to model this new applet on glibc's getent command I cannot find any reference to glibc's getent command, can you point me to such reference? What about this one? Is it the right one?? http://perkamon.alioth.debian.org/online/man1/getent.1.php ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 2012-07-03 05:11, Baruch Siach wrote: Hi Eial, On Tue, Jul 03, 2012 at 10:57:50AM +0300, Eial Czerwacki wrote: I'd like to propose a new applet, gethostbyname. all this applet does is to get a host name and return the first ip address. IMHO, this applet should be called 'host', just like the similarly named BIND utility. No, they're different things: BIND's `host' utility specifically queries DNS--and only DNS: it doesn't resolve names via /etc/hosts, NIS, mDNS, etc. gethostbyname() uses whatever resolver backends are available in libc (i.e.: nsswitch). So it might be a good idea for Eial to model this new applet on glibc's getent command (both in name and behaviour). -- Don't be afraid to ask (λf.((λx.xx) (λr.f(rr. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Am 03.07.2012 16:48, schrieb Eial Czerwacki: On 07/03/2012 05:39 PM, Joshua Judson Rosen wrote: On 2012-07-03 05:11, Baruch Siach wrote: Hi Eial, On Tue, Jul 03, 2012 at 10:57:50AM +0300, Eial Czerwacki wrote: I'd like to propose a new applet, gethostbyname. all this applet does is to get a host name and return the first ip address. IMHO, this applet should be called 'host', just like the similarly named BIND utility. No, they're different things: BIND's `host' utility specifically queries DNS--and only DNS: it doesn't resolve names via /etc/hosts, NIS, mDNS, etc. gethostbyname() uses whatever resolver backends are available in libc (i.e.: nsswitch). So it might be a good idea for Eial to model this new applet on glibc's getent command (both in name and behaviour). Joshua, I cannot find any reference to glibc's getent command, can you point me to such reference? For glibc there are actualy only getent{sp,mnt,serv,..}ent calls but there is also a getent cmd that comes with glibc (i totally forgot about it). /usr/bin/getent --usage Usage: getent [-?V] [-s CONFIG] [--service=CONFIG] [--help] [--usage] [--version] Datenbank [Schlüssel ...] re, wh ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 2012-07-03 10:58, ra...@gmx.de wrote: So it might be a good idea for Eial to model this new applet on glibc's getent command I cannot find any reference to glibc's getent command, can you point me to such reference? What about this one? Is it the right one?? http://perkamon.alioth.debian.org/online/man1/getent.1.php Yes--that's the one. The output from getent hosts ... is a line in the format used by /etc/hosts, e.g.: $ getent hosts localhost 127.0.0.1 localhost.localdomain localhost -- Don't be afraid to ask (λf.((λx.xx) (λr.f(rr. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On Tue, 2012-07-03 at 11:36 -0400, Joshua Judson Rosen wrote: On 2012-07-03 10:58, ra...@gmx.de wrote: So it might be a good idea for Eial to model this new applet on glibc's getent command I cannot find any reference to glibc's getent command, can you point me to such reference? What about this one? Is it the right one?? http://perkamon.alioth.debian.org/online/man1/getent.1.php Yes--that's the one. Yes that's it. IMHO we shouldn't be inventing new applets for busybox. Adding an implementation of the getent(1) and/or host(1) commands (both very useful, but as mentioned before they do different things and have different purposes) would be very useful for some no doubt. Creating applets with no precedent in other UNIX/POSIX systems is (again IMHO) not a good idea for busybox. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Paul! IMHO we shouldn't be inventing new applets for busybox. ... Creating applets with no precedent in other UNIX/POSIX systems is (again IMHO) not a good idea for busybox. In principle you are right, but Busybox is used on many small systems where several higher functions are controlled by shell scripts. As those scripts need access to several kind of information it is a good idea to have small applets build into Busybox to retrieve this information and present it in a compatible and easy to use manor. As this the getent command seams to be a good idea to be included in Busybox. The command gives access to several kind of information which is mostly based on glibc nsswitch functionality but this function is emulated within Busybox in severals ways (passwd, shadow, group, gshadow etc.). Implementing this in Busybox in a way that uses libbb functionality is perfect for information retrieval in shell scripts without need to look for the method on how this information is made available by the system. This could help to avoid to deal with system specific purposes in shell scripts as they are solved on a central (and fast/compact) place in Busybox. I would vote for a carefully designed implementation of a getent Busybox applet. -- Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On 07/04/2012 05:08 AM, ra...@gmx.de wrote: Hi Paul! IMHO we shouldn't be inventing new applets for busybox. ... Creating applets with no precedent in other UNIX/POSIX systems is (again IMHO) not a good idea for busybox. In principle you are right, but Busybox is used on many small systems where several higher functions are controlled by shell scripts. As those scripts need access to several kind of information it is a good idea to have small applets build into Busybox to retrieve this information and present it in a compatible and easy to use manor. As this the getent command seams to be a good idea to be included in Busybox. The command gives access to several kind of information which is mostly based on glibc nsswitch functionality but this function is emulated within Busybox in severals ways (passwd, shadow, group, gshadow etc.). Implementing this in Busybox in a way that uses libbb functionality is perfect for information retrieval in shell scripts without need to look for the method on how this information is made available by the system. This could help to avoid to deal with system specific purposes in shell scripts as they are solved on a central (and fast/compact) place in Busybox. I would vote for a carefully designed implementation of a getent Busybox applet. -- Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox does getent needs a valid host file in the system? after viewing both host and getent I'm sure that host is exactly what I've implemented. I don't think it is a good idea to base the implementation on getent. Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! does getent needs a valid host file in the system? First of all, an empty file is a valid host file. As a missing file is usually assumed to equal an empty file, the host file doesn't need to be there either. after viewing both host and getent I'm sure that host is exactly what I've implemented. I don't think it is a good idea to base the implementation on getent. host is a pure and direct DNS query which does NOT use gethostbyname (or similar mechanism) to get any local stored name. On the other side 'getent hosts' uses the libc functionality (also used by gethostbyname) to query the IP address by it's name. glibc uses nsswitch to configure how this query is done and this is usually 'host, bind': which means it first tries to lookup the name in /etc/host and to query the DNS server afterwards if not found locally. If you use gethostbyname to query the IP address you have implemented the functionality of 'getent hosts' with a single key (= name) specification not the pure DNS based host command from bind package (which does only DNS query and ignores locally provided addresses). I hope that clarifies this. -- Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hello Harald, On 07/04/2012 08:34 AM, ra...@gmx.de wrote: Hi Eial ! does getent needs a valid host file in the system? First of all, an empty file is a valid host file. As a missing file is usually assumed to equal an empty file, the host file doesn't need to be there either. after viewing both host and getent I'm sure that host is exactly what I've implemented. I don't think it is a good idea to base the implementation on getent. host is a pure and direct DNS query which does NOT use gethostbyname (or similar mechanism) to get any local stored name. On the other side 'getent hosts' uses the libc functionality (also used by gethostbyname) to query the IP address by it's name. glibc uses nsswitch to configure how this query is done and this is usually 'host, bind': which means it first tries to lookup the name in /etc/host and to query the DNS server afterwards if not found locally. If you use gethostbyname to query the IP address you have implemented the functionality of 'getent hosts' with a single key (= name) specification not the pure DNS based host command from bind package (which does only DNS query and ignores locally provided addresses). I hope that clarifies this. that clears the issue. so gethostbyname (or getaddrinfo as suggested by Baruch) doesn't checks the local /etc/host first? Eial. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
On Wed, 2012-07-04 at 04:08 +0200, ra...@gmx.de wrote: Hi Paul! IMHO we shouldn't be inventing new applets for busybox. ... Creating applets with no precedent in other UNIX/POSIX systems is (again IMHO) not a good idea for busybox. In principle you are right, but Busybox is used on many small systems where several higher functions are controlled by shell scripts. As those scripts need access to several kind of information it is a good idea to have small applets build into Busybox to retrieve this information and present it in a compatible and easy to use manor. Sorry but I don't agree with this. Busybox is not intended (IMHO) to be that kind of anything goes swiss army knife where any command line utility someone can dream up should be added. It's intended to provide POSIX-based implementations of existing standard tools plus minimal (in size) enhancements, as well as bare-bones implementations of other common Linux utilities. Of course, I have no standing here since I don't work on the code. That's just my opinion. As this the getent command seams to be a good idea to be included in Busybox. The command gives access to several kind of information which is mostly based on glibc nsswitch functionality but this function is emulated within Busybox in severals ways (passwd, shadow, group, gshadow etc.). Implementing this in Busybox in a way that uses libbb functionality is perfect for information retrieval in shell scripts without need to look for the method on how this information is made available by the system. This could help to avoid to deal with system specific purposes in shell scripts as they are solved on a central (and fast/compact) place in Busybox. Yes, this is why I seconded the recommendation of it. I'm not sure what you mean by emulated functions. getent is not much more than a command-line interface to the POSIX standard get*ent() functions like getpwent(), gethostent(), etc. They all handle nsswitch.conf etc. for you: users don't need to mess with that. On a standard system getent just calls those functions and formats the output (basically). Perhaps there's something about the Busybox environment which makes this less than ideal? ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] new applet gethostbyname
Hi Eial ! so gethostbyname (or getaddrinfo as suggested by Baruch) doesn't checks the local /etc/host first? No ! In glibc gethostbyname (getaddrinfo is a different entry to same functionality) uses the nsswitch and usually checks the local addresses first (if not configured differently). Only the host command from bind ignores local addresses. $ host NAME -- only query DNS for NAME $ getent hosts NAME -- check /etc/hosts then queries DNS (if nsswitch not configured differently) -- Harald ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox