aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc-applets.c8
-rw-r--r--src/rc/rc.c29
-rw-r--r--src/rc/runscript.c44
3 files changed, 31 insertions, 50 deletions
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index eea4a01d..57d03446 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -276,8 +276,8 @@ static int do_service(int argc, char **argv)
ok = (rc_service_state(service) & RC_SERVICE_STARTING);
else if (strcmp(applet, "service_stopping") == 0)
ok = (rc_service_state(service) & RC_SERVICE_STOPPING);
- else if (strcmp(applet, "service_coldplugged") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_COLDPLUGGED);
+ else if (strcmp(applet, "service_hotplugged") == 0)
+ ok = (rc_service_state(service) & RC_SERVICE_HOTPLUGGED);
else if (strcmp(applet, "service_wasinactive") == 0)
ok = (rc_service_state(service) & RC_SERVICE_WASINACTIVE);
else if (strcmp(applet, "service_started_daemon") == 0) {
@@ -329,8 +329,8 @@ static int do_mark_service(int argc, char **argv)
ok = rc_service_mark(service, RC_SERVICE_STARTING);
else if (strcmp(applet, "mark_service_stopping") == 0)
ok = rc_service_mark(service, RC_SERVICE_STOPPING);
- else if (strcmp(applet, "mark_service_coldplugged") == 0)
- ok = rc_service_mark(service, RC_SERVICE_COLDPLUGGED);
+ else if (strcmp(applet, "mark_service_hotplugged") == 0)
+ ok = rc_service_mark(service, RC_SERVICE_HOTPLUGGED);
else if (strcmp(applet, "mark_service_failed") == 0)
ok = rc_service_mark(service, RC_SERVICE_FAILED);
else
diff --git a/src/rc/rc.c b/src/rc/rc.c
index cb4045f0..4b76a6de 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -87,7 +87,7 @@ static char *PREVLEVEL = NULL;
const char *applet = NULL;
static char *runlevel = NULL;
-static RC_STRINGLIST *coldplugged_services = NULL;
+static RC_STRINGLIST *hotplugged_services = NULL;
static RC_STRINGLIST *stop_services = NULL;
static RC_STRINGLIST *start_services = NULL;
static RC_STRINGLIST *types_n = NULL;
@@ -162,7 +162,7 @@ static void cleanup(void)
p1 = p2;
}
- rc_stringlist_free(coldplugged_services);
+ rc_stringlist_free(hotplugged_services);
rc_stringlist_free(stop_services);
rc_stringlist_free(start_services);
rc_stringlist_free(types_n);
@@ -738,20 +738,13 @@ interactive_option:
}
pid = service_start(service->value);
-
/* Remember the pid if we're running in parallel */
if (pid > 0) {
add_pid(pid);
-
if (! parallel) {
rc_waitpid(pid);
remove_pid(pid);
- /* Attempt to open the logger as a service may
- * mount the needed /dev/pts for this to work */
- if (rc_logger_tty == -1)
- rc_logger_open(runlevel);
}
-
}
}
@@ -1024,8 +1017,8 @@ int main(int argc, char **argv)
stop_services = tmplist;
}
- /* Load our list of coldplugged services */
- coldplugged_services = rc_services_in_state(RC_SERVICE_COLDPLUGGED);
+ /* Load our list of hotplugged services */
+ hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
if (strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 &&
strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0)
@@ -1048,10 +1041,10 @@ int main(int argc, char **argv)
free(tmplist);
}
- if (coldplugged_services) {
+ if (hotplugged_services) {
if (!start_services)
start_services = rc_stringlist_new();
- TAILQ_FOREACH(service, coldplugged_services, entries)
+ TAILQ_FOREACH(service, hotplugged_services, entries)
rc_stringlist_addu(start_services, service->value);
}
}
@@ -1102,10 +1095,10 @@ int main(int argc, char **argv)
rc_plugin_run(RC_HOOK_RUNLEVEL_START_IN, runlevel);
hook_out = RC_HOOK_RUNLEVEL_START_OUT;
- /* Re-add our coldplugged services if they stopped */
- if (coldplugged_services)
- TAILQ_FOREACH(service, coldplugged_services, entries)
- rc_service_mark(service->value, RC_SERVICE_COLDPLUGGED);
+ /* Re-add our hotplugged services if they stopped */
+ if (hotplugged_services)
+ TAILQ_FOREACH(service, hotplugged_services, entries)
+ rc_service_mark(service->value, RC_SERVICE_HOTPLUGGED);
/* Order the services to start */
if (start_services) {
@@ -1132,7 +1125,7 @@ int main(int argc, char **argv)
do_start_services(parallel);
/* FIXME: If we skip the boot runlevel and go straight
* to default from sysinit, we should now re-evaluate our
- * start services + coldplugged services and call
+ * start services + hotplugged services and call
* do_start_services a second time. */
/* Wait for our services to finish */
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index d0425ab7..0b34d854 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -39,6 +39,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
+#include <fnmatch.h>
#include <getopt.h>
#include <libgen.h>
#include <limits.h>
@@ -246,11 +247,11 @@ in_control()
}
static void
-uncoldplug()
+unhotplug()
{
char file[PATH_MAX];
- snprintf(file, sizeof(file), RC_SVCDIR "/coldplugged/%s", applet);
+ snprintf(file, sizeof(file), RC_SVCDIR "/hotplugged/%s", applet);
if (exists(file) && unlink(file) != 0)
eerror("%s: unlink `%s': %s", applet, file, strerror(errno));
}
@@ -702,7 +703,7 @@ svc_start(bool deps)
! state & RC_SERVICE_STOPPED)
exit(EXIT_FAILURE);
background = true;
- rc_service_mark(service, RC_SERVICE_COLDPLUGGED);
+ rc_service_mark(service, RC_SERVICE_HOTPLUGGED);
if (rc_runlevel_starting())
ewarnx("WARNING: %s will be started when the runlevel"
" has finished.", applet);
@@ -1103,15 +1104,13 @@ svc_restart(bool deps)
static bool
service_plugable(void)
{
- char *list;
- char *p;
- char *star;
- char *token;
- bool allow = true;
- char *match = rc_conf_value("rc_plug_services");
- bool truefalse;
+ char *list, *p, *token;
+ bool allow = true, truefalse;
+ char *match = rc_conf_value("rc_hotplug");
- if (! match)
+ if (!match)
+ match = rc_conf_value("rc_plug_services");
+ if (!match)
return true;
list = xstrdup(match);
@@ -1123,22 +1122,11 @@ service_plugable(void)
} else
truefalse = true;
- star = strchr(token, '*');
- if (star) {
- if (strncmp(applet, token,
- (size_t)(star - token)) == 0)
- {
- allow = truefalse;
- break;
- }
- } else {
- if (strcmp(applet, token) == 0) {
- allow = truefalse;
- break;
- }
+ if (fnmatch(token, applet, 0) == 0) {
+ allow = truefalse;
+ break;
}
}
-
#ifdef DEBUG_MEMORY
free(list);
#endif
@@ -1308,7 +1296,7 @@ runscript(int argc, char **argv)
}
if (rc_yesno(getenv("IN_HOTPLUG"))) {
- if (!rc_conf_yesno("rc_hotplug") || !service_plugable())
+ if (!service_plugable())
eerrorx("%s: not allowed to be hotplugged", applet);
}
@@ -1405,7 +1393,7 @@ runscript(int argc, char **argv)
! rc_runlevel_stopping() &&
rc_service_state(service) &
RC_SERVICE_STOPPED)
- uncoldplug();
+ unhotplug();
if (in_background &&
rc_service_state(service) &
@@ -1426,7 +1414,7 @@ runscript(int argc, char **argv)
RC_SERVICE_STOPPED))
eerrorx("rc_service_mark: %s",
strerror(errno));
- uncoldplug();
+ unhotplug();
} else
svc_exec(optarg, NULL);