LIBDIR -> LIB. When interuppted, ensure service state is restored correctly. When stopping, don't uncoldplug too early.

This commit is contained in:
Roy Marples 2007-04-08 16:03:48 +00:00
parent a66136655e
commit 6e2ef07dd3
6 changed files with 28 additions and 21 deletions

View File

@ -77,7 +77,7 @@ endif
# We also define _BSD_SOURCE so both Linux and the BSDs get a few # We also define _BSD_SOURCE so both Linux and the BSDs get a few
# handy functions which makes our lives a lot easier # handy functions which makes our lives a lot easier
override CFLAGS += -DLIBDIR=\"$(LIB)\" override CFLAGS += -DLIB=\"$(LIB)\"
# IMPORTANT!!! # IMPORTANT!!!
# Remove this when releasing as it's a security risk # Remove this when releasing as it's a security risk

View File

@ -637,15 +637,17 @@ char **rc_config_env (char **env)
} }
rc_strlist_free (config); rc_strlist_free (config);
i = strlen ("RC_LIBDIR=//rcscripts") + strlen (LIBDIR) + 2; /* One char less to drop the trailing / */
i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR);
line = rc_xmalloc (sizeof (char *) * i); line = rc_xmalloc (sizeof (char *) * i);
snprintf (line, i, "RC_LIBDIR=/" LIBDIR "/rcscripts"); snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR);
env = rc_strlist_add (env, line); env = rc_strlist_add (env, line);
free (line); free (line);
i += strlen ("/init.d"); /* One char less to drop the trailing / */
i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR);
line = rc_xmalloc (sizeof (char *) * i); line = rc_xmalloc (sizeof (char *) * i);
snprintf (line, i, "RC_SVCDIR=/" LIBDIR "/rcscripts/init.d"); snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR);
env = rc_strlist_add (env, line); env = rc_strlist_add (env, line);
free (line); free (line);

View File

@ -7,11 +7,11 @@
#ifndef __RC_MISC_H__ #ifndef __RC_MISC_H__
#define __RC_MISC_H__ #define __RC_MISC_H__
#ifndef LIBDIR #ifndef LIB
# define LIBDIR "lib" # define LIB "lib"
#endif #endif
#define RC_LIBDIR "/" LIBDIR "/rcscripts/" #define RC_LIBDIR "/" LIB "/rcscripts/"
#define RC_SVCDIR RC_LIBDIR "init.d/" #define RC_SVCDIR RC_LIBDIR "init.d/"
#define RC_DEPTREE RC_SVCDIR "deptree" #define RC_DEPTREE RC_SVCDIR "deptree"
#define RC_RUNLEVELDIR "/etc/runlevels/" #define RC_RUNLEVELDIR "/etc/runlevels/"

View File

@ -1109,7 +1109,7 @@ int main (int argc, char **argv)
sulogin (false); sulogin (false);
} }
mkdir (RC_SVCDIR "/softscripts.old", 0755); mkdir (RC_SVCDIR "softscripts.old", 0755);
rc_plugin_run (rc_hook_runlevel_start_in, runlevel); rc_plugin_run (rc_hook_runlevel_start_in, runlevel);
/* Re-add our coldplugged services if they stopped */ /* Re-add our coldplugged services if they stopped */

View File

@ -237,13 +237,15 @@ static void cleanup (void)
else if (rc_service_state (applet, rc_service_stopping)) else if (rc_service_state (applet, rc_service_stopping))
{ {
/* If the we're shutting down, do it cleanly */ /* If the we're shutting down, do it cleanly */
if ((softlevel && rc_runlevel_stopping () && if ((softlevel &&
rc_runlevel_stopping () &&
(strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 || (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 ||
strcmp (softlevel, RC_LEVEL_REBOOT) == 0)) || strcmp (softlevel, RC_LEVEL_REBOOT) == 0)))
! rc_service_state (applet, rc_service_wasinactive))
rc_mark_service (applet, rc_service_stopped); rc_mark_service (applet, rc_service_stopped);
else else if (rc_service_state (applet, rc_service_wasinactive))
rc_mark_service (applet, rc_service_inactive); rc_mark_service (applet, rc_service_inactive);
else
rc_mark_service (applet, rc_service_started);
} }
if (exclusive && rc_exists (exclusive)) if (exclusive && rc_exists (exclusive))
unlink (exclusive); unlink (exclusive);
@ -1049,11 +1051,14 @@ int main (int argc, char **argv)
{ {
if (in_background) if (in_background)
get_started_services (); get_started_services ();
else if (! rc_runlevel_stopping ())
uncoldplug (applet);
svc_stop (service, deps); svc_stop (service, deps);
if (! in_background &&
! rc_runlevel_stopping () &&
rc_service_state (service, rc_service_stopped))
uncoldplug (applet);
if (in_background && if (in_background &&
rc_service_state (service, rc_service_inactive)) rc_service_state (service, rc_service_inactive))
{ {

View File

@ -22,11 +22,11 @@
#include <rc.h> #include <rc.h>
#ifndef LIBDIR #ifndef LIB
# define LIBDIR "lib" # define LIB "lib"
#endif #endif
#define SPLASH_CACHEDIR "/" LIBDIR "/splash/cache" #define SPLASH_CACHEDIR "/" LIB "/splash/cache"
#define SPLASH_CMD "bash -c 'export SOFTLEVEL='%s'; export BOOTLEVEL=${RC_BOOTLEVEL}; export DEFAULTLEVEL=${RC_DEFAULTLEVEL}; export svcdir=${RC_SVCDIR}; add_suffix() { echo \"$@\"; }; . /etc/init.d/functions.sh; . /sbin/splash-functions.sh; splash %s %s %s'" #define SPLASH_CMD "bash -c 'export SOFTLEVEL='%s'; export BOOTLEVEL=${RC_BOOTLEVEL}; export DEFAULTLEVEL=${RC_DEFAULTLEVEL}; export svcdir=${RC_SVCDIR}; add_suffix() { echo \"$@\"; }; . /etc/init.d/functions.sh; . /sbin/splash-functions.sh; splash %s %s %s'"