image.bbclass: Adding loop back for machine name in hosts file
PATCH 1/1 image.bbclass: Adding loop back for machine name in hosts file
From: Sujith H <[email protected]>
If hostname is not added to /etc/hosts file then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.
root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)
Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6q
program version(s) netid(s) service owner
100000 2,3,4 local,udp,tcp,udp6,tcp6 portmapper superuser
root@mx6q:~#--- meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)
meta/classes/image.bbclass +8 -0
@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi } +ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >> ${IMAGE_ROOTFS}${sysconfdir}/hosts + fi +} + # Enable postinst logging if debug-tweaks is enabled postinst_enable_logging () { mkdir -p ${IMAGE_ROOTFS}${sysconfdir}/default
Signature · 1 line
1.8.4
Hi,
Let me know if any more changes have to be made to make this patch look better.
Quoted 43 lines · Sujith H
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6q program version(s) netid(s) service owner 100000 2,3,4 local,udp,tcp,udp6,tcp6 portmapper superuser root@mx6q:~#Signed-off-by Sujith H <[email protected]>--- meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)meta/classes/image.bbclass +5
-0@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi } +ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >>${IMAGE_ROOTFS}${sysconfdir}/hosts
meta/classes/image.bbclass +3
-1+ fi +} + # Enable postinst logging if debug-tweaks is enabled postinst_enable_logging () { mkdir -p ${IMAGE_ROOTFS}${sysconfdir}/default --
Quoted 3 lines
1.8.4
Thanks,
Sujith H
Signature · 5 lines
സുജിത് ഹരിദാസന് Bangalore <Project>Contributor to KDE project http://fci.wikia.com/wiki/Anti-DRM-Campaign <Blog> http://sujithh.info
Hi Sujith,
Quoted 35 lines · On Monday 04 August 2014 19:27:08 Sujith H wrote:
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6q program version(s) netid(s) service owner 100000 2,3,4 local,udp,tcp,udp6,tcp6 portmapper superuser root@mx6q:~#Signed-off-by Sujith H <[email protected]>--- meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)meta/classes/image.bbclass +5
-0@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi } +ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >>${IMAGE_ROOTFS}${sysconfdir}/hosts + fi
meta/classes/image.bbclass ssh_disable_dns_lookup () { · line 351
Quoted 2 lines
meta/classes/image.bbclass +2
-0+} +
I think in the earlier discussion the conclusion was that we do not want this enabled by default, which the above will do.
The question I have is, if this isn't a good idea, is there a better solution?
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Hi Paul,
On Mon, Aug 4, 2014 at 7:48 PM, Paul Eggleton <[email protected]
Quoted 48 lines
wrote:
Hi Sujith,
Quoted 7 lines · On Monday 04 August 2014 19:27:08 Sujith H wrote:
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.Quoted 7 lines
root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6q program version(s) netid(s) service owner 100000 2,3,4 local,udp,tcp,udp6,tcp6 portmappersuperuser
Quoted 21 lines
root@mx6q:~#
Signed-off-by Sujith H <[email protected]>--- meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)meta/classes/image.bbclass +5
-0@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi } +ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >>${IMAGE_ROOTFS}${sysconfdir}/hosts + fi
meta/classes/image.bbclass ssh_disable_dns_lookup () { · line 351
Quoted 2 lines
meta/classes/image.bbclass +2
-0+} +I think in the earlier discussion the conclusion was that we do not want this
enabled by default, which the above will do.
Quoted 4 lines
The question I have is, if this isn't a good idea, is there a better solution?
I totally agree with the discussion. Is it a good idea to implement like check made for zap_empty_root_password?
For zap_empty_root_password there is a conditional check if debug-tweaks are enabled then zap_empty_root_password is
called. So can I use debug-tweaks to handle add_machine_name_loop_back in the patch?
Cheers,
Quoted 7 lines
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
Thanks,
Sujith H
Signature · 5 lines
സുജിത് ഹരിദാസന് Bangalore <Project>Contributor to KDE project http://fci.wikia.com/wiki/Anti-DRM-Campaign <Blog> http://sujithh.info
Quoted 62 lines · On Monday 04 August 2014 20:03:09 sujith h wrote:
Hi Paul,
On Mon, Aug 4, 2014 at 7:48 PM, Paul Eggleton <[email protected]
Quoted 55 lines
wrote:
Hi Sujith,
Quoted 10 lines · On Monday 04 August 2014 19:27:08 Sujith H wrote:
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Quoted 6 lines
Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6qprogram version(s) netid(s) service owner
100000 2,3,4 local,udp,tcp,udp6,tcp6 portmappersuperuser
Quoted 24 lines
root@mx6q:~#
Signed-off-by Sujith H <[email protected]>---
meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)meta/classes/image.bbclass +5
-0@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi } +ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >>${IMAGE_ROOTFS}${sysconfdir}/hosts + fi
meta/classes/image.bbclass ssh_disable_dns_lookup () { · line 351
Quoted 2 lines
meta/classes/image.bbclass +2
-0+} +I think in the earlier discussion the conclusion was that we do not want this
enabled by default, which the above will do.Quoted 2 lines
The question I have is, if this isn't a good idea, is there a better solution?
Quoted 6 lines
I totally agree with the discussion. Is it a good idea to implement like check made for
zap_empty_root_password?
Forzap_empty_root_passwordthere is a conditional check if debug-tweaks are enabled thenzap_empty_root_passwordis
called. So can I use debug-tweaks to handleadd_machine_name_loop_backin the patch?
No, that would not be right - debug-tweaks is for a specific purpose which is unrelated to this.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
On Mon, Aug 4, 2014 at 8:19 PM, Paul Eggleton <[email protected]
Quoted 75 lines
wrote:
Quoted 4 lines · On Monday 04 August 2014 20:03:09 sujith h wrote:
Hi Paul,
On Mon, Aug 4, 2014 at 7:48 PM, Paul Eggleton <
Quoted 12 lines
Quoted 12 lines
wrote:
Hi Sujith,
Quoted 7 lines · On Monday 04 August 2014 19:27:08 Sujith H wrote:
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6qprogram version(s) netid(s) service
owner
Quoted 23 lines
Quoted 23 lines
Quoted 2 lines
100000 2,3,4 local,udp,tcp,udp6,tcp6 portmappersuperuser
Quoted 18 lines
root@mx6q:~#
Signed-off-by Sujith H <[email protected]>---
meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)meta/classes/image.bbclass +0
-0@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi }Quoted 10 lines
Quoted 10 lines
meta/classes/image.bbclass ssh_disable_dns_lookup () { · line 351
Quoted 8 lines
meta/classes/image.bbclass +5
-0+ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >>${IMAGE_ROOTFS}${sysconfdir}/hosts + fi
meta/classes/image.bbclass +2
-0+} +I think in the earlier discussion the conclusion was that we do not
want
Quoted 6 lines
Quoted 5 lines
this
enabled by default, which the above will do.The question I have is, if this isn't a good idea, is there a better solution?
Quoted 6 lines
I totally agree with the discussion. Is it a good idea to implement like check made for
zap_empty_root_password?
Forzap_empty_root_passwordthere is a conditional check if debug-tweaks are enabled thenzap_empty_root_passwordis
called. So can I use debug-tweaks to handleadd_machine_name_loop_backin the patch?
Quoted 4 lines
No, that would not be right - debug-tweaks is for a specific purpose which is
unrelated to this.
Ok. How about adding :
ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("TOOLCHAIN_TARGET_TASK", "packagegroup-core-boot", "add_machine_name_loop_back; ", "",d)}'
Again here the problem is that when packagegroup-core-boot will be added, this change will be forced to rootfs :(
Quoted 9 lines
Cheers,
Paul--
Paul Eggleton
Intel Open Source Technology Centre
Thanks,
Sujith H
Signature · 5 lines
സുജിത് ഹരിദാസന് Bangalore <Project>Contributor to KDE project http://fci.wikia.com/wiki/Anti-DRM-Campaign <Blog> http://sujithh.info
Quoted 44 lines · Paul Eggleton
Hi Sujith,
Quoted 35 lines · On Monday 04 August 2014 19:27:08 Sujith H wrote:
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Below is the output after this change:
root@mx6q:~# rpcinfo -s mx6q program version(s) netid(s) service owner 100000 2,3,4 local,udp,tcp,udp6,tcp6 portmapper superuser root@mx6q:~#Signed-off-by Sujith H <[email protected]>--- meta/classes/image.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+)meta/classes/image.bbclass +5
-0@@ -341,6 +341,14 @@ ssh_disable_dns_lookup () { fi } +ROOTFS_POSTPROCESS_COMMAND += "add_machine_name_loop_back;" + +add_machine_name_loop_back() { + if [ -n ${MACHINE} ]; then + echo 127.0.1.1 " "${MACHINE} >>${IMAGE_ROOTFS}${sysconfdir}/hosts + fi
meta/classes/image.bbclass ssh_disable_dns_lookup () { · line 351
Quoted 2 lines
meta/classes/image.bbclass +2
-0+} +I think in the earlier discussion the conclusion was that we do not want this enabled by default, which the above will do.
Quoted 1 line
The question I have is, if this isn't a good idea, is there a better solution?
These things belong to first time install/commissioning of the device IMO. They are necessary operations but we do not have first time boot scenario
Quoted 5 lines · Sujith H
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument.
...root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)
Is this really a common/valid use case? 'rpcinfo' is a debug tool and when you want information about the local host, you can execute
# rpcinfo -s localhost
IMHO, when using network related functionality, you have to setup networking. This means:
- setup the hostname; using ${MACHINE} is ambiguous with more than one device and the string can contain chars forbidden by DNS ('_')
- setup name resolving; this can be done by ordinary DNS, (unambiguous) /etc/hosts, mDNS
When DNS mapping of ${MACHINE} (or better hostname) without working DNS is really required, 'systemd' contains 'libnss_myhostname.so' (which is to be registered in /etc/nsswitch) which returns '127.0.0.2' as a fallback.
Enrico
Quoted 19 lines · Enrico Scholz
Quoted 5 lines · Sujith H
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument.
...root@mx6q:~# rpcinfo -s mx6q rpcinfo: can't contact rpcbind: RPC: (unknown error code)Is this really a common/valid use case? 'rpcinfo' is a debug tool and when you want information about the local host, you can execute
# rpcinfo -s localhostIMHO, when using network related functionality, you have to setup networking. This means:
- setup the hostname; using ${MACHINE} is ambiguous with more than one device and the string can contain chars forbidden by DNS ('_')
Quoted 10 lines
- setup name resolving; this can be done by ordinary DNS, (unambiguous)
/etc/hosts, mDNSWhen DNS mapping of ${MACHINE} (or better
hostname) without working DNS is really required, 'systemd' contains 'libnss_myhostname.so' (which is to be registered in/etc/nsswitch) which returns '127.0.0.2' as a fallback.
Is it ok to read from /etc/hostname and then have that in the /etc/hosts file, rather than using ${MACHINE}?
Quoted 8 lines
Enrico
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 5 lines
സുജിത് ഹരിദാസന് Bangalore <Project>Contributor to KDE project http://fci.wikia.com/wiki/Anti-DRM-Campaign <Blog> http://sujithh.info
Quoted 4 lines · sujith h
Is it ok to read from
/etc/hostnameand then have that in the/etc/hostsfile, rather than using ${MACHINE}?
...
+ echo 127.0.1.1 " "${MACHINE} >> ${IMAGE_ROOTFS}${sysconfdir}/hosts
I do not see how this can be done while building the image or the packages. Both the hostname and the ip address can be configured at runtime. As this can happen dynamically e.g. by DHCP and can change at every boot or even at runtime, there is no generic way (e.g. by firstboot mechanisms) to add such entries.
Enrico
Op 4 aug. 2014, om 15:57 heeft Sujith H <[email protected]> het volgende geschreven:
Quoted 6 lines
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.
Isn't this what nssmyhostname is for?
Quoted 4 lines · Koen Kooi
Op 4 aug. 2014, om 15:57 heeft Sujith H <[email protected]> het volgende geschreven:
Quoted 8 lines
Quoted 6 lines
From: Sujith H <[email protected]>
If hostname is not added to
/etc/hostsfile then rpcinfo command fails when hostname is passed as argument. This was observed when rpcinfo command was tested on freescale target. Below was the output observed without this change.Isn't this what nssmyhostname is for?
Yes adding nss-myhostname would be the cleaner solution. Thanks Koen Kooi.
Signature · 5 lines
സുജിത് ഹരിദാസന് Bangalore <Project>Contributor to KDE project http://fci.wikia.com/wiki/Anti-DRM-Campaign <Blog> http://sujithh.info