CHROMIUM: automatically mount /run at boot
We have a small pre-startup shell script that initializes /run and
then processes selinux labels. This 2 syscalls (and libselinux).
Since we consider /run to be absolutely required as part of the
system, and we always want it to be tmpfs, move the setup to
upstart itself to simplify.
BUG=chromium:1063545
TEST=CQ passes
Change-Id: Ic3f8545a8fdaee37eb6de59f95c5a16b8a758304
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/upstart/+/2546468
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: Allen Webb <allenwebb@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/configure.ac b/configure.ac
index 404c5ca..98d2438 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,7 +75,7 @@
if test "x$enable_selinux" = "xyes" ; then
PKG_CHECK_MODULES(SELINUX, [libselinux])
AC_DEFINE(HAVE_SELINUX, 1, [Define if we have SELinux])
- AC_DEFINE(RESTORE_PATHS, [{"/dev"}], [Define restorecon paths])
+ AC_DEFINE(RESTORE_PATHS, [{"/dev", "/run"}], [Define restorecon paths])
fi
# Checks for typedefs, structures, and compiler characteristics.
diff --git a/init/main.c b/init/main.c
index 67bf41c..f354704 100644
--- a/init/main.c
+++ b/init/main.c
@@ -253,6 +253,25 @@
nih_free (err);
}
+ if (system_mount ("tmpfs", "/run", MS_NOSUID | MS_NODEV | MS_NOEXEC,
+ "mode=0755") < 0) {
+ NihError *err;
+
+ err = nih_error_get ();
+ nih_warn ("%s: %s", _("Unable to mount /run filesystem"),
+ err->message);
+ nih_free (err);
+ }
+
+ if (mkdir ("/run/lock", 01777) < 0 && errno != EEXIST) {
+ NihError *err;
+
+ err = nih_error_get ();
+ nih_warn ("%s: %s", _("Unable to mkdir /run/lock"),
+ err->message);
+ nih_free (err);
+ }
+
#ifdef HAVE_SELINUX
if (!getenv ("SELINUX_INIT")) {
/*