[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 025c9693ccab9c6220520ace47aa81553e7ea600 Author: William Hubbs gmail com> AuthorDate: Mon Nov 5 17:39:39 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Nov 5 17:39:39 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=025c9693 rc-service: fix help output src/rc/rc-service.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c index 8b01fa0d..e9795650 100644 --- a/src/rc/rc-service.c +++ b/src/rc/rc-service.c @@ -49,10 +49,12 @@ const char * const longopts_help[] = { "set xtrace when running the command", "ignore dependencies", "tests if the service exists or not", - "if the service is crashed then run the command", - "if the service exists then run the command", - "if the service is inactive then run the command", - "if the service is not started then run the command", + "if the service is crashed run the command", + "if the service exists run the command", + "if the service is inactive run the command", + "if the service is not started run the command", + "if the service is started run the command", + "if the service is stopped run the command", "list all available services", "resolve the service name to an init script", "dry run (show what would happen)",
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 008c9d0036e348242e323c0b5a66f3724b4a839d Author: William Hubbs gmail com> AuthorDate: Tue Nov 6 03:35:00 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Nov 6 03:35:00 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=008c9d00 supervise-daemon: reap zombies We need to make sure to reap zombies so that we can shut down successfully. Fixes #252. Possibly related to #250. src/rc/supervise-daemon.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 883c738d..52525c19 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -197,6 +197,16 @@ static void healthcheck(int sig) do_healthcheck = 1; } +static void reap_zombies(int sig) +{ + int serrno; + (void) sig; + + serrno = errno; + while (waitpid((pid_t)(-1), NULL, WNOHANG) > 0) {} + errno = serrno; +} + static char * expand_home(const char *home, const char *path) { char *opath, *ppath, *p, *nh; @@ -457,6 +467,7 @@ static void supervisor(char *exec, char **argv) signal_setup_restart(SIGPIPE, handle_signal); signal_setup_restart(SIGALRM, handle_signal); signal_setup(SIGTERM, handle_signal); + signal_setup(SIGCHLD, reap_zombies); signal_setup_restart(SIGUSR1, handle_signal); signal_setup_restart(SIGUSR2, handle_signal); signal_setup_restart(SIGBUS, handle_signal);
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: e2416d089396e2b9a72cc56ef9f57886ffb0f1c8 Author: William Hubbs gmail com> AuthorDate: Wed Oct 24 20:24:29 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Oct 24 20:24:40 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e2416d08 openrc-shutdown: do not require a time for -w switch X-Gentoo-Bug: 669500 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=669500 src/rc/openrc-shutdown.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c index ab2e7469..71a91255 100644 --- a/src/rc/openrc-shutdown.c +++ b/src/rc/openrc-shutdown.c @@ -250,6 +250,9 @@ int main(int argc, char **argv) } else if (do_reexec) { send_cmd("reexec"); exit(EXIT_SUCCESS); + } else if (do_wtmp_only) { + log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~"); + exit(EXIT_SUCCESS); } if (optind >= argc) { @@ -329,7 +332,5 @@ int main(int argc, char **argv) send_cmd("reboot"); else if (do_single) send_cmd("single"); - else if (do_wtmp_only) - log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~"); return 0; }
[gentoo-commits] proj/openrc:master commit in: /
commit: a2bcfeb42882b40ca23ddfefca2a17a7988f8082 Author: William Hubbs gmail com> AuthorDate: Wed Oct 24 20:18:10 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Oct 24 20:18:10 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a2bcfeb4 version 0.40 Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index b090cc43..d595bdf0 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,3 +1,3 @@ NAME= openrc -VERSION= 0.39 +VERSION= 0.40 PKG= ${NAME}-${VERSION}
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: ee3c4afdb75b98cd472b7ffbb46adc9d8a1e1b15 Author: William Hubbs gmail com> AuthorDate: Fri Nov 2 23:22:11 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Nov 2 23:22:11 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ee3c4afd openrc-init: add SELinux support This is for #173. src/rc/openrc-init.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index e557c63d..c57a3b06 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -31,6 +31,10 @@ #include #include +#ifdef HAVE_SELINUX +# include +#endif + #include "helpers.h" #include "rc.h" #include "rc-wtmp.h" @@ -161,10 +165,36 @@ int main(int argc, char **argv) bool reexec = false; sigset_t signals; struct sigaction sa; +#ifdef HAVE_SELINUX + int enforce = 0; +#endif if (getpid() != 1) return 1; +#ifdef HAVE_SELINUX + if (getenv("SELINUX_INIT") == NULL) { + if (is_selinux_enabled() != 1) { + if (selinux_init_load_policy(&enforce) == 0) { + putenv("SELINUX_INIT=YES"); + execv(argv[0], argv); + } else { + if (enforce > 0) { + /* +* SELinux in enforcing mode but load_policy failed +* At this point, we probably can't open /dev/console, +* so log() won't work +*/ + fprintf(stderr,"Unable to load SELinux Policy.\n"); + fprintf(stderr,"Machine is in enforcing mode.\n"); + fprintf(stderr,"Halting now.\n"); + exit(1); + } + } + } + } +#endif + printf("OpenRC init version %s starting\n", VERSION); if (argc > 1)
[gentoo-commits] proj/openrc:master commit in: /
commit: 53f7afd3b3daf659d58d6545dc79cd45c4c54277 Author: William Hubbs gmail com> AuthorDate: Tue Oct 23 22:14:01 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 23 22:14:01 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=53f7afd3 Update ChangeLog ChangeLog | 644 +- 1 file changed, 170 insertions(+), 474 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba89667b..5aecd05a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,173 @@ +commit 75e9b66f6ff36d06bf1f8bd4824000f9f26106e0 +Author: William Hubbs +Commit: William Hubbs + +news.md: add information about the modules service changes + +commit d70b1c55b67b44b98c23ceed25bc428481f7e00a +Author: William Hubbs +Commit: William Hubbs + +modules: Add --first-time switch to modprobe commands + +On Linux, kernel modules should be loaded once during boot, either in an +initramfs or by this service. + +This does not change anything other than printing out messages if a +module is loaded more than once. + +X-Gentoo-Bug: 659530 +X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=659530 + +commit c1e582586d398b4452f568240985247294f645ef +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon: add health checks + +Health checks are a way to monitor a service and make sure it stays +healthy. + +If a service is not healthy, it will be automatically restarted after +running the unhealthy() function to clean up. + +commit 7a75bfb00c52687a236c92bec78b5e7ab4844701 +Author: William Hubbs +Commit: William Hubbs + +news.md: add note about scheduled shutdown + +commit aacf841de4983ab33755081a6f69cdf5e3a47007 +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon-guide.md: re-format and add more variables + +commit 3f918161aafa61c1c2005709fda0b9bec4c412d8 +Author: William Hubbs +Commit: William Hubbs + +openrc-shutdown: Add scheduled shutdown and the ability to cancel a shutdown + +You can now schedule a shutdown for a certain time or a cpecific number +of minutes into the future. + +When a shutdown is running, you can now cancel it with ^c from the +keyboard or by running "openrc-shutdown -c" from another shell. + +commit 710c874e6e3bc57b1561eb8f2108244bf24ed32e +Author: Zac Medico +Commit: William Hubbs + +supervise-daemon: fix respawn_max off by one + +Fix the comparison between respawn_count and respawn_max so that +respawn_max = 1 will allow for one respawn. Since respawn_count is +incremented before the comparison, use a 'greater than' comparison +so that respawn will be triggered when respawn_count is equal to +respawn_max. + +Fixes: https://github.com/OpenRC/openrc/issues/247 +Fixes: https://github.com/OpenRC/openrc/issues/248 + +commit 07908be0903229a69b9e0f733ed13eeff0b55a44 +Author: Austin English +Commit: Mike Frysinger + +misc: style fixups + +commit 02af093043a7444381b0d8a0a3e8e97247505f95 +Author: Austin English +Commit: Mike Frysinger + +misc: whitespace fixes + +commit 67e2d6033dd7ac6db0269ee060ed20484825ff9f +Author: William Hubbs +Commit: William Hubbs + +Complete implementation of forever timeout value in stop schedules + +commit eca4357892315ca7340bbfc2b373d7660a34142f +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon: use nanosleep() instead of sleep() + +We will be using sigalrm in this process for health checking, and +sigalrm cannot be used with sleep() safely. + +commit 7ee3e5b2d6dbb9c279011b59ec132d27d04f843e +Author: William Hubbs +Commit: William Hubbs + +openrc-init: convert sleep() call to nanosleep() + +Nanosleep is the safer call to use in case we need to use alarms +eventually. + +commit 7cb8d943236fe651ac54c64f8167f7c4369f649c +Author: William Hubbs +Commit: William Hubbs + +Stop mounting efivarfs read-only + +We do not need to do this any longer since all supported linux kernels +make efivarfs immutable and the tools that manipulate it are aware of +this feature. + +This fixes https://github.com/openrc/openrc/issues/238. + +commit 84ed570eaefcbb55b99ba425030bf7d1d1d46137 +Author: Zac Medico +Commit: William Hubbs + +librc: fix EACCES errno false-positive crash + +Use errno != EACCES to fix false-positive for non-root users +with grsecurity kernels. + +Fixes: 37e29442721a ("librc: Add check for crashed state") +This fixes #237 + +commit 2eea73bfd5ce2f9993d52293fe7d25c0c804d592 +Author: William Hubbs +Commit: William Hubbs + +rc-functions.sh: Remove addon support + +This is an old relic from Gentoo baselayout-1.x which should not be used +any longer. + +commit a571a42421b337380b6f5751635c55906bb8b508 +Author: William Hubbs +Commit: William Hubbs + +modules: remove the ability to rena
[gentoo-commits] proj/openrc:master commit in: /
commit: 7a75bfb00c52687a236c92bec78b5e7ab4844701 Author: William Hubbs gmail com> AuthorDate: Tue Oct 23 18:34:08 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 23 18:34:08 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7a75bfb0 news.md: add note about scheduled shutdown NEWS.md | 4 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 3767c18b..d4d96577 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,10 @@ information: https://github.com/openrc/openrc/issues/238 +This version adds timed shutdown and cancelation of shutdown to +openrc-shutdown. Shutdowns can now be delayed for a certain amount of +time or scheduled for an exact time. + ## OpenRC 0.37 start-stop-daemon now supports logging stdout and stderr of daemons to
[gentoo-commits] proj/openrc:master commit in: init.d/
commit: d70b1c55b67b44b98c23ceed25bc428481f7e00a Author: William Hubbs gmail com> AuthorDate: Tue Oct 23 21:47:37 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 23 21:47:37 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d70b1c55 modules: Add --first-time switch to modprobe commands On Linux, kernel modules should be loaded once during boot, either in an initramfs or by this service. This does not change anything other than printing out messages if a module is loaded more than once. X-Gentoo-Bug: 659530 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=659530 init.d/modules.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init.d/modules.in b/init.d/modules.in index 998972ba..abaab85b 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -56,11 +56,12 @@ load_modules() ebegin "Loading module $x" case "$RC_UNAME" in FreeBSD) kldload "$x"; rc=$? ;; - Linux) modprobe --use-blacklist -q "$x"; rc=$? ;; + Linux) modprobe --first-time -q --use-blacklist "$x"; rc=$? ;; *) ;; esac eend $rc "Failed to load $x" done + return 0 } modules_load_d() @@ -118,7 +119,7 @@ Linux_modules() [ -n "${args}" ] && break done [ -z "$args" ] && eval args=\$module_${xx}_args - eval modprobe --use-blacklist --verbose "$x" "$args" + eval modprobe --first-time --use-blacklist --verbose "$x" "$args" done [ -n "$list" ] && eend }
[gentoo-commits] proj/openrc:master commit in: /, src/rc/, man/, sh/
commit: c1e582586d398b4452f568240985247294f645ef Author: William Hubbs gmail com> AuthorDate: Tue Oct 9 22:49:02 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 23 18:38:14 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c1e58258 supervise-daemon: add health checks Health checks are a way to monitor a service and make sure it stays healthy. If a service is not healthy, it will be automatically restarted after running the unhealthy() function to clean up. NEWS.md | 4 ++ man/supervise-daemon.8| 9 +++ sh/supervise-daemon.sh| 14 + src/rc/Makefile | 2 +- src/rc/supervise-daemon.c | 136 +++--- supervise-daemon-guide.md | 36 6 files changed, 169 insertions(+), 32 deletions(-) diff --git a/NEWS.md b/NEWS.md index d4d96577..f1400197 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,10 @@ This version adds timed shutdown and cancelation of shutdown to openrc-shutdown. Shutdowns can now be delayed for a certain amount of time or scheduled for an exact time. +supervise-daemon supports health checks, which are a periodic way to make sure a +service is healthy. For more information on setting this up, please see +supervise-daemon-guide.md. + ## OpenRC 0.37 start-stop-daemon now supports logging stdout and stderr of daemons to diff --git a/man/supervise-daemon.8 b/man/supervise-daemon.8 index af06ee31..8bcd8b5c 100644 --- a/man/supervise-daemon.8 +++ b/man/supervise-daemon.8 @@ -16,6 +16,10 @@ .Nd starts a daemon and restarts it if it crashes .Sh SYNOPSIS .Nm +.Fl a , -healthcheck-timer +.Ar seconds +.Fl A , -healthcheck-delay +.Ar seconds .Fl D , -respawn-delay .Ar seconds .Fl d , -chdir @@ -90,6 +94,11 @@ Print the action(s) that are taken just before doing them. .Pp The options are as follows: .Bl -tag -width indent +.Fl a , -healthcheck-timer Ar seconds +Run the healthcheck() command, possibly followed by the unhealthy() +command every time this number of seconds passes. +.Fl A , -healthcheck-delay Ar seconds +Wait this long before the first health check. .It Fl D , -respawn-delay Ar seconds wait this number of seconds before restarting a daemon after it crashes. The default is 0. diff --git a/sh/supervise-daemon.sh b/sh/supervise-daemon.sh index 80e0260c..73a70140 100644 --- a/sh/supervise-daemon.sh +++ b/sh/supervise-daemon.sh @@ -10,6 +10,8 @@ # This file may not be copied, modified, propagated, or distributed #except according to the terms contained in the LICENSE file. +extra_commands="healthcheck unhealthy ${extra_commands}" + supervise_start() { if [ -z "$command" ]; then @@ -32,6 +34,8 @@ supervise_start() ${respawn_delay:+--respawn-delay} $respawn_delay \ ${respawn_max:+--respawn-max} $respawn_max \ ${respawn_period:+--respawn-period} $respawn_period \ + ${healthcheck_delay:+--healthcheck-delay} $healthcheck_delay \ + ${healthcheck_timer:+--healthcheck-timer} $healthcheck_timer \ ${command_user+--user} $command_user \ ${umask+--umask} $umask \ ${supervise_daemon_args:-${start_stop_daemon_args}} \ @@ -98,3 +102,13 @@ supervise_status() return 3 fi } + +healthcheck() +{ + return 0 +} + +unhealthy() +{ + return 0 +} diff --git a/src/rc/Makefile b/src/rc/Makefile index 9ba240fa..ea4a8c81 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -161,7 +161,7 @@ rc-update: rc-update.o _usage.o rc-misc.o start-stop-daemon: start-stop-daemon.o _usage.o rc-misc.o rc-pipes.o rc-schedules.o ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD} -supervise-daemon: supervise-daemon.o _usage.o rc-misc.o rc-schedules.o +supervise-daemon: supervise-daemon.o _usage.o rc-misc.o rc-plugin.o rc-schedules.o ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD} service_get_value service_set_value get_options save_options: do_value.o rc-misc.o diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 27089152..883c738d 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -61,15 +61,18 @@ static struct pam_conv conv = { NULL, NULL}; #include "queue.h" #include "rc.h" #include "rc-misc.h" +#include "rc-plugin.h" #include "rc-schedules.h" #include "_usage.h" #include "helpers.h" const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "D:d:e:g:I:Kk:m:N:p:R:r:Su:1:2:3" \ +const char *getoptstring = "A:a:D:d:e:g:H:I:Kk:m:N:p:R:r:Su:1:2:3" \ getoptstring_COMMON; const struct option longopts[] = { + { "healthcheck-timer",1, NULL, 'a'}, + { "healthcheck-delay",1, NULL, 'A'}, { "respawn-delay",1, NULL, 'D'}, { "chdir",1, NULL, 'd'}, { "env",
[gentoo-commits] proj/openrc:master commit in: /
commit: 75e9b66f6ff36d06bf1f8bd4824000f9f26106e0 Author: William Hubbs gmail com> AuthorDate: Tue Oct 23 21:59:20 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 23 21:59:20 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=75e9b66f news.md: add information about the modules service changes NEWS.md | 6 ++ 1 file changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index f1400197..0d386190 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,6 +26,12 @@ supervise-daemon supports health checks, which are a periodic way to make sure a service is healthy. For more information on setting this up, please see supervise-daemon-guide.md. +The --first-time switch has been added to all modprobe commands in the +modules service. This means that, on Linux, you will see failures if a +module was loaded by an initramfs or device manager before this service +runs. These messages are harmless, but to clean them up, you should adjust your +modules autoload configuration. + ## OpenRC 0.37 start-stop-daemon now supports logging stdout and stderr of daemons to
[gentoo-commits] proj/openrc:master commit in: /
commit: aacf841de4983ab33755081a6f69cdf5e3a47007 Author: William Hubbs gmail com> AuthorDate: Mon Oct 22 22:49:25 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Oct 22 22:49:25 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=aacf841d supervise-daemon-guide.md: re-format and add more variables supervise-daemon-guide.md | 65 ++- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/supervise-daemon-guide.md b/supervise-daemon-guide.md index ec885e71..0b15a858 100644 --- a/supervise-daemon-guide.md +++ b/supervise-daemon-guide.md @@ -7,44 +7,73 @@ terminates unexpectedly. The following is a brief guide on using this capability. -## Use Default start, stop and status functions +* Use Default start, stop and status functions + If you write your own start, stop and status functions in your service + script, none of this will work. You must allow OpenRC to use the default + functions. -If you write your own start, stop and status functions in your service -script, none of this will work. You must allow OpenRC to use the default -functions. +* Daemons must not fork + Any deamon that you would like to have monitored by supervise-daemon + must not fork. Instead, it must stay in the foreground. If the daemon + forks, the supervisor will be unable to monitor it. -## Daemons must not fork + If the daemon can be configured to not fork, this should be done in the + daemon's configuration file, or by adding a command line option that + instructs it not to fork to the command_args_foreground variable shown + below. -Any deamon that you would like to have monitored by supervise-daemon -must not fork. Instead, it must stay in the foreground. If the daemon -itself forks, the supervisor will be unable to monitor it. - -If the daemon can be configured to not fork, this should be done in the -daemon's configuration file, or by adding a command line option that -instructs it not to fork to the command_args_foreground variable shown -below. - -## Variable Settings +# Variable Settings The most important setting is the supervisor variable. At the top of your service script, you should set this variable as follows: +``` sh supervisor=supervise-daemon +``` Several other variables affect the way services behave under supervise-daemon. They are documented on the openrc-run man page, but I will list them here for convenience: +``` sh pidfile=/pid/of/supervisor.pid +``` If you are using start-stop-daemon to monitor your scripts, the pidfile is the path to the pidfile the daemon creates. If, on the other hand, you are using supervise-daemon, this is the path to the pidfile the supervisor creates. -command_args_foreground should be used if the daemon you want to monitor +``` sh +command_args_foreground="arguments" +``` + +This should be used if the daemon you want to monitor forks and goes to the background by default. This should be set to the command line option that instructs the daemon to stay in the foreground. -This is very early support, so feel free to file bugs if you have -issues. +``` sh +respawn_delay +``` + +This is the number of seconds to delay before attempting to respawn a +supervised process after it dies unexpectedly. +The default is to respawn immediately. + +``` sh +respawn_max=x +``` + +This is the maximum number of times to respawn a supervised process +during the given respawn period. The default is unlimited. + +``` sh +respawn_period=seconds +``` + +This works in conjunction with respawn_max and respawn_delay above to +decide if a process should not be respawned for some reason. + +For example, if respawn_period is 60, respawn_max is 2 and respawn_delay +is 3 and a process dies more than 4 times, the process will not be +respawned and the supervisor will terminate.
[gentoo-commits] proj/openrc:master commit in: src/rc/, man/
commit: 3f918161aafa61c1c2005709fda0b9bec4c412d8 Author: William Hubbs gmail com> AuthorDate: Fri Oct 5 19:10:59 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Oct 18 22:56:36 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3f918161 openrc-shutdown: Add scheduled shutdown and the ability to cancel a shutdown You can now schedule a shutdown for a certain time or a cpecific number of minutes into the future. When a shutdown is running, you can now cancel it with ^c from the keyboard or by running "openrc-shutdown -c" from another shell. man/openrc-shutdown.8| 3 + src/rc/Makefile | 4 +- src/rc/broadcast.c | 209 +++ src/rc/broadcast.h | 16 src/rc/openrc-shutdown.c | 179 ++-- 5 files changed, 402 insertions(+), 9 deletions(-) diff --git a/man/openrc-shutdown.8 b/man/openrc-shutdown.8 index 5db21334..b09e8c20 100644 --- a/man/openrc-shutdown.8 +++ b/man/openrc-shutdown.8 @@ -16,6 +16,7 @@ .Nd bring the system down .Sh SYNOPSIS .Nm +.Op Fl c , -cancel .Op Fl d , -no-write .Op Fl D , -dry-run .Op Fl H , -halt @@ -32,6 +33,8 @@ is the utility that communicates with to bring down the system or instruct openrc-init to re-execute itself. It supports the following options: .Bl -tag -width "poweroff" +.It Fl c , -cancel +Cancel a pending shutdown. .It Fl d , -no-write Do not write the wtmp boot record. .It Fl D , -dry-run diff --git a/src/rc/Makefile b/src/rc/Makefile index b09c5058..9ba240fa 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -14,7 +14,7 @@ SRCS+=rc-selinux.c endif ifeq (${OS},Linux) -SRCS+= kill_all.c openrc-init.c openrc-shutdown.c rc-wtmp.c +SRCS+= kill_all.c openrc-init.c openrc-shutdown.c broadcast.c rc-wtmp.c endif CLEANFILES=version.h rc-selinux.o @@ -134,7 +134,7 @@ mountinfo: mountinfo.o _usage.o rc-misc.o openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD} -openrc-shutdown: openrc-shutdown.o _usage.o rc-wtmp.o +openrc-shutdown: openrc-shutdown.o rc-misc.o _usage.o broadcast.o rc-wtmp.o ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD} openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o diff --git a/src/rc/broadcast.c b/src/rc/broadcast.c new file mode 100644 index ..dbc861d1 --- /dev/null +++ b/src/rc/broadcast.c @@ -0,0 +1,209 @@ +/* + * broadcast.c + * broadcast a message to every logged in user + */ + +/* + * Copyright 2018 Sony Interactive Entertainment Inc. + * + * This file is part of OpenRC. It is subject to the license terms in + * the LICENSE file found in the top-level directory of this + * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE + * This file may not be copied, modified, propagated, or distributed + *except according to the terms contained in the LICENSE file. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "broadcast.h" +#include "helpers.h" + +#ifndef _PATH_DEV +# define _PATH_DEV "/dev/" +#endif + +#ifndef UT_LINESIZE +#define UT_LINESIZE __UT_LINESIZE +#endif + +static sigjmp_buf jbuf; + +/* + * Alarm handler + */ +/*ARGSUSED*/ +# ifdef __GNUC__ +static void handler(int arg __attribute__((unused))) +# else +static void handler(int arg) +# endif +{ + siglongjmp(jbuf, 1); +} + +static void getuidtty(char **userp, char **ttyp) +{ + struct passwd *pwd; + uid_t uid; + char*tty; + static char uidbuf[32]; + static char ttynm[UT_LINESIZE + 4]; + + uid = getuid(); + if ((pwd = getpwuid(uid)) != NULL) { + uidbuf[0] = 0; + strncat(uidbuf, pwd->pw_name, sizeof(uidbuf) - 1); + } else { + if (uid) + sprintf(uidbuf, "uid %d", (int) uid); + else + sprintf(uidbuf, "root"); + } + + if ((tty = ttyname(0)) != NULL) { + const size_t plen = strlen(_PATH_DEV); + if (strncmp(tty, _PATH_DEV, plen) == 0) { + tty += plen; + if (tty[0] == '/') + tty++; + } + snprintf(ttynm, sizeof(ttynm), "(%.*s) ", +UT_LINESIZE, tty); + } else + ttynm[0] = 0; + + *userp = uidbuf; + *ttyp = ttynm; +} + +/* + * Check whether the given filename looks like a tty device. + */ +static int file_isatty(const char *fname) +{ + struct stat st; + int major; + +
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 07908be0903229a69b9e0f733ed13eeff0b55a44 Author: Austin English gmail com> AuthorDate: Fri Oct 12 22:16:33 2018 + Commit: William Hubbs gentoo org> CommitDate: Sat Oct 13 16:53:54 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=07908be0 misc: style fixups src/rc/kill_all.c| 2 +- src/rc/openrc-init.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rc/kill_all.c b/src/rc/kill_all.c index 0833e5f8..bc079dea 100644 --- a/src/rc/kill_all.c +++ b/src/rc/kill_all.c @@ -58,7 +58,7 @@ static int mount_proc(void) if (exists("/proc/version")) return 0; pid = fork(); - switch(pid) { + switch (pid) { case -1: syslog(LOG_ERR, "Unable to fork"); return -1; diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index e02fa5ee..e557c63d 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -45,7 +45,7 @@ static pid_t do_openrc(const char *runlevel) sigset_t signals; pid = fork(); - switch(pid) { + switch (pid) { case -1: perror("fork"); break; @@ -139,7 +139,7 @@ static void reap_zombies(void) static void signal_handler(int sig) { - switch(sig) { + switch (sig) { case SIGINT: handle_shutdown("reboot", RB_AUTOBOOT); break;
[gentoo-commits] proj/openrc:master commit in: src/rc/, init.d/, sh/
commit: 02af093043a7444381b0d8a0a3e8e97247505f95 Author: Austin English gmail com> AuthorDate: Fri Oct 12 22:16:23 2018 + Commit: William Hubbs gentoo org> CommitDate: Sat Oct 13 16:53:54 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=02af0930 misc: whitespace fixes init.d/modules.in | 2 +- sh/rc-cgroup.sh.in| 2 +- sh/s6.sh | 2 +- sh/start-stop-daemon.sh | 4 ++-- src/rc/kill_all.c | 2 +- src/rc/rc-wtmp.c | 2 +- src/rc/supervise-daemon.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/init.d/modules.in b/init.d/modules.in index 08abae3d..998972ba 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -126,7 +126,7 @@ Linux_modules() start() { case "$RC_UNAME" in - FreeBSD|Linux) + FreeBSD|Linux) modules_load_d ${RC_UNAME}_modules ;; diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index d4b68ada..79ada43f 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -62,7 +62,7 @@ cgroup_set_values() while [ -n "$1" ] && [ "$controller" != "cpuacct" ]; do case "$1" in $controller.*) - if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] && + if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] && [ -n "${val}" ]; then veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val" printf "%s" "$val" > "$cgroup/$name" diff --git a/sh/s6.sh b/sh/s6.sh index 33c478ad..acbe965b 100644 --- a/sh/s6.sh +++ b/sh/s6.sh @@ -57,7 +57,7 @@ s6_stop() ebegin "Stopping ${name:-$RC_SVCNAME}" s6-svc -d -wD -T ${s6_service_timeout_stop:-6} "${s6_service_link}" set -- $(s6-svstat "${s6_service_link}") - [ "$1" = "up" ] && + [ "$1" = "up" ] && yesno "${s6_force_kill:-yes}" && _s6_force_kill "$@" set -- $(s6-svstat "${s6_service_link}") diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh index e68b47ef..2e549ae1 100644 --- a/sh/start-stop-daemon.sh +++ b/sh/start-stop-daemon.sh @@ -38,9 +38,9 @@ ssd_start() service_inactive && _inactive=true mark_service_inactive fi - [ -n "$output_logger" ] && + [ -n "$output_logger" ] && output_logger_arg="--stdout-logger \"$output_logger\"" - [ -n "$error_logger" ] && + [ -n "$error_logger" ] && error_logger_arg="--stderr-logger \"$error_logger\"" #the eval call is necessary for cases like: # command_args="this \"is a\" test" diff --git a/src/rc/kill_all.c b/src/rc/kill_all.c index 3aeaa262..0833e5f8 100644 --- a/src/rc/kill_all.c +++ b/src/rc/kill_all.c @@ -248,7 +248,7 @@ int main(int argc, char **argv) usage(EXIT_FAILURE); } } - + openlog(applet, LOG_CONS|LOG_PID, LOG_DAEMON); if (mount_proc() != 0) { rc_stringlist_free(omits); diff --git a/src/rc/rc-wtmp.c b/src/rc/rc-wtmp.c index 8d494303..40cc280c 100644 --- a/src/rc/rc-wtmp.c +++ b/src/rc/rc-wtmp.c @@ -42,7 +42,7 @@ void log_wtmp(const char *user, const char *id, pid_t pid, int type, strncpy(utmp.ut_name, user, sizeof(utmp.ut_name)); strncpy(utmp.ut_id , id , sizeof(utmp.ut_id )); strncpy(utmp.ut_line, line, sizeof(utmp.ut_line)); - + /* Put the OS version in place of the hostname */ if (uname(&uname_buf) == 0) strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host)); diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 24cc56fa..4e3d22c4 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -835,7 +835,7 @@ int main(int argc, char **argv) if (respawn_delay * respawn_max > respawn_period) ewarn("%s: Please increase the value of --respawn-period to more " - "than %d to avoid infinite respawning", applet, + "than %d to avoid infinite respawning", applet, respawn_delay * respawn_max); if (retry) {
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 710c874e6e3bc57b1561eb8f2108244bf24ed32e Author: Zac Medico gmail com> AuthorDate: Sat Oct 13 19:32:45 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Oct 15 16:50:42 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=710c874e supervise-daemon: fix respawn_max off by one Fix the comparison between respawn_count and respawn_max so that respawn_max = 1 will allow for one respawn. Since respawn_count is incremented before the comparison, use a 'greater than' comparison so that respawn will be triggered when respawn_count is equal to respawn_max. Fixes: https://github.com/OpenRC/openrc/issues/247 Fixes: https://github.com/OpenRC/openrc/issues/248 src/rc/supervise-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 4e3d22c4..27089152 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -510,7 +510,7 @@ static void supervisor(char *exec, char **argv) first_spawn = 0; } else respawn_count++; - if (respawn_count >= respawn_max) { + if (respawn_count > respawn_max) { syslog(LOG_WARNING, "respawned \"%s\" too many times, exiting", exec); exiting = true;
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 67e2d6033dd7ac6db0269ee060ed20484825ff9f Author: William Hubbs gmail com> AuthorDate: Tue Oct 9 16:34:52 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 9 16:34:52 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=67e2d603 Complete implementation of forever timeout value in stop schedules src/rc/rc-schedules.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c index 8f36f073..f7ef20fb 100644 --- a/src/rc/rc-schedules.c +++ b/src/rc/rc-schedules.c @@ -351,8 +351,9 @@ int run_stop_schedule(const char *applet, tkilled += nkilled; break; + case SC_FOREVER: case SC_TIMEOUT: - if (item->value < 1) { + if (item->type == SC_TIMEOUT && item->value < 1) { item = NULL; break; } @@ -360,7 +361,7 @@ int run_stop_schedule(const char *applet, ts.tv_sec = 0; ts.tv_nsec = POLL_INTERVAL; - for (nsecs = 0; nsecs < item->value; nsecs++) { + for (nsecs = 0; item->type == SC_FOREVER || nsecs < item->value; nsecs++) { for (nloops = 0; nloops < ONE_SECOND / POLL_INTERVAL; nloops++)
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 7ee3e5b2d6dbb9c279011b59ec132d27d04f843e Author: William Hubbs gmail com> AuthorDate: Sat Oct 6 17:49:44 2018 + Commit: William Hubbs gentoo org> CommitDate: Sat Oct 6 17:49:44 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7ee3e5b2 openrc-init: convert sleep() call to nanosleep() Nanosleep is the safer call to use in case we need to use alarms eventually. src/rc/openrc-init.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index d8038637..e02fa5ee 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -96,12 +97,15 @@ static void handle_reexec(char *my_name) static void handle_shutdown(const char *runlevel, int cmd) { pid_t pid; + struct timespec ts; pid = do_openrc(runlevel); while (waitpid(pid, NULL, 0) != pid); printf("Sending the final term signal\n"); kill(-1, SIGTERM); - sleep(3); + ts.tv_sec = 3; + ts.tv_nsec = 0; + nanosleep(&ts, NULL); printf("Sending the final kill signal\n"); kill(-1, SIGKILL); sync();
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: eca4357892315ca7340bbfc2b373d7660a34142f Author: William Hubbs gmail com> AuthorDate: Sat Oct 6 17:51:04 2018 + Commit: William Hubbs gentoo org> CommitDate: Sat Oct 6 17:51:04 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=eca43578 supervise-daemon: use nanosleep() instead of sleep() We will be using sigalrm in this process for health checking, and sigalrm cannot be used with sleep() safely. src/rc/supervise-daemon.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 8d56b8d4..24cc56fa 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -425,6 +425,7 @@ static void supervisor(char *exec, char **argv) FILE *fp; int i; int nkilled; + struct timespec ts; time_t respawn_now= 0; time_t first_spawn= 0; @@ -497,7 +498,9 @@ static void supervisor(char *exec, char **argv) if (nkilled > 0) syslog(LOG_INFO, "killed %d processes", nkilled); } else { - sleep(respawn_delay); + ts.tv_sec = respawn_delay; + ts.tv_nsec = 0; + nanosleep(&ts, NULL); if (respawn_max > 0 && respawn_period > 0) { respawn_now = time(NULL); if (first_spawn == 0)
[gentoo-commits] proj/openrc:master commit in: /, init.d/
commit: 7cb8d943236fe651ac54c64f8167f7c4369f649c Author: William Hubbs gmail com> AuthorDate: Tue Aug 14 15:21:27 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Aug 14 15:21:27 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7cb8d943 Stop mounting efivarfs read-only We do not need to do this any longer since all supported linux kernels make efivarfs immutable and the tools that manipulate it are aware of this feature. This fixes https://github.com/openrc/openrc/issues/238. NEWS.md | 7 +++ init.d/sysfs.in | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e9605031..3767c18b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,13 @@ The only place I know that this was used was Gentoo Baselayout 1.x, so it shouldn't affect anyone since baselayout-1 has been dead for a few years. +Since all supported Linux kernel versions now make efivarfs immutable +and all of the tools that access efivarfs are aware of this, we no +longer mount efivarfs read-only. See the following github issue for more +information: + +https://github.com/openrc/openrc/issues/238 + ## OpenRC 0.37 start-stop-daemon now supports logging stdout and stderr of daemons to diff --git a/init.d/sysfs.in b/init.d/sysfs.in index f0d02e5c..89707120 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -101,7 +101,7 @@ mount_misc() if [ -d /sys/firmware/efi/efivars ] && ! mountinfo -q /sys/firmware/efi/efivars; then ebegin "Mounting efivarfs filesystem" - mount -n -t efivarfs -o ro \ + mount -n -t efivarfs -o ${sysfs_opts} \ efivarfs /sys/firmware/efi/efivars 2> /dev/null eend 0 fi
[gentoo-commits] proj/openrc:master commit in: src/librc/
commit: 84ed570eaefcbb55b99ba425030bf7d1d1d46137 Author: Zac Medico gmail com> AuthorDate: Mon Aug 6 21:50:41 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Aug 6 22:39:52 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=84ed570e librc: fix EACCES errno false-positive crash Use errno != EACCES to fix false-positive for non-root users with grsecurity kernels. Fixes: 37e29442721a ("librc: Add check for crashed state") This fixes #237 src/librc/librc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librc/librc.c b/src/librc/librc.c index 01bfac03..c38695cc 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -850,7 +850,7 @@ rc_service_state(const char *service) } if (state & RC_SERVICE_STARTED) { - if (rc_service_daemons_crashed(service)) + if (rc_service_daemons_crashed(service) && errno != EACCES) state |= RC_SERVICE_CRASHED; } if (state & RC_SERVICE_STOPPED) {
[gentoo-commits] proj/openrc:master commit in: sh/, /
commit: 2eea73bfd5ce2f9993d52293fe7d25c0c804d592 Author: William Hubbs gmail com> AuthorDate: Mon Jul 9 23:02:54 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jul 10 00:44:40 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=2eea73bf rc-functions.sh: Remove addon support This is an old relic from Gentoo baselayout-1.x which should not be used any longer. NEWS.md| 7 ++ sh/.gitignore | 1 - sh/Makefile| 2 +- sh/{rc-functions.sh.in => rc-functions.sh} | 36 -- 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/NEWS.md b/NEWS.md index 13c62d6e..e9605031 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,13 @@ OpenRC NEWS This file will contain a list of notable changes for each release. Note the information in this file is in reverse order. +## OpenRC 0.39 + +This version removes the support for addons. +The only place I know that this was used was Gentoo Baselayout 1.x, so +it shouldn't affect anyone since baselayout-1 has been dead for a few +years. + ## OpenRC 0.37 start-stop-daemon now supports logging stdout and stderr of daemons to diff --git a/sh/.gitignore b/sh/.gitignore index 8a007103..186a409c 100644 --- a/sh/.gitignore +++ b/sh/.gitignore @@ -1,6 +1,5 @@ functions.sh gendepends.sh -rc-functions.sh openrc-run.sh cgroup-release-agent.sh init.sh diff --git a/sh/Makefile b/sh/Makefile index 4d7148fb..e5029bcd 100644 --- a/sh/Makefile +++ b/sh/Makefile @@ -1,6 +1,6 @@ DIR= ${LIBEXECDIR}/sh SRCS= init.sh.in functions.sh.in gendepends.sh.in \ - openrc-run.sh.in rc-functions.sh.in ${SRCS-${OS}} + openrc-run.sh.in ${SRCS-${OS}} INC= rc-mount.sh functions.sh rc-functions.sh runit.sh s6.sh \ start-stop-daemon.sh supervise-daemon.sh BIN= gendepends.sh init.sh openrc-run.sh ${BIN-${OS}} diff --git a/sh/rc-functions.sh.in b/sh/rc-functions.sh similarity index 83% rename from sh/rc-functions.sh.in rename to sh/rc-functions.sh index d6336a18..d77c5dd3 100644 --- a/sh/rc-functions.sh.in +++ b/sh/rc-functions.sh @@ -2,42 +2,6 @@ # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. -has_addon() -{ - [ -e /@LIB@/rc/addons/"$1".sh -o -e /@LIB@/rcscripts/addons/"$1".sh ] -} - -_addon_warn() -{ - eindent - ewarn "$RC_SVCNAME uses addon code which is deprecated" - ewarn "and may not be available in the future." - eoutdent -} - -import_addon() -{ - if [ -e /@LIB@/rc/addons/"$1".sh ]; then - _addon_warn - . /@LIB@/rc/addons/"$1".sh - elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then - _addon_warn - . /@LIB@/rcscripts/addons/"$1".sh - else - return 1 - fi -} - -start_addon() -{ - ( import_addon "$1-start" ) -} - -stop_addon() -{ - ( import_addon "$1-stop" ) -} - net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre ncpfs nfs nfs4 ocfs2 shfs smbfs" is_net_fs()
[gentoo-commits] proj/openrc:master commit in: conf.d/, init.d/
commit: a571a42421b337380b6f5751635c55906bb8b508 Author: William Hubbs gmail com> AuthorDate: Fri Jun 29 20:29:46 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 29 20:29:46 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a571a424 modules: remove the ability to rename modules on the fly Kmod doesn't support the -o switch, so if you have been using this your module loads have been failing. conf.d/modules| 5 - init.d/modules.in | 15 ++- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/conf.d/modules b/conf.d/modules index c35b9edf..d13ff895 100644 --- a/conf.d/modules +++ b/conf.d/modules @@ -8,11 +8,6 @@ #modules_2="ipv6" #modules="ohci1394" -# Linux users can give modules a different name when they load - the new name -# will also be used to pick arguments below. -# This is not supported on FreeBSD. -#modules="dummy:dummy1" - # Linux users can give the modules some arguments if needed, per version # if necessary. # Again, the most specific versioned variable will take precedence. diff --git a/init.d/modules.in b/init.d/modules.in index d6dd7a29..08abae3d 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -103,7 +103,7 @@ Linux_modules() x=${x%.*} done - local list= x= xx= y= args= mpargs= a= + local list= x= xx= y= args= for x in $kv_variant_list ; do eval list=\$modules_$(shell_var "$x") [ -n "$list" ] && break @@ -112,24 +112,13 @@ Linux_modules() [ -n "$list" ] && ebegin "Loading kernel modules" for x in $list; do - a=${x#*:} - if [ "$a" = "$x" ]; then - unset mpargs - else - x=${x%%:*} - mpargs="-o $a" - fi - aa=$(shell_var "$a") xx=$(shell_var "$x") for y in $kv_variant_list ; do - eval args=\$module_${aa}_args_$(shell_var "$y") - [ -n "${args}" ] && break eval args=\$module_${xx}_args_$(shell_var "$y") [ -n "${args}" ] && break done - [ -z "$args" ] && eval args=\$module_${aa}_args [ -z "$args" ] && eval args=\$module_${xx}_args - eval modprobe --use-blacklist --verbose "$mpargs" "$x" "$args" + eval modprobe --use-blacklist --verbose "$x" "$args" done [ -n "$list" ] && eend }
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 79648ac1c6355975abca6acf6076e7022037523f Author: Holger Hoffstätte applied-asynchrony com> AuthorDate: Thu Jun 28 21:08:57 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 29 13:49:13 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=79648ac1 rc-status: initialize uptime pointer to prevent memory corruption This fixes #231. src/rc/rc-status.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index 85e71dbb..cebdc5ed 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -87,7 +87,7 @@ static char *get_uptime(const char *service) time_t diff_hours = (time_t) 0; time_t diff_mins = (time_t) 0; time_t diff_secs = (time_t) 0; - char *uptime; + char *uptime = NULL; if (state & RC_SERVICE_STARTED) { start_count = rc_service_value_get(service, "start_count");
[gentoo-commits] proj/openrc:master commit in: /
commit: 02af762e83640ec23bf64c5b814f0d3424d90e10 Author: William Hubbs gmail com> AuthorDate: Thu Jun 28 18:32:19 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Jun 28 18:32:19 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=02af762e version 0.39 Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index d6fa4760..b090cc43 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,3 +1,3 @@ NAME= openrc -VERSION= 0.38 +VERSION= 0.39 PKG= ${NAME}-${VERSION}
[gentoo-commits] proj/openrc:master commit in: src/librc/
commit: 3a803b3135837665d51ef4dd7a8b913c78e71ff6 Author: William Hubbs gmail com> AuthorDate: Wed Jun 27 17:06:19 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Jun 27 17:06:19 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3a803b31 librc-daemon.c: fix memory leaks src/librc/librc-daemon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index 173fcb83..6f3b492f 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -422,6 +422,7 @@ rc_service_daemon_set(const char *service, const char *exec, rename(file, oldfile); strlcpy(oldfile, file, sizeof(oldfile)); } + free(file); } closedir(dp); rc_stringlist_free(match); @@ -446,10 +447,12 @@ rc_service_daemon_set(const char *service, const char *exec, fclose(fp); retval = true; } + free(file); } } else retval = true; + free(dirpath); return retval; } librc_hidden_def(rc_service_daemon_set)
[gentoo-commits] proj/openrc:master commit in: /
commit: 01c34c28e6d6d7bfecc0f88bdf1fb15e97ab8823 Author: William Hubbs gmail com> AuthorDate: Thu Jun 28 18:02:42 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Jun 28 18:02:42 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=01c34c28 Update ChangeLog ChangeLog | 96 +++ 1 file changed, 96 insertions(+) diff --git a/ChangeLog b/ChangeLog index 410d7451..ba89667b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,99 @@ +commit 56ddda54b5aa01474bf563d5a662075c35152858 +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon.c: clean up memory leaks + +commit 3a803b3135837665d51ef4dd7a8b913c78e71ff6 +Author: William Hubbs +Commit: William Hubbs + +librc-daemon.c: fix memory leaks + +commit 72df51e17ba0e1a0f94451b4bbfb338288c4625c +Author: William Hubbs +Commit: William Hubbs + +librc-daemon: convert most snprintf calls to xasprintf + +commit b2f5531194e33c229462e9f52fa1d9388463f7b7 +Author: William Hubbs +Commit: William Hubbs + +librc-misc: convert snprintf calls to xasprintf + +commit 19bf49a710f27d4774ed4c6372d87d6ba15f189e +Author: William Hubbs +Commit: William Hubbs + +libeinfo: convert remaining snprintf calls to xasprintf + +commit 64354831da2adeba5cb2f91a81fa0f56e1ce4ed9 +Author: William Hubbs +Commit: William Hubbs + +openrc: convert snprintf calls to xasprintf + +commit e14edd765fdc4ed43356d2eef35fa99228e5d461 +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon: convert snprintf calls to xasprintf + +commit f9d41243d8499c5d7027177d5aa716d5b5859cd6 +Author: William Hubbs +Commit: William Hubbs + +start-stop-daemon: convert snprintf calls to xasprintf + +commit be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4 +Author: William Hubbs +Commit: William Hubbs + +rc-status: convert snprintf calls to xasprintf + +commit a6165168953b9c7a62c089ce946476b23b73fb12 +Author: William Hubbs +Commit: William Hubbs + +rc-status: fix gcc 7 warnings + +commit 04721ece03b15503aa220f60e7c6159d01ee75e1 +Author: William Hubbs +Commit: William Hubbs + +start-stop-daemon: fix gcc 7 warnings + +commit c7e8f1133a42152cc293e6b637985f81bcf8b310 +Author: William Hubbs +Commit: William Hubbs + +checkpath: fix gcc 7 warnings + +commit 47e4bfae57402eedd017d6098b432c2c411cd374 +Author: William Hubbs +Commit: William Hubbs + +fix gcc 7 warnings in pipe routines + +commit 8a945194afb106428bc700e751078ef9944ee617 +Author: William Hubbs +Commit: William Hubbs + +libeinfo: clean up gcc 7 compiler warnings + +commit aa4a004c297ec7a1fb794ad2e53ef3ac8b3f4fd1 +Author: William Hubbs +Commit: William Hubbs + +version 0.38 + +commit 9ec5d36bdddf5bb0e96b0c561bc5d013a8a2da2a +Author: William Hubbs +Commit: William Hubbs + +Update ChangeLog + commit a097933edab9d7221df1831e098415d604437c98 Author: William Hubbs Commit: William Hubbs
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 56ddda54b5aa01474bf563d5a662075c35152858 Author: William Hubbs gmail com> AuthorDate: Wed Jun 27 22:37:11 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Jun 27 22:37:11 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=56ddda54 supervise-daemon.c: clean up memory leaks src/rc/supervise-daemon.c | 4 1 file changed, 4 insertions(+) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 60bd1f20..8d56b8d4 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -860,10 +860,13 @@ int main(int argc, char **argv) varbuf = NULL; xasprintf(&varbuf, "%i", respawn_delay); rc_service_value_set(svcname, "respawn_delay", varbuf); + free(varbuf); xasprintf(&varbuf, "%i", respawn_max); rc_service_value_set(svcname, "respawn_max", varbuf); + free(varbuf); xasprintf(&varbuf, "%i", respawn_period); rc_service_value_set(svcname, "respawn_period", varbuf); + free(varbuf); child_pid = fork(); if (child_pid == -1) eerrorx("%s: fork: %s", applet, strerror(errno)); @@ -891,6 +894,7 @@ int main(int argc, char **argv) } xasprintf(&varbuf, "%d", x); rc_service_value_set(svcname, "argc", varbuf); + free(varbuf); rc_service_value_set(svcname, "exec", exec); supervisor(exec, argv); } else
[gentoo-commits] proj/openrc:master commit in: src/librc/
commit: 72df51e17ba0e1a0f94451b4bbfb338288c4625c Author: William Hubbs gmail com> AuthorDate: Fri Jun 22 20:41:25 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 22 20:41:25 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=72df51e1 librc-daemon: convert most snprintf calls to xasprintf src/librc/librc-daemon.c | 71 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index a40150a6..173fcb83 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -23,13 +23,13 @@ static bool pid_is_exec(pid_t pid, const char *exec) { - char buffer[32]; + char *buffer = NULL; FILE *fp; int c; bool retval = false; exec = basename_c(exec); - snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid); + xasprintf(&buffer, "/proc/%d/stat", pid); if ((fp = fopen(buffer, "r"))) { while ((c = getc(fp)) != EOF && c != '(') ; @@ -41,23 +41,27 @@ pid_is_exec(pid_t pid, const char *exec) } fclose(fp); } + free(buffer); return retval; } static bool pid_is_argv(pid_t pid, const char *const *argv) { - char cmdline[32]; + char *cmdline = NULL; int fd; char buffer[PATH_MAX]; char *p; ssize_t bytes; - snprintf(cmdline, sizeof(cmdline), "/proc/%u/cmdline", pid); - if ((fd = open(cmdline, O_RDONLY)) < 0) + xasprintf(&cmdline, "/proc/%u/cmdline", pid); + if ((fd = open(cmdline, O_RDONLY)) < 0) { + free(cmdline); return false; + } bytes = read(fd, buffer, sizeof(buffer)); close(fd); + free(cmdline); if (bytes == -1) return false; @@ -88,7 +92,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) char proc_ns[30]; size_t len = 0; pid_t p; - char buffer[PATH_MAX]; + char *buffer = NULL; struct stat sb; pid_t openrc_pid = 0; char *pp; @@ -149,18 +153,22 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) continue; if (pid != 0 && pid != p) continue; - snprintf(buffer, sizeof(buffer), "/proc/%d/ns/pid", p); + xasprintf(&buffer, "/proc/%d/ns/pid", p); if (exists(buffer)) { rc = readlink(buffer, proc_ns, sizeof(proc_ns)); if (rc <= 0) proc_ns[0] = '\0'; } + free(buffer); if (strlen(my_ns) && strlen (proc_ns) && strcmp(my_ns, proc_ns)) continue; if (uid) { - snprintf(buffer, sizeof(buffer), "/proc/%d", p); - if (stat(buffer, &sb) != 0 || sb.st_uid != uid) + xasprintf(&buffer, "/proc/%d", p); + if (stat(buffer, &sb) != 0 || sb.st_uid != uid) { + free(buffer); continue; + } + free(buffer); } if (exec && !pid_is_exec(p, exec)) continue; @@ -169,9 +177,10 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid) continue; /* If this is an OpenVZ host, filter out container processes */ if (openvz_host) { - snprintf(buffer, sizeof(buffer), "/proc/%d/status", p); + xasprintf(&buffer, "/proc/%d/status", p); if (exists(buffer)) { fp = fopen(buffer, "r"); + free(buffer); if (! fp) continue; while (! feof(fp)) { @@ -315,12 +324,13 @@ _match_daemon(const char *path, const char *file, RC_STRINGLIST *match) { char *line = NULL; size_t len = 0; - char ffile[PATH_MAX]; + char *ffile = NULL; FILE *fp; RC_STRING *m; - snprintf(ffile, sizeof(ffile), "%s/%s", path, file); + xasprintf(&ffile, "%s/%s", path, file); fp = fopen(ffile, "r"); + free(ffile); if (!fp) return false; @@ -346,29 +356,22 @@ _match_list(const char *exec, const char *const *argv, const char *pidfile) { RC_STRINGLIST *match = rc_stringlist_new(); int i = 0; - size_t l; char *m; if (exec) { - l = strlen(exec) + 6; - m = xmalloc(sizeof(char) * l); - snprintf(m, l, "exec=%s", exec); +
[gentoo-commits] proj/openrc:master commit in: src/librc/
commit: b2f5531194e33c229462e9f52fa1d9388463f7b7 Author: William Hubbs gmail com> AuthorDate: Wed Jun 20 22:45:01 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Jun 20 22:45:01 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b2f55311 librc-misc: convert snprintf calls to xasprintf src/librc/librc-misc.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c index 9d514bcd..178768c5 100644 --- a/src/librc/librc-misc.c +++ b/src/librc/librc-misc.c @@ -237,13 +237,9 @@ static void rc_config_set_value(RC_STRINGLIST *config, char *value) if (token[i] == '\n') token[i] = 0; - i = strlen(entry) + strlen(token) + 2; - newline = xmalloc(sizeof(char) * i); - snprintf(newline, i, "%s=%s", entry, token); + xasprintf(&newline, "%s=%s", entry, token); } else { - i = strlen(entry) + 2; - newline = xmalloc(sizeof(char) * i); - snprintf(newline, i, "%s=", entry); + xasprintf(&newline, "%s=", entry); } replaced = false; @@ -300,8 +296,7 @@ static RC_STRINGLIST *rc_config_kcl(RC_STRINGLIST *config) if (value != NULL) { len = varlen + strlen(value) + 2; - tmp = xmalloc(sizeof(char) * len); - snprintf(tmp, len, "%s=%s", override->value, value); + xasprintf(&tmp, "%s=%s", override->value, value); } /*
[gentoo-commits] proj/openrc:master commit in: src/libeinfo/
commit: 19bf49a710f27d4774ed4c6372d87d6ba15f189e Author: William Hubbs gmail com> AuthorDate: Wed Jun 20 17:36:51 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Jun 20 17:36:51 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=19bf49a7 libeinfo: convert remaining snprintf calls to xasprintf src/libeinfo/libeinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c index 5a637ffc..b8064540 100644 --- a/src/libeinfo/libeinfo.c +++ b/src/libeinfo/libeinfo.c @@ -904,7 +904,7 @@ void eoutdent(void) { char *env = getenv("EINFO_INDENT"); int amount = 0; - char num[10]; + char *num = NULL; int serrno = errno; if (!env) @@ -918,8 +918,9 @@ void eoutdent(void) if (amount <= 0) unsetenv("EINFO_INDENT"); else { - snprintf(num, 10, "%08d", amount); + xasprintf(&num, "%08d", amount); setenv("EINFO_INDENT", num, 1); + free(num); } errno = serrno; }
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 64354831da2adeba5cb2f91a81fa0f56e1ce4ed9 Author: William Hubbs gmail com> AuthorDate: Wed Jun 20 14:37:20 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Jun 20 14:37:20 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=64354831 openrc: convert snprintf calls to xasprintf src/rc/rc.c | 40 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/rc/rc.c b/src/rc/rc.c index f613b5b6..c6e453b3 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -101,7 +101,6 @@ clean_failed(void) { DIR *dp; struct dirent *d; - size_t l; char *path; /* Clean the failed services state dir now */ @@ -112,16 +111,11 @@ clean_failed(void) (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; - l = strlen(RC_SVCDIR "/failed/") + - strlen(d->d_name) + 1; - path = xmalloc(sizeof(char) * l); - snprintf(path, l, RC_SVCDIR "/failed/%s", d->d_name); - if (path) { - if (unlink(path)) - eerror("%s: unlink `%s': %s", - applet, path, strerror(errno)); - free(path); - } + xasprintf(&path, RC_SVCDIR "/failed/%s", d->d_name); + if (unlink(path)) + eerror("%s: unlink `%s': %s", + applet, path, strerror(errno)); + free(path); } closedir(dp); } @@ -391,7 +385,7 @@ static void handle_signal(int sig) { int serrno = errno; - char signame[10] = { '\0' }; + char *signame = NULL; pid_t pid; RC_PID *pi; int status = 0; @@ -422,16 +416,16 @@ handle_signal(int sig) break; case SIGINT: - if (!signame[0]) - snprintf(signame, sizeof(signame), "SIGINT"); + if (!signame) + xasprintf(&signame, "SIGINT"); /* FALLTHROUGH */ case SIGTERM: - if (!signame[0]) - snprintf(signame, sizeof(signame), "SIGTERM"); + if (!signame) + xasprintf(&signame, "SIGTERM"); /* FALLTHROUGH */ case SIGQUIT: - if (!signame[0]) - snprintf(signame, sizeof(signame), "SIGQUIT"); + if (!signame) + xasprintf(&signame, "SIGQUIT"); eerrorx("%s: caught %s, aborting", applet, signame); /* NOTREACHED */ case SIGUSR1: @@ -512,14 +506,11 @@ runlevel_config(const char *service, const char *level) { char *init = rc_service_resolve(service); char *conf, *dir; - size_t l; bool retval; dir = dirname(init); dir = dirname(init); - l = strlen(dir) + strlen(level) + strlen(service) + 10; - conf = xmalloc(sizeof(char) * l); - snprintf(conf, l, "%s/conf.d/%s.%s", dir, service, level); + xasprintf(&conf, "%s/conf.d/%s.%s", dir, service, level); retval = exists(conf); free(conf); free(init); @@ -744,7 +735,7 @@ int main(int argc, char **argv) bool going_down = false; int depoptions = RC_DEP_STRICT | RC_DEP_TRACE; char *krunlevel = NULL; - char pidstr[10]; + char *pidstr = NULL; int opt; bool parallel; int regen = 0; @@ -844,8 +835,9 @@ int main(int argc, char **argv) setenv("EINFO_LOG", "openrc", 1); /* Export our PID */ - snprintf(pidstr, sizeof(pidstr), "%d", getpid()); + xasprintf(&pidstr, "%d", getpid()); setenv("RC_PID", pidstr, 1); + free(pidstr); /* Create a list of all services which should be started for the new or * current runlevel including those in boot, sysinit and hotplugged
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: f9d41243d8499c5d7027177d5aa716d5b5859cd6 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 22:46:12 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 22:46:12 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f9d41243 start-stop-daemon: convert snprintf calls to xasprintf src/rc/start-stop-daemon.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index a04a00ec..33f886c4 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -167,20 +167,20 @@ handle_signal(int sig) { int status; int serrno = errno; - char signame[10] = { '\0' }; + char *signame = NULL; switch (sig) { case SIGINT: - if (!signame[0]) - snprintf(signame, sizeof(signame), "SIGINT"); + if (!signame) + xasprintf(&signame, "SIGINT"); /* FALLTHROUGH */ case SIGTERM: - if (!signame[0]) - snprintf(signame, sizeof(signame), "SIGTERM"); + if (!signame) + xasprintf(&signame, "SIGTERM"); /* FALLTHROUGH */ case SIGQUIT: - if (!signame[0]) - snprintf(signame, sizeof(signame), "SIGQUIT"); + if (!signame) + xasprintf(&signame, "SIGQUIT"); eerrorx("%s: caught %s, aborting", applet, signame); /* NOTREACHED */ @@ -199,6 +199,9 @@ handle_signal(int sig) eerror("%s: caught unknown signal %d", applet, sig); } + /* free signame */ + free(signame); + /* Restore errno */ errno = serrno; } @@ -207,7 +210,6 @@ static char * expand_home(const char *home, const char *path) { char *opath, *ppath, *p, *nh; - size_t len; struct passwd *pw; if (!path || *path != '~') @@ -238,9 +240,7 @@ expand_home(const char *home, const char *path) return xstrdup(home); } - len = strlen(ppath) + strlen(home) + 1; - nh = xmalloc(len); - snprintf(nh, len, "%s%s", home, ppath); + xasprintf(&nh, "%s%s", home, ppath); free(opath); return nh; }
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: e14edd765fdc4ed43356d2eef35fa99228e5d461 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 22:57:10 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 22:57:10 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e14edd76 supervise-daemon: convert snprintf calls to xasprintf src/rc/supervise-daemon.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 952c610b..60bd1f20 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -186,7 +186,6 @@ static void handle_signal(int sig) static char * expand_home(const char *home, const char *path) { char *opath, *ppath, *p, *nh; - size_t len; struct passwd *pw; if (!path || *path != '~') @@ -217,9 +216,7 @@ static char * expand_home(const char *home, const char *path) return xstrdup(home); } - len = strlen(ppath) + strlen(home) + 1; - nh = xmalloc(len); - snprintf(nh, len, "%s%s", home, ppath); + xasprintf(&nh, "%s%s", home, ppath); free(opath); return nh; }
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 22:06:33 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 22:06:33 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=be7ad06d rc-status: convert snprintf calls to xasprintf src/rc/rc-status.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index a6b8d299..85e71dbb 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -126,7 +126,7 @@ static char *get_uptime(const char *service) static void print_service(const char *service) { - char status[60]; + char *status = NULL; char *uptime = NULL; char *child_pid = NULL; char *start_time = NULL; @@ -136,12 +136,12 @@ print_service(const char *service) ECOLOR color = ECOLOR_BAD; if (state & RC_SERVICE_STOPPING) - snprintf(status, sizeof(status), "stopping "); + xasprintf(&status, "stopping "); else if (state & RC_SERVICE_STARTING) { - snprintf(status, sizeof(status), "starting "); + xasprintf(&status, "starting "); color = ECOLOR_WARN; } else if (state & RC_SERVICE_INACTIVE) { - snprintf(status, sizeof(status), "inactive "); + xasprintf(&status, "inactive "); color = ECOLOR_WARN; } else if (state & RC_SERVICE_STARTED) { errno = 0; @@ -150,30 +150,31 @@ print_service(const char *service) child_pid = rc_service_value_get(service, "child_pid"); start_time = rc_service_value_get(service, "start_time"); if (start_time && child_pid) - snprintf(status, sizeof(status), " unsupervised "); + xasprintf(&status, " unsupervised "); else - snprintf(status, sizeof(status), " crashed "); + xasprintf(&status, " crashed "); free(child_pid); free(start_time); } else { uptime = get_uptime(service); if (uptime) { - snprintf(status, sizeof(status), " started %s", uptime); + xasprintf(&status, " started %s", uptime); free(uptime); } else - snprintf(status, sizeof(status), " started "); + xasprintf(&status, " started "); color = ECOLOR_GOOD; } } else if (state & RC_SERVICE_SCHEDULED) { - snprintf(status, sizeof(status), "scheduled"); + xasprintf(&status, "scheduled"); color = ECOLOR_WARN; } else - snprintf(status, sizeof(status), " stopped "); + xasprintf(&status, " stopped "); errno = 0; if (c && *c && isatty(fileno(stdout))) printf("\n"); ebracket(cols, color, status); + free(status); } static void
[gentoo-commits] proj/openrc:master commit in: src/libeinfo/
commit: 8a945194afb106428bc700e751078ef9944ee617 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 18:52:40 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 18:52:40 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=8a945194 libeinfo: clean up gcc 7 compiler warnings src/libeinfo/libeinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c index 198af0f4..5a637ffc 100644 --- a/src/libeinfo/libeinfo.c +++ b/src/libeinfo/libeinfo.c @@ -883,7 +883,7 @@ eindent(void) { char *env = getenv("EINFO_INDENT"); int amount = 0; - char num[10]; + char *num; if (env) { errno = 0; @@ -894,8 +894,9 @@ eindent(void) amount += INDENT_WIDTH; if (amount > INDENT_MAX) amount = INDENT_MAX; - snprintf(num, 10, "%08d", amount); + xasprintf(&num, "%08d", amount); setenv("EINFO_INDENT", num, 1); + free(num); } hidden_def(eindent)
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: a6165168953b9c7a62c089ce946476b23b73fb12 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 21:15:22 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 21:18:48 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a6165168 rc-status: fix gcc 7 warnings src/rc/rc-status.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index ab80d901..a6b8d299 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -75,7 +75,7 @@ print_level(const char *prefix, const char *level) printf("%s\n", level); } -static void get_uptime(const char *service, char *uptime, int uptime_size) +static char *get_uptime(const char *service) { RC_SERVICE state = rc_service_state(service); char *start_count; @@ -87,8 +87,8 @@ static void get_uptime(const char *service, char *uptime, int uptime_size) time_t diff_hours = (time_t) 0; time_t diff_mins = (time_t) 0; time_t diff_secs = (time_t) 0; + char *uptime; - uptime[0] = '\0'; if (state & RC_SERVICE_STARTED) { start_count = rc_service_value_get(service, "start_count"); start_time_string = rc_service_value_get(service, "start_time"); @@ -110,23 +110,24 @@ static void get_uptime(const char *service, char *uptime, int uptime_size) diff_secs %= diff_mins * (time_t) 60; } if (diff_days > 0) - snprintf(uptime, uptime_size, + xasprintf(&uptime, "%ld day(s) %02ld:%02ld:%02ld (%s)", diff_days, diff_hours, diff_mins, diff_secs, start_count); else - snprintf(uptime, uptime_size, + xasprintf(&uptime, "%02ld:%02ld:%02ld (%s)", diff_hours, diff_mins, diff_secs, start_count); } } + return uptime; } static void print_service(const char *service) { char status[60]; - char uptime [40]; + char *uptime = NULL; char *child_pid = NULL; char *start_time = NULL; int cols = printf(" %s", service); @@ -155,8 +156,12 @@ print_service(const char *service) free(child_pid); free(start_time); } else { - get_uptime(service, uptime, 40); - snprintf(status, sizeof(status), " started %s", uptime); + uptime = get_uptime(service); + if (uptime) { + snprintf(status, sizeof(status), " started %s", uptime); + free(uptime); + } else + snprintf(status, sizeof(status), " started "); color = ECOLOR_GOOD; } } else if (state & RC_SERVICE_SCHEDULED) {
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: c7e8f1133a42152cc293e6b637985f81bcf8b310 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 19:01:54 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 19:01:54 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c7e8f113 checkpath: fix gcc 7 warnings src/rc/checkpath.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c index 07e5f78a..448c9cf8 100644 --- a/src/rc/checkpath.c +++ b/src/rc/checkpath.c @@ -269,11 +269,13 @@ int main(int argc, char **argv) switch (opt) { case 'D': trunc = true; + /* falls through */ case 'd': type = inode_dir; break; case 'F': trunc = true; + /* falls through */ case 'f': type = inode_file; break;
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 04721ece03b15503aa220f60e7c6159d01ee75e1 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 20:32:10 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 20:32:10 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=04721ece start-stop-daemon: fix gcc 7 warnings src/rc/start-stop-daemon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index fceb3058..a04a00ec 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -386,6 +386,7 @@ int main(int argc, char **argv) case 'c': /* --chuid | */ /* DEPRECATED */ ewarn("WARNING: -c/--chuid is deprecated and will be removed in the future, please use -u/--user instead"); + /* falls through */ case 'u': /* --user | */ { p = optarg;
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 47e4bfae57402eedd017d6098b432c2c411cd374 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 18:59:16 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 18:59:16 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=47e4bfae fix gcc 7 warnings in pipe routines src/rc/rc-pipes.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/rc/rc-pipes.c b/src/rc/rc-pipes.c index 2d7b623e..70fefa80 100644 --- a/src/rc/rc-pipes.c +++ b/src/rc/rc-pipes.c @@ -37,21 +37,20 @@ int rc_pipe_command(char *cmd) return -1; pid = fork(); - if (pid < 0) - return -1; - else if (pid > 0) { + if (pid > 0) { /* parent */ - close(pfd[0]); + close(pfd[pipe_read_end]); return pfd[pipe_write_end]; } else if (pid == 0) { /* child */ close(pfd[pipe_write_end]); - if (pfd[0] != STDIN_FILENO) { - if (dup2(pfd[0], STDIN_FILENO) < 0) + if (pfd[pipe_read_end] != STDIN_FILENO) { + if (dup2(pfd[pipe_read_end], STDIN_FILENO) < 0) exit(1); - close(pfd[0]); + close(pfd[pipe_read_end]); } execl("/bin/sh", "sh", "-c", cmd, NULL); exit(1); } + return -1; }
[gentoo-commits] proj/openrc:master commit in: /
commit: aa4a004c297ec7a1fb794ad2e53ef3ac8b3f4fd1 Author: William Hubbs gmail com> AuthorDate: Sun Jun 17 17:45:51 2018 + Commit: William Hubbs gentoo org> CommitDate: Sun Jun 17 17:45:51 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=aa4a004c version 0.38 Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index 317a55e0..d6fa4760 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,3 +1,3 @@ NAME= openrc -VERSION= 0.37 +VERSION= 0.38 PKG= ${NAME}-${VERSION}
[gentoo-commits] proj/openrc:master commit in: /
commit: 9ec5d36bdddf5bb0e96b0c561bc5d013a8a2da2a Author: William Hubbs gmail com> AuthorDate: Fri Jun 15 23:04:43 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 15 23:04:43 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=9ec5d36b Update ChangeLog ChangeLog | 12 1 file changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index dc76d74e..410d7451 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +commit a097933edab9d7221df1831e098415d604437c98 +Author: William Hubbs +Commit: William Hubbs + +sh/start-stop-daemon.sh: fix processing of the logger arguments + +commit a6f5b1bb63070c24145df72040fa7b465948003c +Author: William Hubbs +Commit: William Hubbs + +Update ChangeLog + commit e6d01471fe2a8eb8a15bb906d7c91c11805d1bef Author: William Hubbs Commit: William Hubbs
[gentoo-commits] proj/openrc:master commit in: sh/
commit: a097933edab9d7221df1831e098415d604437c98 Author: William Hubbs gmail com> AuthorDate: Fri Jun 15 22:44:39 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 15 22:44:39 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a097933e sh/start-stop-daemon.sh: fix processing of the logger arguments sh/start-stop-daemon.sh | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh index 69666ff7..e68b47ef 100644 --- a/sh/start-stop-daemon.sh +++ b/sh/start-stop-daemon.sh @@ -38,6 +38,10 @@ ssd_start() service_inactive && _inactive=true mark_service_inactive fi + [ -n "$output_logger" ] && + output_logger_arg="--stdout-logger \"$output_logger\"" + [ -n "$error_logger" ] && + error_logger_arg="--stderr-logger \"$error_logger\"" #the eval call is necessary for cases like: # command_args="this \"is a\" test" # to work properly. @@ -47,8 +51,8 @@ ssd_start() ${directory:+--chdir} $directory \ ${output_log+--stdout} $output_log \ ${error_log+--stderr} $error_log \ - ${output_logger+--stdout-logger} \"$output_logger\" \ - ${error_logger+--stderr-logger} \"$error_logger\" \ + ${output_logger_arg} \ + ${error_logger_arg} \ ${procname:+--name} $procname \ ${pidfile:+--pidfile} $pidfile \ ${command_user+--user} $command_user \
[gentoo-commits] proj/openrc:master commit in: /
commit: a6f5b1bb63070c24145df72040fa7b465948003c Author: William Hubbs gmail com> AuthorDate: Fri Jun 15 17:59:13 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 15 17:59:13 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a6f5b1bb Update ChangeLog ChangeLog | 179 +++--- 1 file changed, 42 insertions(+), 137 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a0139ab..dc76d74e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,45 @@ +commit e6d01471fe2a8eb8a15bb906d7c91c11805d1bef +Author: William Hubbs +Commit: William Hubbs + +start-stop-daemon: add ability to log stdout or stderr to processes + +commit d4501a9f06c807f87be04f128e535a74b370fdb4 +Author: William Hubbs +Commit: William Hubbs + +fix a typo + +commit ec8abea4605395a2a59b26906ce4677a578e3c60 +Author: Mike Gilbert +Commit: William Hubbs + +Add helper to spawn process with stdin connected to a pipe + +commit e4ddfa38e0e0318abf442b7aa07e0d8206191dd7 +Author: William Hubbs +Commit: William Hubbs + +user-guide.md: small cleanups + +commit 21d30bc6d9caca31d007631717a480a552b89701 +Author: William Hubbs +Commit: William Hubbs + +service-script-guide.md: small cleanups + +commit 2a1ff6e49c6603bb81eec3cafe2c587fa734289f +Author: William Hubbs +Commit: William Hubbs + +version 0.37 + +commit 6762cb875c9c039b79dcc447b9d0eb65356a7708 +Author: William Hubbs +Commit: William Hubbs + +Update ChangeLog + commit 6edf516a1fe0ad4f4e8738f9fdd1bf0bc7718361 Author: Austin English Commit: Doug Freed @@ -1589,140 +1631,3 @@ Commit: William Hubbs man: fix missing .Pp warnings This fixes #151. - -commit f87a9eec3d23ea01578500972f1df993d5d24fba -Author: William Hubbs -Commit: William Hubbs - -init.d/sysfs: mount efivars read only - -This fixes #134. - -commit 1e837d596e483ceb5cec177a6c7faff24a42384b -Author: William Hubbs -Commit: William Hubbs - -fix argument parsing for the sysvinit shutdown wrapper - -This fixes #140. - -commit dcc686e42b406d63d52ef75de9a326f67d0a06c9 -Author: William Hubbs -Commit: William Hubbs - -scripts/shutdown: fix arguments to be sysvinit shutdown compatible - -This fixes #140. - -commit 2f81c100afdf45ebf787dfc5d3261aa6055640e4 -Author: William Hubbs -Commit: William Hubbs - -Fix link to shutdown for MKSYSVINIT=yes - -commit a511a48d77b1dcb8a3fb0dd1abddb750a152869b -Author: Nuno Silva -Commit: William Hubbs - -init.d/hostname: fix default parameter syntax - -The syntax for expanding a variable with a default value is -${parameter:-word} -not -${parameter-word} -although the latter still works for a reason I could not explain. - -This fixes #143. - -commit 1e5322e5c55ec744a2cdcc3342ef6547eab7c46f -Author: Nuno Silva -Commit: William Hubbs - -init.d/hostname: fix indentation - -This is for #143. - -commit 199a210d2fbc524c9c400a06f832dabffd7ed1b3 -Author: udeved -Commit: William Hubbs - -scripts/Makefile: make symlinks absolute instead of relative - -This closes #142. - -commit 5b7667af32effddf867a5d021c66d43f0645d374 -Author: udeved -Commit: William Hubbs - -scripts/Makefile: respect SBINDIR with MKSYSVINIT - -This is for #142. - -commit 11243f85b67e5f450ddf50346ffd4a1b2c6faeb5 -Author: Jory A. Pratt -Commit: William Hubbs - -kill_all: include limits.h for PATH_MAX - -commit 3c40826d3466cdda1a46abcd5c86b661b8185f46 -Author: William Hubbs -Commit: William Hubbs - -version 0.28 - -commit 560d874d2fee63bf7ca11f17cf9933021b639a1d -Author: William Hubbs -Commit: William Hubbs - -fix compile issue for musl - -commit e84366fd232a41c3ba79ed351e93c74cef8d7c8d -Author: William Hubbs -Commit: William Hubbs - -Update ChangeLog - -commit caacedc0a82285fb2d25c6d3473f154044c7ad66 -Author: William Hubbs -Commit: William Hubbs - -man: update openrc-shutdown man page - -Add the new wtmp options and fix some cross references. - -commit 84d140a1f6abf95a4170d13527152d3ab14e6613 -Author: William Hubbs -Commit: William Hubbs - -scripts/shutdown: pass --single to openrc-shutdown - -Sysvinit shutdown has a default of single user mode, but openrc-shutdown -makes you choose a default action. Because of this, the shutdown wrapper -needs to pass --single to openrc-shutdown. - -commit ee886c44824b1dd892eaff2c6da666286e61bc73 -Author: William Hubbs -Commit: William Hubbs - -openrc-shutdown: add --single option and clean up option processing - -commit 1801561c2d36c330df7fd02c7508f503a61ff5ba -Author: William Hubbs -Commit: William Hubbs - -init.d/bootmisc: use openrc-shutdown instead of halt to write halt record - -This fixes #139 and fixes #128. -and fixes #124. - -commit 7689106aa10f7852b707b4c21ec080ccb2767280 -Author: William Hubbs -Commit: William Hubbs - -ad
[gentoo-commits] proj/openrc:master commit in: /, man/, sh/, src/rc/
commit: e6d01471fe2a8eb8a15bb906d7c91c11805d1bef Author: William Hubbs gmail com> AuthorDate: Fri Jun 15 17:23:50 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Jun 15 17:23:50 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e6d01471 start-stop-daemon: add ability to log stdout or stderr to processes NEWS.md| 9 + man/openrc-run.8 | 17 man/start-stop-daemon.8| 27 +- sh/start-stop-daemon.sh| 2 ++ src/rc/Makefile| 2 +- src/rc/start-stop-daemon.c | 48 ++ 6 files changed, 99 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 328247da..13c62d6e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,15 @@ OpenRC NEWS This file will contain a list of notable changes for each release. Note the information in this file is in reverse order. +## OpenRC 0.37 + +start-stop-daemon now supports logging stdout and stderr of daemons to +processes instead of files. These processes are defined by the +output_logger and error_logger variables in standard service scripts, or +by the -3/--output-logger or -4/--error-logger switches if you use +start-stop-daemon directly. For more information on this, see the +start-stop-daemon man page. + ## OpenRC 0.36 In this release, the modules-load service has been combined into the diff --git a/man/openrc-run.8 b/man/openrc-run.8 index f0750406..03f8b680 100644 --- a/man/openrc-run.8 +++ b/man/openrc-run.8 @@ -173,6 +173,23 @@ variable is set. The same thing as .Pa output_log but for the standard error output. +.It Ar output_logger +This is a process which will be used to log the standard output from the +service. If you are starting this service with +.Xr start-stop-daemon 8 , +, you must set +.Pa command_background +to true. Keep in mind that this command must be executable as a shell +command inside the chroot if the +.Pa chroot +variable is set. Keep in mind also that this command works by accepting +the stdout of the service on stdin. +An example of a command that can be run this way is logger if you want +your service output to go to syslog. +.It Ar error_logger +The same thing as +.Pa output_logger +but for the standard error output. .It Ar directory .Xr start-stop-daemon 8 and diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8 index 706a12ed..ecadb958 100644 --- a/man/start-stop-daemon.8 +++ b/man/start-stop-daemon.8 @@ -131,9 +131,34 @@ Modifies the scheduling priority of the daemon. .It Fl 1 , -stdout Ar logfile Redirect the standard output of the process to logfile when started with .Fl background . -Must be an absolute pathname, but relative to the path optionally given with +The logfile Must be an absolute pathname, but relative to the path +optionally given with .Fl r , -chroot . The logfile can also be a named pipe. +.It Fl 2 , -stderr Ar logfile +Redirect the standard error of the process to logfile when started with +.Fl background . +The logfile must be an absolute pathname, but relative to the path +optionally given with +.Fl r , -chroot . +The logfile can also be a named pipe. +.It Fl 3 , -stdout-logger Ar cmd +Run cmd as a child process redirecting the standard output to the +standard input of cmd when started with +.Fl background . +Cmd must be an absolute pathname, but relative to the path optionally given with +.Fl r , -chroot . +This process must be prepared to accept input on stdin and be able to +log it or send it to another location. +.It Fl 4 , -stderr-logger Ar cmd +Run cmd as a child process and +Redirect the standard error of the process to the standard input of cmd +when started with +.Fl background . +Cmd must be an absolute pathname, but relative to the path optionally given with +.Fl r , -chroot . +This process must be prepared to accept input on stdin and be able to +log it or send it to another location. .It Fl w , -wait Ar milliseconds Wait .Ar milliseconds diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh index 35c642c0..69666ff7 100644 --- a/sh/start-stop-daemon.sh +++ b/sh/start-stop-daemon.sh @@ -47,6 +47,8 @@ ssd_start() ${directory:+--chdir} $directory \ ${output_log+--stdout} $output_log \ ${error_log+--stderr} $error_log \ + ${output_logger+--stdout-logger} \"$output_logger\" \ + ${error_logger+--stderr-logger} \"$error_logger\" \ ${procname:+--name} $procname \ ${pidfile:+--pidfile} $pidfile \ ${command_user+--user} $command_user \ diff --git a/src/rc/Makefile b/src/rc/Makefile index 4b0983b5..b09c5058 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -158,7 +158,7 @@ rc-service: rc-service.o _usage.o rc-misc.o rc-update: rc-update.o _usage.o rc-misc.o ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD} -st
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: d4501a9f06c807f87be04f128e535a74b370fdb4 Author: William Hubbs gmail com> AuthorDate: Thu Jun 14 19:55:42 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Jun 14 19:55:42 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d4501a9f fix a typo src/rc/rc-pipes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/rc-pipes.c b/src/rc/rc-pipes.c index 55f3ff8d..2d7b623e 100644 --- a/src/rc/rc-pipes.c +++ b/src/rc/rc-pipes.c @@ -19,7 +19,7 @@ #include #include -#include "rc-pipe-command.h" +#include "rc-pipes.h" static const int pipe_read_end = 0; static const int pipe_write_end = 1;
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: ec8abea4605395a2a59b26906ce4677a578e3c60 Author: Mike Gilbert gentoo org> AuthorDate: Wed Jun 13 18:49:42 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Jun 13 18:49:42 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ec8abea4 Add helper to spawn process with stdin connected to a pipe src/rc/Makefile | 4 ++-- src/rc/rc-pipes.c | 57 +++ src/rc/rc-pipes.h | 18 ++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/rc/Makefile b/src/rc/Makefile index 5e2a5e94..4b0983b5 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -5,8 +5,8 @@ include ${MK}/os.mk SRCS= checkpath.c do_e.c do_mark_service.c do_service.c \ do_value.c fstabinfo.c is_newer_than.c is_older_than.c \ mountinfo.c openrc-run.c rc-abort.c rc.c \ - rc-depend.c rc-logger.c rc-misc.c rc-plugin.c \ - rc-service.c rc-status.c rc-update.c \ + rc-depend.c rc-logger.c rc-misc.c rc-pipes.c \ + rc-plugin.c rc-service.c rc-status.c rc-update.c \ shell_var.c start-stop-daemon.c supervise-daemon.c swclock.c _usage.c ifeq (${MKSELINUX},yes) diff --git a/src/rc/rc-pipes.c b/src/rc/rc-pipes.c new file mode 100644 index ..55f3ff8d --- /dev/null +++ b/src/rc/rc-pipes.c @@ -0,0 +1,57 @@ +/* + * rc-pipes.c + * Helper to handle spawning processes and connecting them to pipes. + */ + +/* + * Copyright (c) 2018 The OpenRC Authors. + * See the Authors file at the top-level directory of this distribution and + * https://github.com/OpenRC/openrc/blob/master/AUTHORS + * + * This file is part of OpenRC. It is subject to the license terms in + * the LICENSE file found in the top-level directory of this + * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE + * This file may not be copied, modified, propagated, or distributed + *except according to the terms contained in the LICENSE file. + */ + +#include +#include +#include + +#include "rc-pipe-command.h" + +static const int pipe_read_end = 0; +static const int pipe_write_end = 1; + +/* + * Starts a command with stdin redirected from a pipe + * Returns the write end of the pipe or -1 + */ +int rc_pipe_command(char *cmd) +{ + int pfd[2]; + pid_t pid; + + if (pipe(pfd) < 0) + return -1; + + pid = fork(); + if (pid < 0) + return -1; + else if (pid > 0) { + /* parent */ + close(pfd[0]); + return pfd[pipe_write_end]; + } else if (pid == 0) { + /* child */ + close(pfd[pipe_write_end]); + if (pfd[0] != STDIN_FILENO) { + if (dup2(pfd[0], STDIN_FILENO) < 0) + exit(1); + close(pfd[0]); + } + execl("/bin/sh", "sh", "-c", cmd, NULL); + exit(1); + } +} diff --git a/src/rc/rc-pipes.h b/src/rc/rc-pipes.h new file mode 100644 index ..0c605ced --- /dev/null +++ b/src/rc/rc-pipes.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2018 The OpenRC Authors. + * See the Authors file at the top-level directory of this distribution and + * https://github.com/OpenRC/openrc/blob/master/AUTHORS + * + * This file is part of OpenRC. It is subject to the license terms in + * the LICENSE file found in the top-level directory of this + * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE + * This file may not be copied, modified, propagated, or distributed + *except according to the terms contained in the LICENSE file. + */ + +#ifndef RC_PIPES_H +#define RC_PIPES_H + +int rc_pipe_command(char *cmd); + +#endif
[gentoo-commits] proj/openrc:master commit in: /
commit: e4ddfa38e0e0318abf442b7aa07e0d8206191dd7 Author: William Hubbs gmail com> AuthorDate: Tue Jun 5 22:34:09 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 5 22:34:09 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e4ddfa38 user-guide.md: small cleanups user-guide.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/user-guide.md b/user-guide.md index a3566add..97d938d5 100644 --- a/user-guide.md +++ b/user-guide.md @@ -90,8 +90,8 @@ the service script by hand. FIXME: Document stacked runlevels -The default startup uses the runlevels `boot`, `sysinit` and `default`, in that -order. Shutdown uses the `shutdown` runlevel. +The default startup uses the runlevels `sysinit`, `boot`, and `default`, +in that order. Shutdown uses the `shutdown` runlevel. # The Magic of `conf.d` @@ -162,7 +162,6 @@ stopped, by using: The `rc_cgroup_cleanup` setting can be changed to yes to make this happen automatically when the service is stopped. - # Caching For performance reasons OpenRC keeps a cache of pre-parsed service metadata
[gentoo-commits] proj/openrc:master commit in: /
commit: 21d30bc6d9caca31d007631717a480a552b89701 Author: William Hubbs gmail com> AuthorDate: Tue Jun 5 22:26:57 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 5 22:26:57 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=21d30bc6 service-script-guide.md: small cleanups service-script-guide.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/service-script-guide.md b/service-script-guide.md index 2ae97029..e5c61f8d 100644 --- a/service-script-guide.md +++ b/service-script-guide.md @@ -29,7 +29,9 @@ Not using this interpreter will break the use of dependencies and is not supported. (iow: if you insist on using `#!/bin/sh` you're on your own) A `depend` function declares the dependencies of this service script. -All scripts must have start/stop/status functions, but defaults are provided and should be used unless you have a very strong reason not to use them. +All scripts must have start/stop/status functions, but defaults are +provided and should be used unless you have a very strong reason not to +use them. Extra functions can be added easily:
[gentoo-commits] proj/openrc:master commit in: /
commit: 2a1ff6e49c6603bb81eec3cafe2c587fa734289f Author: William Hubbs gmail com> AuthorDate: Tue Jun 5 21:11:28 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Jun 5 21:11:28 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=2a1ff6e4 version 0.37 Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index 56545645..317a55e0 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,3 +1,3 @@ NAME= openrc -VERSION= 0.36 +VERSION= 0.37 PKG= ${NAME}-${VERSION}
[gentoo-commits] proj/openrc:master commit in: /
commit: 6762cb875c9c039b79dcc447b9d0eb65356a7708 Author: William Hubbs gmail com> AuthorDate: Thu May 31 21:53:25 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu May 31 21:53:25 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6762cb87 Update ChangeLog ChangeLog | 780 ++ 1 file changed, 331 insertions(+), 449 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59ead5ca..3a0139ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,334 @@ +commit 6edf516a1fe0ad4f4e8738f9fdd1bf0bc7718361 +Author: Austin English +Commit: Doug Freed + +sh/supervise-daemon.sh: use start_stop_daemon_args if supervise_daemon_args is undefined + +commit 7e56a49e23c810673b83e48eb9ca36229bb4016e +Author: William Hubbs +Commit: William Hubbs + +Logger: only log printable characters and newlines + +X-Gentoo-Bug: 651412 +X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651412 + +commit fa5aea80c50fb724d2c98a6542307adbafd0e62d +Author: William Hubbs +Commit: William Hubbs + +openrc-run.sh: move crashed test outside started test + +This is handled inside librc, so we don't need the nesting in this +script. + +commit 0f4fa41574a4ebf8117493e5411f8ab522010467 +Author: William Hubbs +Commit: William Hubbs + +Add mark_service_crashed binary + +commit 5d6dd97bba3559b57fb1c1de35e644c6dbd6baa7 +Author: William Hubbs +Commit: William Hubbs + +rc-misc: add the crashed state + +commit 37e29442721af0dc3846e87ef2b85a474af3cf2b +Author: William Hubbs +Commit: William Hubbs + +librc: Add check for crashed state + +In rc_service_state,, call rc_service_daemons_crashed to check for +a crashed daemon if the service is started. + +commit 4e0eace837287845504c9895429dc9f64872d075 +Author: William Hubbs +Commit: William Hubbs + +librc: Add crashed state + +commit faa8318b3ba278544413a39d4a5ae4457711793f +Author: William Hubbs +Commit: William Hubbs + +Remove the _rc_can_find_pids function + +This test to find if we could see pid 1 was being used inconsistently in +rc-status and mark_service_crashed to decide whether we could test to +see if the daemon for the service was crashed, and it was not part of +the librc library. + +I am removing it from the executables because of inconsistent usage. I +will add it to the library if it is needed there. + +commit 08da36149c0b41c64a09369c3eef5e2f5a6fa39c +Author: William Hubbs +Commit: William Hubbs + +rc-service: add --ifstarted and --ifstopped options + +commit 56870d0db18209396f8276bdc05d413fe4dd7a88 +Author: William Hubbs +Commit: William Hubbs + +Man: rc-service man page cleanups + +commit 4d47ce440c3e8f193cff82a77e6691ee6e7fac33 +Author: William Hubbs +Commit: William Hubbs + +rc-service: add -d/--debug and -D/--nodeps options + +commit 958f57d895b6573b39e62097e5e9881f16174715 +Author: William Hubbs +Commit: William Hubbs + +openrc-run: respect the RC_NODEPS environment variable + +commit 04886efd85328988657c34440da9ba6aa2841cfd +Author: William Hubbs +Commit: William Hubbs + +Add RC_DEBUG and RC_NODEPS to environment whitelist + +These are needed so rc-service can pass debug and nodeps options to +openrc-run. + +commit d980798d6444bbfc508796a233e962bf4dd61275 +Author: William Hubbs +Commit: William Hubbs + +openrc-run: respect the IN_DRYRUN environment variable + +This allows rc-service to pass the tryrun option to openrc-run. + +This is for #225. + +commit 414a9aae6ce066d2a6ad42e7e24d1c12a7b46409 +Author: William Hubbs +Commit: William Hubbs + +rc-misc.c: Add IN_DRYRUN to environment whitelist + +This allows rc-service to pass the dryrun option to openrc-run. + +This is for #225. + +commit a7f475ca04856ef8232364c5b0c3191566b0696c +Author: William Hubbs +Commit: William Hubbs + +rc-service: add a --dry-run option + +This is for #225. + +commit 3c53680018c1799d0d804e241a9fa4d3b9423896 +Author: William Hubbs +Commit: William Hubbs + +build: standardize installation modes + +Gentoo was changing some of our installation modes from 0444 to 0644. +There isn't a reason to install things 0444, so we are switching these +to 0644 so the Gentoo ebuild doesn't need this extra step. + +commit f0ad647303daca528cb9b75f9a07d422318635c2 +Author: William Hubbs +Commit: William Hubbs + +Revert "savecache: stop saving the dependency tree" + +It is safe to save the deptree, but we also need to regenerate it at +boot time. + +commit b35e03b6b1acc841ac33f601dd39c1152523621e +Author: William Hubbs +Commit: William Hubbs + +Revert "Logger: only log printable characters and newlines" + +This reverts commit 2b1392af2fe9e5dfc8eda2f19d896efdc41840bf. +This seems to create issues shutting down, so I need to look into it +further. + +commit 2
[gentoo-commits] proj/openrc:master commit in: sh/, man/
commit: 6edf516a1fe0ad4f4e8738f9fdd1bf0bc7718361 Author: Austin English gmail com> AuthorDate: Wed May 30 16:11:10 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed May 30 16:11:10 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6edf516a sh/supervise-daemon.sh: use start_stop_daemon_args if supervise_daemon_args is undefined man/openrc-run.8 | 3 +++ sh/supervise-daemon.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/man/openrc-run.8 b/man/openrc-run.8 index f9109ef3..f0750406 100644 --- a/man/openrc-run.8 +++ b/man/openrc-run.8 @@ -119,6 +119,9 @@ The amount of time, in milliseconds, s6-svc should wait for the service to go down when stopping the service. The default is 6. .It Ar start_stop_daemon_args List of arguments passed to start-stop-daemon when starting the daemon. +.It Ar supervise_daemon_args +List of arguments passed to supervise-daemon when starting the daemon. +If undefined, start_stop_daemon_args is used as a fallback. .It Ar command Daemon to start or stop via .Nm start-stop-daemon diff --git a/sh/supervise-daemon.sh b/sh/supervise-daemon.sh index b600b9c6..80e0260c 100644 --- a/sh/supervise-daemon.sh +++ b/sh/supervise-daemon.sh @@ -34,7 +34,7 @@ supervise_start() ${respawn_period:+--respawn-period} $respawn_period \ ${command_user+--user} $command_user \ ${umask+--umask} $umask \ - $supervise_daemon_args \ + ${supervise_daemon_args:-${start_stop_daemon_args}} \ $command \ -- $command_args $command_args_foreground rc=$?
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 5d6dd97bba3559b57fb1c1de35e644c6dbd6baa7 Author: William Hubbs gmail com> AuthorDate: Mon May 21 23:16:12 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 22 17:20:38 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5d6dd97b rc-misc: add the crashed state src/rc/rc-misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index e933409f..2df4fd42 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -423,6 +423,7 @@ static const struct { { "service_hotplugged", RC_SERVICE_HOTPLUGGED, }, { "service_wasinactive", RC_SERVICE_WASINACTIVE, }, { "service_failed", RC_SERVICE_FAILED, }, + { "service_crashed", RC_SERVICE_CRASHED, }, }; RC_SERVICE lookup_service_state(const char *service)
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 7e56a49e23c810673b83e48eb9ca36229bb4016e Author: William Hubbs gmail com> AuthorDate: Tue May 22 22:11:43 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 22 22:11:43 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7e56a49e Logger: only log printable characters and newlines X-Gentoo-Bug: 651412 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651412 src/rc/rc-logger.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c index 062ce3d9..22926211 100644 --- a/src/rc/rc-logger.c +++ b/src/rc/rc-logger.c @@ -87,6 +87,8 @@ write_log(int logfd, const char *buffer, size_t bytes) } if (!in_escape) { + if (!isprint((int) *p) && *p != '\n') + goto cont; if (write(logfd, p++, 1) == -1) eerror("write: %s", strerror(errno)); continue;
[gentoo-commits] proj/openrc:master commit in: sh/
commit: fa5aea80c50fb724d2c98a6542307adbafd0e62d Author: William Hubbs gmail com> AuthorDate: Tue May 22 16:12:12 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 22 17:20:38 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=fa5aea80 openrc-run.sh: move crashed test outside started test This is handled inside librc, so we don't need the nesting in this script. sh/openrc-run.sh.in | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in index e3dff6ce..7e9064c2 100644 --- a/sh/openrc-run.sh.in +++ b/sh/openrc-run.sh.in @@ -133,11 +133,10 @@ _status() elif service_inactive; then ewarn "status: inactive" return 16 + elif service_crashed; then + eerror "status: crashed" + return 32 elif service_started; then - if service_crashed; then - eerror "status: crashed" - return 32 - fi einfo "status: started" return 0 else
[gentoo-commits] proj/openrc:master commit in: src/librc/
commit: 37e29442721af0dc3846e87ef2b85a474af3cf2b Author: William Hubbs gmail com> AuthorDate: Fri May 18 23:28:07 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 22 17:19:41 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=37e29442 librc: Add check for crashed state In rc_service_state,, call rc_service_daemons_crashed to check for a crashed daemon if the service is started. src/librc/librc.c | 4 1 file changed, 4 insertions(+) diff --git a/src/librc/librc.c b/src/librc/librc.c index 4473a1bb..01bfac03 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -849,6 +849,10 @@ rc_service_state(const char *service) } } + if (state & RC_SERVICE_STARTED) { + if (rc_service_daemons_crashed(service)) + state |= RC_SERVICE_CRASHED; + } if (state & RC_SERVICE_STOPPED) { dirs = ls_dir(RC_SVCDIR "/scheduled", 0); TAILQ_FOREACH(dir, dirs, entries) {
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 0f4fa41574a4ebf8117493e5411f8ab522010467 Author: William Hubbs gmail com> AuthorDate: Tue May 22 16:08:35 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 22 17:20:38 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0f4fa415 Add mark_service_crashed binary src/rc/.gitignore | 1 + src/rc/Makefile | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rc/.gitignore b/src/rc/.gitignore index 91d57075..a43088aa 100644 --- a/src/rc/.gitignore +++ b/src/rc/.gitignore @@ -56,6 +56,7 @@ mark_service_inactive mark_service_wasinactive mark_service_hotplugged mark_service_failed +mark_service_crashed rc-abort rc openrc diff --git a/src/rc/Makefile b/src/rc/Makefile index cb90875c..5e2a5e94 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -41,6 +41,7 @@ RC_SBINPROGS= mark_service_starting mark_service_started \ mark_service_stopping mark_service_stopped \ mark_service_inactive mark_service_wasinactive \ mark_service_hotplugged mark_service_failed \ + mark_service_crashed \ rc-abort swclock ifeq (${OS},Linux) @@ -123,7 +124,8 @@ is_older_than: is_older_than.o rc-misc.o mark_service_starting mark_service_started \ mark_service_stopping mark_service_stopped \ mark_service_inactive mark_service_wasinactive \ -mark_service_hotplugged mark_service_failed: do_mark_service.o rc-misc.o +mark_service_hotplugged mark_service_failed \ +mark_service_crashed: do_mark_service.o rc-misc.o ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD} mountinfo: mountinfo.o _usage.o rc-misc.o
[gentoo-commits] proj/openrc:master commit in: src/librc/
commit: 4e0eace837287845504c9895429dc9f64872d075 Author: William Hubbs gmail com> AuthorDate: Thu May 17 22:42:14 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 22 17:19:22 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4e0eace8 librc: Add crashed state src/librc/librc.c | 1 + src/librc/rc.h.in | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librc/librc.c b/src/librc/librc.c index ee65b00a..4473a1bb 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -50,6 +50,7 @@ static const rc_service_state_name_t rc_service_state_names[] = { { RC_SERVICE_HOTPLUGGED, "hotplugged" }, { RC_SERVICE_FAILED, "failed" }, { RC_SERVICE_SCHEDULED, "scheduled"}, + { RC_SERVICE_CRASHED, "crashed"}, { 0, NULL} }; diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index 1f984d52..d2e51dc6 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -188,7 +188,8 @@ typedef enum /* Optional states service could also be in */ RC_SERVICE_FAILED = 0x0200, RC_SERVICE_SCHEDULED = 0x0400, - RC_SERVICE_WASINACTIVE = 0x0800 + RC_SERVICE_WASINACTIVE = 0x0800, + RC_SERVICE_CRASHED = 0x1000, } RC_SERVICE; /*! Add the service to the runlevel
[gentoo-commits] proj/openrc:master commit in: src/includes/, src/rc/
commit: faa8318b3ba278544413a39d4a5ae4457711793f Author: William Hubbs gmail com> AuthorDate: Fri May 18 21:48:21 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri May 18 21:48:21 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=faa8318b Remove the _rc_can_find_pids function This test to find if we could see pid 1 was being used inconsistently in rc-status and mark_service_crashed to decide whether we could test to see if the daemon for the service was crashed, and it was not part of the librc library. I am removing it from the executables because of inconsistent usage. I will add it to the library if it is needed there. src/includes/rc-misc.h | 3 --- src/rc/do_service.c| 4 +--- src/rc/rc-misc.c | 28 src/rc/rc-status.c | 7 +-- 4 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h index e6789911..d05255f4 100644 --- a/src/includes/rc-misc.h +++ b/src/includes/rc-misc.h @@ -66,9 +66,6 @@ int parse_mode(mode_t *, char *); /* Handy function so we can wrap einfo around our deptree */ RC_DEPTREE *_rc_deptree_load (int, int *); -/* Test to see if we can see pid 1 or not */ -bool _rc_can_find_pids(void); - RC_SERVICE lookup_service_state(const char *service); void from_time_t(char *time_string, time_t tv); time_t to_time_t(char *timestring); diff --git a/src/rc/do_service.c b/src/rc/do_service.c index a36a09ca..5d78e8df 100644 --- a/src/rc/do_service.c +++ b/src/rc/do_service.c @@ -68,9 +68,7 @@ int main(int argc, char **argv) ok = rc_service_started_daemon(service, exec, NULL, idx); } else if (strcmp(applet, "service_crashed") == 0) { - ok = (_rc_can_find_pids() && - rc_service_daemons_crashed(service) && - errno != EACCES); + ok = ( rc_service_daemons_crashed(service) && errno != EACCES); } else eerrorx("%s: unknown applet", applet); diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 50c09747..e933409f 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -411,34 +411,6 @@ RC_DEPTREE * _rc_deptree_load(int force, int *regen) return rc_deptree_load(); } -bool _rc_can_find_pids(void) -{ - RC_PIDLIST *pids; - RC_PID *pid; - RC_PID *pid2; - bool retval = false; - - if (geteuid() == 0) - return true; - - /* If we cannot see process 1, then we don't test to see if -* services crashed or not */ - pids = rc_find_pids(NULL, NULL, 0, 1); - if (pids) { - pid = LIST_FIRST(pids); - if (pid) { - retval = true; - while (pid) { - pid2 = LIST_NEXT(pid, entries); - free(pid); - pid = pid2; - } - } - free(pids); - } - return retval; -} - static const struct { const char * const name; RC_SERVICE bit; diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index d29f876a..ab80d901 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -54,7 +54,6 @@ const char *usagestring = "" \ "Usage: rc-status [options] ...\n"\ " or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]"; -static bool test_crashed = false; static RC_DEPTREE *deptree; static RC_STRINGLIST *types; @@ -145,9 +144,7 @@ print_service(const char *service) color = ECOLOR_WARN; } else if (state & RC_SERVICE_STARTED) { errno = 0; - if (test_crashed && - rc_service_daemons_crashed(service) && - errno != EACCES) + if (rc_service_daemons_crashed(service) && errno != EACCES) { child_pid = rc_service_value_get(service, "child_pid"); start_time = rc_service_value_get(service, "start_time"); @@ -240,8 +237,6 @@ int main(int argc, char **argv) char *p, *runlevel = NULL; int opt, retval = 0; - test_crashed = _rc_can_find_pids(); - applet = basename_c(argv[0]); while ((opt = getopt_long(argc, argv, getoptstring, longopts, (int *) 0)) != -1)
[gentoo-commits] proj/openrc:master commit in: src/rc/, man/
commit: 08da36149c0b41c64a09369c3eef5e2f5a6fa39c Author: William Hubbs gmail com> AuthorDate: Wed May 16 18:25:22 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed May 16 18:25:22 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=08da3614 rc-service: add --ifstarted and --ifstopped options man/rc-service.8| 8 src/rc/rc-service.c | 16 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/man/rc-service.8 b/man/rc-service.8 index 2834f361..72d5a559 100644 --- a/man/rc-service.8 +++ b/man/rc-service.8 @@ -40,6 +40,14 @@ .Ar service cmd .Op Ar ... .Nm +.Op Fl s , -ifstarted +.Ar service cmd +.Op Ar ... +.Nm +.Op Fl S , -ifstopped +.Ar service cmd +.Op Ar ... +.Nm .Fl e , -exists .Ar service .Nm diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c index ea69dab5..8b01fa0d 100644 --- a/src/rc/rc-service.c +++ b/src/rc/rc-service.c @@ -29,7 +29,7 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "cdDe:ilr:INZ" getoptstring_COMMON; +const char *getoptstring = "cdDe:ilr:INsSZ" getoptstring_COMMON; const struct option longopts[] = { { "debug", 0, NULL, 'd' }, { "nodeps", 0, NULL, 'D' }, @@ -38,6 +38,8 @@ const struct option longopts[] = { { "ifexists", 0, NULL, 'i' }, { "ifinactive", 0, NULL, 'I' }, { "ifnotstarted", 0, NULL, 'N' }, + { "ifstarted", 0, NULL, 's' }, + { "ifstopped", 0, NULL, 'S' }, { "list", 0, NULL, 'l' }, { "resolve", 1, NULL, 'r' }, { "dry-run", 0, NULL, 'Z' }, @@ -73,6 +75,8 @@ int main(int argc, char **argv) bool if_exists = false; bool if_inactive = false; bool if_notstarted = false; + bool if_started = false; + bool if_stopped = false; applet = basename_c(argv[0]); /* Ensure that we are only quiet when explicitly told to be */ @@ -124,6 +128,12 @@ int main(int argc, char **argv) free(service); return EXIT_SUCCESS; /* NOTREACHED */ + case 's': + if_started = true; + break; + case 'S': + if_stopped = true; + break; case 'Z': setenv("IN_DRYRUN", "yes", 1); break; @@ -148,6 +158,10 @@ int main(int argc, char **argv) return 0; if (if_notstarted && (state & RC_SERVICE_STARTED)) return 0; + if (if_started && ! (state & RC_SERVICE_STARTED)) + return 0; + if (if_stopped && ! (state & RC_SERVICE_STOPPED)) + return 0; *argv = service; execv(*argv, argv); eerrorx("%s: %s", applet, strerror(errno));
[gentoo-commits] proj/openrc:master commit in: man/, src/rc/
commit: 4d47ce440c3e8f193cff82a77e6691ee6e7fac33 Author: William Hubbs gmail com> AuthorDate: Tue May 15 21:59:21 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 21:59:21 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4d47ce44 rc-service: add -d/--debug and -D/--nodeps options man/rc-service.8| 14 ++ src/rc/rc-service.c | 12 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/man/rc-service.8 b/man/rc-service.8 index a0202a8e..3613f8b8 100644 --- a/man/rc-service.8 +++ b/man/rc-service.8 @@ -20,6 +20,14 @@ .Ar service cmd .Op Ar ... .Nm +.Fl d , -debug +.Ar service cmd +.Op Ar ... +.Nm +.Fl D , -nodeps +.Ar service cmd +.Op Ar ... +.Nm .Op Fl i , -ifexists .Ar service cmd .Op Ar ... @@ -72,6 +80,12 @@ otherwise -1. .Fl r , -resolve does the same and also prints the full path of the service to stdout. .Pp +.Fl d , -debug +sets -x when running the service script(s). +.Pp +.Fl D , -nodeps +ignores dependencies when running the service. +.Pp .Fl Z , -dry-run prints out the commands it would execute rather than executing them. .Sh SEE ALSO diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c index 77f0336b..ea69dab5 100644 --- a/src/rc/rc-service.c +++ b/src/rc/rc-service.c @@ -29,8 +29,10 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "ce:ilr:INZ" getoptstring_COMMON; +const char *getoptstring = "cdDe:ilr:INZ" getoptstring_COMMON; const struct option longopts[] = { + { "debug", 0, NULL, 'd' }, + { "nodeps", 0, NULL, 'D' }, { "exists", 1, NULL, 'e' }, { "ifcrashed", 0, NULL, 'c' }, { "ifexists", 0, NULL, 'i' }, @@ -42,6 +44,8 @@ const struct option longopts[] = { longopts_COMMON }; const char * const longopts_help[] = { + "set xtrace when running the command", + "ignore dependencies", "tests if the service exists or not", "if the service is crashed then run the command", "if the service exists then run the command", @@ -78,6 +82,12 @@ int main(int argc, char **argv) longopts, (int *) 0)) != -1) { switch (opt) { + case 'd': + setenv("RC_DEBUG", "yes", 1); + break; + case 'D': + setenv("RC_NODEPS", "yes", 1); + break; case 'e': service = rc_service_resolve(optarg); opt = service ? EXIT_SUCCESS : EXIT_FAILURE;
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 04886efd85328988657c34440da9ba6aa2841cfd Author: William Hubbs gmail com> AuthorDate: Tue May 15 21:18:19 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 21:18:19 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=04886efd Add RC_DEBUG and RC_NODEPS to environment whitelist These are needed so rc-service can pass debug and nodeps options to openrc-run. src/rc/rc-misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index e676ad9e..50c09747 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -52,6 +52,7 @@ rc_conf_yesno(const char *setting) static const char *const env_whitelist[] = { "EERROR_QUIET", "EINFO_QUIET", "IN_BACKGROUND", "IN_DRYRUN", "IN_HOTPLUG", + "RC_DEBUG", "RC_NODEPS", "LANG", "LC_MESSAGES", "TERM", "EINFO_COLOR", "EINFO_VERBOSE", NULL
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 958f57d895b6573b39e62097e5e9881f16174715 Author: William Hubbs gmail com> AuthorDate: Tue May 15 21:27:42 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 21:27:42 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=958f57d8 openrc-run: respect the RC_NODEPS environment variable src/rc/openrc-run.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c index ac682c4c..43889f2d 100644 --- a/src/rc/openrc-run.c +++ b/src/rc/openrc-run.c @@ -1268,6 +1268,9 @@ int main(int argc, char **argv) case_RC_COMMON_GETOPT } + if (rc_yesno(getenv("RC_NODEPS"))) + deps = false; + /* If we're changing runlevels and not called by rc then we cannot work with any dependencies */ if (deps && getenv("RC_PID") == NULL &&
[gentoo-commits] proj/openrc:master commit in: man/
commit: 56870d0db18209396f8276bdc05d413fe4dd7a88 Author: William Hubbs gmail com> AuthorDate: Tue May 15 22:09:56 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 22:09:56 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=56870d0d Man: rc-service man page cleanups man/rc-service.8 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man/rc-service.8 b/man/rc-service.8 index 3613f8b8..2834f361 100644 --- a/man/rc-service.8 +++ b/man/rc-service.8 @@ -44,7 +44,8 @@ .Ar service .Nm .Fl Z , -dry-run -.Ar service +.Ar service cmd +.Op Ar ... .Nm .Fl l , -list .Nm @@ -87,7 +88,7 @@ sets -x when running the service script(s). ignores dependencies when running the service. .Pp .Fl Z , -dry-run -prints out the commands it would execute rather than executing them. +displays commands rather than executing them. .Sh SEE ALSO .Xr openrc 8 , .Xr stdout 3
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: d980798d6444bbfc508796a233e962bf4dd61275 Author: William Hubbs gmail com> AuthorDate: Tue May 15 00:08:19 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 00:08:19 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d980798d openrc-run: respect the IN_DRYRUN environment variable This allows rc-service to pass the tryrun option to openrc-run. This is for #225. src/rc/openrc-run.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c index 73def8fb..ac682c4c 100644 --- a/src/rc/openrc-run.c +++ b/src/rc/openrc-run.c @@ -1282,6 +1282,8 @@ int main(int argc, char **argv) unsetenv("IN_BACKGROUND"); } + if (rc_yesno(getenv("IN_DRYRUN"))) + dry_run = true; if (rc_yesno(getenv("IN_HOTPLUG"))) { if (!service_plugable()) eerrorx("%s: not allowed to be hotplugged", applet);
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 414a9aae6ce066d2a6ad42e7e24d1c12a7b46409 Author: William Hubbs gmail com> AuthorDate: Tue May 15 00:04:42 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 00:04:42 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=414a9aae rc-misc.c: Add IN_DRYRUN to environment whitelist This allows rc-service to pass the dryrun option to openrc-run. This is for #225. src/rc/rc-misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 2c9903c3..e676ad9e 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -51,7 +51,7 @@ rc_conf_yesno(const char *setting) static const char *const env_whitelist[] = { "EERROR_QUIET", "EINFO_QUIET", - "IN_BACKGROUND", "IN_HOTPLUG", + "IN_BACKGROUND", "IN_DRYRUN", "IN_HOTPLUG", "LANG", "LC_MESSAGES", "TERM", "EINFO_COLOR", "EINFO_VERBOSE", NULL
[gentoo-commits] proj/openrc:master commit in: man/, src/rc/
commit: a7f475ca04856ef8232364c5b0c3191566b0696c Author: William Hubbs gmail com> AuthorDate: Tue May 15 00:00:04 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 15 00:00:04 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a7f475ca rc-service: add a --dry-run option This is for #225. man/rc-service.8| 6 ++ src/rc/rc-service.c | 7 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/man/rc-service.8 b/man/rc-service.8 index 8f075de4..a0202a8e 100644 --- a/man/rc-service.8 +++ b/man/rc-service.8 @@ -35,6 +35,9 @@ .Fl e , -exists .Ar service .Nm +.Fl Z , -dry-run +.Ar service +.Nm .Fl l , -list .Nm .Fl r , -resolve @@ -68,6 +71,9 @@ return 0 if it can find otherwise -1. .Fl r , -resolve does the same and also prints the full path of the service to stdout. +.Pp +.Fl Z , -dry-run +prints out the commands it would execute rather than executing them. .Sh SEE ALSO .Xr openrc 8 , .Xr stdout 3 diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c index 8e7b00dc..77f0336b 100644 --- a/src/rc/rc-service.c +++ b/src/rc/rc-service.c @@ -29,7 +29,7 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "ce:ilr:IN" getoptstring_COMMON; +const char *getoptstring = "ce:ilr:INZ" getoptstring_COMMON; const struct option longopts[] = { { "exists", 1, NULL, 'e' }, { "ifcrashed", 0, NULL, 'c' }, @@ -38,6 +38,7 @@ const struct option longopts[] = { { "ifnotstarted", 0, NULL, 'N' }, { "list", 0, NULL, 'l' }, { "resolve", 1, NULL, 'r' }, + { "dry-run", 0, NULL, 'Z' }, longopts_COMMON }; const char * const longopts_help[] = { @@ -48,6 +49,7 @@ const char * const longopts_help[] = { "if the service is not started then run the command", "list all available services", "resolve the service name to an init script", + "dry run (show what would happen)", longopts_help_COMMON }; const char *usagestring = "" \ @@ -112,6 +114,9 @@ int main(int argc, char **argv) free(service); return EXIT_SUCCESS; /* NOTREACHED */ + case 'Z': + setenv("IN_DRYRUN", "yes", 1); + break; case_RC_COMMON_GETOPT }
[gentoo-commits] proj/openrc:master commit in: mk/
commit: 3c53680018c1799d0d804e241a9fa4d3b9423896 Author: William Hubbs gmail com> AuthorDate: Fri May 11 20:38:27 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri May 11 20:38:27 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3c536800 build: standardize installation modes Gentoo was changing some of our installation modes from 0444 to 0644. There isn't a reason to install things 0444, so we are switching these to 0644 so the Gentoo ebuild doesn't need this extra step. mk/sys.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mk/sys.mk b/mk/sys.mk index db3fb779..92bb55ea 100644 --- a/mk/sys.mk +++ b/mk/sys.mk @@ -45,20 +45,20 @@ SBINDIR?= ${PREFIX}/sbin SBINMODE?= 0755 INCDIR?= ${UPREFIX}/include -INCMODE?= 0444 +INCMODE?= 0644 _LIBNAME_SH= case `readlink /lib` in /lib64|lib64) echo "lib64";; *) echo "lib";; esac _LIBNAME:= $(shell ${_LIBNAME_SH}) LIBNAME?= ${_LIBNAME} LIBDIR?= ${UPREFIX}/${LIBNAME} -LIBMODE?= 0444 +LIBMODE?= 0644 SHLIBDIR?= ${PREFIX}/${LIBNAME} LIBEXECDIR?= ${PREFIX}/libexec/rc MANPREFIX?=${UPREFIX}/share MANDIR?= ${MANPREFIX}/man -MANMODE?= 0444 +MANMODE?= 0644 BASHCOMPDIR?= ${UPREFIX}/share/bash-completion/completions
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: b35e03b6b1acc841ac33f601dd39c1152523621e Author: William Hubbs gmail com> AuthorDate: Fri May 11 00:35:24 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri May 11 00:35:24 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b35e03b6 Revert "Logger: only log printable characters and newlines" This reverts commit 2b1392af2fe9e5dfc8eda2f19d896efdc41840bf. This seems to create issues shutting down, so I need to look into it further. src/rc/rc-logger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c index 1da3f59c..062ce3d9 100644 --- a/src/rc/rc-logger.c +++ b/src/rc/rc-logger.c @@ -87,9 +87,8 @@ write_log(int logfd, const char *buffer, size_t bytes) } if (!in_escape) { - if (isprint((unsigned char) *p) || *p == '\n') - if (write(logfd, p++, 1) == -1) - eerror("write: %s", strerror(errno)); + if (write(logfd, p++, 1) == -1) + eerror("write: %s", strerror(errno)); continue; }
[gentoo-commits] proj/openrc:master commit in: init.d/
commit: f0ad647303daca528cb9b75f9a07d422318635c2 Author: William Hubbs gmail com> AuthorDate: Wed May 9 22:54:18 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri May 11 16:54:48 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f0ad6473 Revert "savecache: stop saving the dependency tree" It is safe to save the deptree, but we also need to regenerate it at boot time. init.d/savecache.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d/savecache.in b/init.d/savecache.in index 949600cd..74f17798 100644 --- a/init.d/savecache.in +++ b/init.d/savecache.in @@ -49,7 +49,7 @@ start() fi ebegin "Saving dependency cache" local rc=0 save= - for x in shutdowntime softlevel rc.log; do + for x in depconfig deptree rc.log shutdowntime softlevel; do [ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x" done if [ -n "$save" ]; then
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 2b1392af2fe9e5dfc8eda2f19d896efdc41840bf Author: William Hubbs gmail com> AuthorDate: Wed May 9 22:30:08 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed May 9 22:30:08 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=2b1392af Logger: only log printable characters and newlines X-Gentoo-Bug: 651412 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651412 src/rc/rc-logger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c index 062ce3d9..1da3f59c 100644 --- a/src/rc/rc-logger.c +++ b/src/rc/rc-logger.c @@ -87,8 +87,9 @@ write_log(int logfd, const char *buffer, size_t bytes) } if (!in_escape) { - if (write(logfd, p++, 1) == -1) - eerror("write: %s", strerror(errno)); + if (isprint((unsigned char) *p) || *p == '\n') + if (write(logfd, p++, 1) == -1) + eerror("write: %s", strerror(errno)); continue; }
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 022b8cbd061ac79b6aed4024220cd0386d2c Author: Andrey Utkin gentoo org> AuthorDate: Sat Apr 21 22:13:15 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed May 2 18:42:59 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=022b start-stop-daemon: don't fail stopping if pidfile is gone If pidfile does not exist when we are stopping the daemon, assume it is already stopped, and report success. hostapd is an example of a daemon which removes its pidfile when it is exiting. If this daemon terminates prematurely, that is, without s-s-d involvement, then openrc fails to restart it, because s-s-d "stop" command fails when pidfile is missing. X-Gentoo-Bug: 646274 X-Gentoo-Bug-URL: https://bugs.gentoo.org/646274 src/rc/start-stop-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 1b565829..0b3b423f 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -661,7 +661,7 @@ int main(int argc, char **argv) parse_schedule(applet, NULL, sig); if (pidfile) { pid = get_pid(applet, pidfile); - if (pid == -1) + if (pid == -1 && errno != ENOENT) exit(EXIT_FAILURE); } else { pid = 0;
[gentoo-commits] proj/openrc:master commit in: man/
commit: 49a90f27a848ba02a363fc0c844d6284728bdd73 Author: William Hubbs gmail com> AuthorDate: Tue Apr 24 15:40:57 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Apr 24 15:40:57 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=49a90f27 typo fix man/openrc-run.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/openrc-run.8 b/man/openrc-run.8 index 426afdcc..f9109ef3 100644 --- a/man/openrc-run.8 +++ b/man/openrc-run.8 @@ -594,7 +594,7 @@ rc_net_tap1_provide="!net" # It's also possible to negate keywords. This is mainly useful for prefix # users testing OpenRC. rc_keyword="!-prefix" -# This can also be used to block a script from runining in all +# This can also be used to block a script from running in all # containers except one or two rc_keyword="!-containers !-docker" .Ed
[gentoo-commits] proj/openrc:master commit in: mk/
commit: f4e2142089487b7f5c99da949d7bf8d038724df7 Author: William Hubbs gmail com> AuthorDate: Tue May 1 18:28:57 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue May 1 18:29:13 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f4e21420 Add _POSIX_C_SOURCE definition to Linux build We need this to allow builds on uclibc-ng based systems. X-Gentoo-Bug: 650908 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=650908 mk/os-Linux.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/os-Linux.mk b/mk/os-Linux.mk index 2479ff5b..9e8a1485 100644 --- a/mk/os-Linux.mk +++ b/mk/os-Linux.mk @@ -11,7 +11,7 @@ SFX= .Linux.in PKG_PREFIX?= /usr -CPPFLAGS+= -D_DEFAULT_SOURCE +CPPFLAGS+= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L LIBDL= -Wl,-Bdynamic -ldl ifeq (${MKSELINUX},yes)
[gentoo-commits] proj/openrc:master commit in: /, init.d/
commit: 6b475ab26992f1dd8815700828df46abc4b71d27 Author: William Hubbs gmail com> AuthorDate: Fri Mar 16 19:33:01 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Mar 16 19:33:01 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6b475ab2 init.d/modules: add code from modules-load service There is no reason for these to be separate services. I did add a provide so that we don't break backward compatibility. NEWS.md| 7 + init.d/Makefile| 4 +-- init.d/modules-load.in | 72 -- init.d/modules.in | 62 +-- 4 files changed, 69 insertions(+), 76 deletions(-) diff --git a/NEWS.md b/NEWS.md index b64d5d8a..f7849093 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,13 @@ OpenRC NEWS This file will contain a list of notable changes for each release. Note the information in this file is in reverse order. +## OpenRC 0.36 + +In this release, the modules-load service has been combined into the +modules service since there is no reason I know of to keep them +separate. However, modules also provides modules-load in case you were +using modules-load in your dependencies. + ## OpenRC 0.35 In this version, the cgroups mounting logic has been moved from the diff --git a/init.d/Makefile b/init.d/Makefile index 9c97e1ed..e18f7a9f 100644 --- a/init.d/Makefile +++ b/init.d/Makefile @@ -19,10 +19,10 @@ SRCS-FreeBSD= hostid.in modules.in moused.in newsyslog.in pf.in rarpd.in \ rc-enabled.in rpcbind.in savecore.in syslogd.in # These are FreeBSD specific SRCS-FreeBSD+= adjkerntz.in devd.in dumpon.in encswap.in ipfw.in \ - modules-load.in mixer.in nscd.in powerd.in syscons.in + mixer.in nscd.in powerd.in syscons.in SRCS-Linux=agetty.in binfmt.in devfs.in cgroups.in dmesg.in hwclock.in \ - consolefont.in keymaps.in killprocs.in modules.in modules-load.in \ + consolefont.in keymaps.in killprocs.in modules.in \ mount-ro.in mtab.in numlock.in procfs.in net-online.in sysfs.in \ termencoding.in diff --git a/init.d/modules-load.in b/init.d/modules-load.in deleted file mode 100644 index f71f704d.. --- a/init.d/modules-load.in +++ /dev/null @@ -1,72 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2016 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -description="Loads a list of modules from systemd-compatible locations." - -depend() -{ - keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver -} - -find_modfiles() -{ - local dirs="/usr/lib/modules-load.d /run/modules-load.d /etc/modules-load.d" - local basenames files fn x y - for x in $dirs; do - [ ! -d $x ] && continue - for y in $x/*.conf; do - [ -f $y ] && basenames="${basenames}\n${y##*/}" - done - done - basenames=$(printf "$basenames" | sort -u) - for x in $basenames; do - for y in $dirs; do - [ -r $y/$x ] && - fn=$y/$x - done - files="$files $fn" - done - echo $files -} - -load_modules() -{ - local file m modules rc x - file=$1 - [ -z "$file" ] && return 0 - while read m x; do - case $m in - \;*) continue ;; - \#*) continue ;; - *) modules="$modules $m" - ;; - esac - done < $file - for x in $modules; do - ebegin "Loading module $x" - case "$RC_UNAME" in - FreeBSD) kldload "$x"; rc=$? ;; - Linux) modprobe --use-blacklist -q "$x"; rc=$? ;; - *) ;; - esac - eend $rc "Failed to load $x" - done -} - -start() -{ - local x - files=$(find_modfiles) - for x in $files; do - load_modules $x - done - return 0 -} diff --git a/init.d/modules.in b/init.d/modules.in index 2eab77f0..d6dd7a29 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -14,10 +14,65 @@ description="Loads a user defined list of kernel modules." depend() { use isapnp - want modules-load + provide modules-load keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver } +find_modfiles() +{ + local dirs="/usr/lib/modules-load.d /run/mo
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 2ae60ca0419d60c86904a8e15e71e902549e18d4 Author: Scall users noreply github com> AuthorDate: Wed Mar 21 12:33:33 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Mar 21 12:33:33 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=2ae60ca0 rc-update: fix typo src/rc/rc-update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c index abe40b88..b0a73609 100644 --- a/src/rc/rc-update.c +++ b/src/rc/rc-update.c @@ -62,7 +62,7 @@ add(const char *runlevel, const char *service) if (!rc_service_exists(service)) { if (errno == ENOEXEC) - eerror("%s: service `%s' is not executeable", + eerror("%s: service `%s' is not executable", applet, service); else eerror("%s: service `%s' does not exist",
[gentoo-commits] proj/openrc:master commit in: /, init.d/
commit: a3d0e293eebcb92564c473e61ca42724844fb279 Author: William Hubbs gmail com> AuthorDate: Mon May 7 23:12:55 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon May 7 23:12:55 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a3d0e293 Remove localmount from dependencies for linux-only services This removes localmount from the dependencies of the consolefont, keymaps, numlock and procfs services. These services are Linux only and the default modern linux system has / and /usr on the same file system. This also fixes the following issue. X-Gentoo-Bug: 651998 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651998 NEWS.md | 7 +++ init.d/consolefont.in | 2 +- init.d/keymaps.in | 2 +- init.d/numlock.in | 1 - init.d/procfs.in | 1 - 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index f7849093..328247da 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,13 @@ modules service since there is no reason I know of to keep them separate. However, modules also provides modules-load in case you were using modules-load in your dependencies. +The consolefont, keymaps, numlock and procfs service scripts no longer +have a dependency on localmount. +If you are a linux user and are still separaating / from /usr, +you will need to add the following line to the appropriate conf.d files: + +rc_need="localmount" + ## OpenRC 0.35 In this version, the cgroups mounting logic has been moved from the diff --git a/init.d/consolefont.in b/init.d/consolefont.in index 9fe95afa..d65dd14c 100644 --- a/init.d/consolefont.in +++ b/init.d/consolefont.in @@ -13,7 +13,7 @@ description="Sets a font for the consoles." depend() { - need localmount termencoding + need termencoding after hotplug bootmisc modules keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } diff --git a/init.d/keymaps.in b/init.d/keymaps.in index 2cc8a39f..4bece821 100644 --- a/init.d/keymaps.in +++ b/init.d/keymaps.in @@ -13,7 +13,7 @@ description="Applies a keymap for the consoles." depend() { - need localmount termencoding + need termencoding after bootmisc clock keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu } diff --git a/init.d/numlock.in b/init.d/numlock.in index 875ffc09..6c33c95f 100644 --- a/init.d/numlock.in +++ b/init.d/numlock.in @@ -15,7 +15,6 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} depend() { - need localmount keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver } diff --git a/init.d/procfs.in b/init.d/procfs.in index 8fed9514..edc8ee19 100644 --- a/init.d/procfs.in +++ b/init.d/procfs.in @@ -16,7 +16,6 @@ depend() after clock use devfs want modules - need localmount keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver }
[gentoo-commits] proj/openrc:master commit in: init.d/
commit: b302b0c094c2c99b810aec9c8877adcd1effabac Author: William Hubbs gmail com> AuthorDate: Fri Mar 16 18:48:05 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Mar 16 18:53:02 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b302b0c0 net-online: always start after net X-Gentoo-Bug: 650600 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=650600 init.d/net-online.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d/net-online.in b/init.d/net-online.in index 484fe87d..b496e258 100644 --- a/init.d/net-online.in +++ b/init.d/net-online.in @@ -13,7 +13,7 @@ description="Delays until the network is online or a specific timeout" depend() { - after modules + after modules net need sysfs provide network-online keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 5346fbf2c90b33b3abc01588e4727d4402f8db62 Author: William Hubbs gmail com> AuthorDate: Thu Mar 15 01:05:45 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Mar 15 01:05:45 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5346fbf2 supervise-daemon: fix off-by-one error src/rc/supervise-daemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 669db3a2..952c610b 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -232,8 +232,8 @@ static char *make_cmdline(char **argv) for (c = argv; c && *c; c++) len += (strlen(*c) + 1); - cmdline = xmalloc(len); - memset(cmdline, 0, len); + cmdline = xmalloc(len+1); + memset(cmdline, 0, len+1); for (c = argv; c && *c; c++) { strcat(cmdline, *c); strcat(cmdline, " ");
[gentoo-commits] proj/openrc:master commit in: init.d/
commit: 40aa69cf3a99fa080375a702631da4d2311ebf3e Author: William Hubbs gmail com> AuthorDate: Thu Mar 15 01:37:02 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Mar 15 01:37:02 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=40aa69cf agetty.in: allow status to be displayed init.d/agetty.in | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/init.d/agetty.in b/init.d/agetty.in index 390b1317..971ee86c 100644 --- a/init.d/agetty.in +++ b/init.d/agetty.in @@ -16,7 +16,6 @@ term_type="${term_type:-linux}" command=/sbin/agetty command_args_foreground="${agetty_options} ${port} ${baud} ${term_type}" pidfile="/run/${RC_SVCNAME}.pid" -export EINFO_QUIET="${quiet:-yes}" depend() { after local @@ -29,5 +28,12 @@ start_pre() { eerror "symbolic links to it for the ports you want to start" eerror "agetty on and add those to the appropriate runlevels." return 1 + else + export EINFO_QUIET="${quiet:-yes}" fi } + +stop_pre() +{ + export EINFO_QUIET="${quiet:-yes}" +}
[gentoo-commits] proj/openrc:master commit in: mk/
commit: 92e6bdee12fa9d87a2535446ceccee261305e87c Author: William Hubbs gmail com> AuthorDate: Wed Mar 14 18:07:46 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Mar 14 18:07:46 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=92e6bdee Use _BSD_SOURCE on FreeBSD mk/os-FreeBSD.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/os-FreeBSD.mk b/mk/os-FreeBSD.mk index f8431bc3..a4b2bfd3 100644 --- a/mk/os-FreeBSD.mk +++ b/mk/os-FreeBSD.mk @@ -12,4 +12,4 @@ include ${MK}/os-BSD.mk -CPPFLAGS+= -D_POSIX_C_SOURCE=200809L +CPPFLAGS+= -D_BSD_SOURCE
[gentoo-commits] proj/openrc:master commit in: mk/
commit: 71f275b2aa04d9a9323a49d1421796c4d50b1436 Author: William Hubbs gmail com> AuthorDate: Wed Mar 14 15:45:40 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Mar 14 15:45:40 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=71f275b2 typo fix mk/os-FreeBSD.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/os-FreeBSD.mk b/mk/os-FreeBSD.mk index 6a567e30..f8431bc3 100644 --- a/mk/os-FreeBSD.mk +++ b/mk/os-FreeBSD.mk @@ -12,4 +12,4 @@ include ${MK}/os-BSD.mk -CPPFLAGS+= -D_POSIX_C_SOURCE=200809 +CPPFLAGS+= -D_POSIX_C_SOURCE=200809L
[gentoo-commits] proj/openrc:master commit in: mk/
commit: 59a9e53378891be7b12ed304ccb609e27da70751 Author: William Hubbs gmail com> AuthorDate: Tue Mar 13 23:03:54 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Mar 13 23:04:54 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=59a9e533 Add _POSIX_C_SOURCE macro to FreeBSD build mk/os-FreeBSD.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/os-FreeBSD.mk b/mk/os-FreeBSD.mk index 4bd1a33a..6a567e30 100644 --- a/mk/os-FreeBSD.mk +++ b/mk/os-FreeBSD.mk @@ -12,4 +12,4 @@ include ${MK}/os-BSD.mk -CPPFLAGS+= -D_WITH_GETLINE +CPPFLAGS+= -D_POSIX_C_SOURCE=200809
[gentoo-commits] proj/openrc:master commit in: mk/
commit: 6dc0d0af333592203fabd4746279bb15d2801c0b Author: William Hubbs gmail com> AuthorDate: Tue Mar 13 23:14:39 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Mar 13 23:14:55 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6dc0d0af Remove _XOPEN_SOURCE macros from builds mk/os-GNU-kFreeBSD.mk | 2 +- mk/os-GNU.mk | 2 +- mk/os-Linux.mk| 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mk/os-GNU-kFreeBSD.mk b/mk/os-GNU-kFreeBSD.mk index 4fc934e0..93b48291 100644 --- a/mk/os-GNU-kFreeBSD.mk +++ b/mk/os-GNU-kFreeBSD.mk @@ -13,6 +13,6 @@ SFX= .GNU-kFreeBSD.in PKG_PREFIX?= /usr -CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=700 +CPPFLAGS+= -D_BSD_SOURCE LIBDL= -Wl,-Bdynamic -ldl LIBKVM?= diff --git a/mk/os-GNU.mk b/mk/os-GNU.mk index d5c4172f..adaefd44 100644 --- a/mk/os-GNU.mk +++ b/mk/os-GNU.mk @@ -11,5 +11,5 @@ SFX= .GNU.in PKG_PREFIX?= /usr -CPPFLAGS+= -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -DMAXPATHLEN=4096 -DPATH_MAX=4096 +CPPFLAGS+= -D_DEFAULT_SOURCE -DMAXPATHLEN=4096 -DPATH_MAX=4096 LIBDL= -Wl,-Bdynamic -ldl diff --git a/mk/os-Linux.mk b/mk/os-Linux.mk index 3a3c5167..2479ff5b 100644 --- a/mk/os-Linux.mk +++ b/mk/os-Linux.mk @@ -11,7 +11,7 @@ SFX= .Linux.in PKG_PREFIX?= /usr -CPPFLAGS+= -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 +CPPFLAGS+= -D_DEFAULT_SOURCE LIBDL= -Wl,-Bdynamic -ldl ifeq (${MKSELINUX},yes)
[gentoo-commits] proj/openrc:master commit in: man/
commit: fa3c60c0d8fd2267be5c1b156530b136a2503088 Author: William Hubbs gmail com> AuthorDate: Mon Mar 12 23:15:06 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Mar 12 23:15:06 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=fa3c60c0 man: document default retry sppecification for start-stop-daemon man/start-stop-daemon.8 | 1 + 1 file changed, 1 insertion(+) diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8 index 1506a1a5..706a12ed 100644 --- a/man/start-stop-daemon.8 +++ b/man/start-stop-daemon.8 @@ -151,6 +151,7 @@ These options are only used for stopping daemons: .It Fl R , -retry Ar timeout | Ar signal Ns / Ns Ar timeout The retry specification can be either a timeout in seconds or multiple signal/timeout pairs (like SIGTERM/5). +If this option is not given, the default is SIGTERM/5. .El .Sh ENVIRONMENT .Va SSD_IONICELEVEL
[gentoo-commits] proj/openrc:master commit in: man/
commit: 122768d339175c925a1a228792f4725b7c802f46 Author: William Hubbs gmail com> AuthorDate: Mon Mar 12 23:22:05 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Mar 12 23:22:40 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=122768d3 man: document default retry specification for supervise-daemon man/supervise-daemon.8 | 1 + 1 file changed, 1 insertion(+) diff --git a/man/supervise-daemon.8 b/man/supervise-daemon.8 index 0d34a249..af06ee31 100644 --- a/man/supervise-daemon.8 +++ b/man/supervise-daemon.8 @@ -120,6 +120,7 @@ description of --respawn-max for more information. .It Fl R , -retry Ar timeout | Ar signal Ns / Ns Ar timeout The retry specification can be either a timeout in seconds or multiple signal/timeout pairs (like SIGTERM/5). +If this option is not given, the default is SIGTERM/5. .It Fl r , -chroot Ar path chroot to this directory before starting the daemon. All other paths, such as the path to the daemon, chdir and pidfile, should be relative to the chroot.
[gentoo-commits] proj/openrc:master commit in: sh/
commit: 61905bfcf560219939c902dbb8fe9bc5088a42cf Author: William Hubbs gmail com> AuthorDate: Mon Mar 12 02:40:57 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Mar 12 02:41:01 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=61905bfc Clean up cgroups v2 code Remove the IFS manipulation and simplify the loop that processes the settings. sh/rc-cgroup.sh.in | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index 5bc7db54..d4b68ada 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -184,18 +184,17 @@ cgroup2_set_limits() cgroup_path="$(cgroup2_find_path)" [ -d "${cgroup_path}" ] || return 0 rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}" - local OIFS="$IFS" - IFS=" -" [ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}" - printf "%d" 0 > "${rc_cgroup_path}/cgroup.procs" - echo "${rc_cgroup_settings}" | while IFS="$OIFS" read -r key value; do - [ -z "${key}" ] || [ -z "${value}" ] && continue - [ ! -e "${rc_cgroup_path}/${key}" ] && continue - veinfo "${RC_SVCNAME}: cgroups: ${key} ${value}" - printf "%s" "${value}" > "${rc_cgroup_path}/${key}" + [ -f "${rc_cgroup_path}"/cgroup.procs ] && + printf 0 > "${rc_cgroup_path}"/cgroup.procs + [ -z "${rc_cgroup_settings}" ] && return 0 + echo "${rc_cgroup_settings}" | while read -r key value; do + [ -z "${key}" ] && continue + [ -z "${value}" ] && continue + [ ! -f "${rc_cgroup_path}/${key}" ] && continue + veinfo "${RC_SVCNAME}: cgroups: setting ${key} to ${value}" + printf "%s\n" "${value}" > "${rc_cgroup_path}/${key}" done - IFS="$OIFS" return 0 }
[gentoo-commits] proj/openrc:master commit in: init.d/
commit: 3e68013631765e00eddf118bc24e38254e7f6d64 Author: Scall users noreply github com> AuthorDate: Tue Mar 6 01:16:26 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Mar 6 01:16:26 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3e680136 init.d: swap should always be started after root Otherwise if a swap file is being used, and swap is started before root, swapon may fail because of a read-only filesystem. init.d/swap.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d/swap.in b/init.d/swap.in index 546cb5f5..c40b263d 100644 --- a/init.d/swap.in +++ b/init.d/swap.in @@ -11,7 +11,7 @@ depend() { - after clock + after clock root before localmount keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver }
[gentoo-commits] proj/openrc:master commit in: mk/
commit: 109869641f7b58d07819f6b65d7b085abf75083b Author: William Hubbs gmail com> AuthorDate: Thu Mar 1 17:47:29 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Mar 1 17:47:29 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=10986964 fix build on FreeBSD mk/os-FreeBSD.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mk/os-FreeBSD.mk b/mk/os-FreeBSD.mk index 0e4fd101..4bd1a33a 100644 --- a/mk/os-FreeBSD.mk +++ b/mk/os-FreeBSD.mk @@ -11,3 +11,5 @@ # Generic definitions include ${MK}/os-BSD.mk + +CPPFLAGS+= -D_WITH_GETLINE
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: b46123f2e19a5eb8dc02b898e8c20a2ccc211615 Author: Chris Cromer users noreply github com> AuthorDate: Fri Mar 2 00:31:33 2018 + Commit: William Hubbs gentoo org> CommitDate: Fri Mar 2 00:31:33 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b46123f2 openrc-run: fix memory size (#213) Fixes #212 src/rc/openrc-run.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c index daeafc52..73def8fb 100644 --- a/src/rc/openrc-run.c +++ b/src/rc/openrc-run.c @@ -1152,7 +1152,7 @@ int main(int argc, char **argv) } lnk = xmalloc(4096); memset(lnk, 0, 4096); - if (readlink(argv[1], lnk, sizeof(lnk)-1)) { + if (readlink(argv[1], lnk, 4096)) { dir = dirname(path); if (strchr(lnk, '/')) { save = xstrdup(dir);
[gentoo-commits] proj/openrc:master commit in: /
commit: e8a2305de0320dc98bf187bb97f936e2dc4a4554 Author: William Hubbs gmail com> AuthorDate: Thu Mar 1 17:46:02 2018 + Commit: William Hubbs gentoo org> CommitDate: Thu Mar 1 17:46:02 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e8a2305d version 0.36 Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index 48a56d98..56545645 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,3 +1,3 @@ NAME= openrc -VERSION= 0.35 +VERSION= 0.36 PKG= ${NAME}-${VERSION}
[gentoo-commits] proj/openrc:master commit in: /
commit: f62975a1f8c4d5d4abdf78d8cad5509216138f03 Author: William Hubbs gmail com> AuthorDate: Wed Feb 28 22:21:52 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Feb 28 22:21:52 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f62975a1 Update ChangeLog ChangeLog | 1162 - 1 file changed, 767 insertions(+), 395 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bee7a44..59ead5ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,770 @@ +commit 5bb6f9aa318a6d0507971b74d88c3fd2803bae4b +Author: Jason Zaman +Commit: William Hubbs + +init.sh: apply SELinux label for /run early in boot + +Some initramfs mount /run which then ends up with the wrong labels. +Force relabel all of /run right after its mounted to fix. + +commit 1ab8541a6ccb9d72c6faeaf2d616fc49f6cdfaf6 +Author: Jason Zaman +Commit: William Hubbs + +init-early.sh.Linux.in: apply the selinux label to /dev/console early + +/dev/console is relabelled later in the devfs init script, but by then we +have already missed some of the messages, so fix that label early. + +commit 038c03bef315314ddb1e460c67d29b2599b494ad +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon: make an error message more verbose + +commit e51dc29e2f3b2718a62347e8588115e786a9f3c8 +Author: William Hubbs +Commit: William Hubbs + +cgroups: fix indentation + +commit c6047f887a362cb8d96624fbd73484ca703acf53 +Author: William Hubbs +Commit: William Hubbs + +cgroups: add rc_cgroup_memory_use_hierarchy setting for cgroups v1 + +commit 0506d68427e342366d826aae4bfbbc6cc0adecc2 +Author: William Hubbs +Commit: William Hubbs + +fstabinfo: fix an error message + +commit c3d666acaf51c771671b0fa54bd8ec0f5d29859e +Author: William Hubbs +Commit: William Hubbs + +openrc: remove unused #define's. + +commit e93b1d76d150c4477015052fc3df9b94647e5b5d +Author: William Hubbs +Commit: William Hubbs + +openrc: convert another execl() call to execlp() + +commit acf1e43f815898c4a4957db352f71f3fb629edf3 +Author: William Hubbs +Commit: William Hubbs + +openrc-init: convert execl calls to execlp + +commit f383fd87b121492a04362ca9041f686d981718f1 +Author: William Hubbs +Commit: William Hubbs + +kill_all: change execl call to execlp + +commit cfded513cd9b7febe4b7cf39a80411e4303f0655 +Author: William Hubbs +Commit: William Hubbs + +openrc-init: set a default path + +The default path provided by the system if one isn't set only includes +"/bin:/usr/bin". This adds the default path setting from sysvinit. + +commit 16ff3cd8df6169f73e3d7cf00758a4703f62cbf0 +Author: Christian Brauner +Commit: William Hubbs + +check whether /sys/fs/cgroup is a mountpoint + +The current check only tries to detect whether /sys/fs/cgroup exists and +whether it is writable or not. But when the init system doesn't mount +cgroups then /sys/fs/cgroup will just be an empty directory. When paired +with unprivileged containers that mount sysfs this will cause misleading +errors to be printed since /sys/fs/cgroup will be owned by user +nobody:nogroup in this case. Independent of this specific problem this +check will also be misleading when the /sys/fs/cgroup exists and is in +fact writable by the init system but isn't actually a mountpoint. + +Note from William. "grep -qs" doesn't need to redirect output to +/dev/null since it is completely silent. + +This fixes #209. + +commit 38032626a6c2f8e869197999f32ac3634667cc86 +Author: William Hubbs +Commit: William Hubbs + +improve cgroup configuration checks + +make the base/controller functions return successfully if cgroups v1/v2 +are not configured in the kernel + +commit aa7d3a7911b658c550e7ce76cd6d7d46541fc323 +Author: William Hubbs +Commit: William Hubbs + +openrc: force deptree update for sysinit runlevel + +commit 98262647a9d2f3c65a7ceb1aaa81095522c1ef06 +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon: zero out the cmdline buffer when it is allocated + +commit 5868abe97babcc287794dcb36ad8e77989b6ddcf +Author: William Hubbs +Commit: William Hubbs + +start-stop-daemon: compiler warning cleanup + +commit 71aad16256604e0e9e146221957a9b00cfe67b99 +Author: William Hubbs +Commit: William Hubbs + +openrc-run: clean up a compiler warning + +commit e275da84de1589253da5ff6a7c272cf1c82f8567 +Author: William Hubbs +Commit: William Hubbs + +supervise-daemon: remove references to PATH_MAX + +commit a6cc7f06cf3807a0e0590697e1f14e6ab9055271 +Author: William Hubbs +Commit: William Hubbs + +rc.c: remove PATH_MAX references + +commit c1178c8eebb92c9f3702e981cd4af9ef41f51884 +Author: William Hubbs +Commit: William Hubbs + +rc-selinux.c: remove references to path_max + +commit 3c031ca9780c555817fe9ccb8b23ceb231129724 +Author: William Hubbs +Commit: Wil
[gentoo-commits] proj/openrc:master commit in: sh/
commit: 1ab8541a6ccb9d72c6faeaf2d616fc49f6cdfaf6 Author: Jason Zaman perfinion com> AuthorDate: Wed Feb 28 17:24:55 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Feb 28 17:24:55 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1ab8541a init-early.sh.Linux.in: apply the selinux label to /dev/console early /dev/console is relabelled later in the devfs init script, but by then we have already missed some of the messages, so fix that label early. sh/init-early.sh.Linux.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sh/init-early.sh.Linux.in b/sh/init-early.sh.Linux.in index 1898c440..f07bc11b 100644 --- a/sh/init-early.sh.Linux.in +++ b/sh/init-early.sh.Linux.in @@ -33,6 +33,9 @@ else kmode="-a" fi +# Set the SELinux label on console before everything so we dont lose output +[ -x /sbin/restorecon ] && /sbin/restorecon -F /dev/console + # Try and set a font and as early as we can if service_present "$RC_DEFAULTLEVEL" consolefont || service_present "$RC_BOOTLEVEL" consolefont; then
[gentoo-commits] proj/openrc:master commit in: sh/
commit: 5bb6f9aa318a6d0507971b74d88c3fd2803bae4b Author: Jason Zaman perfinion com> AuthorDate: Wed Feb 28 18:41:54 2018 + Commit: William Hubbs gentoo org> CommitDate: Wed Feb 28 18:42:58 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5bb6f9aa init.sh: apply SELinux label for /run early in boot Some initramfs mount /run which then ends up with the wrong labels. Force relabel all of /run right after its mounted to fix. sh/init.sh.Linux.in | 1 + 1 file changed, 1 insertion(+) diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in index b07463b3..7ee25b57 100644 --- a/sh/init.sh.Linux.in +++ b/sh/init.sh.Linux.in @@ -83,6 +83,7 @@ elif ! mountinfo -q /run; then fi fi +[ -x /sbin/restorecon ] && /sbin/restorecon -rF /run checkpath -d $RC_SVCDIR checkpath -d -m 0775 -o root:uucp /run/lock
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 038c03bef315314ddb1e460c67d29b2599b494ad Author: William Hubbs gmail com> AuthorDate: Tue Feb 27 22:02:20 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Feb 27 22:02:20 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=038c03be supervise-daemon: make an error message more verbose src/rc/supervise-daemon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 6d36a5aa..669db3a2 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -581,7 +581,8 @@ int main(int argc, char **argv) openlog(applet, LOG_PID, LOG_DAEMON); if (argc >= 1 && svcname && strcmp(argv[1], svcname)) - eerrorx("%s: the first argument must be %s", applet, svcname); + eerrorx("%s: the first argument is %s and must be %s", + applet, argv[1], svcname); if ((tmp = getenv("SSD_NICELEVEL"))) if (sscanf(tmp, "%d", &nicelevel) != 1)
[gentoo-commits] proj/openrc:master commit in: init.d/
commit: e51dc29e2f3b2718a62347e8588115e786a9f3c8 Author: William Hubbs gmail com> AuthorDate: Tue Feb 27 21:56:54 2018 + Commit: William Hubbs gentoo org> CommitDate: Tue Feb 27 21:56:54 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e51dc29e cgroups: fix indentation init.d/cgroups.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d/cgroups.in b/init.d/cgroups.in index 01f5dd48..3d5bfa7b 100644 --- a/init.d/cgroups.in +++ b/init.d/cgroups.in @@ -57,7 +57,7 @@ cgroup1_controllers() mkdir "/sys/fs/cgroup/${name}" mount -n -t cgroup -o "${cgroup_opts},${name}" \ "${name}" "/sys/fs/cgroup/${name}" - yesno "${rc_cgroup_memory_use_hierarchy:-no}" && + yesno "${rc_cgroup_memory_use_hierarchy:-no}" && [ "${name}" = memory ] && echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy ;;
[gentoo-commits] proj/openrc:master commit in: init.d/, etc/
commit: c6047f887a362cb8d96624fbd73484ca703acf53 Author: William Hubbs gmail com> AuthorDate: Mon Feb 26 20:33:15 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Feb 26 20:33:15 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c6047f88 cgroups: add rc_cgroup_memory_use_hierarchy setting for cgroups v1 etc/rc.conf | 5 + init.d/cgroups.in | 3 +++ 2 files changed, 8 insertions(+) diff --git a/etc/rc.conf b/etc/rc.conf index b7296d35..32c905d4 100644 --- a/etc/rc.conf +++ b/etc/rc.conf @@ -227,6 +227,11 @@ rc_tty_number=12 # /sys/fs/cgroup in hybrid or legacy mode. #rc_controller_cgroups="YES" +# The following setting turns on the memory.use_hierarchy setting in the +# root memory cgroup for cgroups v1. +# It must be set to yes in this file if you want this functionality. +#rc_cggroup_memory_use_hierarchy="NO" + # The following settings allow you to set up values for the cgroups version 1 # controllers for your services. # They can be set in this file;, however, if you do this, the settings diff --git a/init.d/cgroups.in b/init.d/cgroups.in index 8ec91ef6..01f5dd48 100644 --- a/init.d/cgroups.in +++ b/init.d/cgroups.in @@ -57,6 +57,9 @@ cgroup1_controllers() mkdir "/sys/fs/cgroup/${name}" mount -n -t cgroup -o "${cgroup_opts},${name}" \ "${name}" "/sys/fs/cgroup/${name}" + yesno "${rc_cgroup_memory_use_hierarchy:-no}" && + [ "${name}" = memory ] && + echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy ;; esac done < /proc/cgroups
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: 0506d68427e342366d826aae4bfbbc6cc0adecc2 Author: William Hubbs gmail com> AuthorDate: Mon Feb 26 19:46:47 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Feb 26 19:46:47 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0506d684 fstabinfo: fix an error message src/rc/fstabinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c index a2e707aa..a35a52f6 100644 --- a/src/rc/fstabinfo.c +++ b/src/rc/fstabinfo.c @@ -141,7 +141,7 @@ do_mount(struct ENT *ent, bool remount) /* NOTREACHED */ case 0: execvp(argv[0], argv); - eerror("%s: execv: %s", applet, strerror(errno)); + eerror("%s: execvp: %s", applet, strerror(errno)); _exit(EXIT_FAILURE); /* NOTREACHED */ default:
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: e93b1d76d150c4477015052fc3df9b94647e5b5d Author: William Hubbs gmail com> AuthorDate: Mon Feb 26 19:13:44 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Feb 26 19:13:44 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e93b1d76 openrc: convert another execl() call to execlp() src/rc/rc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rc/rc.c b/src/rc/rc.c index 3054f6c2..a65f35e1 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -288,8 +288,8 @@ open_shell(void) /* VSERVER systems cannot really drop to shells */ if (sys && strcmp(sys, RC_SYS_VSERVER) == 0) { - execl("/sbin/halt", "/sbin/halt", "-f", (char *) NULL); - eerrorx("%s: unable to exec `/sbin/halt': %s", + execlp("halt", "halt", "-f", (char *) NULL); + eerrorx("%s: unable to exec `halt -f': %s", applet, strerror(errno)); } #endif
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: c3d666acaf51c771671b0fa54bd8ec0f5d29859e Author: William Hubbs gmail com> AuthorDate: Mon Feb 26 19:14:31 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Feb 26 19:14:31 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c3d666ac openrc: remove unused #define's. src/rc/rc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rc/rc.c b/src/rc/rc.c index a65f35e1..f613b5b6 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -78,9 +78,6 @@ const char *usagestring = "" \ #define INITSH RC_LIBEXECDIR "/sh/init.sh" #define INITEARLYSH RC_LIBEXECDIR "/sh/init-early.sh" -#define SHUTDOWN"/sbin/shutdown" -#define SULOGIN "/sbin/sulogin" - #define INTERACTIVE RC_SVCDIR "/interactive" #define DEVBOOT"/dev/.rcboot"
[gentoo-commits] proj/openrc:master commit in: src/rc/
commit: acf1e43f815898c4a4957db352f71f3fb629edf3 Author: William Hubbs gmail com> AuthorDate: Mon Feb 26 18:21:14 2018 + Commit: William Hubbs gentoo org> CommitDate: Mon Feb 26 18:21:14 2018 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=acf1e43f openrc-init: convert execl calls to execlp src/rc/openrc-init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index de570e56..d8038637 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -54,7 +54,7 @@ static pid_t do_openrc(const char *runlevel) sigemptyset(&signals); sigprocmask(SIG_SETMASK, &signals, NULL); printf("Starting %s runlevel\n", runlevel); - execl("/sbin/openrc", "/sbin/openrc", runlevel, NULL); + execlp("openrc", "openrc", runlevel, NULL); perror("exec"); break; default: @@ -89,7 +89,7 @@ static void init(const char *default_runlevel) static void handle_reexec(char *my_name) { - execl(my_name, my_name, "reexec", NULL); + execlp(my_name, my_name, "reexec", NULL); return; }