From 66299c783dee4efb7bfbb8283afec90c554c68bf Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 11 Apr 2010 07:41:25 +0000 Subject: [PATCH] Add compatibility code to handle old path /etc/powerstatus for a while. --- doc/Changelog | 2 ++ src/init.c | 11 ++++++++++- src/paths.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/Changelog b/doc/Changelog index aa4ae67..4cc6afb 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -27,6 +27,8 @@ sysvinit (2.88dsf) UNRELEASED; urgency=low find a usable pty. Patch from Rob Leslie via Debian. * Make sure bootlogd fflush() every line, even if asked not to flush to disk using fdatasync(). Patch from Scott Gifford via Debian. + * Add compatibility code to handle old path "/etc/powerstatus" for a + while. [ Werner Fink ] * Add the comment from Andrea Arcangeli about the correct diff --git a/src/init.c b/src/init.c index aa81d37..7b414f0 100644 --- a/src/init.c +++ b/src/init.c @@ -2409,7 +2409,16 @@ void process_signals() pwrstat = c; close(fd); unlink(PWRSTAT); - } + } else if ((fd = open(PWRSTAT_OLD, O_RDONLY)) >= 0) { + /* Path changed 2010-03-20. Look for the old path for a while. */ + initlog(L_VB, "warning: found obsolete path %s, use %s instead", + PWRSTAT_OLD, PWRSTAT); + c = 0; + read(fd, &c, 1); + pwrstat = c; + close(fd); + unlink(PWRSTAT_OLD); + } do_power_fail(pwrstat); DELSET(got_signals, SIGPWR); } diff --git a/src/paths.h b/src/paths.h index bb5040d..232a944 100644 --- a/src/paths.h +++ b/src/paths.h @@ -35,6 +35,7 @@ #define SHELL "/bin/sh" /* Default shell */ #define SULOGIN "/sbin/sulogin" /* Sulogin */ #define INITSCRIPT "/etc/initscript" /* Initscript. */ +#define PWRSTAT_OLD "/etc/powerstatus" /* COMPAT: SIGPWR reason (OK/BAD) */ #define PWRSTAT "/var/run/powerstatus" /* COMPAT: SIGPWR reason (OK/BAD) */ #if 0