aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-13 17:47:23 +0000
committerRoy Marples <roy@marples.name>2008-01-13 17:47:23 +0000
commit87e4e4410cb542f3b56989d02e088c5efdfaf157 (patch)
tree14ffb2f5a665b6a9015925a8fed2ed0bb5fdc164
parentabc7a79755c82ed5b6737901d71f8f7f15e1d992 (diff)
Remove rc_service_plugable function and make it private as it needs to read from our config file.
-rw-r--r--src/includes/rc-misc.h1
-rw-r--r--src/librc/librc.c39
-rw-r--r--src/librc/librc.h1
-rw-r--r--src/librc/rc.h5
-rw-r--r--src/librc/rc.map1
-rw-r--r--src/rc/rc-misc.c38
-rw-r--r--src/rc/rc.c6
-rw-r--r--src/rc/runscript.c2
8 files changed, 43 insertions, 50 deletions
diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h
index b7208e67..8052dff3 100644
--- a/src/includes/rc-misc.h
+++ b/src/includes/rc-misc.h
@@ -115,6 +115,7 @@ char *rc_conf_value (const char *var);
bool rc_conf_yesno (const char *var);
char **env_filter (void);
char **env_config (void);
+bool service_plugable (const char *service);
/* basename_c never modifies the argument. As such, if there is a trailing
* slash then an empty string is returned. */
diff --git a/src/librc/librc.c b/src/librc/librc.c
index a03e2f12..436aa47f 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -833,42 +833,3 @@ char **rc_services_scheduled (const char *service)
return (list);
}
librc_hidden_def(rc_services_scheduled)
-
-bool rc_service_plugable (const char *service)
-{
- char *list;
- char *p;
- char *star;
- char *token;
- bool allow = true;
- char *match = getenv ("RC_PLUG_SERVICES");
- if (! match)
- return true;
-
- list = xstrdup (match);
- p = list;
- while ((token = strsep (&p, " "))) {
- bool truefalse = true;
- if (token[0] == '!') {
- truefalse = false;
- token++;
- }
-
- star = strchr (token, '*');
- if (star) {
- if (strncmp (service, token, star - token) == 0) {
- allow = truefalse;
- break;
- }
- } else {
- if (strcmp (service, token) == 0) {
- allow = truefalse;
- break;
- }
- }
- }
-
- free (list);
- return (allow);
-}
-librc_hidden_def(rc_service_plugable)
diff --git a/src/librc/librc.h b/src/librc/librc.h
index d70ffa17..5907e62e 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -99,7 +99,6 @@ librc_hidden_proto(rc_service_exists)
librc_hidden_proto(rc_service_extra_commands)
librc_hidden_proto(rc_service_in_runlevel)
librc_hidden_proto(rc_service_mark)
-librc_hidden_proto(rc_service_plugable)
librc_hidden_proto(rc_service_resolve)
librc_hidden_proto(rc_service_schedule_clear)
librc_hidden_proto(rc_service_schedule_start)
diff --git a/src/librc/rc.h b/src/librc/rc.h
index fe1213b0..465e5153 100644
--- a/src/librc/rc.h
+++ b/src/librc/rc.h
@@ -148,11 +148,6 @@ bool rc_service_mark (const char *service, rc_service_state_t state);
* @return NULL terminated string list of commands */
char **rc_service_extra_commands (const char *service);
-/*! Check if the service is allowed to be hot/cold plugged
- * @param service to check
- * @return true if allowed, otherwise false */
-bool rc_service_plugable (const char *service);
-
/*! Resolves a service name to its full path.
* @param service to check
* @return pointer to full path of service */
diff --git a/src/librc/rc.map b/src/librc/rc.map
index ff7ef7d1..8de23c41 100644
--- a/src/librc/rc.map
+++ b/src/librc/rc.map
@@ -28,7 +28,6 @@ global:
rc_service_in_runlevel;
rc_service_mark;
rc_service_options;
- rc_service_plugable;
rc_service_resolve;
rc_service_schedule_clear;
rc_service_schedule_start;
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index 0d6be40d..fe6022e2 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -387,3 +387,41 @@ char **env_config (void)
free (runlevel);
return (env);
}
+
+bool service_plugable (const char *service)
+{
+ char *list;
+ char *p;
+ char *star;
+ char *token;
+ bool allow = true;
+ char *match = rc_conf_value ("rc_plug_services");
+ if (! match)
+ return true;
+
+ list = xstrdup (match);
+ p = list;
+ while ((token = strsep (&p, " "))) {
+ bool truefalse = true;
+ if (token[0] == '!') {
+ truefalse = false;
+ token++;
+ }
+
+ star = strchr (token, '*');
+ if (star) {
+ if (strncmp (service, token, star - token) == 0) {
+ allow = truefalse;
+ break;
+ }
+ } else {
+ if (strcmp (service, token) == 0) {
+ allow = truefalse;
+ break;
+ }
+ }
+ }
+
+ free (list);
+ return (allow);
+}
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 4bf6541e..6fcbd981 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -1195,7 +1195,7 @@ int main (int argc, char **argv)
continue;
if (rc_service_exists (d->d_name) &&
- rc_service_plugable (d->d_name))
+ service_plugable (d->d_name))
rc_service_mark (d->d_name, RC_SERVICE_COLDPLUGGED);
i = strlen (DEVBOOT "/") + strlen (d->d_name) + 1;
@@ -1229,7 +1229,7 @@ int main (int argc, char **argv)
tmp = xmalloc (sizeof (char) * i);
snprintf (tmp, i, "net.%s", d->d_name);
if (rc_service_exists (tmp) &&
- rc_service_plugable (tmp))
+ service_plugable (tmp))
rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);
CHAR_FREE (tmp);
}
@@ -1250,7 +1250,7 @@ int main (int argc, char **argv)
tmp = xmalloc (sizeof (char) * i);
snprintf (tmp, i, "moused.%s", d->d_name);
if (rc_service_exists (tmp) &&
- rc_service_plugable (tmp))
+ service_plugable (tmp))
rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);
CHAR_FREE (tmp);
}
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 1f3d6625..e136e944 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1185,7 +1185,7 @@ int runscript (int argc, char **argv)
}
if (rc_yesno (getenv ("IN_HOTPLUG"))) {
- if (! rc_conf_yesno ("rc_hotplug") || ! rc_service_plugable (applet))
+ if (! rc_conf_yesno ("rc_hotplug") || ! service_plugable (applet))
eerrorx ("%s: not allowed to be hotplugged", applet);
}