* [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp @ 2016-09-28 16:07 Root, Build 2016-10-05 23:20 ` Arnout Vandecappelle 0 siblings, 1 reply; 6+ messages in thread From: Root, Build @ 2016-09-28 16:07 UTC (permalink / raw) To: buildroot 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. Signed-off-by: Gerald Van Baren <jerry@vibrationresearch.com> --- package/dhcp/dhcp.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk index 5cb6043..80c984b 100644 --- a/package/dhcp/dhcp.mk +++ b/package/dhcp/dhcp.mk @@ -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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp 2016-09-28 16:07 [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp Root, Build @ 2016-10-05 23:20 ` Arnout Vandecappelle 2016-10-06 17:38 ` Jerry Van Baren 2016-10-24 21:01 ` Thomas Petazzoni 0 siblings, 2 replies; 6+ messages in thread From: Arnout Vandecappelle @ 2016-10-05 23:20 UTC (permalink / raw) To: buildroot On 28-09-16 18:07, Root, Build wrote: > 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? > 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 > > Signed-off-by: Gerald Van Baren <jerry@vibrationresearch.com> > --- > package/dhcp/dhcp.mk | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk > index 5cb6043..80c984b 100644 > --- a/package/dhcp/dhcp.mk > +++ b/package/dhcp/dhcp.mk > @@ -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 > -- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp 2016-10-05 23:20 ` Arnout Vandecappelle @ 2016-10-06 17:38 ` Jerry Van Baren 2016-10-06 19:22 ` Arnout Vandecappelle 2016-10-24 21:01 ` Thomas Petazzoni 1 sibling, 1 reply; 6+ messages in thread From: Jerry Van Baren @ 2016-10-06 17:38 UTC (permalink / raw) To: buildroot Hi Arnout, On Wed, Oct 5, 2016 at 7:20 PM, Arnout Vandecappelle <arnout@mind.be> wrote: > > > On 28-09-16 18:07, Root, Build wrote: >> 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? 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). > 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. >> 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. The symlink works fine, the chgrp to root on /tmp/dhcpd.leases doesn't. :-( Thanks, gvb >> >> Signed-off-by: Gerald Van Baren <jerry@vibrationresearch.com> >> --- >> package/dhcp/dhcp.mk | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk >> index 5cb6043..80c984b 100644 >> --- a/package/dhcp/dhcp.mk >> +++ b/package/dhcp/dhcp.mk >> @@ -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 >> > > -- > 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp 2016-10-06 17:38 ` Jerry Van Baren @ 2016-10-06 19:22 ` Arnout Vandecappelle 2016-10-06 21:02 ` Jerry Van Baren 0 siblings, 1 reply; 6+ messages in thread From: Arnout Vandecappelle @ 2016-10-06 19:22 UTC (permalink / raw) To: buildroot On 06-10-16 19:38, Jerry Van Baren wrote: > Hi Arnout, > > On Wed, Oct 5, 2016 at 7:20 PM, Arnout Vandecappelle <arnout@mind.be> wrote: >> >> >> On 28-09-16 18:07, Root, Build wrote: >>> 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? > > 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. 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. > > (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! > > 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. > >> 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. > > As you note, the autobuilders are not catching it, so it might be > something in how > my build machine is set up. > >>> 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. > > The symlink works fine, the chgrp to root on /tmp/dhcpd.leases doesn't. :-( So, easy solution: in your overlay, put the dhcpd.leases in /tmp where it belongs. Regards, Arnout -- 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp 2016-10-06 19:22 ` Arnout Vandecappelle @ 2016-10-06 21:02 ` Jerry Van Baren 0 siblings, 0 replies; 6+ messages in thread From: Jerry Van Baren @ 2016-10-06 21:02 UTC (permalink / raw) To: buildroot [snip] > 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! BINGO! I missed that. Thanks! gvb ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp 2016-10-05 23:20 ` Arnout Vandecappelle 2016-10-06 17:38 ` Jerry Van Baren @ 2016-10-24 21:01 ` Thomas Petazzoni 1 sibling, 0 replies; 6+ messages in thread From: Thomas Petazzoni @ 2016-10-24 21:01 UTC (permalink / raw) To: buildroot Hello, On Thu, 6 Oct 2016 01:20:56 +0200, Arnout Vandecappelle wrote: > > 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. 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 -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-10-24 21:01 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-28 16:07 [Buildroot] [PATCH] Fix dhcp symlink in target/var/lib/dhcp Root, Build 2016-10-05 23:20 ` Arnout Vandecappelle 2016-10-06 17:38 ` Jerry Van Baren 2016-10-06 19:22 ` Arnout Vandecappelle 2016-10-06 21:02 ` Jerry Van Baren 2016-10-24 21:01 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox