Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] dhcp: add systemd service file
Date: Mon, 27 Oct 2014 13:04:29 +0100	[thread overview]
Message-ID: <20141027120424.GA24636@pc-eric> (raw)
In-Reply-To: <20140922173447.GC4358@free.fr>

On Mon, Sep 22, 2014 at 07:34:47PM +0200, Yann E. MORIN wrote:
> Eric, All,
>
> On 2014-09-22 12:52 +0200, Eric Le Bihan spake thusly:
> > On Sun, Sep 21, 2014 at 10:44:45PM +0200, Yann E. MORIN wrote:
> > > On 2014-09-15 23:04 +0200, Eric Le Bihan spake thusly:
> > > > Add a systemd service file to start dhcpd.
> [--SNIP--]
> > > > +	echo "d /var/lib/dhcp 0755 - - - -" > \
> > > > +		$(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf
> > > > +	echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \
> > > > +		$(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf
> > >
> > > I'm not sure to understand those two. Are they needed on the target?
> > >
> > > They suspiciously look like our 'makedev' syntax. Does systemd recognise
> > > this too?
> >
> > Among the zillion of tools provided by systemd, there is 'systemd-tmpfiles'
> > [1]. This program creates, deletes, and cleans up volatile and temporary
> > files and directories based on configuration files stored in
> > /usr/lib/tmpfiles.d and /etc/tmpfiles.d.
> >
> > It is true that these files follow a syntax similar to makedev [2]. But unlike
> > 'makedev' which sets the proper access rights for / entries at build time,
> > 'systemd-tmpfiles' creates the files at runtime if they are missing.
> >
> > In the current default skeleton used by Buildroot, parts of /var are
> > tmpfs-based and thus get cleaned at each reboot. 'systemd-tmpfiles' can
> > recreate them.
> >
> > For some reasons, when using systemd, dhcpd complains at start-up about
> > /var/lib/dhcp/dhcpd.leases not being accessible. So the Makefile installs a
> > file named /usr/lib/tmpfiles.d/dhcp.conf, which contains "instructions" for
> > creating the missing file with the proper access rights.
>
> Thanks for the thorough explanations!
>
> > I know that a package named 'foo' can add system users via FOO_USERS, thanks
> > to 'mkusers'. Can the same be done with 'makedev'?
>
> Yes, it is possible, see:
>     http://nightly.buildroot.org/#_infrastructure_for_packages_with_specific_build_systems
> and:
>     http://nightly.buildroot.org/#makedev-syntax
>
> You'd need something like:
>
>     define LIBFOO_PERMISSIONS
>         /var/lib/dhcp d 0755 0 0 - - - - -
>         /var/lib/dhcp/dhcpd.leases f 0600 0 0 - - - - -
>     endef
>
> > This would allow a package
> > to create files with the proper owner and access rights without having to
> > provide additional files.
>
> Problem is /var/lib/dhcp/dhcpd.leases should be on a RW filesystem, and
> the only one Buildroot gurantees to be RW is /tmp (which is a tmpfs).
>
> But /var/lib does not point to a subdir in /tmp so whether we use
> systemd's feature to create missing files, or the makedev above, we'd
> still need to make /var/lib/dhcp a symling to somewhere in /tmp.
>

I re-read dhcp.mk: we can see that, when installing the program in the
target directory, /var/lib/dhcp is created as a symlink to /tmp, which is
good. Besides the Busybox/SysV init script S80dhcp-server creates
/var/lib/dhcp/dhcpd.leases if it does not exist. Great!

So the problem is already solved when using Busybox/SysV and for systemd,
it is solved via the proposed patch :-)

Best regards
ELB

  reply	other threads:[~2014-10-27 12:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 21:04 [Buildroot] [PATCH] dhcp: add systemd service file Eric Le Bihan
2014-09-21 20:44 ` Yann E. MORIN
2014-09-22 10:52   ` Eric Le Bihan
2014-09-22 17:34     ` Yann E. MORIN
2014-10-27 12:04       ` Eric Le Bihan [this message]
2014-10-26 21:13 ` Thomas Petazzoni
2014-10-27 17:14   ` Eric Le Bihan
2014-10-29 22:08 ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2014-09-15 20:38 Eric Le Bihan
2014-09-15 21:08 ` Eric Le Bihan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141027120424.GA24636@pc-eric \
    --to=eric.le.bihan.dev@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox