aboutsummaryrefslogtreecommitdiff
path: root/src/rc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc.c')
-rw-r--r--src/rc.c784
1 files changed, 392 insertions, 392 deletions
diff --git a/src/rc.c b/src/rc.c
index 16d45eb5..ac41e91d 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -6,7 +6,7 @@
Also a multicall binary for various commands that can be used in shell
scripts to query service state, mark service state and provide the
Gentoo einfo family of informational functions.
-
+
Copyright 2007 Gentoo Foundation
Released under the GPLv2
*/
@@ -123,36 +123,36 @@ static int do_e (int argc, char **argv)
strcmp (applet, "vweend") == 0)
{
if (argc > 0)
- {
- errno = 0;
- retval = strtol (argv[0], NULL, 0);
- if (errno != 0)
- retval = EXIT_FAILURE;
- else
- {
- argc--;
- argv++;
- }
- }
+ {
+ errno = 0;
+ retval = strtol (argv[0], NULL, 0);
+ if (errno != 0)
+ retval = EXIT_FAILURE;
+ else
+ {
+ argc--;
+ argv++;
+ }
+ }
else
- retval = EXIT_FAILURE;
- }
+ retval = EXIT_FAILURE;
+ }
if (argc > 0)
{
for (i = 0; i < argc; i++)
- l += strlen (argv[i]) + 1;
+ l += strlen (argv[i]) + 1;
message = rc_xmalloc (l);
p = message;
for (i = 0; i < argc; i++)
- {
- if (i > 0)
- *p++ = ' ';
- memcpy (p, argv[i], strlen (argv[i]));
- p += strlen (argv[i]);
- }
+ {
+ if (i > 0)
+ *p++ = ' ';
+ memcpy (p, argv[i], strlen (argv[i]));
+ p += strlen (argv[i]);
+ }
*p = 0;
}
@@ -245,9 +245,9 @@ static int do_service (int argc, char **argv)
{
int idx = 0;
if (argc > 2)
- sscanf (argv[2], "%d", &idx);
+ sscanf (argv[2], "%d", &idx);
exit (rc_service_started_daemon (argv[0], argv[1], idx)
- ? 0 : 1);
+ ? 0 : 1);
}
else
eerrorx ("%s: unknown applet", applet);
@@ -288,21 +288,21 @@ static int do_mark_service (int argc, char **argv)
int l;
if (runscript_pid && sscanf (runscript_pid, "%d", &pid) == 1)
- if (kill (pid, SIGHUP) != 0)
- eerror ("%s: failed to signal parent %d: %s",
- applet, pid, strerror (errno));
+ if (kill (pid, SIGHUP) != 0)
+ eerror ("%s: failed to signal parent %d: %s",
+ applet, pid, strerror (errno));
/* Remove the exclsive time test. This ensures that it's not
- in control as well */
+ in control as well */
l = strlen (RC_SVCDIR "exclusive") +
strlen (svcname) +
strlen (runscript_pid) +
4;
mtime = rc_xmalloc (l);
snprintf (mtime, l, RC_SVCDIR "exclusive/%s.%s",
- svcname, runscript_pid);
+ svcname, runscript_pid);
if (rc_exists (mtime) && unlink (mtime) != 0)
- eerror ("%s: unlink: %s", applet, strerror (errno));
+ eerror ("%s: unlink: %s", applet, strerror (errno));
free (mtime);
}
@@ -326,7 +326,7 @@ static int do_options (int argc, char **argv)
memset (buffer, 0, 1024);
ok = rc_get_service_option (service, argv[0], buffer);
if (ok)
- printf ("%s", buffer);
+ printf ("%s", buffer);
}
else if (strcmp (applet, "save_options") == 0)
ok = rc_set_service_option (service, argv[0], argv[1]);
@@ -392,15 +392,15 @@ static void sulogin (bool cont)
pid_t pid = fork();
if (pid == -1)
- eerrorx ("%s: fork: %s", applet, strerror (errno));
+ eerrorx ("%s: fork: %s", applet, strerror (errno));
if (pid == 0)
- {
- newenv = rc_filter_env ();
- mycmd = rc_xstrdup ("/sbin/sulogin");
- myarg = rc_xstrdup (getenv ("CONSOLE"));
- execle (mycmd, mycmd, myarg, (char *) NULL, newenv);
- eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno));
- }
+ {
+ newenv = rc_filter_env ();
+ mycmd = rc_xstrdup ("/sbin/sulogin");
+ myarg = rc_xstrdup (getenv ("CONSOLE"));
+ execle (mycmd, mycmd, myarg, (char *) NULL, newenv);
+ eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno));
+ }
waitpid (pid, &status, 0);
}
else
@@ -429,8 +429,8 @@ static void set_ksoftlevel (const char *runlevel)
strcmp (runlevel, RC_LEVEL_SYSINIT) == 0)
{
if (rc_exists (RC_SVCDIR "ksoftlevel") &&
- unlink (RC_SVCDIR "ksoftlevel") != 0)
- eerror ("unlink `%s': %s", RC_SVCDIR "ksoftlevel", strerror (errno));
+ unlink (RC_SVCDIR "ksoftlevel") != 0)
+ eerror ("unlink `%s': %s", RC_SVCDIR "ksoftlevel", strerror (errno));
return;
}
@@ -439,7 +439,7 @@ static void set_ksoftlevel (const char *runlevel)
eerror ("fopen `%s': %s", RC_SVCDIR "ksoftlevel", strerror (errno));
return;
}
-
+
fprintf (fp, "%s", runlevel);
fclose (fp);
}
@@ -465,13 +465,13 @@ static void handle_signal (int sig)
{
case SIGINT:
if (! signame[0])
- snprintf (signame, sizeof (signame), "SIGINT");
+ snprintf (signame, sizeof (signame), "SIGINT");
case SIGTERM:
if (! signame[0])
- snprintf (signame, sizeof (signame), "SIGTERM");
+ snprintf (signame, sizeof (signame), "SIGTERM");
case SIGQUIT:
if (! signame[0])
- snprintf (signame, sizeof (signame), "SIGQUIT");
+ snprintf (signame, sizeof (signame), "SIGQUIT");
eerrorx ("%s: caught %s, aborting", applet, signame);
default:
@@ -554,28 +554,28 @@ int main (int argc, char **argv)
#ifdef __linux__
/* clearenv isn't portable, but there's no harm in using it
- if we have it */
+ if we have it */
clearenv ();
#else
char *var;
/* No clearenv present here then.
- We could manipulate environ directly ourselves, but it seems that
- some kernels bitch about this according to the environ man pages
- so we walk though environ and call unsetenv for each value. */
+ We could manipulate environ directly ourselves, but it seems that
+ some kernels bitch about this according to the environ man pages
+ so we walk though environ and call unsetenv for each value. */
while (environ[0])
- {
- tmp = rc_xstrdup (environ[0]);
- p = tmp;
- var = strsep (&p, "=");
- unsetenv (var);
- free (tmp);
- }
+ {
+ tmp = rc_xstrdup (environ[0]);
+ p = tmp;
+ var = strsep (&p, "=");
+ unsetenv (var);
+ free (tmp);
+ }
tmp = NULL;
#endif
STRLIST_FOREACH (env, p, i)
if (strcmp (p, "RC_SOFTLEVEL") != 0 && strcmp (p, "SOFTLEVEL") != 0)
- putenv (p);
+ putenv (p);
/* We don't free our list as that would be null in environ */
}
@@ -595,151 +595,151 @@ int main (int argc, char **argv)
if (RUNLEVEL && newlevel)
{
if (strcmp (RUNLEVEL, "S") == 0 || strcmp (RUNLEVEL, "1") == 0)
- {
- /* OK, we're either in runlevel 1 or single user mode */
- if (strcmp (newlevel, RC_LEVEL_SYSINIT) == 0)
- {
- struct utsname uts;
- pid_t pid;
- pid_t wpid;
- int status = 0;
+ {
+ /* OK, we're either in runlevel 1 or single user mode */
+ if (strcmp (newlevel, RC_LEVEL_SYSINIT) == 0)
+ {
+ struct utsname uts;
+ pid_t pid;
+ pid_t wpid;
+ int status = 0;
#ifdef __linux__
- FILE *fp;
+ FILE *fp;
#endif
- uname (&uts);
-
- printf ("\n");
- PEINFO_GOOD;
- printf (" Gentoo/%s; ", uts.sysname);
- PEINFO_BRACKET;
- printf ("http://www.gentoo.org/");
- PEINFO_NORMAL;
- printf ("\n Copyright 1999-2007 Gentoo Foundation; "
- "Distributed under the GPLv2\n\n");
-
- printf ("Press ");
- PEINFO_GOOD;
- printf ("I");
- PEINFO_NORMAL;
- printf (" to enter interactive boot mode\n\n");
-
- setenv ("RC_SOFTLEVEL", newlevel, 1);
- rc_plugin_run (rc_hook_runlevel_start_in, newlevel);
-
- if ((pid = fork ()) == -1)
- eerrorx ("%s: fork: %s", applet, strerror (errno));
-
- if (pid == 0)
- {
- mycmd = rc_xstrdup (INITSH);
- execl (mycmd, mycmd, (char *) NULL);
- eerrorx ("%s: unable to exec `" INITSH "': %s",
- applet, strerror (errno));
- }
-
- do
- {
- wpid = waitpid (pid, &status, 0);
- if (wpid < 1)
- eerror ("waitpid: %s", strerror (errno));
- } while (! WIFEXITED (status) && ! WIFSIGNALED (status));
-
- if (! WIFEXITED (status) || ! WEXITSTATUS (status) == 0)
- exit (EXIT_FAILURE);
-
- /* If we requested a softlevel, save it now */
+ uname (&uts);
+
+ printf ("\n");
+ PEINFO_GOOD;
+ printf (" Gentoo/%s; ", uts.sysname);
+ PEINFO_BRACKET;
+ printf ("http://www.gentoo.org/");
+ PEINFO_NORMAL;
+ printf ("\n Copyright 1999-2007 Gentoo Foundation; "
+ "Distributed under the GPLv2\n\n");
+
+ printf ("Press ");
+ PEINFO_GOOD;
+ printf ("I");
+ PEINFO_NORMAL;
+ printf (" to enter interactive boot mode\n\n");
+
+ setenv ("RC_SOFTLEVEL", newlevel, 1);
+ rc_plugin_run (rc_hook_runlevel_start_in, newlevel);
+
+ if ((pid = fork ()) == -1)
+ eerrorx ("%s: fork: %s", applet, strerror (errno));
+
+ if (pid == 0)
+ {
+ mycmd = rc_xstrdup (INITSH);
+ execl (mycmd, mycmd, (char *) NULL);
+ eerrorx ("%s: unable to exec `" INITSH "': %s",
+ applet, strerror (errno));
+ }
+
+ do
+ {
+ wpid = waitpid (pid, &status, 0);
+ if (wpid < 1)
+ eerror ("waitpid: %s", strerror (errno));
+ } while (! WIFEXITED (status) && ! WIFSIGNALED (status));
+
+ if (! WIFEXITED (status) || ! WEXITSTATUS (status) == 0)
+ exit (EXIT_FAILURE);
+
+ /* If we requested a softlevel, save it now */
#ifdef __linux__
- set_ksoftlevel (NULL);
-
- if ((fp = fopen ("/proc/cmdline", "r")))
- {
- char buffer[RC_LINEBUFFER];
- char *soft;
-
- memset (buffer, 0, sizeof (buffer));
- if (fgets (buffer, RC_LINEBUFFER, fp) &&
- (soft = strstr (buffer, "softlevel=")))
- {
- i = soft - buffer;
- if (i == 0 || buffer[i - 1] == ' ')
- {
- char *level;
-
- /* Trim the trailing carriage return if present */
- i = strlen (buffer) - 1;
- if (buffer[i] == '\n')
- buffer[i] = 0;
-
- soft += strlen ("softlevel=");
- level = strsep (&soft, " ");
- set_ksoftlevel (level);
- }
- }
- fclose (fp);
- }
+ set_ksoftlevel (NULL);
+
+ if ((fp = fopen ("/proc/cmdline", "r")))
+ {
+ char buffer[RC_LINEBUFFER];
+ char *soft;
+
+ memset (buffer, 0, sizeof (buffer));
+ if (fgets (buffer, RC_LINEBUFFER, fp) &&
+ (soft = strstr (buffer, "softlevel=")))
+ {
+ i = soft - buffer;
+ if (i == 0 || buffer[i - 1] == ' ')
+ {
+ char *level;
+
+ /* Trim the trailing carriage return if present */
+ i = strlen (buffer) - 1;
+ if (buffer[i] == '\n')
+ buffer[i] = 0;
+
+ soft += strlen ("softlevel=");
+ level = strsep (&soft, " ");
+ set_ksoftlevel (level);
+ }
+ }
+ fclose (fp);
+ }
#endif
- rc_plugin_run (rc_hook_runlevel_start_out, newlevel);
+ rc_plugin_run (rc_hook_runlevel_start_out, newlevel);
- if (want_interactive ())
- mark_interactive ();
+ if (want_interactive ())
+ mark_interactive ();
- exit (EXIT_SUCCESS);
- }
+ exit (EXIT_SUCCESS);
+ }
#ifdef __linux__
- /* Parse the inittab file so we can work out the level to telinit */
- if (strcmp (newlevel, RC_LEVEL_BOOT) != 0 &&
- strcmp (newlevel, RC_LEVEL_SINGLE) != 0)
- {
- char **inittab = rc_get_list (NULL, "/etc/inittab");
- char *line;
- char *p;
- char *token;
- char lvl[2] = {0, 0};
-
- STRLIST_FOREACH (inittab, line, i)
- {
- p = line;
- token = strsep (&p, ":");
- if (! token || token[0] != 'l')
- continue;
-
- if ((token = strsep (&p, ":")) == NULL)
- continue;
-
- /* Snag the level */
- lvl[0] = token[0];
-
- /* The name is spaced after this */
- if ((token = strsep (&p, " ")) == NULL)
- continue;
-
- if ((token = strsep (&p, " ")) == NULL)
- continue;
-
- if (strcmp (token, newlevel) == 0)
- break;
- }
- rc_strlist_free (inittab);
-
- /* We have a level, so telinit into it */
- if (lvl[0] == 0)
- {
- eerrorx ("%s: couldn't find a runlevel called `%s'",
- applet, newlevel);
- }
- else
- {
- mycmd = rc_xstrdup ("/sbin/telinit");
- myarg = rc_xstrdup (lvl);
- execl (mycmd, mycmd, myarg, (char *) NULL);
- eerrorx ("%s: unable to exec `/sbin/telinit': %s",
- applet, strerror (errno));
- }
- }
+ /* Parse the inittab file so we can work out the level to telinit */
+ if (strcmp (newlevel, RC_LEVEL_BOOT) != 0 &&
+ strcmp (newlevel, RC_LEVEL_SINGLE) != 0)
+ {
+ char **inittab = rc_get_list (NULL, "/etc/inittab");
+ char *line;
+ char *p;
+ char *token;
+ char lvl[2] = {0, 0};
+
+ STRLIST_FOREACH (inittab, line, i)
+ {
+ p = line;
+ token = strsep (&p, ":");
+ if (! token || token[0] != 'l')
+ continue;
+
+ if ((token = strsep (&p, ":")) == NULL)
+ continue;
+
+ /* Snag the level */
+ lvl[0] = token[0];
+
+ /* The name is spaced after this */
+ if ((token = strsep (&p, " ")) == NULL)
+ continue;
+
+ if ((token = strsep (&p, " ")) == NULL)
+ continue;
+
+ if (strcmp (token, newlevel) == 0)
+ break;
+ }
+ rc_strlist_free (inittab);
+
+ /* We have a level, so telinit into it */
+ if (lvl[0] == 0)
+ {
+ eerrorx ("%s: couldn't find a runlevel called `%s'",
+ applet, newlevel);
+ }
+ else
+ {
+ mycmd = rc_xstrdup ("/sbin/telinit");
+ myarg = rc_xstrdup (lvl);
+ execl (mycmd, mycmd, myarg, (char *) NULL);
+ eerrorx ("%s: unable to exec `/sbin/telinit': %s",
+ applet, strerror (errno));
+ }
+ }
#endif
- }
+ }
}
/* Check we're in the runlevel requested, ie from
@@ -750,63 +750,63 @@ int main (int argc, char **argv)
if (newlevel)
{
if (myarg)
- {
- free (myarg);
- myarg = NULL;
- }
+ {
+ free (myarg);
+ myarg = NULL;
+ }
if (strcmp (newlevel, RC_LEVEL_SINGLE) == 0)
- {
- if (! RUNLEVEL ||
- (strcmp (RUNLEVEL, "S") != 0 &&
- strcmp (RUNLEVEL, "1") != 0))
- {
- /* Remember the current runlevel for when we come back */
- set_ksoftlevel (runlevel);
+ {
+ if (! RUNLEVEL ||
+ (strcmp (RUNLEVEL, "S") != 0 &&
+ strcmp (RUNLEVEL, "1") != 0))
+ {
+ /* Remember the current runlevel for when we come back */
+ set_ksoftlevel (runlevel);
#ifdef __linux__
- mycmd = rc_xstrdup ("/sbin/telinit");
- myarg = rc_xstrdup ("S");
- execl (mycmd, mycmd, myarg, (char *) NULL);
- eerrorx ("%s: unable to exec `/%s': %s",
- mycmd, applet, strerror (errno));
+ mycmd = rc_xstrdup ("/sbin/telinit");
+ myarg = rc_xstrdup ("S");
+ execl (mycmd, mycmd, myarg, (char *) NULL);
+ eerrorx ("%s: unable to exec `/%s': %s",
+ mycmd, applet, strerror (errno));
#else
- if (kill (1, SIGTERM) != 0)
- eerrorx ("%s: unable to send SIGTERM to init (pid 1): %s",
- applet, strerror (errno));
- exit (EXIT_SUCCESS);
+ if (kill (1, SIGTERM) != 0)
+ eerrorx ("%s: unable to send SIGTERM to init (pid 1): %s",
+ applet, strerror (errno));
+ exit (EXIT_SUCCESS);
#endif
- }
- }
+ }
+ }
else if (strcmp (newlevel, RC_LEVEL_REBOOT) == 0)
- {
- if (! RUNLEVEL ||
- strcmp (RUNLEVEL, "6") != 0)
- {
- mycmd = rc_xstrdup ("/sbin/shutdown");
- myarg = rc_xstrdup ("-r");
- tmp = rc_xstrdup ("now");
- execl (mycmd, mycmd, myarg, tmp, (char *) NULL);
- eerrorx ("%s: unable to exec `%s': %s",
- mycmd, applet, strerror (errno));
- }
- }
+ {
+ if (! RUNLEVEL ||
+ strcmp (RUNLEVEL, "6") != 0)
+ {
+ mycmd = rc_xstrdup ("/sbin/shutdown");
+ myarg = rc_xstrdup ("-r");
+ tmp = rc_xstrdup ("now");
+ execl (mycmd, mycmd, myarg, tmp, (char *) NULL);
+ eerrorx ("%s: unable to exec `%s': %s",
+ mycmd, applet, strerror (errno));
+ }
+ }
else if (strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0)
- {
- if (! RUNLEVEL ||
- strcmp (RUNLEVEL, "0") != 0)
- {
- mycmd = rc_xstrdup ("/sbin/shutdown");
+ {
+ if (! RUNLEVEL ||
+ strcmp (RUNLEVEL, "0") != 0)
+ {
+ mycmd = rc_xstrdup ("/sbin/shutdown");
#ifdef __linux__
- myarg = rc_xstrdup ("-h");
+ myarg = rc_xstrdup ("-h");
#else
- myarg = rc_xstrdup ("-p");
+ myarg = rc_xstrdup ("-p");
#endif
- tmp = rc_xstrdup ("now");
- execl (mycmd, mycmd, myarg, tmp, (char *) NULL);
- eerrorx ("%s: unable to exec `%s': %s",
- mycmd, applet, strerror (errno));
- }
- }
+ tmp = rc_xstrdup ("now");
+ execl (mycmd, mycmd, myarg, tmp, (char *) NULL);
+ eerrorx ("%s: unable to exec `%s': %s",
+ mycmd, applet, strerror (errno));
+ }
+ }
}
/* Export our current softlevel */
@@ -819,31 +819,31 @@ int main (int argc, char **argv)
strcmp (newlevel, RC_LEVEL_DEFAULT) == 0)
{
/* We should only use ksoftlevel if we were in single user mode
- If not, we need to erase ksoftlevel now. */
+ If not, we need to erase ksoftlevel now. */
if (PREVLEVEL &&
- (strcmp (PREVLEVEL, "1") == 0 ||
- strcmp (PREVLEVEL, "S") == 0 ||
- strcmp (PREVLEVEL, "N") == 0))
- {
- FILE *fp;
-
- if (! (fp = fopen (RC_SVCDIR "ksoftlevel", "r")))
- eerror ("fopen `%s': %s", RC_SVCDIR "ksoftlevel",
- strerror (errno));
- else
- {
- if (fgets (ksoftbuffer, sizeof (ksoftbuffer), fp))
- {
- i = strlen (ksoftbuffer) - 1;
- if (ksoftbuffer[i] == '\n')
- ksoftbuffer[i] = 0;
- newlevel = ksoftbuffer;
- }
- fclose (fp);
- }
- }
+ (strcmp (PREVLEVEL, "1") == 0 ||
+ strcmp (PREVLEVEL, "S") == 0 ||
+ strcmp (PREVLEVEL, "N") == 0))
+ {
+ FILE *fp;
+
+ if (! (fp = fopen (RC_SVCDIR "ksoftlevel", "r")))
+ eerror ("fopen `%s': %s", RC_SVCDIR "ksoftlevel",
+ strerror (errno));
+ else
+ {
+ if (fgets (ksoftbuffer, sizeof (ksoftbuffer), fp))
+ {
+ i = strlen (ksoftbuffer) - 1;
+ if (ksoftbuffer[i] == '\n')
+ ksoftbuffer[i] = 0;
+ newlevel = ksoftbuffer;
+ }
+ fclose (fp);
+ }
+ }
else
- set_ksoftlevel (NULL);
+ set_ksoftlevel (NULL);
}
if (newlevel &&
@@ -866,7 +866,7 @@ int main (int argc, char **argv)
{
tmp = rc_strcatpaths (RC_RUNLEVELDIR, newlevel, (char *) NULL);
if (! rc_is_dir (tmp))
- eerrorx ("%s: is not a valid runlevel", newlevel);
+ eerrorx ("%s: is not a valid runlevel", newlevel);
CHAR_FREE (tmp);
}
@@ -892,10 +892,10 @@ int main (int argc, char **argv)
STRLIST_FOREACH (start_services, service, i)
if (rc_allow_plug (service))
- rc_mark_service (service, rc_service_coldplugged);
+ rc_mark_service (service, rc_service_coldplugged);
/* We need to dump this list now.
- This may seem redunant, but only Linux needs this and saves on
- code bloat. */
+ This may seem redunant, but only Linux needs this and saves on
+ code bloat. */
rc_strlist_free (start_services);
start_services = NULL;
}
@@ -912,36 +912,36 @@ int main (int argc, char **argv)
/* The net interfaces are easy - they're all in net /dev/net :) */
start_services = rc_ls_dir (NULL, "/dev/net", 0);
STRLIST_FOREACH (start_services, service, i)
- {
- j = (strlen ("net.") + strlen (service) + 1);
- tmp = rc_xmalloc (sizeof (char *) * j);
- snprintf (tmp, j, "net.%s", service);
+ {
+ j = (strlen ("net.") + strlen (service) + 1);
+ tmp = rc_xmalloc (sizeof (char *) * j);
+ snprintf (tmp, j, "net.%s", service);
if (rc_service_exists (tmp) && rc_allow_plug (tmp))
rc_mark_service (tmp, rc_service_coldplugged);
- CHAR_FREE (tmp);
- }
+ CHAR_FREE (tmp);
+ }
rc_strlist_free (start_services);
/* The mice are a little more tricky.
If we coldplug anything else, we'll probably do it here. */
start_services = rc_ls_dir (NULL, "/dev", 0);
STRLIST_FOREACH (start_services, service, i)
- {
- if (strncmp (service, "psm", 3) == 0 ||
- strncmp (service, "ums", 3) == 0)
- {
- char *p = service + 3;
- if (p && isdigit (*p))
- {
- j = (strlen ("moused.") + strlen (service) + 1);
- tmp = rc_xmalloc (sizeof (char *) * j);
- snprintf (tmp, j, "moused.%s", service);
- if (rc_service_exists (tmp) && rc_allow_plug (tmp))
- rc_mark_service (tmp, rc_service_coldplugged);
- CHAR_FREE (tmp);
- }
- }
- }
+ {
+ if (strncmp (service, "psm", 3) == 0 ||
+ strncmp (service, "ums", 3) == 0)
+ {
+ char *p = service + 3;
+ if (p && isdigit (*p))
+ {
+ j = (strlen ("moused.") + strlen (service) + 1);
+ tmp = rc_xmalloc (sizeof (char *) * j);
+ snprintf (tmp, j, "moused.%s", service);
+ if (rc_service_exists (tmp) && rc_allow_plug (tmp))
+ rc_mark_service (tmp, rc_service_coldplugged);
+ CHAR_FREE (tmp);
+ }
+ }
+ }
rc_strlist_free (start_services);
start_services = NULL;
}
@@ -957,7 +957,7 @@ int main (int argc, char **argv)
types = rc_strlist_add (types, "iuse");
types = rc_strlist_add (types, "iafter");
deporder = rc_get_depends (deptree, types, stop_services,
- runlevel, depoptions);
+ runlevel, depoptions);
rc_strlist_free (stop_services);
rc_strlist_free (types);
stop_services = deporder;
@@ -967,24 +967,24 @@ int main (int argc, char **argv)
/* Load our list of coldplugged services */
coldplugged_services = rc_ls_dir (coldplugged_services,
- RC_SVCDIR_COLDPLUGGED, RC_LS_INITD);
+ RC_SVCDIR_COLDPLUGGED, RC_LS_INITD);
/* Load our start services now.
We have different rules dependent on runlevel. */
if (newlevel && strcmp (newlevel, RC_LEVEL_BOOT) == 0)
{
if (coldplugged_services)
- {
- einfon ("Device initiated services:");
- STRLIST_FOREACH (coldplugged_services, service, i)
- {
- printf (" %s", service);
- start_services = rc_strlist_add (start_services, service);
- }
- printf ("\n");
- }
+ {
+ einfon ("Device initiated services:");
+ STRLIST_FOREACH (coldplugged_services, service, i)
+ {
+ printf (" %s", service);
+ start_services = rc_strlist_add (start_services, service);
+ }
+ printf ("\n");
+ }
tmp = rc_strcatpaths (RC_RUNLEVELDIR, newlevel ? newlevel : runlevel,
- (char *) NULL);
+ (char *) NULL);
start_services = rc_ls_dir (start_services, tmp, RC_LS_INITD);
CHAR_FREE (tmp);
}
@@ -992,22 +992,22 @@ int main (int argc, char **argv)
{
/* Store our list of coldplugged services */
coldplugged_services = rc_ls_dir (coldplugged_services, RC_SVCDIR_COLDPLUGGED,
- RC_LS_INITD);
+ RC_LS_INITD);
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)
- {
- /* We need to include the boot runlevel services if we're not in it */
- start_services = rc_ls_dir (start_services, RC_RUNLEVELDIR RC_LEVEL_BOOT,
- RC_LS_INITD);
- STRLIST_FOREACH (coldplugged_services, service, i)
- start_services = rc_strlist_add (start_services, service);
-
- tmp = rc_strcatpaths (RC_RUNLEVELDIR,
- newlevel ? newlevel : runlevel, (char *) NULL);
- start_services = rc_ls_dir (start_services, tmp, RC_LS_INITD);
- CHAR_FREE (tmp);
- }
+ strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
+ strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0)
+ {
+ /* We need to include the boot runlevel services if we're not in it */
+ start_services = rc_ls_dir (start_services, RC_RUNLEVELDIR RC_LEVEL_BOOT,
+ RC_LS_INITD);
+ STRLIST_FOREACH (coldplugged_services, service, i)
+ start_services = rc_strlist_add (start_services, service);
+
+ tmp = rc_strcatpaths (RC_RUNLEVELDIR,
+ newlevel ? newlevel : runlevel, (char *) NULL);
+ start_services = rc_ls_dir (start_services, tmp, RC_LS_INITD);
+ CHAR_FREE (tmp);
+ }
}
/* Save out softlevel now */
@@ -1027,82 +1027,82 @@ int main (int argc, char **argv)
int k;
if (rc_service_state (service, rc_service_stopped))
- continue;
+ continue;
/* We always stop the service when in these runlevels */
if (going_down)
- {
- rc_stop_service (service);
- continue;
- }
+ {
+ rc_stop_service (service);
+ continue;
+ }
/* If we're in the start list then don't bother stopping us */
STRLIST_FOREACH (start_services, svc1, j)
if (strcmp (svc1, service) == 0)
- {
- found = true;
- break;
- }
+ {
+ found = true;
+ break;
+ }
/* Unless we would use a different config file */
if (found)
- {
- int len;
- if (! newlevel)
- continue;
-
- len = strlen (service) + strlen (runlevel) + 2;
- tmp = rc_xmalloc (sizeof (char *) * len);
- snprintf (tmp, len, "%s.%s", service, runlevel);
- conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
- found = rc_exists (conf);
- CHAR_FREE (conf);
- CHAR_FREE (tmp);
- if (! found)
- {
- len = strlen (service) + strlen (newlevel) + 2;
- tmp = rc_xmalloc (sizeof (char *) * len);
- snprintf (tmp, len, "%s.%s", service, newlevel);
- conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
- found = rc_exists (conf);
- CHAR_FREE (conf);
- CHAR_FREE (tmp);
- if (!found)
- continue;
- }
- }
+ {
+ int len;
+ if (! newlevel)
+ continue;
+
+ len = strlen (service) + strlen (runlevel) + 2;
+ tmp = rc_xmalloc (sizeof (char *) * len);
+ snprintf (tmp, len, "%s.%s", service, runlevel);
+ conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
+ found = rc_exists (conf);
+ CHAR_FREE (conf);
+ CHAR_FREE (tmp);
+ if (! found)
+ {
+ len = strlen (service) + strlen (newlevel) + 2;
+ tmp = rc_xmalloc (sizeof (char *) * len);
+ snprintf (tmp, len, "%s.%s", service, newlevel);
+ conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
+ found = rc_exists (conf);
+ CHAR_FREE (conf);
+ CHAR_FREE (tmp);
+ if (!found)
+ continue;
+ }
+ }
else
- /* Allow coldplugged services not to be in the runlevels list */
- {
- if (rc_service_state (service, rc_service_coldplugged))
- continue;
- }
+ /* Allow coldplugged services not to be in the runlevels list */
+ {
+ if (rc_service_state (service, rc_service_coldplugged))
+ continue;
+ }
/* We got this far! Or last check is to see if any any service that
- going to be started depends on us */
+ going to be started depends on us */
stopdeps = rc_strlist_add (stopdeps, service);
deporder = rc_get_depends (deptree, types, stopdeps,
- runlevel, RC_DEP_STRICT);
+ runlevel, RC_DEP_STRICT);
rc_strlist_free (stopdeps);
stopdeps = NULL;
found = false;
STRLIST_FOREACH (deporder, svc1, j)
- {
- STRLIST_FOREACH (start_services, svc2, k)
- if (strcmp (svc1, svc2) == 0)
- {
- found = true;
- break;
- }
- if (found)
- break;
- }
+ {
+ STRLIST_FOREACH (start_services, svc2, k)
+ if (strcmp (svc1, svc2) == 0)
+ {
+ found = true;
+ break;
+ }
+ if (found)
+ break;
+ }
rc_strlist_free (deporder);
deporder = NULL;
/* After all that we can finally stop the blighter! */
if (! found)
- rc_stop_service (service);
+ rc_stop_service (service);
}
rc_strlist_free (types);
types = NULL;
@@ -1132,14 +1132,14 @@ int main (int argc, char **argv)
myarg = rc_xstrdup (runlevel);
execl (mycmd, mycmd, myarg, (char *) NULL);
eerrorx ("%s: unable to exec `%s': %s",
- applet, HALTSH, strerror (errno));
+ applet, HALTSH, strerror (errno));
}
/* Single user is done now */
if (strcmp (runlevel, RC_LEVEL_SINGLE) == 0)
{
if (rc_exists (INTERACTIVE))
- unlink (INTERACTIVE);
+ unlink (INTERACTIVE);
sulogin (false);
}
@@ -1155,7 +1155,7 @@ int main (int argc, char **argv)
types = rc_strlist_add (types, "iuse");
types = rc_strlist_add (types, "iafter");
deporder = rc_get_depends (deptree, types, start_services,
- runlevel, depoptions);
+ runlevel, depoptions);
rc_strlist_free (types);
types = NULL;
rc_strlist_free (start_services);
@@ -1165,31 +1165,31 @@ int main (int argc, char **argv)
STRLIST_FOREACH (start_services, service, i)
{
if (rc_service_state (service, rc_service_stopped))
- {
- if (! interactive)
- interactive = want_interactive ();
+ {
+ if (! interactive)
+ interactive = want_interactive ();
- if (interactive)
- {
+ if (interactive)
+ {
interactive_retry:
- printf ("\n");
- einfo ("About to start the service %s", service);
- eindent ();
- einfo ("1) Start the service\t\t2) Skip the service");
- einfo ("3) Continue boot process\t\t4) Exit to shell");
- eoutdent ();
+ printf ("\n");
+ einfo ("About to start the service %s", service);
+ eindent ();
+ einfo ("1) Start the service\t\t2) Skip the service");
+ einfo ("3) Continue boot process\t\t4) Exit to shell");
+ eoutdent ();
interactive_option:
- switch (read_key (true))
- {
- case '1': break;
- case '2': continue;
- case '3': interactive = false; break;
- case '4': sulogin (true); goto interactive_retry;
- default: goto interactive_option;
- }
- }
- rc_start_service (service);
- }
+ switch (read_key (true))
+ {
+ case '1': break;
+ case '2': continue;
+ case '3': interactive = false; break;
+ case '4': sulogin (true); goto interactive_retry;
+ default: goto interactive_option;
+ }
+ }
+ rc_start_service (service);
+ }
}
/* Wait for our services to finish */
@@ -1204,7 +1204,7 @@ interactive_option:
else
{
if (rc_exists (INTERACTIVE))
- unlink (INTERACTIVE);
+ unlink (INTERACTIVE);
}
return (EXIT_SUCCESS);