Package: libvpd
Version: libvpd: udev rules fail whilst /var/lib is not-mounted or read-only
Severity: important

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Dear Maintainer,

As discussed at https://launchpad.net/bugs/1682774 some users
experience a race condition with udev rules. Specifically state file
vpdupdate is not writable at all times throughout the system
lifecycle.

It has been recommended to use /run, a runtime directory, for the
vpdupdate notify file since that persist and is writable at all
times.

A patch to this effect has been provided. See attached.

Could you please consider to apply it?

Regards,

Dimitri.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJZnXAcAAoJEMrC2LnNLKX5+9QH/RKWXFEwf1Eds9MAZoog4d/Q
vF3FUL4iyBEeIYcE50yMFXhxBagam/T3RgtN/XB31l7ud8qAkyS/W/aq/rVpTBeB
BVGHNKHR3KFUdYJWNBxu7Cjj5EFW2GNE30j3lVs4/RA4kkfiI6N6ylGKa3m41I1g
1yggZTcDXl/4CZb1hAWNnIE6jlLYvbdj5Hi3w5VSLvwefy9sPIBQipxNC0v1rC6B
ia9tgRi3n5t0TDfrcwDSqgiAWhDpeWiI7anU5zmK8MauTLM3M3bC7oLtozsRvYs+
gdRUXmPMcykP3aXcw48l1JaMQGl23KZ7KLf1aTRi6obL6g0W4fXoWCgR4Zd9XnY=
=47co
-----END PGP SIGNATURE-----
>From 7d959c5ff48978853b01c43e959236988a46a018 Mon Sep 17 00:00:00 2001
From: Brahadambal Srinivasan <[email protected]>
Date: Fri, 23 Jun 2017 11:13:27 +0530
Subject: [PATCH] Changes run.vpdupdate creation path from /var/lib/lsvpd to
 /run

Process '/bin/touch /var/lib/lsvpd/run.vpdupdate' failed with
 exit code 1.

Canonical folks suggested that it can happen if any of below condition meets:
  - If it's running before /var/lib/lsvpd is mounted
  - If it's being run while the root filesystem is still mounted read only?
and suggested to create file under /run/ if we are not worried about file data.

Advantage when we create file under /run:
 - If udev triggers libvpd rules before mounting /var or even if it is
read-only then also we won't get above mentioned issue.

This patch changes run.vpdupdate file creation path from /var/lib/lsvpd/ to /run/ .

Signed-off-by: Brahadambal Srinivasan <[email protected]>
Tested-by: Ankit Kumar <[email protected]>
Reviewed-by: Ankit Kumar <[email protected]>
Signed-off-by: Vasant Hegde <[email protected]>
---
 90-vpdupdate.rules   | 2 +-
 Makefile.am          | 2 --
 libvpd.spec.in       | 1 -
 src/vpdretriever.cpp | 4 ++--
 4 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/90-vpdupdate.rules b/90-vpdupdate.rules
index d332c3c..5a4b42d 100644
--- a/90-vpdupdate.rules
+++ b/90-vpdupdate.rules
@@ -1 +1 @@
-KERNELS=="*", ACTION=="*", DEVPATH=="/devices/*", RUN+="/bin/touch /var/lib/lsvpd/run.vpdupdate"
+KERNELS=="*", ACTION=="*", DEVPATH=="/devices/*", RUN+="/bin/touch /run/run.vpdupdate"
diff --git a/Makefile.am b/Makefile.am
index 6788e43..2bd2326 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,7 +67,5 @@ libtool: $(LIBTOOL_DEPS)
 install-exec-hook:
 	mkdir -p $(DESTDIR)/${sysconfdir}/udev/rules.d/
 	mkdir -p $(DESTDIR)/${localstatedir}/lib/lsvpd/
-	install -D --mode=644 run.vpdupdate \
-		${DESTDIR}/${localstatedir}/lib/lsvpd/run.vpdupdate
 	install -D --mode=644 90-vpdupdate.rules \
                 ${DESTDIR}/${sysconfdir}/udev/rules.d/90-vpdupdate.rules
diff --git a/libvpd.spec.in b/libvpd.spec.in
index c05bacf..71f9101 100644
--- a/libvpd.spec.in
+++ b/libvpd.spec.in
@@ -53,7 +53,6 @@ Contains header files for building with libvpd.
 %{_libdir}/libvpd_cxx-@[email protected].*
 %{_libdir}/libvpd-@[email protected].*
 %{_sysconfdir}/udev/rules.d/90-vpdupdate.rules
-%{_var}/lib/lsvpd/run.vpdupdate
 
 %files devel
 %defattr(-,root,root,-)
diff --git a/src/vpdretriever.cpp b/src/vpdretriever.cpp
index 6f7f137..9f7e7a0 100644
--- a/src/vpdretriever.cpp
+++ b/src/vpdretriever.cpp
@@ -44,7 +44,7 @@ namespace lsvpd
 {
 	const string VpdRetriever::DEFAULT_DIR  ( "/var/lib/lsvpd/" );
 	const string VpdRetriever::DEFAULT_FILE ( "vpd.db" );
-	const string VpdRetriever::UDEV_NOTIFY_FILE ( "run.vpdupdate" );
+	const string VpdRetriever::UDEV_NOTIFY_FILE ( "/run/run.vpdupdate" );
 
 	VpdRetriever::VpdRetriever( string envDir,
 		string dbFileName ) throw( VpdException& )
@@ -63,7 +63,7 @@ namespace lsvpd
 	{
 		struct stat vpd_stat,udev_stat;
 		const string vpddb = VpdRetriever::DEFAULT_DIR + VpdRetriever::DEFAULT_FILE;
-		const string udev_file = VpdRetriever::DEFAULT_DIR + VpdRetriever::UDEV_NOTIFY_FILE;
+		const string udev_file = VpdRetriever::UDEV_NOTIFY_FILE;
 		Logger logger;
 		int flag = 1;
 
-- 
2.9.3

Reply via email to