diff options
author | Roy Marples <roy@marples.name> | 2008-01-11 15:51:40 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-01-11 15:51:40 +0000 |
commit | abde759d5bf6028135667779297d30491f1f4688 (patch) | |
tree | 079a40a45ce9199933cc3c0367d671804289018f /src/rc | |
parent | fec312d4482e17328394f3e87b4ad28b1f062b7f (diff) |
Re-indent to a standard tw of 8.
Diffstat (limited to 'src/rc')
-rw-r--r-- | src/rc/_usage.c | 2 | ||||
-rw-r--r-- | src/rc/checkpath.c | 16 | ||||
-rw-r--r-- | src/rc/fstabinfo.c | 12 | ||||
-rw-r--r-- | src/rc/mountinfo.c | 32 | ||||
-rw-r--r-- | src/rc/rc-depend.c | 8 | ||||
-rw-r--r-- | src/rc/rc-logger.c | 12 | ||||
-rw-r--r-- | src/rc/rc-misc.c | 8 | ||||
-rw-r--r-- | src/rc/rc-plugin.c | 4 | ||||
-rw-r--r-- | src/rc/rc-status.c | 14 | ||||
-rw-r--r-- | src/rc/rc-update.c | 18 | ||||
-rw-r--r-- | src/rc/rc.c | 188 | ||||
-rw-r--r-- | src/rc/runscript.c | 92 | ||||
-rw-r--r-- | src/rc/start-stop-daemon.c | 56 |
13 files changed, 232 insertions, 230 deletions
diff --git a/src/rc/_usage.c b/src/rc/_usage.c index b079e320..32b4bbc1 100644 --- a/src/rc/_usage.c +++ b/src/rc/_usage.c @@ -37,7 +37,7 @@ static void usage (int exit_status) printf ("\n\nOptions: [" getoptstring "]\n"); for (i = 0; longopts[i].name; ++i) { int len = printf (" -%c, --%s %s", longopts[i].val, longopts[i].name, - has_arg[longopts[i].has_arg]); + has_arg[longopts[i].has_arg]); char *lo = xstrdup (longopts_help[i]); char *p = lo; diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c index 612a0769..db81a631 100644 --- a/src/rc/checkpath.c +++ b/src/rc/checkpath.c @@ -75,7 +75,7 @@ static int do_check (char *path, uid_t uid, gid_t gid, mode_t mode, int file) } } else { if ((file && S_ISDIR (st.st_mode)) || - (! file && ! S_ISDIR (st.st_mode))) + (! file && ! S_ISDIR (st.st_mode))) { if (file) eerror ("%s: is a directory", path); @@ -84,7 +84,7 @@ static int do_check (char *path, uid_t uid, gid_t gid, mode_t mode, int file) return (-1); } } - + if (mode && (st.st_mode & 0777) != mode) { einfo ("%s: correcting mode", applet); if (chmod (path, mode)) { @@ -126,7 +126,7 @@ static int parse_mode (mode_t *mode, char *text) } static int parse_owner (struct passwd **user, struct group **group, - const char *owner) + const char *owner) { char *u = xstrdup (owner); char *g = strchr (u, ':'); @@ -164,7 +164,7 @@ static int parse_owner (struct passwd **user, struct group **group, static struct option longopts[] = { { "directory", 0, NULL, 'd'}, { "file", 0, NULL, 'f'}, - { "mode", 1, NULL, 'm'}, + { "mode", 1, NULL, 'm'}, { "owner", 1, NULL, 'o'}, longopts_COMMON }; @@ -191,7 +191,7 @@ int checkpath (int argc, char **argv) applet = basename_c (argv[0]); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'd': @@ -202,11 +202,13 @@ int checkpath (int argc, char **argv) break; case 'm': if (parse_mode (&mode, optarg) != 0) - eerrorx ("%s: invalid mode `%s'", applet, optarg); + eerrorx ("%s: invalid mode `%s'", + applet, optarg); break; case 'o': if (parse_owner (&pw, &gr, optarg) != 0) - eerrorx ("%s: owner `%s' not found", applet, optarg); + eerrorx ("%s: owner `%s' not found", + applet, optarg); break; case_RC_COMMON_GETOPT diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c index 5f8e469a..e67d8313 100644 --- a/src/rc/fstabinfo.c +++ b/src/rc/fstabinfo.c @@ -81,7 +81,7 @@ static struct mntent *getmntfile (const char *file) if (strcmp (file, ent->mnt_dir) == 0) break; END_ENT; - + return (ent); } #endif @@ -134,7 +134,7 @@ int fstabinfo (int argc, char **argv) unsetenv ("EINFO_QUIET"); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'b': @@ -156,9 +156,9 @@ int fstabinfo (int argc, char **argv) START_ENT; while ((ent = GET_ENT)) { if (((optarg[0] == '=' && i == ENT_PASS (ent)) || - (optarg[0] == '<' && i > ENT_PASS (ent)) || - (optarg[0] == '>' && i < ENT_PASS (ent))) && - strcmp (ENT_FILE (ent), "none") != 0) + (optarg[0] == '<' && i > ENT_PASS (ent)) || + (optarg[0] == '>' && i < ENT_PASS (ent))) && + strcmp (ENT_FILE (ent), "none") != 0) rc_strlist_add (&files, ENT_FILE (ent)); } END_ENT; @@ -182,7 +182,7 @@ int fstabinfo (int argc, char **argv) } break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c index e7e29578..989dcbdc 100644 --- a/src/rc/mountinfo.c +++ b/src/rc/mountinfo.c @@ -86,8 +86,8 @@ struct args { }; static int process_mount (char ***list, struct args *args, - char *from, char *to, char *fstype, char *options, - int netdev) + char *from, char *to, char *fstype, char *options, + int netdev) { char *p; @@ -107,24 +107,24 @@ static int process_mount (char ***list, struct args *args, return (1); } else { if (args->node_regex && - regexec (args->node_regex, from, 0, NULL, 0) != 0) + regexec (args->node_regex, from, 0, NULL, 0) != 0) return (1); if (args->skip_node_regex && - regexec (args->skip_node_regex, from, 0, NULL, 0) == 0) + regexec (args->skip_node_regex, from, 0, NULL, 0) == 0) return (1); if (args->fstype_regex && - regexec (args->fstype_regex, fstype, 0, NULL, 0) != 0) + regexec (args->fstype_regex, fstype, 0, NULL, 0) != 0) return (-1); if (args->skip_fstype_regex && - regexec (args->skip_fstype_regex, fstype, 0, NULL, 0) == 0) + regexec (args->skip_fstype_regex, fstype, 0, NULL, 0) == 0) return (-1); if (args->options_regex && - regexec (args->options_regex, options, 0, NULL, 0) != 0) + regexec (args->options_regex, options, 0, NULL, 0) != 0) return (-1); if (args->skip_options_regex && - regexec (args->skip_options_regex, options, 0, NULL, 0) == 0) + regexec (args->skip_options_regex, options, 0, NULL, 0) == 0) return (-1); } @@ -247,11 +247,11 @@ static char **find_mounts (struct args *args) } process_mount (&list, args, - mnts[i].f_mntfromname, - mnts[i].f_mntonname, - mnts[i].f_fstypename, - options, - netdev); + mnts[i].f_mntfromname, + mnts[i].f_mntonname, + mnts[i].f_fstypename, + options, + netdev); free (options); options = NULL; @@ -271,7 +271,7 @@ static struct mntent *getmntfile (const char *file) if (strcmp (file, ent->mnt_dir) == 0) break; endmntent (fp); - + return (ent); } @@ -395,7 +395,7 @@ int mountinfo (int argc, char **argv) args.netdev = net_ignore; while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'e': @@ -456,7 +456,7 @@ int mountinfo (int argc, char **argv) REG_FREE (args.skip_node_regex); REG_FREE (args.options_regex); REG_FREE (args.skip_options_regex); - + rc_strlist_reverse (nodes); result = EXIT_FAILURE; diff --git a/src/rc/rc-depend.c b/src/rc/rc-depend.c index c5e9e662..4a5d64e1 100644 --- a/src/rc/rc-depend.c +++ b/src/rc/rc-depend.c @@ -99,7 +99,7 @@ int rc_depend (int argc, char **argv) applet = basename_c (argv[0]); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 's': @@ -116,7 +116,7 @@ int rc_depend (int argc, char **argv) options &= RC_DEP_TRACE; break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } @@ -140,7 +140,7 @@ int rc_depend (int argc, char **argv) rc_strlist_add (&list, argv[optind]); errno = 0; depends = rc_deptree_depends (deptree, NULL, (const char **) list, - runlevel, 0); + runlevel, 0); if (! depends && errno == ENOENT) eerror ("no dependency info for service `%s'", argv[optind]); else @@ -167,7 +167,7 @@ int rc_depend (int argc, char **argv) } depends = rc_deptree_depends (deptree, (const char **) types, - (const char **) services, runlevel, options); + (const char **) services, runlevel, options); if (depends) { STRLIST_FOREACH (depends, service, i) { diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c index 0c48e444..0d9c514c 100644 --- a/src/rc/rc-logger.c +++ b/src/rc/rc-logger.c @@ -96,7 +96,7 @@ static void write_log (int logfd, const char *buffer, size_t bytes) in_term = true; break; } - + if (! in_escape) { write (logfd, p++, 1); continue; @@ -159,7 +159,7 @@ void rc_logger_open (const char *level) eerrorx ("pipe: %s", strerror (errno)); for (i = 0; i < 2; i++) if ((s = fcntl (signal_pipe[i], F_GETFD, 0) == -1 || - fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1)) + fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1)) eerrorx ("fcntl: %s", strerror (errno)); tcgetattr (STDOUT_FILENO, &tt); @@ -213,7 +213,7 @@ void rc_logger_open (const char *level) if (logbuf_size - logbuf_len < bytes) { logbuf_size += BUFSIZ * 10; logbuf = xrealloc (logbuf, sizeof (char ) * - logbuf_size); + logbuf_size); } memcpy (logbuf + logbuf_len, buffer, bytes); @@ -242,7 +242,7 @@ void rc_logger_open (const char *level) /* Try and cat our new logfile to a more permament location and then * punt it */ system (MOVELOG); - + exit (0); default: setpgid (rc_logger_pid, 0); @@ -251,8 +251,8 @@ void rc_logger_open (const char *level) dup2 (slave_tty, STDOUT_FILENO); dup2 (slave_tty, STDERR_FILENO); if (slave_tty != STDIN_FILENO && - slave_tty != STDOUT_FILENO && - slave_tty != STDERR_FILENO) + slave_tty != STDOUT_FILENO && + slave_tty != STDERR_FILENO) close (slave_tty); close (signal_pipe[0]); signal_pipe[0] = -1; diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 3cfbe175..0d6be40d 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -186,7 +186,7 @@ char **env_filter (void) /* Ensure our PATH is prefixed with the system locations first for a little extra security */ if (strcmp (env_name, "PATH") == 0 && - strncmp (PATH_PREFIX, env_var, pplen) != 0) + strncmp (PATH_PREFIX, env_var, pplen) != 0) { got_path = true; env_len = strlen (env_name) + strlen (env_var) + pplen + 2; @@ -233,7 +233,7 @@ char **env_filter (void) return (env); } - /* Other systems may need this at some point, but for now it's Linux only */ +/* Other systems may need this at some point, but for now it's Linux only */ #ifdef __linux__ static bool file_regex (const char *file, const char *regex) { @@ -338,7 +338,7 @@ char **env_config (void) } else if (file_regex ("/proc/cpuinfo", "UML")) { snprintf (sys, sizeof (sys), "UML"); } else if (file_regex ("/proc/self/status", - "(s_context|VxID|envID):[[:space:]]*[1-9]")) + "(s_context|VxID|envID):[[:space:]]*[1-9]")) { snprintf (sys, sizeof (sys), "VPS"); } @@ -381,7 +381,7 @@ char **env_config (void) errno = 0; if ((! rc_conf_yesno ("rc_color") && errno == 0) || - rc_conf_yesno ("rc_nocolor")) + rc_conf_yesno ("rc_nocolor")) rc_strlist_add (&env, "EINFO_COLOR=no"); free (runlevel); diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c index 861f064d..f50b4343 100644 --- a/src/rc/rc-plugin.c +++ b/src/rc/rc-plugin.c @@ -167,7 +167,7 @@ void rc_plugin_run (rc_hook_t hook, const char *value) * plugin will probably hang when running in silent mode. */ for (i = 0; i < 2; i++) if ((flags = fcntl (pfd[i], F_GETFD, 0)) < 0 || - fcntl (pfd[i], F_SETFD, flags | FD_CLOEXEC) < 0) + fcntl (pfd[i], F_SETFD, flags | FD_CLOEXEC) < 0) eerror ("fcntl: %s", strerror (errno)); /* We run the plugin in a new process so we never crash @@ -214,7 +214,7 @@ void rc_plugin_run (rc_hook_t hook, const char *value) } } } - + free (buffer); close (pfd[0]); diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index 155192fa..f57584ab 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -48,9 +48,9 @@ static const char *types_nua[] = { "ineed", "iuse", "iafter", NULL }; static void print_level (char *level) { printf ("Runlevel: %s%s%s\n", - ecolor (ECOLOR_HILITE), - level, - ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_HILITE), + level, + ecolor (ECOLOR_NORMAL)); } static void print_service (char *service) @@ -121,7 +121,7 @@ int rc_status (int argc, char **argv) int depopts = RC_DEP_STRICT | RC_DEP_START | RC_DEP_TRACE; while ((opt = getopt_long (argc, argv, getoptstring, longopts, - (int *) 0)) != -1) + (int *) 0)) != -1) switch (opt) { case 'a': levels = rc_runlevel_list (); @@ -155,7 +155,7 @@ int rc_status (int argc, char **argv) rc_strlist_free (services); exit (EXIT_SUCCESS); - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } while (optind < argc) @@ -178,8 +178,8 @@ int rc_status (int argc, char **argv) services = rc_services_in_runlevel (level); if (deptree) { ordered = rc_deptree_depends (deptree, types_nua, - (const char **) services, - level, depopts); + (const char **) services, + level, depopts); rc_strlist_free (services); services = ordered; ordered = NULL; diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c index 4f07503f..463c0cfe 100644 --- a/src/rc/rc-update.c +++ b/src/rc/rc-update.c @@ -59,14 +59,14 @@ static int add (const char *runlevel, const char *service) eerror ("%s: service `%s' does not exist", applet, service); else if (rc_service_in_runlevel (service, runlevel)) { ewarn ("%s: %s already installed in runlevel `%s'; skipping", - applet, service, runlevel); + applet, service, runlevel); retval = 0; } else if (rc_service_add (runlevel, service)) { einfo ("%s added to runlevel %s", service, runlevel); retval = 1; } else eerror ("%s: failed to add service `%s' to runlevel `%s': %s", - applet, service, runlevel, strerror (errno)); + applet, service, runlevel, strerror (errno)); return (retval); } @@ -83,10 +83,10 @@ static int delete (const char *runlevel, const char *service) if (errno == ENOENT) eerror ("%s: service `%s' is not in the runlevel `%s'", - applet, service, runlevel); + applet, service, runlevel); else eerror ("%s: failed to remove service `%s' from runlevel `%s': %s", - applet, service, runlevel, strerror (errno)); + applet, service, runlevel, strerror (errno)); return (retval); } @@ -162,7 +162,7 @@ int rc_update (int argc, char **argv) applet = basename_c (argv[0]); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'a': @@ -175,15 +175,15 @@ int rc_update (int argc, char **argv) action |= DOSHOW; break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } verbose = rc_yesno (getenv ("EINFO_VERBOSE")); if ((action & DOSHOW && action != DOSHOW) || - (action & DOADD && action != DOADD) || - (action & DODELETE && action != DODELETE)) + (action & DOADD && action != DOADD) || + (action & DODELETE && action != DODELETE)) eerrorx ("%s: cannot mix commands", applet); /* We need to be backwards compatible */ @@ -192,7 +192,7 @@ int rc_update (int argc, char **argv) if (strcmp (argv[optind], "add") == 0) action = DOADD; else if (strcmp (argv[optind], "delete") == 0 || - strcmp (argv[optind], "del") == 0) + strcmp (argv[optind], "del") == 0) action = DODELETE; else if (strcmp (argv[optind], "show") == 0) action = DOSHOW; diff --git a/src/rc/rc.c b/src/rc/rc.c index 015dd86f..4bf6541e 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -123,8 +123,8 @@ static void clean_failed (void) if ((dp = opendir (RC_SVCDIR "/failed"))) { while ((d = readdir (dp))) { if (d->d_name[0] == '.' && - (d->d_name[1] == '\0' || - (d->d_name[1] == '.' && d->d_name[2] == '\0'))) + (d->d_name[1] == '\0' || + (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; i = strlen (RC_SVCDIR "/failed/") + strlen (d->d_name) + 1; @@ -133,7 +133,7 @@ static void clean_failed (void) if (path) { if (unlink (path)) eerror ("%s: unlink `%s': %s", applet, path, - strerror (errno)); + strerror (errno)); free (path); } } @@ -147,7 +147,7 @@ static void cleanup (void) pidlist_t *pl = service_pids; rc_plugin_unload (); - + if (! rc_in_plugin && termios_orig) { tcsetattr (fileno (stdin), TCSANOW, termios_orig); free (termios_orig); @@ -204,21 +204,21 @@ static int do_e (int argc, char **argv) if (strcmp (applet, "eval_ecolors") == 0) { printf ("GOOD='%s'\nWARN='%s'\nBAD='%s'\nHILITE='%s'\nBRACKET='%s'\nNORMAL='%s'\n", - ecolor (ECOLOR_GOOD), - ecolor (ECOLOR_WARN), - ecolor (ECOLOR_BAD), - ecolor (ECOLOR_HILITE), - ecolor (ECOLOR_BRACKET), - ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_GOOD), + ecolor (ECOLOR_WARN), + ecolor (ECOLOR_BAD), + ecolor (ECOLOR_HILITE), + ecolor (ECOLOR_BRACKET), + ecolor (ECOLOR_NORMAL)); exit (EXIT_SUCCESS); } if (argc > 0) { if (strcmp (applet, "eend") == 0 || - strcmp (applet, "ewend") == 0 || - strcmp (applet, "veend") == 0 || - strcmp (applet, "vweend") == 0) + strcmp (applet, "ewend") == 0 || + strcmp (applet, "veend") == 0 || + strcmp (applet, "vweend") == 0) { errno = 0; retval = strtol (argv[0], NULL, 0); @@ -229,7 +229,7 @@ static int do_e (int argc, char **argv) argv++; } } else if (strcmp (applet, "esyslog") == 0 || - strcmp (applet, "elog") == 0) { + strcmp (applet, "elog") == 0) { char *dot = strchr (argv[0], '.'); if ((level = syslog_decode (dot + 1, prioritynames)) == -1) eerrorx ("%s: invalid log level `%s'", applet, argv[0]); @@ -405,7 +405,7 @@ static int do_mark_service (int argc, char **argv) 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)); + applet, pid, strerror (errno)); /* Remove the exclusive time test. This ensures that it's not in control as well */ @@ -415,7 +415,7 @@ static int do_mark_service (int argc, char **argv) 4; mtime = xmalloc (l); snprintf (mtime, l, RC_SVCDIR "exclusive/%s.%s", - svcname, runscript_pid); + svcname, runscript_pid); if (exists (mtime) && unlink (mtime) != 0) eerror ("%s: unlink: %s", applet, strerror (errno)); free (mtime); @@ -436,7 +436,7 @@ static int do_value (int argc, char **argv) eerrorx ("%s: no option specified", applet); if (strcmp (applet, "service_get_value") == 0 || - strcmp (applet, "get_options") == 0) + strcmp (applet, "get_options") == 0) { char *option = rc_service_value_get (service, argv[0]); if (option) { @@ -445,7 +445,7 @@ static int do_value (int argc, char **argv) ok = true; } } else if (strcmp (applet, "service_set_value") == 0 || - strcmp (applet, "save_options") == 0) + strcmp (applet, "save_options") == 0) ok = rc_service_value_set (service, argv[0], argv[1]); else eerrorx ("%s: unknown applet", applet); @@ -493,7 +493,7 @@ static char *proc_getent (const char *ent) } if ((proc = rc_getline (fp)) && - (p = strstr (proc, ent))) + (p = strstr (proc, ent))) { i = p - proc; if (i == '\0' || proc[i - 1] == ' ') { @@ -554,9 +554,9 @@ static bool want_interactive (void) return (false); if (PREVLEVEL && - strcmp (PREVLEVEL, "N") != 0 && - strcmp (PREVLEVEL, "S") != 0 && - strcmp (PREVLEVEL, "1") != 0) + strcmp (PREVLEVEL, "N") != 0 && + strcmp (PREVLEVEL, "S") != 0 && + strcmp (PREVLEVEL, "1") != 0) return (false); if (! gotinteractive) { @@ -609,11 +609,11 @@ static void sulogin (bool cont) execle (SULOGIN, SULOGIN, (char *) NULL, newenv); eerror ("%s: unable to exec `%s': %s", applet, SULOGIN, - strerror (errno)); + strerror (errno)); #else execle ("/bin/sh", "/bin/sh", (char *) NULL, newenv); eerror ("%s: unable to exec `/bin/sh': %s", applet, - strerror (errno)); + strerror (errno)); #endif _exit (EXIT_FAILURE); } @@ -637,11 +637,11 @@ static void single_user (void) #ifdef __linux__ execl ("/sbin/telinit", "/sbin/telinit", "S", (char *) NULL); eerrorx ("%s: unable to exec `/sbin/telinit': %s", - applet, strerror (errno)); + applet, strerror (errno)); #else if (kill (1, SIGTERM) != 0) eerrorx ("%s: unable to send SIGTERM to init (pid 1): %s", - applet, strerror (errno)); + applet, strerror (errno)); exit (EXIT_SUCCESS); #endif } @@ -651,12 +651,12 @@ static bool set_ksoftlevel (const char *level) FILE *fp; if (! level || - strcmp (level, getenv ("RC_BOOTLEVEL")) == 0 || - strcmp (level, RC_LEVEL_SINGLE) == 0 || - strcmp (level, RC_LEVEL_SYSINIT) == 0) + strcmp (level, getenv ("RC_BOOTLEVEL")) == 0 || + strcmp (level, RC_LEVEL_SINGLE) == 0 || + strcmp (level, RC_LEVEL_SYSINIT) == 0) { if (exists (RC_KSOFTLEVEL) && - unlink (RC_KSOFTLEVEL) != 0) + unlink (RC_KSOFTLEVEL) != 0) eerror ("unlink `%s': %s", RC_KSOFTLEVEL, strerror (errno)); return (false); } @@ -786,11 +786,11 @@ static void handle_signal (int sig) /* Only drop into single user mode if we're booting */ if ((PREVLEVEL && - (strcmp (PREVLEVEL, "S") == 0 || - strcmp (PREVLEVEL, "1") == 0)) || - (RUNLEVEL && - (strcmp (RUNLEVEL, "S") == 0 || - strcmp (RUNLEVEL, "1") == 0))) + (strcmp (PREVLEVEL, "S") == 0 || + strcmp (PREVLEVEL, "1") == 0)) || + (RUNLEVEL && + (strcmp (RUNLEVEL, "S") == 0 || + strcmp (RUNLEVEL, "1") == 0))) single_user (); exit (EXIT_FAILURE); @@ -814,7 +814,7 @@ static void run_script (const char *script) else if (pid == 0) { execl (script, script, (char *) NULL); eerror ("%s: unable to exec `%s': %s", - script, applet, strerror (errno)); + script, applet, strerror (errno)); _exit (EXIT_FAILURE); } @@ -868,9 +868,9 @@ int main (int argc, char **argv) if (argc > 1 && (strcmp (argv[1], "--version") == 0)) { printf ("%s (OpenRC" #ifdef BRANDING - " " BRANDING + " " BRANDING #endif - ") version " VERSION "\n", applet); + ") version " VERSION "\n", applet); exit (EXIT_SUCCESS); } @@ -885,7 +885,7 @@ int main (int argc, char **argv) else if (strcmp (applet, "rc-status") == 0) exit (rc_status (argc, argv)); else if (strcmp (applet, "rc-update") == 0 || - strcmp (applet, "update-rc") == 0) + strcmp (applet, "update-rc") == 0) exit (rc_update (argc, argv)); else if (strcmp (applet, "runscript") == 0) exit (runscript (argc, argv)); @@ -902,9 +902,9 @@ int main (int argc, char **argv) exit (do_e (argc, argv)); if (strcmp (applet, "service_get_value") == 0 || - strcmp (applet, "service_set_value") == 0 || - strcmp (applet, "get_options") == 0 || - strcmp (applet, "save_options") == 0) + strcmp (applet, "service_set_value") == 0 || + strcmp (applet, "get_options") == 0 || + strcmp (applet, "save_options") == 0) exit (do_value (argc, argv)); if (strncmp (applet, "service_", strlen ("service_")) == 0) @@ -928,7 +928,7 @@ int main (int argc, char **argv) if (p && sscanf (p, "%d", &pid) == 1) { if (kill (pid, SIGUSR1) != 0) eerrorx ("rc-abort: failed to signal parent %d: %s", - pid, strerror (errno)); + pid, strerror (errno)); exit (EXIT_SUCCESS); } exit (EXIT_FAILURE); @@ -986,14 +986,14 @@ int main (int argc, char **argv) argc++; argv--; while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'o': if (strlen (optarg) == 0) optarg = NULL; exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE); - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } @@ -1035,9 +1035,9 @@ int main (int argc, char **argv) */ if (newlevel) { if (strcmp (newlevel, RC_LEVEL_SYSINIT) == 0 && - RUNLEVEL && - (strcmp (RUNLEVEL, "S") == 0 || - strcmp (RUNLEVEL, "1") == 0)) + RUNLEVEL && + (strcmp (RUNLEVEL, "S") == 0 || + strcmp (RUNLEVEL, "1") == 0)) { /* OK, we're either in runlevel 1 or single user mode */ struct utsname uts; @@ -1053,19 +1053,19 @@ int main (int argc, char **argv) uname (&uts); printf ("\n %sOpenRC %s" VERSION "%s is starting up %s%s%s\n\n", - ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE), - ecolor (ECOLOR_NORMAL), ecolor (ECOLOR_BRACKET), + ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE), + ecolor (ECOLOR_NORMAL), ecolor (ECOLOR_BRACKET), #ifdef BRANDING - BRANDING + BRANDING #else - "" + "" #endif - , ecolor (ECOLOR_NORMAL)); + , ecolor (ECOLOR_NORMAL)); if (! rc_yesno (getenv ("EINFO_QUIET")) && - rc_conf_yesno ("rc_interactive")) + rc_conf_yesno ("rc_interactive")) printf ("Press %sI%s to enter interactive boot mode\n\n", - ecolor (ECOLOR_GOOD), ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_GOOD), ecolor (ECOLOR_NORMAL)); setenv ("RC_SOFTLEVEL", newlevel, 1); rc_plugin_run (RC_HOOK_RUNLEVEL_START_IN, newlevel); @@ -1088,8 +1088,8 @@ int main (int argc, char **argv) exit (EXIT_SUCCESS); } else if (strcmp (newlevel, RC_LEVEL_SINGLE) == 0) { if (! RUNLEVEL || - (strcmp (RUNLEVEL, "S") != 0 && - strcmp (RUNLEVEL, "1") != 0)) + (strcmp (RUNLEVEL, "S") != 0 && + strcmp (RUNLEVEL, "1") != 0)) { /* Remember the current runlevel for when we come back */ set_ksoftlevel (runlevel); @@ -1097,27 +1097,27 @@ int main (int argc, char **argv) } } else if (strcmp (newlevel, RC_LEVEL_REBOOT) == 0) { if (! RUNLEVEL || - strcmp (RUNLEVEL, "6") != 0) + strcmp (RUNLEVEL, "6") != 0) { rc_logger_close (); execl (SHUTDOWN, SHUTDOWN, "-r", "now", (char *) NULL); eerrorx ("%s: unable to exec `" SHUTDOWN "': %s", - applet, strerror (errno)); + applet, strerror (errno)); } } else if (strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0) { if (! RUNLEVEL || - strcmp (RUNLEVEL, "0") != 0) + strcmp (RUNLEVEL, "0") != 0) { rc_logger_close (); execl (SHUTDOWN, SHUTDOWN, #ifdef __linux__ - "-h", + "-h", #else - "-p", + "-p", #endif - "now", (char *) NULL); + "now", (char *) NULL); eerrorx ("%s: unable to exec `" SHUTDOWN "': %s", - applet, strerror (errno)); + applet, strerror (errno)); } } } @@ -1128,27 +1128,27 @@ int main (int argc, char **argv) /* We should only use ksoftlevel if we were in single user mode If not, we need to erase ksoftlevel now. */ if (PREVLEVEL && - (strcmp (PREVLEVEL, "1") == 0 || - strcmp (PREVLEVEL, "S") == 0 || - strcmp (PREVLEVEL, "N") == 0)) + (strcmp (PREVLEVEL, "1") == 0 || + strcmp (PREVLEVEL, "S") == 0 || + strcmp (PREVLEVEL, "N") == 0)) { /* Try not to join boot and ksoftlevels together */ if (! newlevel || - strcmp (newlevel, getenv ("RC_BOOTLEVEL")) != 0) + strcmp (newlevel, getenv ("RC_BOOTLEVEL")) != 0) if (get_ksoftlevel (ksoftbuffer, sizeof (ksoftbuffer))) newlevel = ksoftbuffer; } else if (! RUNLEVEL || - (strcmp (RUNLEVEL, "1") != 0 && - strcmp (RUNLEVEL, "S") != 0 && - strcmp (RUNLEVEL, "N") != 0)) + (strcmp (RUNLEVEL, "1") != 0 && + strcmp (RUNLEVEL, "S") != 0 && + strcmp (RUNLEVEL, "N") != 0)) { set_ksoftlevel (NULL); } if (newlevel && - (strcmp (newlevel, RC_LEVEL_REBOOT) == 0 || - strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (newlevel, RC_LEVEL_SINGLE) == 0)) + (strcmp (newlevel, RC_LEVEL_REBOOT) == 0 || + strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0 || + strcmp (newlevel, RC_LEVEL_SINGLE) == 0)) { going_down = true; rc_runlevel_set (newlevel); @@ -1190,12 +1190,12 @@ int main (int argc, char **argv) if ((dp = opendir (DEVBOOT))) { while ((d = readdir (dp))) { if (d->d_name[0] == '.' && - (d->d_name[1] == '\0' || - (d->d_name[1] == '.' && d->d_name[2] == '\0'))) + (d->d_name[1] == '\0' || + (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; if (rc_service_exists (d->d_name) && - rc_service_plugable (d->d_name)) + rc_service_plugable (d->d_name)) rc_service_mark (d->d_name, RC_SERVICE_COLDPLUGGED); i = strlen (DEVBOOT "/") + strlen (d->d_name) + 1; @@ -1204,7 +1204,7 @@ int main (int argc, char **argv) if (tmp) { if (unlink (tmp)) eerror ("%s: unlink `%s': %s", applet, tmp, - strerror (errno)); + strerror (errno)); free (tmp); } } @@ -1217,9 +1217,9 @@ int main (int argc, char **argv) the device node to the init script to simulate the coldplug into runlevel for our dependency tree to work. */ if (newlevel && strcmp (newlevel, bootlevel) == 0 && - (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || - strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) && - rc_conf_yesno ("rc_coldplug")) + (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || + strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) && + rc_conf_yesno ("rc_coldplug")) { #if defined(__DragonFly__) || defined(__FreeBSD__) /* The net interfaces are easy - they're all in net /dev/net :) */ @@ -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)) + rc_service_plugable (tmp)) rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED); CHAR_FREE (tmp); } @@ -1242,7 +1242,7 @@ int main (int argc, char **argv) if ((dp = opendir ("/dev"))) { while ((d = readdir (dp))) { if (strncmp (d->d_name, "psm", 3) == 0 || - strncmp (d->d_name, "ums", 3) == 0) + strncmp (d->d_name, "ums", 3) == 0) { char *p = d->d_name + 3; if (p && isdigit ((int) *p)) { @@ -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)) + rc_service_plugable (tmp)) rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED); CHAR_FREE (tmp); } @@ -1274,8 +1274,8 @@ int main (int argc, char **argv) rc_strlist_free (tmplist); deporder = rc_deptree_depends (deptree, types_nua, - (const char **) stop_services, - runlevel, depoptions | RC_DEP_STOP); + (const char **) stop_services, + runlevel, depoptions | RC_DEP_STOP); rc_strlist_free (stop_services); stop_services = deporder; @@ -1310,8 +1310,8 @@ int main (int argc, char **argv) rc_strlist_join (&coldplugged_services, tmplist); rc_strlist_free (tmplist); 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) + 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 */ tmplist = rc_services_in_runlevel (bootlevel); @@ -1394,8 +1394,8 @@ int main (int argc, char **argv) going to be started depends on us */ rc_strlist_add (&stopdeps, service); deporder = rc_deptree_depends (deptree, types_n, - (const char **) stopdeps, - runlevel, RC_DEP_STRICT); + (const char **) stopdeps, + runlevel, RC_DEP_STRICT); rc_strlist_free (stopdeps); stopdeps = NULL; found = false; @@ -1444,12 +1444,12 @@ int main (int argc, char **argv) /* Run the halt script if needed */ if (strcmp (runlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (runlevel, RC_LEVEL_REBOOT) == 0) + strcmp (runlevel, RC_LEVEL_REBOOT) == 0) { rc_logger_close (); execl (HALTSH, HALTSH, runlevel, (char *) NULL); eerrorx ("%s: unable to exec `%s': %s", - applet, HALTSH, strerror (errno)); + applet, HALTSH, strerror (errno)); } /* Single user is done now */ @@ -1468,8 +1468,8 @@ int main (int argc, char **argv) /* Order the services to start */ deporder = rc_deptree_depends (deptree, types_nua, - (const char **) start_services, - runlevel, depoptions | RC_DEP_START); + (const char **) start_services, + runlevel, depoptions | RC_DEP_START); rc_strlist_free (start_services); start_services = deporder; deporder = NULL; diff --git a/src/rc/runscript.c b/src/rc/runscript.c index c688da43..1f3d6625 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -262,18 +262,18 @@ static void start_services (char **list) { return; if (state & RC_SERVICE_INACTIVE || - state & RC_SERVICE_WASINACTIVE || - state & RC_SERVICE_STARTING || - state & RC_SERVICE_STARTED) + state & RC_SERVICE_WASINACTIVE || + state & RC_SERVICE_STARTING || + state & RC_SERVICE_STARTED) { STRLIST_FOREACH (list, svc, i) { if (rc_service_state (svc) & RC_SERVICE_STOPPED) { if (state & RC_SERVICE_INACTIVE || - state & RC_SERVICE_WASINACTIVE) + state & RC_SERVICE_WASINACTIVE) { rc_service_schedule_start (service, svc); ewarn ("WARNING: %s is scheduled to started when %s has started", - svc, applet); + svc, applet); } else rc_service_start (svc); } @@ -404,7 +404,7 @@ static bool svc_exec (const char *arg1, const char *arg2) eerrorx ("%s: pipe: %s", service, applet); for (i = 0; i < 2; i++) if ((flags = fcntl (signal_pipe[i], F_GETFD, 0) == -1 || - fcntl (signal_pipe[i], F_SETFD, flags | FD_CLOEXEC) == -1)) + fcntl (signal_pipe[i], F_SETFD, flags | FD_CLOEXEC) == -1)) eerrorx ("%s: fcntl: %s", service, strerror (errno)); /* Open a pty for our prefixed output @@ -439,15 +439,15 @@ static bool svc_exec (const char *arg1, const char *arg2) if (exists (RC_SVCDIR "/runscript.sh")) { execl (RC_SVCDIR "/runscript.sh", RC_SVCDIR "/runscript.sh", - service, arg1, arg2, (char *) NULL); + service, arg1, arg2, (char *) NULL); eerror ("%s: exec `" RC_SVCDIR "/runscript.sh': %s", - service, strerror (errno)); + service, strerror (errno)); _exit (EXIT_FAILURE); } else { execl (RC_LIBDIR "/sh/runscript.sh", RC_LIBDIR "/sh/runscript.sh", - service, arg1, arg2, (char *) NULL); + service, arg1, arg2, (char *) NULL); eerror ("%s: exec `" RC_LIBDIR "/sh/runscript.sh': %s", - service, strerror (errno)); + service, strerror (errno)); _exit (EXIT_FAILURE); } } @@ -584,9 +584,9 @@ static void make_exclusive () exclusive = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL); if (mkfifo (exclusive, 0600) != 0 && errno != EEXIST && - (errno != EACCES || geteuid () == 0)) + (errno != EACCES || geteuid () == 0)) eerrorx ("%s: unable to create fifo `%s': %s", - applet, exclusive, strerror (errno)); + applet, exclusive, strerror (errno)); path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL); i = strlen (path) + 16; @@ -596,7 +596,7 @@ static void make_exclusive () if (exists (mtime_test) && unlink (mtime_test) != 0) { eerror ("%s: unlink `%s': %s", - applet, mtime_test, strerror (errno)); + applet, mtime_test, strerror (errno)); free (mtime_test); mtime_test = NULL; return; @@ -604,7 +604,7 @@ static void make_exclusive () if (symlink (service, mtime_test) != 0) { eerror ("%s: symlink `%s' to `%s': %s", - applet, service, mtime_test, strerror (errno)); + applet, service, mtime_test, strerror (errno)); free (mtime_test); mtime_test = NULL; } @@ -645,7 +645,7 @@ static void svc_start (bool deps) if (rc_yesno (getenv ("IN_HOTPLUG")) || in_background) { if (! state & RC_SERVICE_INACTIVE && - ! state & RC_SERVICE_STOPPED) + ! state & RC_SERVICE_STOPPED) exit (EXIT_FAILURE); background = true; } @@ -694,11 +694,11 @@ static void svc_start (bool deps) rc_strlist_free (need_services); need_services = rc_deptree_depends (deptree, types_n, svcl, - softlevel, depoptions); + softlevel, depoptions); rc_strlist_free (use_services); use_services = rc_deptree_depends (deptree, types_nu, svcl, - softlevel, depoptions); + softlevel, depoptions); if (! rc_runlevel_starting ()) { STRLIST_FOREACH (use_services, svc, i) @@ -711,7 +711,7 @@ static void svc_start (bool deps) /* Now wait for them to start */ services = rc_deptree_depends (deptree, types_nua, svcl, - softlevel, depoptions); + softlevel, depoptions); /* We use tmplist to hold our scheduled by list */ rc_strlist_free (tmplist); @@ -725,7 +725,7 @@ static void svc_start (bool deps) /* Don't wait for services which went inactive but are now in * starting state which we are after */ if (svcs & RC_SERVICE_STARTING && - svcs & RC_SERVICE_WASINACTIVE) { + svcs & RC_SERVICE_WASINACTIVE) { bool use = false; STRLIST_FOREACH (use_services, svc2, j) if (strcmp (svc, svc2) == 0) { @@ -744,11 +744,11 @@ static void svc_start (bool deps) STRLIST_FOREACH (need_services, svc2, j) if (strcmp (svc, svc2) == 0) { if (svcs & RC_SERVICE_INACTIVE || - svcs & RC_SERVICE_WASINACTIVE) + svcs & RC_SERVICE_WASINACTIVE) rc_strlist_add (&tmplist, svc); else eerrorx ("ERROR: cannot start %s as %s would not start", - applet, svc); + applet, svc); } } @@ -786,7 +786,7 @@ static void svc_start (bool deps) p += snprintf (p, len, "%s", svc); } ewarnx ("WARNING: %s is scheduled to start when %s has started", - applet, tmp); + applet, tmp); } rc_strlist_free (services); @@ -852,12 +852,12 @@ static void svc_stop (bool deps) rc_service_state_t state = rc_service_state (service); if (rc_runlevel_stopping () && - state & RC_SERVICE_FAILED) + state & RC_SERVICE_FAILED) exit (EXIT_FAILURE); if (rc_yesno (getenv ("IN_HOTPLUG")) || in_background) if (! (state & RC_SERVICE_STARTED) && - ! (state & RC_SERVICE_INACTIVE)) + ! (state & RC_SERVICE_INACTIVE)) exit (EXIT_FAILURE); if (state & RC_SERVICE_STOPPED) { @@ -875,7 +875,7 @@ static void svc_stop (bool deps) rc_plugin_run (RC_HOOK_SERVICE_STOP_IN, applet); if (! rc_runlevel_stopping () && - rc_service_in_runlevel (service, RC_LEVEL_BOOT)) + rc_service_in_runlevel (service, RC_LEVEL_BOOT)) ewarn ("WARNING: you are stopping a boot service"); if (deps && ! (state & RC_SERVICE_WASINACTIVE)) { @@ -896,17 +896,17 @@ static void svc_stop (bool deps) tmplist = NULL; rc_strlist_free (services); services = rc_deptree_depends (deptree, types_m, svcl, - softlevel, depoptions); + softlevel, depoptions); rc_strlist_reverse (services); STRLIST_FOREACH (services, svc, i) { rc_service_state_t svcs = rc_service_state (svc); if (svcs & RC_SERVICE_STARTED || - svcs & RC_SERVICE_INACTIVE) + svcs & RC_SERVICE_INACTIVE) { svc_wait (deptree, svc); svcs = rc_service_state (svc); if (svcs & RC_SERVICE_STARTED || - svcs & RC_SERVICE_INACTIVE) + svcs & RC_SERVICE_INACTIVE) { pid_t pid = rc_service_stop (svc); if (! rc_conf_yesno ("rc_parallel")) @@ -928,15 +928,15 @@ static void svc_stop (bool deps) if (rc_runlevel_stopping ()) { /* If shutting down, we should stop even if a dependant failed */ if (softlevel && - (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (softlevel, RC_LEVEL_REBOOT) == 0 || - strcmp (softlevel, RC_LEVEL_SINGLE) == 0)) + (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 || + strcmp (softlevel, RC_LEVEL_REBOOT) == 0 || + strcmp (softlevel, RC_LEVEL_SINGLE) == 0)) continue; rc_service_mark (service, RC_SERVICE_FAILED); } eerrorx ("ERROR: cannot stop %s as %s is still up", - applet, svc); + applet, svc); } } rc_strlist_free (tmplist); @@ -945,7 +945,7 @@ static void svc_stop (bool deps) /* We now wait for other services that may use us and are stopping This is important when a runlevel stops */ services = rc_deptree_depends (deptree, types_mua, svcl, - softlevel, depoptions); + softlevel, depoptions); STRLIST_FOREACH (services, svc, i) { if (rc_service_state (svc) & RC_SERVICE_STOPPED) continue; @@ -1161,7 +1161,7 @@ int runscript (int argc, char **argv) /* Right then, parse any options there may be */ while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) switch (opt) { case 'd': setenv ("RC_DEBUG", "yes", 1); @@ -1209,7 +1209,7 @@ int runscript (int argc, char **argv) exit (EXIT_FAILURE); if (strcmp (optarg, "status") != 0 && - strcmp (optarg, "help") != 0) { + strcmp (optarg, "help") != 0) { /* Only root should be able to run us */ } @@ -1223,7 +1223,7 @@ int runscript (int argc, char **argv) doneone = true; if (strcmp (optarg, "describe") == 0 || - strcmp (optarg, "help") == 0) + strcmp (optarg, "help") == 0) { char *save = prefix; @@ -1232,12 +1232,12 @@ int runscript (int argc, char **argv) svc_exec (optarg, NULL); eprefix (save); } else if (strcmp (optarg, "ineed") == 0 || - strcmp (optarg, "iuse") == 0 || - strcmp (optarg, "needsme") == 0 || - strcmp (optarg, "usesme") == 0 || - strcmp (optarg, "iafter") == 0 || - strcmp (optarg, "ibefore") == 0 || - strcmp (optarg, "iprovide") == 0) { + strcmp (optarg, "iuse") == 0 || + strcmp (optarg, "needsme") == 0 || + strcmp (optarg, "usesme") == 0 || + strcmp (optarg, "iafter") == 0 || + strcmp (optarg, "ibefore") == 0 || + strcmp (optarg, "iprovide") == 0) { int depoptions = RC_DEP_TRACE; const char *t[] = { optarg, NULL }; const char *s[] = { applet, NULL }; @@ -1264,7 +1264,7 @@ int runscript (int argc, char **argv) eerrorx ("%s: root access required", applet); if (strcmp (optarg, "conditionalrestart") == 0 || - strcmp (optarg, "condrestart") == 0) + strcmp (optarg, "condrestart") == 0) { if (rc_service_state (service) & RC_SERVICE_STARTED) svc_restart (deps); @@ -1280,12 +1280,12 @@ int runscript (int argc, char **argv) if (deps) { if (! in_background && - ! rc_runlevel_stopping () && - rc_service_state (service) & RC_SERVICE_STOPPED) + ! rc_runlevel_stopping () && + rc_service_state (service) & RC_SERVICE_STOPPED) uncoldplug (); if (in_background && - rc_service_state (service) & RC_SERVICE_INACTIVE) + rc_service_state (service) & RC_SERVICE_INACTIVE) { int j; STRLIST_FOREACH (restart_services, svc, j) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index e0c55386..901194e9 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -168,7 +168,7 @@ static int parse_signal (const char *sig) for (i = 0; i < sizeof (signallist) / sizeof (signallist[0]); i++) if (strcmp (sig, signallist[i].name) == 0 || - (s && strcmp (s, signallist[i].name) == 0)) + (s && strcmp (s, signallist[i].name) == 0)) return (signallist[i].signal); eerrorx ("%s: `%s' is not a valid signal", applet, sig); @@ -186,9 +186,9 @@ static void parse_schedule_item (schedulelist_t *item, const char *string) errno = 0; if (sscanf (string, "%d", &item->value) != 1) eerrorx ("%s: invalid timeout value in schedule `%s'", applet, - string); + string); } else if ((after_hyph = string + (string[0] == '-')) && - ((sig = parse_signal (after_hyph)) != -1)) + ((sig = parse_signal (after_hyph)) != -1)) { item->type = schedule_signal; item->value = (int) sig; @@ -253,7 +253,7 @@ static void parse_schedule (const char *string, int default_signal) if (next->type == schedule_forever) { if (repeatat) eerrorx ("%s: invalid schedule, `forever' appears more than once", - applet); + applet); repeatat = next; continue; @@ -305,8 +305,8 @@ static pid_t get_pid (const char *pidfile, bool quiet) /* return number of processed killed, -1 on error */ static int do_stop (const char *exec, const char *cmd, - const char *pidfile, uid_t uid,int sig, - bool quiet, bool verbose, bool test) + const char *pidfile, uid_t uid,int sig, + bool quiet, bool verbose, bool test) { pid_t *pids; bool killed; @@ -338,7 +338,7 @@ static int do_stop (const char *exec, const char *cmd, killed = (kill (pids[i], sig) == 0 || errno == ESRCH ? true : false); if (verbose) eend (killed ? 0 : 1, "%s: failed to send signal %d to PID %d: %s", - applet, sig, pids[i], strerror (errno)); + applet, sig, pids[i], strerror (errno)); if (! killed) { nkilled = -1; } else { @@ -352,8 +352,8 @@ static int do_stop (const char *exec, const char *cmd, } static int run_stop_schedule (const char *exec, const char *cmd, - const char *pidfile, uid_t uid, - bool quiet, bool verbose, bool test) + const char *pidfile, uid_t uid, + bool quiet, bool verbose, bool test) { schedulelist_t *item = schedule; int nkilled = 0; @@ -382,7 +382,7 @@ static int run_stop_schedule (const char *exec, const char *cmd, case schedule_signal: nrunning = 0; nkilled = do_stop (exec, cmd, pidfile, uid, item->value, - quiet, verbose, test); + quiet, verbose, test); if (nkilled == 0) { if (tkilled == 0) { if (! quiet) @@ -407,7 +407,7 @@ static int run_stop_schedule (const char *exec, const char *cmd, while (nloops) { if ((nrunning = do_stop (exec, cmd, pidfile, - uid, 0, true, false, true)) == 0) + uid, 0, true, false, true)) == 0) return (true); if (nanosleep (&ts, NULL) == -1) { @@ -584,7 +584,7 @@ int start_stop_daemon (int argc, char **argv) eerror ("%s: invalid nice level `%s' (SSD_NICELEVEL)", applet, env); while ((opt = getopt_long (argc, argv, getoptstring, longopts, - (int *) 0)) != -1) + (int *) 0)) != -1) switch (opt) { case 'K': /* --stop */ stop = true; @@ -702,7 +702,7 @@ int start_stop_daemon (int argc, char **argv) redirect_stderr = optarg; break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } quiet = rc_yesno (getenv ("EINFO_QUIET")); @@ -712,9 +712,9 @@ int start_stop_daemon (int argc, char **argv) * instead of forcing --stop --oknodo as well */ if (! start && ! stop) if (sig != SIGINT && - sig != SIGTERM && - sig != SIGQUIT && - sig != SIGKILL) + sig != SIGTERM && + sig != SIGQUIT && + sig != SIGKILL) { oknodo = true; stop = true; @@ -737,7 +737,7 @@ int start_stop_daemon (int argc, char **argv) if ((redirect_stdout || redirect_stderr) && ! background) eerrorx ("%s: --stdout and --stderr are only relevant with --background", - applet); + applet); argc -= optind; argv += optind; @@ -839,7 +839,7 @@ int start_stop_daemon (int argc, char **argv) if (nicelevel) { if (setpriority (PRIO_PROCESS, mypid, nicelevel) == -1) eerrorx ("%s: setpritory %d: %s", applet, nicelevel, - strerror(errno)); + strerror(errno)); } if (ch_root && chroot (ch_root) < 0) @@ -852,7 +852,7 @@ int start_stop_daemon (int argc, char **argv) FILE *fp = fopen (pidfile, "w"); if (! fp) eerrorx ("%s: fopen `%s': %s", applet, pidfile, strerror - (errno)); + (errno)); fprintf (fp, "%d\n", mypid); fclose (fp); } @@ -902,7 +902,7 @@ int start_stop_daemon (int argc, char **argv) /* Clean the environment of any RC_ variables */ STRLIST_FOREACH (environ, env, i) { if (strncmp (env, "RC_", 3) == 0 || - strncmp (env, "SSD_NICELEVEL=", strlen ("SSD_NICELEVEL=")) == 0) + strncmp (env, "SSD_NICELEVEL=", strlen ("SSD_NICELEVEL=")) == 0) continue; /* For the path, remove the rcscript bin dir from it */ @@ -918,9 +918,9 @@ int start_stop_daemon (int argc, char **argv) p += 5; while ((token = strsep (&p, ":"))) { if (strcmp (token, RC_LIBDIR "/bin") == 0 || - strcmp (token, RC_LIBDIR "/sbin") == 0) + strcmp (token, RC_LIBDIR "/sbin") == 0) continue; - + t = strlen (token); if (newpath) { l = strlen (newpath); @@ -949,15 +949,15 @@ int start_stop_daemon (int argc, char **argv) stderr_fd = devnull_fd; if (redirect_stdout) { if ((stdout_fd = open (redirect_stdout, O_WRONLY | O_CREAT | O_APPEND, - S_IRUSR | S_IWUSR)) == -1) + S_IRUSR | S_IWUSR)) == -1) eerrorx ("%s: unable to open the logfile for stdout `%s': %s", - applet, redirect_stdout, strerror (errno)); + applet, redirect_stdout, strerror (errno)); } if (redirect_stderr) { if ((stderr_fd = open (redirect_stderr, O_WRONLY | O_CREAT | O_APPEND, - S_IRUSR | S_IWUSR)) == -1) + S_IRUSR | S_IWUSR)) == -1) eerrorx ("%s: unable to open the logfile for stderr `%s': %s", - applet, redirect_stderr, strerror (errno)); + applet, redirect_stderr, strerror (errno)); } if (background) { @@ -1011,7 +1011,7 @@ int start_stop_daemon (int argc, char **argv) int nloops = START_WAIT / POLL_INTERVAL; int nloopsp = WAIT_PIDFILE / POLL_INTERVAL; bool alive = false; - + ts.tv_sec = 0; ts.tv_nsec = POLL_INTERVAL; @@ -1049,7 +1049,7 @@ int start_stop_daemon (int argc, char **argv) if (get_pid (pidfile, true) == -1) { if (! nloopsp) eerrorx ("%s: did not create a valid pid in `%s'", - applet, pidfile); + applet, pidfile); alive = true; } else nloopsp = 0; |