From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.24]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kiaQB-0006On-8N for ptxdist@pengutronix.de; Fri, 27 Nov 2020 10:52:07 +0100 Received: from home by smtp.strato.de (RZmta 47.3.4 DYNA|AUTH) with ESMTPSA id e08086wAR9q6twE (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Fri, 27 Nov 2020 10:52:06 +0100 (CET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by home (Postfix) with ESMTP id F0D771A0260 for ; Fri, 27 Nov 2020 10:52:05 +0100 (CET) From: "Artur Wiebe" In-Reply-To: <20201127083841.GC1592430@pengutronix.de> Date: Fri, 27 Nov 2020 10:52:05 +0100 MIME-Version: 1.0 Message-ID: <234bd5-5fc0cc80-9-426f2080@104488028> Subject: Re: [ptxdist] =?utf-8?b?Pz09P3V0Zi04P3E/ID89PT91dGYtOD9xPyBbUEFUQ0hd?= =?utf-8?q?_machine-id=3A_make_using_rc-once_optional?= List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de Hi Michael, On Friday, November 27, 2020 09:38 CET, Michael Olbrich wrote: > On Wed, Nov 25, 2020 at 05:56:49PM +0100, Artur Wiebe wrote: > > If not set only an empty /etc/machine-id will be installed. > > > > Signed-off-by: Artur Wiebe > > --- > > rules/machine-id.in | 22 ++++++++++++++++++---- > > rules/machine-id.make | 4 ++++ > > rules/machine-id.postinst | 5 +++-- > > 3 files changed, 25 insertions(+), 6 deletions(-) > > > > diff --git a/rules/machine-id.in b/rules/machine-id.in > > index f18fec554..2a3901f41 100644 > > --- a/rules/machine-id.in > > +++ b/rules/machine-id.in > > @@ -1,11 +1,25 @@ > > ## SECTION=initmethod > > > > -config MACHINE_ID > > +menuconfig MACHINE_ID > > tristate > > prompt "create /etc/machine-id" > > - select RC_ONCE if RUNTIME > > - select UTIL_LINUX_NG if !INITMETHOD_SYSTEMD > > - select UTIL_LINUX_NG_UUIDGEN if !INITMETHOD_SYSTEMD > > + select RC_ONCE if MACHINE_ID_RC_ONCE && RUNTIME > > + select UTIL_LINUX_NG if MACHINE_ID_RC_ONCE && !INITMETHOD_SYSTEMD > > + select UTIL_LINUX_NG_UUIDGEN if MACHINE_ID_RC_ONCE && !INITMETHOD_SYSTEMD > > help > > Enable this to make sure there is always a unique /etc/machine-id > > available in the system. > > + > > +if MACHINE_ID > > + > > +config MACHINE_ID_RC_ONCE > > + bool "generate (bbinit) or save (systemd) machine-id using rc-once at first boot" > > + default y > > Hmmm, maybe should have no prompt and 'depends on RC_ONCE' (instead of > selecting it above). I don't think there is a use-case for not persisting > the machine-id if rc-once is available. > > This is different from the ssh server key case: There are other ways to > create the keys. Why should one select rc-once, if it is not needed by any other package? Maybe make it even invisible? In my projects I use an initramfs where I mount an overlayfs over /etc. When systemd starts /etc/mancine-id is writable while / is never mounted rw. So I want just to install an empty /etc/machine-id and let systemd generate and write the new one. rc-once just jeopardize this. > > > + help > > + If not set only an empty /etc/machine-id will be installed. > > + Systemd: > > + If /etc/machine-id exists and is empty, systemd will bind-mount > > + a file containing the new machine-id over it and later try > > + to commit it to disk (if /etc/ is writable). > > + > > +endif > > diff --git a/rules/machine-id.make b/rules/machine-id.make > > index 3883d64cb..e1cbdcc42 100644 > > --- a/rules/machine-id.make > > +++ b/rules/machine-id.make > > @@ -27,7 +27,11 @@ $(STATEDIR)/machine-id.targetinstall: > > @$(call install_fixup,machine-id,AUTHOR,"Michael Olbrich ") > > @$(call install_fixup,machine-id,DESCRIPTION,missing) > > > > + @$(call install_copy, machine-id, 0, 0, 0644, /dev/null, /etc/machine-id) > > Maybe install_alternative and an empty on in projectroot/. Sometimes it's > better to share the same machine-id across devices than having a new one > after rebooting. Good idea. I'll change this. > > Also, this should only happen for !PTXCONF_MACHINE_ID_RC_ONCE. It's not a > good idea to modify files that are installed by a package. This is the case for almost all files in /etc if they are modified on the target. I avoid it with the overlayfs. In this way defaults are installed by the packages and changes are stored on the target. > > > + > > +ifdef MACHINE_ID_RC_ONCE > > ifdef PTXCONF_MACHINE_ID_RC_ONCE > > > @$(call install_alternative, machine-id, 0, 0, 0755, /etc/rc.once.d/machine-id) > > +endif > > > > @$(call install_finish,machine-id) > > > > diff --git a/rules/machine-id.postinst b/rules/machine-id.postinst > > index 2060129d1..f1648226b 100644 > > --- a/rules/machine-id.postinst > > +++ b/rules/machine-id.postinst > > @@ -1,3 +1,4 @@ > > #!/bin/sh > > -touch "$DESTDIR/etc/machine-id" > > So this is still needed inside the 'if'. I moved it into the package because otherwise an empty package is not generated. ERROR: no files installed With this patch machine-id would be reset on reinstall, but why should someone reinstall the machine-id package? Artur > > Michael > > > -$DESTDIR/usr/sbin/enable-rc-once machine-id > > +if [ -f $DESTDIR/etc/rc.once.d/machine-id ]; then > > + $DESTDIR/usr/sbin/enable-rc-once machine-id > > +fi > > -- > > 2.29.2 > > > > > > _______________________________________________ > > ptxdist mailing list > > ptxdist@pengutronix.de > > To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de > > > > _______________________________________________ > ptxdist mailing list > ptxdist@pengutronix.de > To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de