On Wed, 20 Apr 2011 13:22:53 -0500
William Hubbs <willi...@gentoo.org> wrote:

> On Wed, Apr 20, 2011 at 10:02:41PM +0400, Peter Volkov wrote:
> > В Срд, 20/04/2011 в 12:24 -0500, William Hubbs пишет:
> > > The author of the bug feels that the way to fix this is for us to
> > > put a check in openrc that makes it refuse to run services if it
> > > was not used in the boot process.
> > 
> > This is good idea to have in any case since I remember my system
> > went crazy after I've tried to start some service inside chroot.
> 
> My concern about it though is prefix installs. If I implement
> something like this, will it not break openrc on prefix systems?

I'm attaching the patch I suggested to fix the issue.

It is based on the assumption that in order to run cleanly, OpenRC
needs to do some cleanup in ${RC_SVCDIR} (e.g. to mark all services
stopped). It assumes that the basic effect of a running OpenRC
is a determined runlevel stored in ${RC_SVCDIR}/softlevel file.

I tested that approach with clean OpenRC and systemd installs, and it
doesn't create any issues. I'd appreciate if someone with Prefix system
could test it as well.


-- 
Best regards,
Michał Górny
From ac70101ad50348fee636cea36cefcd473ee45690 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Wed, 20 Apr 2011 15:34:08 +0200
Subject: [PATCH] Add a check for softlevel when running init.d scripts.

${RC_SVCDIR}/softlevel should be a good file to check for before running
a OpenRC script. This should fix http://bugs.gentoo.org/show_bug.cgi?id=364159.
---
 src/rc/runscript.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 0eca487..b7cc810 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1112,6 +1112,11 @@ runscript(int argc, char **argv)
 		exit(EXIT_FAILURE);
 	}
 
+	if (!exists(RC_SVCDIR "/softlevel")) {
+		fprintf(stderr, "OpenRC is not running\n");
+		exit(EXIT_FAILURE);
+	}
+
 	if (stat(argv[1], &stbuf) != 0) {
 		fprintf(stderr, "runscript `%s': %s\n",
 		    argv[1], strerror(errno));
-- 
1.7.5.rc1

Attachment: signature.asc
Description: PGP signature

Reply via email to