Fix dhcp symlink in target/var/lib/dhcp
Root
PATCH 1/1 Fix dhcp symlink in target/var/lib/dhcp
The symlink was to /tmp causing an error on the target install step:
rsync: chgrp "/<path>/output/target/var/lib/dhcp" failed: Operation not permitted
Changing the symlink to "../../tmp" rather than "/tmp" references the target's /tmp directory rather than the build machine's /tmp directory.
--- package/dhcp/dhcp.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
package/dhcp/dhcp.mk +3 -3
@@ -56,7 +56,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_SERVER mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(@D)/server/dhcpd $(TARGET_DIR)/usr/sbin/dhcpd $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf
@@ -66,7 +66,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) define DHCP_INSTALL_RELAY mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef
@@ -75,7 +75,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) define DHCP_INSTALL_CLIENT mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(DHCP_DIR)/client/dhclient \ $(TARGET_DIR)/sbin/dhclient $(INSTALL) -m 0644 -D package/dhcp/dhclient.conf \
--
1.9.1
PATCH 1/1 Fix dhcp symlink in target/var/lib/dhcp
Quoted 3 lines · Build
The symlink was to /tmp causing an error on the target install step:
rsync: chgrp "/<path>/output/target/var/lib/dhcp" failed: Operation not permitted
Could you explain this a little more? The install step of this package only
calls $(INSTALL), not rsync or 'make install' or anything like that. So how does this happen?
Also note that we don't have such failures in the autobuilders. And anyway, I
thought that a failing chgrp in rsync was non-fatal?
Quoted 2 lines
Changing the symlink to "../../tmp" rather than "/tmp" references the target's /tmp directory rather than the build machine's /tmp directory.
The problem is that /var/lib itself may be a symlink to somewhere else. Some
people need to have /var/lib in a writeable partition while /var itself is on the readonly rootfs. When /var/lib is a symlink, the ../.. will be interpreted relative to the target of that symlink, which may be a different number of levels down from root.
Also, since /tmp always exists on the build machine, symlinking to /tmp just works.
Regards,
Arnout
Quoted 44 lines
Signed-off-by Gerald Van Baren <[email protected]>--- package/dhcp/dhcp.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)package/dhcp/dhcp.mk +3
-4@@ -56,7 +56,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_SERVER mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(@D)/server/dhcpd $(TARGET_DIR)/usr/sbin/dhcpd $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf@@ -66,7 +66,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) define DHCP_INSTALL_RELAY mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef@@ -75,7 +75,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) define DHCP_INSTALL_CLIENT mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(DHCP_DIR)/client/dhclient \ $(TARGET_DIR)/sbin/dhclient $(INSTALL) -m 0644 -D package/dhcp/dhclient.conf \ --1.9.1
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 Fix dhcp symlink in target/var/lib/dhcp
Hi Arnout,
Quoted 10 lines · Arnout Vandecappelle
Quoted 3 lines · Build
The symlink was to /tmp causing an error on the target install step:
rsync: chgrp "/<path>/output/target/var/lib/dhcp" failed: Operation not permittedCould you explain this a little more? The install step of this package only
calls $(INSTALL), not rsync or 'make install' or anything like that. So how does this happen?
I have not dug to the bottom of this, but the issue is the DHCP (server, not client)
package is creates
/var/lib/dhcp/dhcpd.leases
which ends up in /tmp/dhcpd.leases without the patch. With the patch it ends up in .../output/target/tmp/dhcpd.leases.
(Informed guessing here) When buildroot creates the file system image, it does a rsync with chgrp (and chown) to the proper owner (root.root), but that is not allowed
as an unprivileged user running buildroot on the host's /tmp directory.
I'm running very stock Ubuntu 14.04.5 x86 "server" installation cross compiling to an ARM target.
I did not have a problem with older versions of Buildroot, it was when we pulled our baseline forward to 2016.08 that we had the problem (previously was 2014 timeframe).
Quoted 2 lines
Also note that we don't have such failures in the autobuilders. And anyway, I
thought that a failing chgrp in rsync was non-fatal?
Not for me. :-/ I will look into it further. Total speculation: it may be a double fault
where the chown root fails followed by a chgrp root which also fails, aborting the script.
As you note, the autobuilders are not catching it, so it might be something in how
my build machine is set up.
Quoted 10 lines
Quoted 2 lines
Changing the symlink to "../../tmp" rather than "/tmp" references the target's /tmp directory rather than the build machine's /tmp directory.
The problem is that
/var/libitself may be a symlink to somewhere else. Some
people need to have/var/libin a writeable partition while /var itself is on the readonly rootfs. When/var/libis a symlink, the ../.. will be interpreted relative to the target of that symlink, which may be a different number of levels down from root.Also, since /tmp always exists on the build machine, symlinking to /tmp just works.
The symlink works fine, the chgrp to root on /tmp/dhcpd.leases doesn't. :-(
Thanks,
gvb
Quoted 52 lines
Quoted 38 lines
Signed-off-by Gerald Van Baren <[email protected]>--- package/dhcp/dhcp.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)package/dhcp/dhcp.mk +3
-4@@ -56,7 +56,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_SERVER mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(@D)/server/dhcpd $(TARGET_DIR)/usr/sbin/dhcpd $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf@@ -66,7 +66,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) define DHCP_INSTALL_RELAY mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef@@ -75,7 +75,7 @@ endif ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) define DHCP_INSTALL_CLIENT mkdir -p $(TARGET_DIR)/var/lib - (cd $(TARGET_DIR)/var/lib; ln -snf /tmp dhcp) + (cd $(TARGET_DIR)/var/lib; ln -snf ../../tmp dhcp) $(INSTALL) -m 0755 -D $(DHCP_DIR)/client/dhclient \ $(TARGET_DIR)/sbin/dhclient $(INSTALL) -m 0644 -D package/dhcp/dhclient.conf \ --Quoted 6 lines
1.9.1
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot--
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 Fix dhcp symlink in target/var/lib/dhcp
Quoted 14 lines · Jerry Van Baren
Hi Arnout,
Quoted 10 lines · Arnout Vandecappelle
Quoted 3 lines · Build
The symlink was to /tmp causing an error on the target install step:
rsync: chgrp "/<path>/output/target/var/lib/dhcp" failed: Operation not permittedCould you explain this a little more? The install step of this package only
calls $(INSTALL), not rsync or 'make install' or anything like that. So how does this happen?
Quoted 6 lines
I have not dug to the bottom of this, but the issue is the DHCP (server, not client)
package is creates
/var/lib/dhcp/dhcpd.leases
which ends up in/tmp/dhcpd.leaseswithout the patch. With the patch it ends up in .../output/target/tmp/dhcpd.leases.
I forgot to explain this in my original mail: it doesn't (or shouldn't) matter
if the dhcpd.leases file is lost, because (in many situations) a tmpfs will be mounted on /tmp at runtime so the pre-installed dhcpd.leases is lost anyway.
Moreover, the dhcp package doesn't even install this leases file. I just tested
it here: with any combination of DHCP sub-options, no leases file is installed in output/target/tmp or output/target/var/lib/* or anywhere else.
Quoted 5 lines
(Informed guessing here) When buildroot creates the file system image, it does a rsync with chgrp (and chown) to the proper owner (root.root), but that is not allowed
as an unprivileged user running buildroot on the host's /tmp directory.
Actually, no, buildroot doesn't do any rsyncing. It only rsyncs the skeleton
from package/skeleton to the target directory, but that is at the beginning of the build before anything else is done.
There is also an rsync of the BR2_ROOTFS_OVERLAY directories at the end of the
build. Aha, that is probably what happens: you have a var/lib/dhcp/dhcpd.leases in you overlay!
Quoted 7 lines
I'm running very stock Ubuntu 14.04.5 x86 "server" installation cross compiling to an ARM target.
I did not have a problem with older versions of Buildroot, it was when we pulled our baseline forward to 2016.08 that we had the problem (previously was 2014 timeframe).
Aha bis: the symlink logic for the dhcp package has been there since 2005, but
the --keep-dirlinks argument of the rootfs overlay's rsync command was added this year.
Quoted 8 lines
Quoted 3 lines
Also note that we don't have such failures in the autobuilders. And anyway, I
thought that a failing chgrp in rsync was non-fatal?Not for me. :-/ I will look into it further. Total speculation: it may be a double fault
where the chown root fails followed by a chgrp root which also fails, aborting the script.
My rsync 3.1.1 doesn't complain when I use the -a option and it can't preserve
owner or group.
Quoted 14 lines
As you note, the autobuilders are not catching it, so it might be something in how
my build machine is set up.Quoted 9 lines
Quoted 2 lines
Changing the symlink to "../../tmp" rather than "/tmp" references the target's /tmp directory rather than the build machine's /tmp directory.
The problem is that
/var/libitself may be a symlink to somewhere else. Some
people need to have/var/libin a writeable partition while /var itself is on the readonly rootfs. When/var/libis a symlink, the ../.. will be interpreted relative to the target of that symlink, which may be a different number of levels down from root.
Quoted 3 lines
Quoted 1 line
Also, since /tmp always exists on the build machine, symlinking to /tmp just works.
The symlink works fine, the chgrp to root on
/tmp/dhcpd.leasesdoesn't. :-(
So, easy solution: in your overlay, put the dhcpd.leases in /tmp where it belongs.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 Fix dhcp symlink in target/var/lib/dhcp
[snip]
Quoted 3 lines
There is also an rsync of the
BR2_ROOTFS_OVERLAYdirectories at the end of the
build. Aha, that is probably what happens: you have a var/lib/dhcp/dhcpd.leases in you overlay!
BINGO! I missed that.
Thanks!
gvb
PATCH 1/1 Fix dhcp symlink in target/var/lib/dhcp
In reply to Arnout VandecappelleHello,
Quoted 10 lines · Arnout Vandecappelle
Quoted 2 lines
Changing the symlink to "../../tmp" rather than "/tmp" references the target's /tmp directory rather than the build machine's /tmp directory.
The problem is that
/var/libitself may be a symlink to somewhere else. Some
people need to have/var/libin a writeable partition while /var itself is on the readonly rootfs. When/var/libis a symlink, the ../.. will be interpreted relative to the target of that symlink, which may be a different number of levels down from root.Also, since /tmp always exists on the build machine, symlinking to /tmp just works.
Note that the skeleton already installs /var/lib/misc -> ../../tmp
However, since this is part of the skeleton, one can assume that those folks who replace /var/lib with a symlink will adapt the skeleton accordingly (by using their own custom skeleton).
However, there's one thing I'm not entirely happy with with the current /var/lib -> /tmp symlink. It means that the Buildroot build will potentially install random stuff in /tmp. This doesn't seem really nice.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com