* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-02-07 8:30 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-02-07 8:30 UTC (permalink / raw
To: gentoo-commits
commit: 04379b2de9cf447e793294c4fe3f0d9b70194ffe
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Feb 7 08:25:00 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 7 08:25:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=04379b2d
fix symlink target
The target for the symlinks in ${SBINDIR} (the same directory as the rc
binary) was "rc". This is not correct; the target should be
${SBINDIR}/rc instead.
---
src/rc/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index cf63cca..5397415 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -79,7 +79,7 @@ install: all
${INSTALL} -d ${DESTDIR}${BINDIR}
$(call make-links,${BINLINKS},${SBINDIR}/${PROG},${DESTDIR}${BINDIR})
${INSTALL} -d ${DESTDIR}${SBINDIR}
- $(call make-links,${SBINLINKS},${PROG},${DESTDIR}${SBINDIR})
+ $(call make-links,${SBINLINKS},${SBINDIR}/${PROG},${DESTDIR}${SBINDIR})
${INSTALL} -d ${DESTDIR}${LINKDIR}/bin
$(call make-links,${RC_BINLINKS},${SBINDIR}/${PROG},${DESTDIR}${LINKDIR}/bin)
${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-02-15 0:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-02-15 0:50 UTC (permalink / raw
To: gentoo-commits
commit: 73d1a8698e101b1dcf589b27b35ac9b09ea6d02c
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 13 01:15:29 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 15 00:40:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=73d1a869
make version option common
This reworks the code for the version option so that it is part of the
parser loop and is a common option to all applets.
---
src/rc/_usage.c | 20 +++++++++++++++++++-
src/rc/_usage.h | 8 ++++++--
src/rc/rc.c | 16 ++--------------
3 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/src/rc/_usage.c b/src/rc/_usage.c
index ec1ce1d..175634a 100644
--- a/src/rc/_usage.c
+++ b/src/rc/_usage.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
* All rights reserved
-
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -24,6 +24,8 @@
* SUCH DAMAGE.
*/
+#include "version.h"
+
#if lint
# define _noreturn
#endif
@@ -34,6 +36,22 @@
#endif
_noreturn static void
+show_version(void)
+{
+ const char *bootlevel = NULL;
+
+ printf("%s (OpenRC", applet);
+ if ((bootlevel = rc_sys()))
+ printf(" [%s]", bootlevel);
+ printf(") %s", VERSION);
+#ifdef BRANDING
+ printf(" (%s)", BRANDING);
+#endif
+ printf("\n");
+ exit(EXIT_SUCCESS);
+}
+
+_noreturn static void
usage(int exit_status)
{
const char * const has_arg[] = { "", "<arg>", "[arg]" };
diff --git a/src/rc/_usage.h b/src/rc/_usage.h
index d65e05e..5e116c9 100644
--- a/src/rc/_usage.h
+++ b/src/rc/_usage.h
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
* All rights reserved
-
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -24,11 +24,12 @@
* SUCH DAMAGE.
*/
-#define getoptstring_COMMON "Chqv"
+#define getoptstring_COMMON "ChqVv"
#define longopts_COMMON \
{ "help", 0, NULL, 'h'}, \
{ "nocolor", 0, NULL, 'C'}, \
+ { "version", 0, NULL, 'V'}, \
{ "verbose", 0, NULL, 'v'}, \
{ "quiet", 0, NULL, 'q'}, \
{ NULL, 0, NULL, 0 }
@@ -36,11 +37,13 @@
#define longopts_help_COMMON \
"Display this help output", \
"Disable color output", \
+ "Display software version", \
"Run verbosely", \
"Run quietly"
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
+#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version();
#define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1);
#define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1);
#define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
@@ -48,6 +51,7 @@
#define case_RC_COMMON_GETOPT \
case 'C': case_RC_COMMON_getopt_case_C; break; \
case 'h': case_RC_COMMON_getopt_case_h; break; \
+ case 'V': case_RC_COMMON_getopt_case_V; break; \
case 'v': case_RC_COMMON_getopt_case_v; break; \
case 'q': case_RC_COMMON_getopt_case_q; break; \
default: case_RC_COMMON_getopt_default; break;
diff --git a/src/rc/rc.c b/src/rc/rc.c
index bdda2ef..525ccdc 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -837,18 +837,6 @@ main(int argc, char **argv)
if (!applet)
eerrorx("arguments required");
- if (argc > 1 && (strcmp(argv[1], "--version") == 0)) {
- printf("%s (OpenRC", applet);
- if ((bootlevel = rc_sys()))
- printf(" [%s]", bootlevel);
- printf(") " VERSION
-#ifdef BRANDING
- " (" BRANDING ")"
-#endif
- "\n");
- exit(EXIT_SUCCESS);
- }
-
/* Run our built in applets. If we ran one, we don't return. */
run_applets(argc, argv);
@@ -905,8 +893,8 @@ main(int argc, char **argv)
}
exit(EXIT_SUCCESS);
/* NOTREACHED */
- case_RC_COMMON_GETOPT
- }
+ case_RC_COMMON_GETOPT
+ }
}
newlevel = argv[optind++];
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-02-16 15:02 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-02-16 15:02 UTC (permalink / raw
To: gentoo-commits
commit: b512d0db98b73bfe2bbeac84c19db039dc256c4f
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 15 14:50:44 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Feb 16 15:00:38 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=b512d0db
new implementation of applet option
This reworks the implementation of the --applet option so that it is
processed in run_applets() and does not require two calls to the
getopts_long() function. It is based on code by Robin Johnson and Chris
Richards.
X-Gentoo-Bug: 351712
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=351712
---
src/rc/rc-applets.c | 11 +++++++++++
src/rc/rc.c | 22 +++++++---------------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index 8381113..6068cb6 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -429,6 +429,17 @@ run_applets(int argc, char **argv)
char *p;
pid_t pid = 0;
+ /* Bug 351712: We need an extra way to explicitly select an applet OTHER
+ * than trusting argv[0], as argv[0] is not going to be the applet value if
+ * we are doing SELinux context switching. For this, we allow calls such as
+ * 'rc --applet APPLET', and shift ALL of argv down by two array items. */
+ if (strcmp(applet, "rc") == 0 && argc >= 3 &&
+ (strcmp(argv[1],"--applet") == 0 || strcmp(argv[1], "-a") == 0)) {
+ applet = argv[2];
+ argv += 2;
+ argc -= 2;
+ }
+
/* These are designed to be applications in their own right */
if (strcmp(applet, "fstabinfo") == 0)
exit(fstabinfo(argc, argv));
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 525ccdc..140667a 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -773,14 +773,16 @@ handle_bad_signal(int sig)
#endif
#include "_usage.h"
-#define getoptstring "o:s:S" getoptstring_COMMON
+#define getoptstring "a:o:s:S" getoptstring_COMMON
static const struct option longopts[] = {
+ { "applet", 1, NULL, 'a' },
{ "override", 1, NULL, 'o' },
{ "service", 1, NULL, 's' },
{ "sys", 0, NULL, 'S' },
longopts_COMMON
};
static const char * const longopts_help[] = {
+ "runs the applet specified by the next argument",
"override the next runlevel to change into\n"
"when leaving single user or boot runlevels",
"runs the service specified with the rest\nof the arguments",
@@ -817,20 +819,6 @@ main(int argc, char **argv)
signal_setup(SIGSEGV, handle_bad_signal);
#endif
- /* Bug 351712: We need an extra way to explicitly select an applet OTHER
- * than trusting argv[0], as argv[0] is not going to be the applet value if
- * we are doing SELinux context switching. For this, we allow calls such as
- * 'rc --applet APPLET', and shift ALL of argv down by two array items. */
- if (strcmp(basename_c(argv[0]), "rc") == 0 && argc > 1 && strcmp(argv[1], "--applet") == 0) {
- if (argc == 2)
- eerrorx("applet argument required");
- for (i = 2; i < argc; i++)
- argv[i - 2] = argv[i];
- argv[argc - 2] = NULL;
- argv[argc - 1] = NULL;
- argc -= 2;
- }
- /* Now we can trust our applet value in argv[0] */
applet = basename_c(argv[0]);
LIST_INIT(&service_pids);
atexit(cleanup);
@@ -858,6 +846,10 @@ main(int argc, char **argv)
longopts, (int *) 0)) != -1)
{
switch (opt) {
+ case 'a':
+ /* Do nothing, actual logic in run_applets, this
+ * is a placeholder */
+ break;
case 'o':
if (*optarg == '\0')
optarg = NULL;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-05-23 19:25 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-05-23 19:25 UTC (permalink / raw
To: gentoo-commits
commit: d59e245bc7edc05e5d7a77df25717029b0710c55
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 18:15:15 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 23 19:23:15 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d59e245b
Fix dirname calls in runscript
runscript will try to get the dir and basename of a file/link in case it
contains at least one slash. This patch gives a temporary copy of the path to
the dirname() function since dirname() can modify its argument.
---
src/rc/runscript.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 0eca487..58eb609 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1101,7 +1101,8 @@ runscript(int argc, char **argv)
bool doneone = false;
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
- char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, pidstr[10];
+ char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, *save2 = NULL;
+ char pidstr[10];
size_t l = 0, ll;
const char *file;
struct stat stbuf;
@@ -1133,7 +1134,8 @@ runscript(int argc, char **argv)
dir = dirname(path);
if (strchr(lnk, '/')) {
save = xstrdup(dir);
- dir = dirname(lnk);
+ save2 = xstrdup(lnk);
+ dir = dirname(save2);
if (strcmp(dir, save) == 0)
file = basename_c(argv[1]);
else
@@ -1149,6 +1151,7 @@ runscript(int argc, char **argv)
service = xstrdup(lnk);
}
free(save);
+ free(save2);
}
if (!service)
service = xstrdup(path);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-05-28 15:42 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2011-05-28 15:42 UTC (permalink / raw
To: gentoo-commits
commit: f8ff4a86a3f24ea49f278c14a9ce5c0dbc8223e2
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat May 28 15:42:49 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat May 28 15:42:49 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f8ff4a86
rc: delete now unused local "i" variable
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/rc.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 140667a..122f53c 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -806,7 +806,6 @@ main(int argc, char **argv)
int opt;
bool parallel;
int regen = 0;
- int i;
#ifdef __linux__
char *proc;
char *p;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-05-28 16:12 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2011-05-28 16:12 UTC (permalink / raw
To: gentoo-commits
commit: 11d8b70d74b339777c7849dc3688244e85587501
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat May 28 16:11:37 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat May 28 16:11:37 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=11d8b70d
rc-update: sort "show" output
X-Gentoo-Bug: 367305
X-Gentoo-Bug-URL: http://bugs.gentoo.org/367305
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/rc-update.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 5517c69..40dfb50 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -164,6 +164,7 @@ show(RC_STRINGLIST *runlevels, bool verbose)
char buffer[PATH_MAX];
size_t l;
+ rc_stringlist_sort(&services);
TAILQ_FOREACH(service, services, entries) {
in = rc_stringlist_new();
inone = false;
@@ -299,6 +300,7 @@ rc_update(int argc, char **argv)
runlevels = rc_runlevel_list();
}
+ rc_stringlist_sort(&runlevels);
show (runlevels, verbose);
} else {
if (!service)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-06-05 14:52 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-06-05 14:52 UTC (permalink / raw
To: gentoo-commits
commit: 4eb37f67cf1edbece52b5617cb763bbd899ab385
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 5 14:49:12 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Jun 5 14:49:12 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=4eb37f67
Warn if deprecated commandline options are used for start-stop-daemon
---
src/rc/start-stop-daemon.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 72b8aff..b5c2b6e 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -791,6 +791,9 @@ start_stop_daemon(int argc, char **argv)
case 'u': /* --user <username>|<uid> */
case 'c': /* --chuid <username>|<uid> */
{
+ /* DEPRECATED */
+ ewarn("WARNING: -c/--chuid is deprecated and will be removed in the future, please use -u/--user instead");
+
p = optarg;
tmp = strsep(&p, ":");
changeuser = xstrdup(tmp);
@@ -867,6 +870,8 @@ start_stop_daemon(int argc, char **argv)
break;
case 'o': /* --oknodo */
+ /* DEPRECATED */
+ ewarn("WARNING: -o/--oknodo is deprecated and will be removed in the future");
oknodo = true;
break;
@@ -887,6 +892,8 @@ start_stop_daemon(int argc, char **argv)
break;
case 'a': /* --startas <name> */
+ /* DEPRECATED */
+ ewarn("WARNING: -a/--startas is deprecated and will be removed in the future, please use -x/--exec or -n/--name instead");
startas = optarg;
break;
case 'w':
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-06-27 21:21 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-06-27 21:21 UTC (permalink / raw
To: gentoo-commits
commit: 24ba7955634dd571a4c34dd712dc8a592eea4d73
Author: Joe Harvell <jharvell <AT> dogpad <DOT> net>
AuthorDate: Mon Jun 27 21:20:47 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Mon Jun 27 21:20:47 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=24ba7955
Only print the deprecation warning for --chuid/-c when using it
The deprecation warning has been printed when using the replecement functions as
well, bug 373243.
---
src/rc/start-stop-daemon.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index b5c2b6e..3017701 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -788,12 +788,11 @@ start_stop_daemon(int argc, char **argv)
background = true;
break;
- case 'u': /* --user <username>|<uid> */
case 'c': /* --chuid <username>|<uid> */
- {
/* DEPRECATED */
ewarn("WARNING: -c/--chuid is deprecated and will be removed in the future, please use -u/--user instead");
-
+ case 'u': /* --user <username>|<uid> */
+ {
p = optarg;
tmp = strsep(&p, ":");
changeuser = xstrdup(tmp);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-06-30 18:21 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-06-30 18:21 UTC (permalink / raw
To: gentoo-commits
commit: 70a3a3cf39f5cf0efa888cf3a2a377ef08fd6f50
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 30 18:13:39 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Jun 30 18:21:48 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=70a3a3cf
Add --startas/-a back to the optstring
X-Gentoo-Bug: 373609
X-Gentoo-Bug-URL: https://bugs.gentoo.org/373609
---
src/rc/start-stop-daemon.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 204b46b..da2a81a 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -599,7 +599,7 @@ expand_home(const char *home, const char *path)
}
#include "_usage.h"
-#define getoptstring "I:KN:PR:Sbc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON
+#define getoptstring "I:KN:PR:Sa:bc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON
static const struct option longopts[] = {
{ "ionice", 1, NULL, 'I'},
{ "stop", 0, NULL, 'K'},
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-07-04 22:54 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-07-04 22:54 UTC (permalink / raw
To: gentoo-commits
commit: 003d4ba15be5f43eb868cf89e8c8c7db46e9dc94
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 4 22:51:29 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Mon Jul 4 22:51:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=003d4ba1
Don't write into optarg, this also fixes a compiler warning.
---
src/rc/runscript.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index a6a8d0e..f62e8dc 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1333,12 +1333,6 @@ runscript(int argc, char **argv)
prefix = NULL;
retval = svc_exec("status", NULL);
} else {
- if (strcmp(optarg, "pause") == 0) {
- ewarn("WARNING: 'pause' is deprecated; please use '--nodeps stop'");
- deps = false;
- optarg = "stop";
- }
-
if (strcmp(optarg, "conditionalrestart") == 0 ||
strcmp(optarg, "condrestart") == 0)
{
@@ -1349,7 +1343,11 @@ runscript(int argc, char **argv)
svc_restart();
} else if (strcmp(optarg, "start") == 0) {
svc_start();
- } else if (strcmp(optarg, "stop") == 0) {
+ } else if (strcmp(optarg, "stop") == 0 || strcmp(optarg, "pause") == 0) {
+ if (strcmp(optarg, "pause") == 0) {
+ ewarn("WARNING: 'pause' is deprecated; please use '--nodeps stop'");
+ deps = false;
+ }
if (deps && in_background)
get_started_services();
svc_stop();
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-07-05 22:52 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-07-05 22:52 UTC (permalink / raw
To: gentoo-commits
commit: 44dc7db4f89382fe198d1115a20d30ceb10cce02
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 5 21:37:07 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Jul 5 21:42:21 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=44dc7db4
Improve logging
Add "e" (O_CLOEXEC) to all fopen() calls.
Remove system() call and replace it by fopen() and friends.
This also fixes bug 368933
X-Gentoo-Bug: 368933
X-Gentoo-Bug-URL: https://bugs.gentoo.org/368933
---
src/rc/rc-logger.c | 54 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 41 insertions(+), 13 deletions(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 6178ba9..593c16f 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -57,10 +57,8 @@
#include "rc.h"
#include "rc-misc.h"
-#define LOGFILE RC_SVCDIR "/rc.log"
-#define PERMLOG "/var/log/rc.log"
-#define MOVELOG "cat " LOGFILE " 2>/dev/null >>" PERMLOG " && " \
- "rm -f " LOGFILE
+#define TMPLOG RC_SVCDIR "/rc.log"
+#define DEFAULTLOG "/var/log/rc.log"
static int signal_pipe[2] = { -1, -1 };
static int fd_stdout = -1;
@@ -149,12 +147,15 @@ rc_logger_open(const char *level)
int slave_tty;
struct termios tt;
struct winsize ws;
- char *buffer;
+ char buffer[BUFSIZ];
struct pollfd fd[2];
int s = 0;
size_t bytes;
int i;
FILE *log = NULL;
+ FILE *plog = NULL;
+ const char *logfile;
+ int log_error = 0;
if (!rc_conf_yesno("rc_logger"))
return;
@@ -192,7 +193,7 @@ rc_logger_open(const char *level)
signal_pipe[1] = -1;
runlevel = level;
- if ((log = fopen(LOGFILE, "a")))
+ if ((log = fopen(TMPLOG, "ae")))
write_time(log, "started");
else {
free(logbuf);
@@ -201,7 +202,6 @@ rc_logger_open(const char *level)
logbuf_len = 0;
}
- buffer = xmalloc(sizeof (char) * BUFSIZ);
fd[0].fd = signal_pipe[0];
fd[0].events = fd[1].events = POLLIN;
fd[0].revents = fd[1].revents = 0;
@@ -242,9 +242,8 @@ rc_logger_open(const char *level)
if (fd[0].revents & (POLLIN | POLLHUP))
break;
}
- free(buffer);
if (logbuf) {
- if ((log = fopen(LOGFILE, "a"))) {
+ if ((log = fopen(TMPLOG, "ae"))) {
write_time(log, "started");
write_log(fileno(log), logbuf, logbuf_len);
}
@@ -255,10 +254,39 @@ rc_logger_open(const char *level)
fclose(log);
}
- /* Try and cat our new logfile to a more permament location
- and then punt it */
- if (system(MOVELOG) == -1)
- eerror("system: %s: %s", MOVELOG, strerror(errno));
+ /* Append the temporary log to the real log */
+ logfile = rc_conf_value("rc_logger_path");
+ if (logfile == NULL)
+ logfile = DEFAULTLOG;
+
+ if ((plog = fopen(logfile, "ae"))) {
+ if ((log = fopen(TMPLOG, "re"))) {
+ while ((bytes = fread(buffer, sizeof(*buffer), BUFSIZ, log)) > 0) {
+ if (fwrite(buffer, sizeof(*buffer), bytes, plog) < bytes) {
+ log_error = 1;
+ eerror("Error: write(%s) failed: %s", logfile, strerror(errno));
+ break;
+ }
+ }
+ } else {
+ log_error = 1;
+ eerror("Error: fopen(%s) failed: %s", TMPLOG, strerror(errno));
+ }
+
+ fclose(log);
+ fclose(plog);
+ } else {
+ log_error = 1;
+ eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
+ }
+
+ /* Try to keep the temporary log in case of errors */
+ if (!log_error) {
+ if (unlink(TMPLOG) == -1)
+ eerror("Error: unlink(%s) failed: %s", TMPLOG, strerror(errno));
+ } else if (exists(TMPLOG))
+ eerrorx("Warning: temporary logfile left behind: %s", TMPLOG);
+
exit(0);
/* NOTREACHED */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-07-20 19:40 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-07-20 19:40 UTC (permalink / raw
To: gentoo-commits
commit: 07694255a4901c33a8ee3ff49701fd49affad2b8
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 20 19:38:55 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jul 20 19:38:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=07694255
rename save and save2 for clarity
The names saveDir and saveLnk seem to better define how these variables
are used.
---
src/rc/runscript.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index f62e8dc..0907ce1 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1100,7 +1100,8 @@ runscript(int argc, char **argv)
bool doneone = false;
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
- char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, *save2 = NULL;
+ char path[PATH_MAX], lnk[PATH_MAX];
+ char *dir, *saveDir = NULL, *saveLnk = NULL;
char pidstr[10];
size_t l = 0, ll;
const char *file;
@@ -1132,14 +1133,14 @@ runscript(int argc, char **argv)
if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
dir = dirname(path);
if (strchr(lnk, '/')) {
- save = xstrdup(dir);
- save2 = xstrdup(lnk);
- dir = dirname(save2);
- if (strcmp(dir, save) == 0)
+ saveDir = xstrdup(dir);
+ saveLnk = xstrdup(lnk);
+ dir = dirname(saveLnk);
+ if (strcmp(dir, saveDir) == 0)
file = basename_c(argv[1]);
else
file = basename_c(lnk);
- dir = save;
+ dir = saveDir;
} else
file = basename_c(argv[1]);
ll = strlen(dir) + strlen(file) + 2;
@@ -1149,8 +1150,8 @@ runscript(int argc, char **argv)
free(service);
service = xstrdup(lnk);
}
- free(save);
- free(save2);
+ free(saveDir);
+ free(saveLnk);
}
if (!service)
service = xstrdup(path);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-07-26 21:59 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-07-26 21:59 UTC (permalink / raw
To: gentoo-commits
commit: 370e5c775a5072583bc57708bbf2c9e0320b8cd8
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 21:58:42 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 21:58:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=370e5c77
runscript: rename saveDir back to save to fix compile error
---
src/rc/runscript.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 0907ce1..02d9e7e 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1101,7 +1101,7 @@ runscript(int argc, char **argv)
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
char path[PATH_MAX], lnk[PATH_MAX];
- char *dir, *saveDir = NULL, *saveLnk = NULL;
+ char *dir, *save = NULL, *saveLnk = NULL;
char pidstr[10];
size_t l = 0, ll;
const char *file;
@@ -1133,14 +1133,14 @@ runscript(int argc, char **argv)
if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
dir = dirname(path);
if (strchr(lnk, '/')) {
- saveDir = xstrdup(dir);
+ save = xstrdup(dir);
saveLnk = xstrdup(lnk);
dir = dirname(saveLnk);
- if (strcmp(dir, saveDir) == 0)
+ if (strcmp(dir, save) == 0)
file = basename_c(argv[1]);
else
file = basename_c(lnk);
- dir = saveDir;
+ dir = save;
} else
file = basename_c(argv[1]);
ll = strlen(dir) + strlen(file) + 2;
@@ -1150,7 +1150,7 @@ runscript(int argc, char **argv)
free(service);
service = xstrdup(lnk);
}
- free(saveDir);
+ free(save);
free(saveLnk);
}
if (!service)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-09-01 22:14 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-09-01 22:14 UTC (permalink / raw
To: gentoo-commits
commit: b71f3bd2fd2ba39c1018baaf2dba74ed53c82cdc
Author: Diego <flameeyes <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 1 22:05:46 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Sep 1 22:08:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=b71f3bd2
Start-stop-daemon: remove call to pam_authenticate
---
src/rc/start-stop-daemon.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index da2a81a..b6316ec 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -1184,8 +1184,6 @@ start_stop_daemon(int argc, char **argv)
"nobody", &conv, &pamh);
if (pamr == PAM_SUCCESS)
- pamr = pam_authenticate(pamh, PAM_SILENT);
- if (pamr == PAM_SUCCESS)
pamr = pam_acct_mgmt(pamh, PAM_SILENT);
if (pamr == PAM_SUCCESS)
pamr = pam_open_session(pamh, PAM_SILENT);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-09-02 16:47 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-09-02 16:47 UTC (permalink / raw
To: gentoo-commits
commit: 6d5b452ef5ef335821bd86eb9ad574acaa774f7b
Author: Flex <frostynova <AT> gmail <DOT> com>
AuthorDate: Fri Sep 2 16:04:23 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Sep 2 16:32:30 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=6d5b452e
Do not ignore return code for custom script functions
X-Gentoo-Bug: 380317
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=380317
---
src/rc/runscript.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 8278f5b..07bcfe7 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1346,7 +1346,7 @@ runscript(int argc, char **argv)
strerror(errno));
unhotplug();
} else
- svc_exec(optarg, NULL);
+ retval = svc_exec(optarg, NULL);
/* We should ensure this list is empty after
* an action is done */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-09-08 17:22 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-09-08 17:22 UTC (permalink / raw
To: gentoo-commits
commit: e2f1464f47588792494686ccb195fe6207ce416f
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 8 17:20:20 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Sep 8 17:20:20 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=e2f1464f
Use the real/actual path when looking for mounts
/proc/mounts contains real/actual paths so we should do the same in mountinfo.
---
src/rc/mountinfo.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 91cb979..5bbee06 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -387,6 +387,7 @@ mountinfo(int argc, char **argv)
regex_t *skip_point_regex = NULL;
RC_STRINGLIST *nodes;
RC_STRING *s;
+ char real_path[PATH_MAX + 1];
int opt;
int result;
bool quiet;
@@ -457,7 +458,10 @@ mountinfo(int argc, char **argv)
if (argv[optind][0] != '/')
eerrorx("%s: `%s' is not a mount point",
argv[0], argv[optind]);
- rc_stringlist_add(args.mounts, argv[optind++]);
+ if (realpath(argv[optind++], real_path) == NULL) {
+ eerrorx("%s: realpath() failed: %s", argv[0], strerror(errno));
+ }
+ rc_stringlist_add(args.mounts, real_path);
}
nodes = find_mounts(&args);
rc_stringlist_free(args.mounts);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-09-08 17:22 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-09-08 17:22 UTC (permalink / raw
To: gentoo-commits
commit: 5df9dc1af534e85236ee72fe24bb31f73aeeb265
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 8 16:42:05 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Sep 8 16:42:05 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=5df9dc1a
Remove unused variable
---
src/rc/runscript.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 07bcfe7..6032c70 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1103,7 +1103,6 @@ runscript(int argc, char **argv)
char *save = NULL;
char pidstr[10];
size_t l = 0, ll;
- const char *file;
struct stat stbuf;
/* Show help if insufficient args */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-11-09 5:10 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2011-11-09 5:10 UTC (permalink / raw
To: gentoo-commits
commit: 16661d02e961f043b89eddd438b1b5dccca83f12
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 9 05:09:58 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Nov 9 05:09:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=16661d02
ssd: fix building when SYS_ioprio_set is missing
Older glibc's might not provide this.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/start-stop-daemon.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index b6316ec..0078c3b 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -107,12 +107,17 @@ static char *changeuser, *ch_root, *ch_dir;
extern char **environ;
-#ifdef __linux__
+#if !defined(SYS_ioprio_set) && defined(__NR_ioprio_set)
+# define SYS_ioprio_set __NR_ioprio_set
+#endif
static inline int ioprio_set(int which, int who, int ioprio)
{
+#ifdef SYS_ioprio_set
return syscall(SYS_ioprio_set, which, who, ioprio);
-}
+#else
+ return 0;
#endif
+}
static void
free_schedulelist(void)
@@ -1150,13 +1155,10 @@ start_stop_daemon(int argc, char **argv)
strerror(errno));
}
-/* Only linux suports setting an IO priority */
-#ifdef __linux__
if (ionicec != -1 &&
ioprio_set(1, mypid, ionicec | ioniced) == -1)
eerrorx("%s: ioprio_set %d %d: %s", applet,
ionicec, ioniced, strerror(errno));
-#endif
if (ch_root && chroot(ch_root) < 0)
eerrorx("%s: chroot `%s': %s",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-11-15 21:26 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-11-15 21:26 UTC (permalink / raw
To: gentoo-commits
commit: 3f2e9c4e1fa5587ec4f7ff07fbc5b5066c2d281e
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 15 20:36:55 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 21:19:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=3f2e9c4e
mountinfo: Do not error out if realpath fails
Reported-By: Dennis Schridde <devurandom <AT> gmx.net>
X-Gentoo-Bug: 383333
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=383333
---
src/rc/mountinfo.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 5bbee06..adce434 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -458,10 +458,10 @@ mountinfo(int argc, char **argv)
if (argv[optind][0] != '/')
eerrorx("%s: `%s' is not a mount point",
argv[0], argv[optind]);
- if (realpath(argv[optind++], real_path) == NULL) {
- eerrorx("%s: realpath() failed: %s", argv[0], strerror(errno));
- }
- rc_stringlist_add(args.mounts, real_path);
+ char *this_path = argv[optind++];
+ if (realpath(this_path, real_path))
+ this_path = real_path;
+ rc_stringlist_add(args.mounts, this_path);
}
nodes = find_mounts(&args);
rc_stringlist_free(args.mounts);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-11-17 22:10 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-11-17 22:10 UTC (permalink / raw
To: gentoo-commits
commit: 66e99b6d637edc33047398b467f2b22bc2f04b60
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 17 22:06:18 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov 17 22:06:18 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=66e99b6d
Fix compile warning
---
src/rc/mountinfo.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index adce434..9382738 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -391,6 +391,7 @@ mountinfo(int argc, char **argv)
int opt;
int result;
bool quiet;
+ char *this_path;
/* Ensure that we are only quiet when explicitly told to be */
unsetenv("EINFO_QUIET");
@@ -458,7 +459,7 @@ mountinfo(int argc, char **argv)
if (argv[optind][0] != '/')
eerrorx("%s: `%s' is not a mount point",
argv[0], argv[optind]);
- char *this_path = argv[optind++];
+ this_path = argv[optind++];
if (realpath(this_path, real_path))
this_path = real_path;
rc_stringlist_add(args.mounts, this_path);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-11-19 8:11 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2011-11-19 8:11 UTC (permalink / raw
To: gentoo-commits
commit: c7cc685458d22b8fd78a9d8be4c0e7d456ff14a1
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 07:33:11 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 07:33:11 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=c7cc6854
rc: fix style around case_RC_COMMON_GETOPT
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/checkpath.c | 2 +-
src/rc/fstabinfo.c | 4 ++--
src/rc/mountinfo.c | 4 ++--
src/rc/rc-depend.c | 2 +-
src/rc/rc-service.c | 4 ++--
src/rc/rc-update.c | 2 +-
src/rc/runscript.c | 2 +-
src/rc/start-stop-daemon.c | 4 ++--
src/rc/swclock.c | 2 +-
9 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 2e3c260..c8bd8ad 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -193,7 +193,7 @@ checkpath(int argc, char **argv)
applet, optarg);
break;
- case_RC_COMMON_GETOPT;
+ case_RC_COMMON_GETOPT
}
}
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index cfbc763..3cf0e02 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -236,8 +236,8 @@ fstabinfo(int argc, char **argv)
}
break;
- case_RC_COMMON_GETOPT
- }
+ case_RC_COMMON_GETOPT
+ }
}
if (optind < argc) {
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 9382738..e5d1d3f 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -451,8 +451,8 @@ mountinfo(int argc, char **argv)
args.mount_type = mount_from;
break;
- case_RC_COMMON_GETOPT
- }
+ case_RC_COMMON_GETOPT
+ }
}
while (optind < argc) {
diff --git a/src/rc/rc-depend.c b/src/rc/rc-depend.c
index af16247..2392e18 100644
--- a/src/rc/rc-depend.c
+++ b/src/rc/rc-depend.c
@@ -173,7 +173,7 @@ rc_depend(int argc, char **argv)
break;
case_RC_COMMON_GETOPT
- }
+ }
}
if (deptree_file) {
diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c
index e47f8b3..2fbdd75 100644
--- a/src/rc/rc-service.c
+++ b/src/rc/rc-service.c
@@ -109,8 +109,8 @@ rc_service(int argc, char **argv)
return EXIT_SUCCESS;
/* NOTREACHED */
- case_RC_COMMON_GETOPT
- }
+ case_RC_COMMON_GETOPT
+ }
}
argc -= optind;
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index d206802..3e51840 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -243,7 +243,7 @@ rc_update(int argc, char **argv)
if (deptree)
rc_deptree_free(deptree);
return ret;
- case_RC_COMMON_GETOPT;
+ case_RC_COMMON_GETOPT
}
verbose = rc_yesno(getenv ("EINFO_VERBOSE"));
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 6032c70..3306500 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1201,7 +1201,7 @@ runscript(int argc, char **argv)
case 'Z':
dry_run = true;
break;
- case_RC_COMMON_GETOPT;
+ case_RC_COMMON_GETOPT
}
/* If we're changing runlevels and not called by rc then we cannot
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 0078c3b..a8a7bd3 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -916,8 +916,8 @@ start_stop_daemon(int argc, char **argv)
redirect_stderr = optarg;
break;
- case_RC_COMMON_GETOPT
- }
+ case_RC_COMMON_GETOPT
+ }
endpwent();
argc -= optind;
diff --git a/src/rc/swclock.c b/src/rc/swclock.c
index 5a92935..0fb518b 100644
--- a/src/rc/swclock.c
+++ b/src/rc/swclock.c
@@ -82,7 +82,7 @@ swclock(int argc, char **argv)
case 'w':
wflag = 1;
break;
- case_RC_COMMON_GETOPT;
+ case_RC_COMMON_GETOPT
}
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-11-19 8:11 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2011-11-19 8:11 UTC (permalink / raw
To: gentoo-commits
commit: c21c1f1e59a9e1fe8dbab22ebbf3f574a591e6ba
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 07:39:08 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 07:42:41 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=c21c1f1e
rc: usage: optimize help string alignment output a little
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/_usage.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/rc/_usage.c b/src/rc/_usage.c
index 1180853..8aa1806 100644
--- a/src/rc/_usage.c
+++ b/src/rc/_usage.c
@@ -75,8 +75,9 @@ usage(int exit_status)
lo = p = xstrdup(longopts_help[i]);
while ((token = strsep(&p, "\n"))) {
- while (++len < 37)
- printf(" ");
+ len = 36 - len;
+ if (len > 0)
+ printf("%*s", len, "");
puts(token);
len = 0;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-11-19 8:11 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2011-11-19 8:11 UTC (permalink / raw
To: gentoo-commits
commit: 453d13296d84472e6317472c2b27015b3ca612c4
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 07:43:25 2011 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 07:43:25 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=453d1329
rc: usage: do not output non-printable short options in usage
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/_usage.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rc/_usage.c b/src/rc/_usage.c
index 8aa1806..96c2d1a 100644
--- a/src/rc/_usage.c
+++ b/src/rc/_usage.c
@@ -24,6 +24,7 @@
*/
#include "version.h"
+#include <ctype.h>
#if lint
# define _noreturn
@@ -59,6 +60,7 @@ usage(int exit_status)
char *lo;
char *p;
char *token;
+ char val[4] = "-?,";
#ifdef usagestring
printf(usagestring);
@@ -70,8 +72,9 @@ usage(int exit_status)
#endif
printf("\n\nOptions: [" getoptstring "]\n");
for (i = 0; longopts[i].name; ++i) {
- len = printf(" -%c, --%s %s", longopts[i].val, longopts[i].name,
- has_arg[longopts[i].has_arg]);
+ val[1] = longopts[i].val;
+ len = printf(" %3s --%s %s", isprint(longopts[i].val) ? val : "",
+ longopts[i].name, has_arg[longopts[i].has_arg]);
lo = p = xstrdup(longopts_help[i]);
while ((token = strsep(&p, "\n"))) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-11 20:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2011-12-11 20:43 UTC (permalink / raw
To: gentoo-commits
commit: e574b5d441564dfccdcd9b09ed538f7b05d678db
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 11 20:33:25 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Dec 11 20:33:39 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=e574b5d4
fix compile error
A variable used in the previous commit was actually removed in another
commit; that is why I didn't catch it.
Reported-by: Duncan < 1i5t5.duncan <AT> cox.net>
X-Gentoo-Bug: 394369
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=394369
---
src/rc/runscript.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index b460cc3..cd53b34 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1104,6 +1104,7 @@ runscript(int argc, char **argv)
char *dir, *save = NULL, *saveLnk = NULL;
char pidstr[10];
size_t l = 0, ll;
+ const char *file;
struct stat stbuf;
/* Show help if insufficient args */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-29 1:50 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-29 1:50 UTC (permalink / raw
To: gentoo-commits
commit: ec65f181eab6289101a0c0df624c9b022f3742d0
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 01:45:04 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 01:50:24 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=ec65f181
Don't print error when the logfile isn't writeable during shutdown
The logfile or its basedir may be read-only during shutdown because the
directory may be umounted or read-only remounted already. In this case we simply
skip this error.
This is related to a comment in bug 390645 but the initial bug is not fixed
through this commit.
X-Gentoo-Bug: 390645
X-Gentoo-Bug-URL: https://bugs.gentoo.org/390645
---
src/rc/rc-logger.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 52c39f0..8f3b218 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -276,8 +276,14 @@ rc_logger_open(const char *level)
fclose(log);
fclose(plog);
} else {
- log_error = 1;
- eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
+ /*
+ * logfile or its basedir may be read-only during shutdown so skip
+ * the error in this case
+ */
+ if (strcmp(rc_runlevel_get(), "shutdown") != 0) {
+ log_error = 1;
+ eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
+ }
}
/* Try to keep the temporary log in case of errors */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-29 2:10 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-29 2:10 UTC (permalink / raw
To: gentoo-commits
commit: b754a27f627ddeab57835761058ee0fd2e1cac42
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:08:29 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:08:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=b754a27f
Remove useless rc_runlevel_get() call
The current runlevel will be passed to rc_logger_open() already.
---
src/rc/rc-logger.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 8f3b218..2b0c6be 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -280,7 +280,7 @@ rc_logger_open(const char *level)
* logfile or its basedir may be read-only during shutdown so skip
* the error in this case
*/
- if (strcmp(rc_runlevel_get(), "shutdown") != 0) {
+ if (strcmp(level, "shutdown") != 0) {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-29 2:18 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-29 2:18 UTC (permalink / raw
To: gentoo-commits
commit: 8dcb7554ee627e9c1062cc1b4ab3bac8fcf89183
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:16:53 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:16:53 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8dcb7554
Use RC_LEVEL_SHUTDOWN
---
src/rc/rc-logger.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 2b0c6be..22d7c72 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -280,7 +280,7 @@ rc_logger_open(const char *level)
* logfile or its basedir may be read-only during shutdown so skip
* the error in this case
*/
- if (strcmp(level, "shutdown") != 0) {
+ if (strcmp(level, RC_LEVEL_SHUTDOWN) != 0) {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-29 12:59 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-29 12:59 UTC (permalink / raw
To: gentoo-commits
commit: 49e99a739361b977b0841c602f10fc9895285197
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 12:55:47 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 12:58:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=49e99a73
Don't try to write the log during sysinit
During the sysinit and shutdown runlevels the logfile destination may be
read-only. Skip the error messages in this case.
X-Gentoo-Bug: 390645
X-Gentoo-Bug-URL: https://bugs.gentoo.org/390645
---
src/rc/rc-logger.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 22d7c72..c085315 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -277,10 +277,10 @@ rc_logger_open(const char *level)
fclose(plog);
} else {
/*
- * logfile or its basedir may be read-only during shutdown so skip
- * the error in this case
+ * logfile or its basedir may be read-only during sysinit and
+ * shutdown so skip the error in this case
*/
- if (strcmp(level, RC_LEVEL_SHUTDOWN) != 0) {
+ if ((strcmp(level, RC_LEVEL_SHUTDOWN) != 0) && (strcmp(level, RC_LEVEL_SYSINIT) != 0)) {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-30 15:03 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-30 15:03 UTC (permalink / raw
To: gentoo-commits
commit: 0d6ae379f43fdab9516e6ed949ba9563972c0c65
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 00:44:15 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Fri Dec 30 15:03:24 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0d6ae379
Compare stricter in proc_getent
The new proc_getent compares stricter so that e.g. "ro" doesn't match
root=/dev/sdaN anymore.
So it has to be either "ro" or "ro=".
---
src/rc/rc.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index ad16f7d..05c99fa 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -173,7 +173,7 @@ proc_getent(const char *ent)
{
FILE *fp;
char *proc, *p, *value = NULL;
- size_t i;
+ size_t i, len;
if (!exists("/proc/cmdline"))
return NULL;
@@ -187,16 +187,25 @@ proc_getent(const char *ent)
i = 0;
if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
eerror("rc_getline: %s", strerror(errno));
- if (*proc && (p = strstr(proc, ent))) {
- i = p - proc;
- if (i == '\0' || proc[i - 1] == ' ') {
- p += strlen(ent);
- if (*p == '=')
- p++;
- value = xstrdup(strsep(&p, " "));
+
+ if(proc != NULL) {
+ len = strlen(ent);
+
+ while((p = strsep(&proc, " "))) {
+ if(strncmp(ent, p, len) == 0 && (p[len] == '\0' || p[len] == ' ' || p[len] == '=')) {
+ p += len;
+
+ if (*p == '=')
+ p++;
+
+ value = xstrdup(p);
+ }
}
- } else
+ }
+
+ if(!value)
errno = ENOENT;
+
fclose(fp);
free(proc);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-30 15:03 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-30 15:03 UTC (permalink / raw
To: gentoo-commits
commit: 372745844b422a0898599cb4019e29dc9f909e6f
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 15:02:44 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Fri Dec 30 15:03:24 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=37274584
Code style fixes
---
src/rc/rc.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 05c99fa..9ee3047 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -188,11 +188,11 @@ proc_getent(const char *ent)
if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
eerror("rc_getline: %s", strerror(errno));
- if(proc != NULL) {
+ if (proc != NULL) {
len = strlen(ent);
- while((p = strsep(&proc, " "))) {
- if(strncmp(ent, p, len) == 0 && (p[len] == '\0' || p[len] == ' ' || p[len] == '=')) {
+ while ((p = strsep(&proc, " "))) {
+ if (strncmp(ent, p, len) == 0 && (p[len] == '\0' || p[len] == ' ' || p[len] == '=')) {
p += len;
if (*p == '=')
@@ -203,7 +203,7 @@ proc_getent(const char *ent)
}
}
- if(!value)
+ if (!value)
errno = ENOENT;
fclose(fp);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2011-12-31 2:36 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2011-12-31 2:36 UTC (permalink / raw
To: gentoo-commits
commit: 34b7632d1d2ed38c7251ac8c2869c8fc416a99f5
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 31 02:35:32 2011 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 02:35:32 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=34b7632d
Do not exit immediately when a service has been stopped already
The old behaviour was to exit(EXIT_SUCCESS) in case the service has been stopped
already, even if further commands has been passed to the init script
(like zap, start).
So using for example /etc/init.d/foo stop zap start would abort immediately
after "stop" if the service has been stopped already. Though there may be cases
were we need it to proceed with the remaining commands, zap and start in this
case.
This patch fixes the behaviour to continue and proceed with the remaining
commands whenever necessary.
X-Gentoo-Bug: 371845
X-Gentoo-Bug-URL: https://bugs.gentoo.org/371845
---
src/rc/runscript.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index cd53b34..2f66971 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -821,7 +821,7 @@ svc_start(void)
svc_start_real();
}
-static void
+static int
svc_stop_check(RC_SERVICE *state)
{
*state = rc_service_state(service);
@@ -848,7 +848,7 @@ svc_stop_check(RC_SERVICE *state)
if (*state & RC_SERVICE_STOPPED) {
ewarn("WARNING: %s is already stopped", applet);
- exit(EXIT_SUCCESS);
+ return 1;
}
rc_service_mark(service, RC_SERVICE_STOPPING);
@@ -861,6 +861,8 @@ svc_stop_check(RC_SERVICE *state)
else if (rc_service_in_runlevel(service, RC_LEVEL_BOOT))
ewarn("WARNING: you are stopping a boot service");
}
+
+ return 0;
}
static void
@@ -986,7 +988,7 @@ svc_stop_real(void)
rc_plugin_run(RC_HOOK_SERVICE_STOP_OUT, applet);
}
-static void
+static int
svc_stop(void)
{
RC_SERVICE state;
@@ -995,13 +997,16 @@ svc_stop(void)
if (dry_run)
einfon("stop:");
else
- svc_stop_check(&state);
+ if (svc_stop_check(&state) == 1)
+ return 1; /* Service has been stopped already */
if (deps)
svc_stop_deps(state);
if (dry_run)
printf(" %s\n", applet);
else
svc_stop_real();
+
+ return 0;
}
static void
@@ -1351,7 +1356,8 @@ runscript(int argc, char **argv)
}
if (deps && in_background)
get_started_services();
- svc_stop();
+ if (svc_stop() == 1)
+ continue; /* Service has been stopped already */
if (deps) {
if (!in_background &&
!rc_runlevel_stopping() &&
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-22 20:46 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-01-22 20:46 UTC (permalink / raw
To: gentoo-commits
commit: 30a565f80d6056ccabadf77e347cf17067133f7e
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 22 20:15:46 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jan 22 20:41:47 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=30a565f8
Drop include for features.h
The following information is taken from the feature_test_macros man
page:
<features.h> is a Linux/glibc-specific header file. Other systems have
an analogous file, but typically with a different name. This header
file is automatically included by other header files as required: it is
not necessary to explicitly include it in order to employ feature test
macros.
Reported-by: Tibor Vago <tibor.vago <AT> gmail.com>
X-Gentoo-Bug: 399635
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=399635
---
src/rc/checkpath.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 4ad4ea7..2afbe90 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -32,7 +32,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <features.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-23 5:27 Robin H. Johnson
0 siblings, 0 replies; 257+ messages in thread
From: Robin H. Johnson @ 2012-01-23 5:27 UTC (permalink / raw
To: gentoo-commits
commit: 319f5003c66130fac091fa2f86070ea9f0a43cb8
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 23 05:24:54 2012 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 23 05:24:54 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=319f5003
Revert "Drop include for features.h"
This reverts commit 30a565f80d6056ccabadf77e347cf17067133f7e.
---
src/rc/checkpath.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 2afbe90..4ad4ea7 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <features.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-23 10:27 Robin H. Johnson
0 siblings, 0 replies; 257+ messages in thread
From: Robin H. Johnson @ 2012-01-23 10:27 UTC (permalink / raw
To: gentoo-commits
commit: 06b8084b2cf9308fe0cbbcdde0741a881b7609fb
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 23 05:30:00 2012 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 23 05:30:00 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=06b8084b
Ensure that when -F is passed, existing files are truncated properly.
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
---
src/rc/checkpath.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 0aee446..86623d9 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -61,7 +61,7 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc
struct stat st;
int fd, flags;
- if (stat(path, &st)) {
+ if (stat(path, &st) || trunc) {
if (type == inode_file) {
einfo("%s: creating file", path);
if (!mode) /* 664 */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-23 10:27 Robin H. Johnson
0 siblings, 0 replies; 257+ messages in thread
From: Robin H. Johnson @ 2012-01-23 10:27 UTC (permalink / raw
To: gentoo-commits
commit: 426b94bd696933a72d8623fa1325b3562096957d
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 23 10:26:58 2012 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 23 10:26:58 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=426b94bd
Per the systemd tmpfiles implementation, we need to watch out for umask during initial creation of files as well as potentially changing permissions later. Also do not abort if the items exist already, per truncate rules in tmpfiles.
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
---
src/rc/checkpath.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 86623d9..b0914f3 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -55,11 +55,17 @@ typedef enum {
extern const char *applet;
+/* TODO: SELinux
+ * This needs a LOT of SELinux loving
+ * See systemd's src/label.c:label_mkdir
+ */
static int
do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc)
{
struct stat st;
int fd, flags;
+ int r;
+ int u;
if (stat(path, &st) || trunc) {
if (type == inode_file) {
@@ -75,7 +81,10 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc
#endif
if (trunc)
flags |= O_TRUNC;
- if ((fd = open(path, flags, mode)) == -1) {
+ u = umask(0);
+ fd = open(path, flags, mode);
+ umask(u);
+ if (fd == -1) {
eerror("%s: open: %s", applet, strerror(errno));
return -1;
}
@@ -84,7 +93,11 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc
einfo("%s: creating directory", path);
if (!mode) /* 775 */
mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
- if (mkdir(path, mode) == -1) {
+ u = umask(0);
+ /* We do not recursively create parents */
+ r = mkdir(path, mode);
+ umask(u);
+ if (r == -1 && errno != EEXIST) {
eerror("%s: mkdir: %s", applet,
strerror (errno));
return -1;
@@ -94,7 +107,10 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc
einfo("%s: creating fifo", path);
if (!mode) /* 600 */
mode = S_IRUSR | S_IWUSR;
- if (mkfifo(path, mode) == -1) {
+ u = umask(0);
+ r = mkfifo(path, mode);
+ umask(u);
+ if (r == -1 && errno != EEXIST) {
eerror("%s: mkfifo: %s", applet,
strerror (errno));
return -1;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-24 18:41 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-01-24 18:41 UTC (permalink / raw
To: gentoo-commits
commit: 8b4fc05ff2645b2ecb0f153492f72dd8b39ba431
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 24 18:41:20 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Jan 24 18:41:50 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8b4fc05f
Disable parallel startup in interactive mode
---
src/rc/rc.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index f284c2e..662062e 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -667,6 +667,7 @@ do_start_services(bool parallel)
interactive = want_interactive();
if (interactive) {
+ parallel = false;
interactive_retry:
printf("\n");
einfo("About to start the service %s",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-28 15:45 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-01-28 15:45 UTC (permalink / raw
To: gentoo-commits
commit: 6be8a0679b8d64ea5b99ea98839eab2ce129988b
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 28 15:40:49 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Jan 28 15:43:54 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=6be8a067
Do not loop flock()
There's no need to loop until flock was successfully as flock() would simply
block till a previous lock has been released.
There's more to do to fix it properly, see my comments in the patch.
Reported-by: James Le Cuirot <chewi <AT> aura-online.co.uk>
X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: https://bugs.gentoo.org/360013
---
src/rc/runscript.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 8e0ced9..b0d8084 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -288,6 +288,13 @@ cleanup(void)
#endif
}
+/* Buffer and lock all output messages so that we get readable content */
+/* FIXME: Use a dynamic lock file that contains the tty/pts as well.
+ * For example openrc-pts8.lock or openrc-tty1.lock.
+ * Using a static lock file makes no sense, esp. in multi-user environments.
+ * Why don't we use (f)printf, as it is thread-safe through POSIX already?
+ * Bug: 360013
+ */
static int
write_prefix(const char *buffer, size_t bytes, bool *prefixed)
{
@@ -297,14 +304,20 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed)
ssize_t ret = 0;
int fd = fileno(stdout), lock_fd = -1;
- /* Spin until we lock the prefix */
- for (;;) {
- lock_fd = open(PREFIX_LOCK, O_WRONLY | O_CREAT, 0664);
- if (lock_fd != -1)
- if (flock(lock_fd, LOCK_EX) == 0)
- break;
- close(lock_fd);
+ /*
+ * Lock the prefix.
+ * open() may fail here when running as user, as RC_SVCDIR may not be writable.
+ */
+ lock_fd = open(PREFIX_LOCK, O_WRONLY | O_CREAT, 0664);
+
+ if (lock_fd != -1) {
+ if (flock(lock_fd, LOCK_EX) != 0)
+ eerror("flock() failed: %s", strerror(errno));
}
+#ifdef RC_DEBUG
+ else
+ ewarn("Couldn't open the prefix lock, please make sure you have enough permissions");
+#endif
for (i = 0; i < bytes; i++) {
/* We don't prefix eend calls (cursor up) */
@@ -332,6 +345,7 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed)
/* Release the lock */
close(lock_fd);
+
return ret;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-28 18:05 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-01-28 18:05 UTC (permalink / raw
To: gentoo-commits
commit: 2d2751c4331a0204c4f7f6c4dd3994f34e0a4d47
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 28 17:56:29 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Jan 28 17:59:16 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=2d2751c4
Do not unlink the temp. log during shutdown
Also ignore errors in case of EROFS (Read-Only file systems)
Reported-by: Maxim Kammerer
X-Gentoo-Bug: 401115
X-Gentoo-Bug-URL: https://bugs.gentoo.org/401115
---
src/rc/rc-logger.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index c085315..468225f 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -280,7 +280,7 @@ rc_logger_open(const char *level)
* logfile or its basedir may be read-only during sysinit and
* shutdown so skip the error in this case
*/
- if ((strcmp(level, RC_LEVEL_SHUTDOWN) != 0) && (strcmp(level, RC_LEVEL_SYSINIT) != 0)) {
+ if (errno != EROFS && ((strcmp(level, RC_LEVEL_SHUTDOWN) != 0) && (strcmp(level, RC_LEVEL_SYSINIT) != 0))) {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
}
@@ -288,8 +288,9 @@ rc_logger_open(const char *level)
/* Try to keep the temporary log in case of errors */
if (!log_error) {
- if (unlink(TMPLOG) == -1)
- eerror("Error: unlink(%s) failed: %s", TMPLOG, strerror(errno));
+ if (errno != EROFS && ((strcmp(level, RC_LEVEL_SHUTDOWN) != 0) && (strcmp(level, RC_LEVEL_SYSINIT) != 0)))
+ if (unlink(TMPLOG) == -1)
+ eerror("Error: unlink(%s) failed: %s", TMPLOG, strerror(errno));
} else if (exists(TMPLOG))
eerrorx("Warning: temporary logfile left behind: %s", TMPLOG);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-01-31 22:59 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-01-31 22:59 UTC (permalink / raw
To: gentoo-commits
commit: 0fcc6251fcde9c722207afa6f953aea7e80d771b
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 31 16:56:57 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 31 22:33:05 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0fcc6251
fstabinfo: add --remount option
This adds a --remount/-R option to fstabinfo. This new option works like
--mount, but it adds the necessary options to remount a file system
that is already mounted.
Reported-by: Piotr Karbowski <piotr.karbowski <AT> gmail.com>
X-Gentoo-Bug: 401573
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401573
---
src/rc/fstabinfo.c | 39 ++++++++++++++++++++++++++++++++-------
1 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 3cf0e02..91f2a56 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -93,9 +93,9 @@ getmntfile(const char *file)
extern const char *applet;
static int
-do_mount(struct ENT *ent)
+do_mount(struct ENT *ent, bool remount)
{
- char *argv[8];
+ char *argv[10];
pid_t pid;
int status;
@@ -104,9 +104,24 @@ do_mount(struct ENT *ent)
argv[2] = ENT_OPTS(*ent);
argv[3] = UNCONST("-t");
argv[4] = ENT_TYPE(*ent);
- argv[5] = ENT_BLOCKDEVICE(*ent);
- argv[6] = ENT_FILE(*ent);
- argv[7] = NULL;
+ if (!remount) {
+ argv[5] = ENT_BLOCKDEVICE(*ent);
+ argv[6] = ENT_FILE(*ent);
+ argv[7] = NULL;
+ } else {
+#ifdef __linux__
+ argv[5] = UNCONST("-o");
+ argv[6] = UNCONST("remount");
+ argv[7] = ENT_BLOCKDEVICE(*ent);
+ argv[8] = ENT_FILE(*ent);
+ argv[9] = NULL;
+#else
+ argv[5] = UNCONST("-u");
+ argv[6] = ENT_BLOCKDEVICE(*ent);
+ argv[7] = ENT_FILE(*ent);
+ argv[8] = NULL;
+#endif
+ }
switch (pid = vfork()) {
case -1:
eerrorx("%s: vfork: %s", applet, strerror(errno));
@@ -127,9 +142,10 @@ do_mount(struct ENT *ent)
}
#include "_usage.h"
-#define getoptstring "Mbmop:t:" getoptstring_COMMON
+#define getoptstring "MRbmop:t:" getoptstring_COMMON
static const struct option longopts[] = {
{ "mount", 0, NULL, 'M' },
+ { "remount", 0, NULL, 'R' },
{ "blockdevice", 0, NULL, 'b' },
{ "mountargs", 0, NULL, 'm' },
{ "options", 0, NULL, 'o' },
@@ -139,6 +155,7 @@ static const struct option longopts[] = {
};
static const char * const longopts_help[] = {
"Mounts the filesytem from the mountpoint",
+ "Remounts the filesystem based on the information in fstab",
"Extract the block device",
"Show arguments needed to mount the entry",
"Extract the options field",
@@ -154,6 +171,7 @@ static const char * const longopts_help[] = {
#define OUTPUT_PASSNO (1 << 4)
#define OUTPUT_BLOCKDEV (1 << 5)
#define OUTPUT_MOUNT (1 << 6)
+#define OUTPUT_REMOUNT (1 << 7)
int
fstabinfo(int argc, char **argv)
@@ -182,6 +200,9 @@ fstabinfo(int argc, char **argv)
case 'M':
output = OUTPUT_MOUNT;
break;
+ case 'R':
+ output = OUTPUT_REMOUNT;
+ break;
case 'b':
output = OUTPUT_BLOCKDEV;
break;
@@ -287,7 +308,11 @@ fstabinfo(int argc, char **argv)
break;
case OUTPUT_MOUNT:
- result += do_mount(ent);
+ result += do_mount(ent, false);
+ break;
+
+ case OUTPUT_REMOUNT:
+ result += do_mount(ent, true);
break;
case OUTPUT_MOUNTARGS:
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-02-10 23:25 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-02-10 23:25 UTC (permalink / raw
To: gentoo-commits
commit: 8c55f1e50da45286b35d611c3c3a823e3446c2b8
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 10 23:24:10 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Fri Feb 10 23:24:46 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8c55f1e5
Remove unused/useless function single_user()
---
src/rc/rc.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 662062e..612cad0 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -306,15 +306,6 @@ open_shell(void)
run_program(shell);
}
-_dead static void
-single_user(void)
-{
- rc_logger_close();
- execl(SHUTDOWN, SHUTDOWN, "now", (char *) NULL);
- eerrorx("%s: unable to exec `" SHUTDOWN "': %s",
- applet, strerror(errno));
-}
-
static bool
set_krunlevel(const char *level)
{
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-02-12 1:23 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-02-12 1:23 UTC (permalink / raw
To: gentoo-commits
commit: d9dc5dc42314368a65579967c02af4945cb8c312
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 12 01:23:04 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Feb 12 01:23:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d9dc5dc4
Use size_t instead of int
---
src/rc/rc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 612cad0..77d2c6d 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -333,11 +333,11 @@ set_krunlevel(const char *level)
return true;
}
-static int
+static size_t
get_krunlevel(char *buffer, int buffer_len)
{
FILE *fp;
- int i = 0;
+ size_t i = 0;
if (!exists(RC_KRUNLEVEL))
return 0;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-02-21 1:08 Jory Pratt
0 siblings, 0 replies; 257+ messages in thread
From: Jory Pratt @ 2012-02-21 1:08 UTC (permalink / raw
To: gentoo-commits
commit: 3c602e7422019430737cbf67f26f9cc30fb00f87
Author: Jory A. Pratt <anarchy <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 21 01:07:54 2012 +0000
Commit: Jory Pratt <anarchy <AT> gentoo <DOT> org>
CommitDate: Tue Feb 21 01:07:54 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=3c602e74
remove the warning about falling back to autodetection
---
src/rc/rc.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 77d2c6d..40b6293 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -831,7 +831,6 @@ main(int argc, char **argv)
if (bootlevel)
printf("%s\n", bootlevel);
} else {
- ewarn("WARNING: rc_sys not defined in rc.conf. Falling back to automatic detection");
bootlevel = rc_sys_v1();
if (bootlevel)
printf("%s\n", bootlevel);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-02-21 2:09 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-02-21 2:09 UTC (permalink / raw
To: gentoo-commits
commit: 04db6c3d39f1c2e81e7d6d98f17388e2003bc17f
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 21 02:04:57 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 21 02:04:57 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=04db6c3d
rc: remove calls to rc_sys_v2 and rc_sys_v1
These separate calls are no longer needed since we do not warn about
falling back to automatic detection.
---
src/rc/rc.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 40b6293..4cf0374 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -826,15 +826,9 @@ main(int argc, char **argv)
eerrorx("%s: %s", applet, strerror(errno));
/* NOTREACHED */
case 'S':
- if (rc_conf_value("rc_sys")) {
- bootlevel = rc_sys_v2();
- if (bootlevel)
- printf("%s\n", bootlevel);
- } else {
- bootlevel = rc_sys_v1();
- if (bootlevel)
- printf("%s\n", bootlevel);
- }
+ bootlevel = rc_sys();
+ if (bootlevel)
+ printf("%s\n", bootlevel);
exit(EXIT_SUCCESS);
/* NOTREACHED */
case_RC_COMMON_GETOPT
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-02-24 2:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-02-24 2:38 UTC (permalink / raw
To: gentoo-commits
commit: 3272261479c2a3ed860f71523497f5662ada55eb
Author: William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 23 22:47:52 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 23 22:47:52 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=32722614
Skip pam if running as root
Reported-by: Piotr Karbowski <piotr.karbowski <AT> gmail.com>
X-Gentoo-Bug: 386623
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=386623
---
src/rc/start-stop-daemon.c | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index a8a7bd3..965b331 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -1178,20 +1178,18 @@ start_stop_daemon(int argc, char **argv)
}
#ifdef HAVE_PAM
- if (changeuser != NULL)
+ if (changeuser != NULL) {
pamr = pam_start("start-stop-daemon",
changeuser, &conv, &pamh);
- else
- pamr = pam_start("start-stop-daemon",
- "nobody", &conv, &pamh);
-
- if (pamr == PAM_SUCCESS)
- pamr = pam_acct_mgmt(pamh, PAM_SILENT);
- if (pamr == PAM_SUCCESS)
- pamr = pam_open_session(pamh, PAM_SILENT);
- if (pamr != PAM_SUCCESS)
- eerrorx("%s: pam error: %s",
- applet, pam_strerror(pamh, pamr));
+
+ if (pamr == PAM_SUCCESS)
+ pamr = pam_acct_mgmt(pamh, PAM_SILENT);
+ if (pamr == PAM_SUCCESS)
+ pamr = pam_open_session(pamh, PAM_SILENT);
+ if (pamr != PAM_SUCCESS)
+ eerrorx("%s: pam error: %s",
+ applet, pam_strerror(pamh, pamr));
+ }
#endif
if (gid && setgid(gid))
@@ -1219,15 +1217,17 @@ start_stop_daemon(int argc, char **argv)
rc_stringlist_add(env_list, environ[i++]);
#ifdef HAVE_PAM
- pamenv = (const char *const *)pam_getenvlist(pamh);
- if (pamenv) {
- while (*pamenv) {
- /* Don't add strings unless they set a var */
- if (strchr(*pamenv, '='))
- putenv(xstrdup(*pamenv));
- else
- unsetenv(*pamenv);
- pamenv++;
+ if (changeuser != NULL) {
+ pamenv = (const char *const *)pam_getenvlist(pamh);
+ if (pamenv) {
+ while (*pamenv) {
+ /* Don't add strings unless they set a var */
+ if (strchr(*pamenv, '='))
+ putenv(xstrdup(*pamenv));
+ else
+ unsetenv(*pamenv);
+ pamenv++;
+ }
}
}
#endif
@@ -1304,7 +1304,7 @@ start_stop_daemon(int argc, char **argv)
setsid();
execvp(exec, argv);
#ifdef HAVE_PAM
- if (pamr == PAM_SUCCESS)
+ if (changeuser != NULL && pamr == PAM_SUCCESS)
pam_close_session(pamh, PAM_SILENT);
#endif
eerrorx("%s: failed to exec `%s': %s",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-04-24 3:32 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-04-24 3:32 UTC (permalink / raw
To: gentoo-commits
commit: 1f5072421e07ec6e6af7efbf339f3b9840494e52
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 24 01:49:04 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Apr 24 01:49:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=1f507242
Remove duplicate getenv("RC_SVCNAME") call
---
src/rc/rc-applets.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index fe12515..865b77e 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -322,7 +322,7 @@ do_mark_service(int argc, char **argv)
if (argc > 1)
service = argv[1];
else
- service = getenv("RC_SVCNAME");
+ service = svcname;
if (service == NULL || *service == '\0')
eerrorx("%s: no service specified", applet);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-05-06 5:16 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2012-05-06 5:16 UTC (permalink / raw
To: gentoo-commits
commit: 2486eb4989918ff5ef645f2a17fedbec559b9485
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun May 6 00:28:28 2012 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun May 6 05:17:30 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=2486eb49
rc: collapse the applet if statements into a single array walk
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/rc-applets.c | 240 ++++++++++++++++++++++++++++-----------------------
1 files changed, 133 insertions(+), 107 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index 5d02682..21562f0 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -253,13 +253,38 @@ do_e(int argc, char **argv)
return retval;
}
+static const struct {
+ const char * const name;
+ RC_SERVICE bit;
+} service_bits[] = {
+ { "service_started", RC_SERVICE_STARTED, },
+ { "service_stopped", RC_SERVICE_STOPPED, },
+ { "service_inactive", RC_SERVICE_INACTIVE, },
+ { "service_starting", RC_SERVICE_STARTING, },
+ { "service_stopping", RC_SERVICE_STOPPING, },
+ { "service_hotplugged", RC_SERVICE_HOTPLUGGED, },
+ { "service_wasinactive", RC_SERVICE_WASINACTIVE, },
+ { "service_failed", RC_SERVICE_FAILED, },
+};
+
+static RC_SERVICE
+lookup_service_state(const char *service)
+{
+ size_t i;
+ for (i = 0; i < ARRAY_SIZE(service_bits); ++i)
+ if (!strcmp(service, service_bits[i].name))
+ return service_bits[i].bit;
+ return 0;
+}
+
static int
do_service(int argc, char **argv)
{
bool ok = false;
char *service;
char *exec;
- int idx = 0;
+ int idx;
+ RC_SERVICE state, bit;
if (argc > 1)
service = argv[1];
@@ -269,21 +294,11 @@ do_service(int argc, char **argv)
if (service == NULL || *service == '\0')
eerrorx("%s: no service specified", applet);
- if (strcmp(applet, "service_started") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_STARTED);
- else if (strcmp(applet, "service_stopped") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_STOPPED);
- else if (strcmp(applet, "service_inactive") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_INACTIVE);
- else if (strcmp(applet, "service_starting") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_STARTING);
- else if (strcmp(applet, "service_stopping") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_STOPPING);
- else if (strcmp(applet, "service_hotplugged") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_HOTPLUGGED);
- else if (strcmp(applet, "service_wasinactive") == 0)
- ok = (rc_service_state(service) & RC_SERVICE_WASINACTIVE);
- else if (strcmp(applet, "service_started_daemon") == 0) {
+ state = rc_service_state(service);
+ bit = lookup_service_state(service);
+ if (bit) {
+ ok = (state & bit);
+ } else if (strcmp(applet, "service_started_daemon") == 0) {
service = getenv("RC_SVCNAME");
exec = argv[1];
if (argc > 3) {
@@ -317,6 +332,7 @@ do_mark_service(int argc, char **argv)
char *runscript_pid;
/* char *mtime; */
pid_t pid;
+ RC_SERVICE bit;
/* size_t l; */
if (argc > 1)
@@ -327,20 +343,9 @@ do_mark_service(int argc, char **argv)
if (service == NULL || *service == '\0')
eerrorx("%s: no service specified", applet);
- if (strcmp(applet, "mark_service_started") == 0)
- ok = rc_service_mark(service, RC_SERVICE_STARTED);
- else if (strcmp(applet, "mark_service_stopped") == 0)
- ok = rc_service_mark(service, RC_SERVICE_STOPPED);
- else if (strcmp(applet, "mark_service_inactive") == 0)
- ok = rc_service_mark(service, RC_SERVICE_INACTIVE);
- else if (strcmp(applet, "mark_service_starting") == 0)
- ok = rc_service_mark(service, RC_SERVICE_STARTING);
- else if (strcmp(applet, "mark_service_stopping") == 0)
- ok = rc_service_mark(service, RC_SERVICE_STOPPING);
- else if (strcmp(applet, "mark_service_hotplugged") == 0)
- ok = rc_service_mark(service, RC_SERVICE_HOTPLUGGED);
- else if (strcmp(applet, "mark_service_failed") == 0)
- ok = rc_service_mark(service, RC_SERVICE_FAILED);
+ if (strncmp(applet, "mark_", 5) &&
+ (bit = lookup_service_state(applet + 5)))
+ ok = rc_service_mark(service, bit);
else
eerrorx("%s: unknown applet", applet);
@@ -409,7 +414,7 @@ do_value(int argc, char **argv)
}
static int
-do_shell_var(int argc, char **argv)
+shell_var(int argc, char **argv)
{
int i;
char *p;
@@ -430,106 +435,127 @@ do_shell_var(int argc, char **argv)
return EXIT_SUCCESS;
}
+static int
+is_older_than(int argc, char **argv)
+{
+ int i;
+
+ if (argc < 3)
+ return EXIT_FAILURE;
+
+ /* This test is perverted - historically the baselayout function
+ * returns 0 on *failure*, which is plain wrong */
+ for (i = 2; i < argc; ++i)
+ if (!rc_newer_than(argv[1], argv[i], NULL, NULL))
+ return EXIT_SUCCESS;
+
+ return EXIT_FAILURE;
+}
+
+static int
+is_newer_than(int argc, char **argv)
+{
+ int i;
+
+ if (argc < 3)
+ return EXIT_FAILURE;
+
+ /* This test is correct as it's not present in baselayout */
+ for (i = 2; i < argc; ++i)
+ if (!rc_newer_than(argv[1], argv[i], NULL, NULL))
+ return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
+
+static int
+is_runlevel_start(_unused int argc, _unused char **argv)
+{
+ return rc_runlevel_starting() ? 0 : 1;
+}
+
+static int
+is_runlevel_stop(_unused int argc, _unused char **argv)
+{
+ return rc_runlevel_stopping() ? 0 : 1;
+}
+
+static int
+rc_abort(_unused int argc, _unused char **argv)
+{
+ const char *p = getenv("RC_PID");
+ int pid;
+
+ if (p && sscanf(p, "%d", &pid) == 1) {
+ if (kill(pid, SIGUSR1) != 0)
+ eerrorx("rc-abort: failed to signal parent %d: %s",
+ pid, strerror(errno));
+ return EXIT_SUCCESS;
+ }
+
+ return EXIT_FAILURE;
+}
+
+static const struct {
+ const char * const name;
+ int (* const applet)(int argc, char **argv);
+} applets[] = {
+#define A(a) { #a, a }
+ A(fstabinfo),
+ A(mountinfo),
+ { "rc-depend", rc_depend, },
+ { "rc-service", rc_service, },
+ { "rc-status", rc_status, },
+ { "rc-update", rc_update, },
+ { "update-rc", rc_update, },
+ A(runscript),
+ { "start-stop-daemon", start_stop_daemon, },
+ A(checkpath),
+ A(swclock),
+ A(shell_var),
+ A(is_older_than),
+ A(is_newer_than),
+ A(is_runlevel_start),
+ A(is_runlevel_stop),
+ { "rc-abort", rc_abort, },
+ /* These are purely for init scripts and do not make sense as
+ * anything else */
+ { "service_get_value", do_value, },
+ { "service_set_value", do_value, },
+ { "get_options", do_value, },
+ { "save_options", do_value, },
+#undef A
+};
+
void
run_applets(int argc, char **argv)
{
- int i = 2;
- char *p;
- pid_t pid = 0;
+ size_t i;
/* Bug 351712: We need an extra way to explicitly select an applet OTHER
* than trusting argv[0], as argv[0] is not going to be the applet value if
* we are doing SELinux context switching. For this, we allow calls such as
* 'rc --applet APPLET', and shift ALL of argv down by two array items. */
if (strcmp(applet, "rc") == 0 && argc >= 3 &&
- (strcmp(argv[1],"--applet") == 0 || strcmp(argv[1], "-a") == 0)) {
+ (strcmp(argv[1],"--applet") == 0 || strcmp(argv[1], "-a") == 0)) {
applet = argv[2];
argv += 2;
argc -= 2;
}
- /* These are designed to be applications in their own right */
- if (strcmp(applet, "fstabinfo") == 0)
- exit(fstabinfo(argc, argv));
- else if (strcmp(applet, "mountinfo") == 0)
- exit(mountinfo(argc, argv));
- else if (strcmp(applet, "rc-depend") == 0)
- exit(rc_depend(argc, argv));
- else if (strcmp(applet, "rc-service") == 0)
- exit(rc_service(argc, argv));
- else if (strcmp(applet, "rc-status") == 0)
- exit(rc_status(argc, argv));
- else if (strcmp(applet, "rc-update") == 0 ||
- strcmp(applet, "update-rc") == 0)
- exit(rc_update(argc, argv));
- else if (strcmp(applet, "runscript") == 0)
- exit(runscript(argc, argv));
- else if (strcmp(applet, "start-stop-daemon") == 0)
- exit(start_stop_daemon(argc, argv));
- else if (strcmp (applet, "checkpath") == 0)
- exit(checkpath(argc, argv));
- else if (strcmp(applet, "swclock") == 0)
- exit(swclock(argc, argv));
-
- /* These could also be applications in their own right */
- if (strcmp(applet, "shell_var") == 0)
- exit(do_shell_var(argc, argv));
-
- /* This test is perverted - historically the baselayout function
- * returns 0 on *failure*, which is plain wrong */
- if (strcmp(applet, "is_older_than") == 0) {
- if (argc < 3)
- exit (EXIT_FAILURE);
- while (i < argc) {
- if (!rc_newer_than(argv[1], argv[i++], NULL, NULL))
- exit(EXIT_SUCCESS);
- }
- exit(EXIT_FAILURE);
- };
- /* This test is correct as it's not present in baselayout */
- if (strcmp(applet, "is_newer_than") == 0) {
- if (argc < 3)
- exit (EXIT_FAILURE);
- while (i < argc) {
- if (!rc_newer_than(argv[1], argv[i++], NULL, NULL))
- exit(EXIT_FAILURE);
- }
- exit(EXIT_SUCCESS);
- };
+ for (i = 0; i < ARRAY_SIZE(applets); ++i)
+ if (!strcmp(applet, applets[i].name))
+ exit(applets[i].applet(argc, argv));
if (applet[0] == 'e' || (applet[0] == 'v' && applet[1] == 'e'))
exit(do_e(argc, argv));
- /* These are purely for init scripts and do not make sense as
- * anything else */
- if (strcmp(applet, "service_get_value") == 0 ||
- strcmp(applet, "service_set_value") == 0 ||
- strcmp(applet, "get_options") == 0 ||
- strcmp(applet, "save_options") == 0)
- exit(do_value(argc, argv));
-
if (strncmp(applet, "service_", strlen("service_")) == 0)
exit(do_service(argc, argv));
if (strncmp(applet, "mark_service_", strlen("mark_service_")) == 0)
exit(do_mark_service(argc, argv));
- if (strcmp(applet, "is_runlevel_start") == 0)
- exit(rc_runlevel_starting() ? 0 : 1);
- else if (strcmp (applet, "is_runlevel_stop") == 0)
- exit(rc_runlevel_stopping() ? 0 : 1);
-
- if (strcmp(applet, "rc-abort") == 0) {
- p = getenv("RC_PID");
- if (p && sscanf(p, "%d", &pid) == 1) {
- if (kill(pid, SIGUSR1) != 0)
- eerrorx("rc-abort: failed to signal parent %d: %s",
- pid, strerror(errno));
- exit(EXIT_SUCCESS);
- }
- exit(EXIT_FAILURE);
- }
-
if (strcmp(applet, "rc") != 0)
eerrorx("%s: unknown applet", applet);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-05-16 22:16 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2012-05-16 22:16 UTC (permalink / raw
To: gentoo-commits
commit: 6241f17e95f9e369a923a1dd205488ad7b7d80ee
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed May 16 22:16:04 2012 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed May 16 22:16:51 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=6241f17e
rc: fix thinko in applet collapse
We want to lookup the service based on the applet name.
Reported-by: Christian Ruppert <idl0r <AT> gentoo.org>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/rc-applets.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index 21562f0..4bc5bdb 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -295,7 +295,7 @@ do_service(int argc, char **argv)
eerrorx("%s: no service specified", applet);
state = rc_service_state(service);
- bit = lookup_service_state(service);
+ bit = lookup_service_state(applet);
if (bit) {
ok = (state & bit);
} else if (strcmp(applet, "service_started_daemon") == 0) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-05-23 23:31 Mike Frysinger
0 siblings, 0 replies; 257+ messages in thread
From: Mike Frysinger @ 2012-05-23 23:31 UTC (permalink / raw
To: gentoo-commits
commit: f5ba232fb41e5e923daa5f573bd58c13daff6f40
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed May 23 23:32:01 2012 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed May 23 23:32:59 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f5ba232f
rc: fix inverted string compare logic
X-Gentoo-Bug: 417227
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=417227
Reported-by: sphakka <marcoep <AT> gmail.com>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
src/rc/rc-applets.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index 4bc5bdb..4481b08 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -343,7 +343,7 @@ do_mark_service(int argc, char **argv)
if (service == NULL || *service == '\0')
eerrorx("%s: no service specified", applet);
- if (strncmp(applet, "mark_", 5) &&
+ if (!strncmp(applet, "mark_", 5) &&
(bit = lookup_service_state(applet + 5)))
ok = rc_service_mark(service, bit);
else
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-08-18 21:26 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-08-18 21:26 UTC (permalink / raw
To: gentoo-commits
commit: 8dc06e325943de7f3e04ddfe42da9143db7046cd
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 18 21:21:40 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Aug 18 21:21:40 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8dc06e32
Fix quiet usage
EINFO_QUIET will always been unset when we first do unsetenv("EINFO_QUIET") and
later query it again anyway..
---
src/rc/mountinfo.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index e5d1d3f..eaace13 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -393,8 +393,7 @@ mountinfo(int argc, char **argv)
bool quiet;
char *this_path;
- /* Ensure that we are only quiet when explicitly told to be */
- unsetenv("EINFO_QUIET");
+ quiet = rc_yesno(getenv("EINFO_QUIET"));
#define DO_REG(_var) \
if (_var) free(_var); \
@@ -475,7 +474,6 @@ mountinfo(int argc, char **argv)
REG_FREE(args.skip_options_regex);
result = EXIT_FAILURE;
- quiet = rc_yesno(getenv("EINFO_QUIET"));
/* We should report the mounts in reverse order to ease unmounting */
TAILQ_FOREACH_REVERSE(s, nodes, rc_stringlist, entries) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-08-18 22:26 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-08-18 22:26 UTC (permalink / raw
To: gentoo-commits
commit: 9afdf50667661812be936fe6d3b3a939b0c54061
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 18 22:26:38 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Aug 18 22:26:38 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9afdf506
Do not silence errors
---
src/rc/start-stop-daemon.c | 45 +++++++++++++++----------------------------
1 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index d1eb8a5..a3d887a 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -305,7 +305,7 @@ parse_schedule(const char *string, int timeout)
}
static pid_t
-get_pid(const char *pidfile, bool quiet)
+get_pid(const char *pidfile)
{
FILE *fp;
pid_t pid;
@@ -314,15 +314,12 @@ get_pid(const char *pidfile, bool quiet)
return -1;
if ((fp = fopen(pidfile, "r")) == NULL) {
- if (!quiet)
- eerror("%s: fopen `%s': %s",
- applet, pidfile, strerror(errno));
+ eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
return -1;
}
if (fscanf(fp, "%d", &pid) != 1) {
- if (!quiet)
- eerror("%s: no pid found in `%s'", applet, pidfile);
+ eerror("%s: no pid found in `%s'", applet, pidfile);
fclose(fp);
return -1;
}
@@ -355,8 +352,7 @@ do_stop(const char *exec, const char *const *argv,
LIST_FOREACH_SAFE(pi, pids, entries, np) {
if (test) {
if (!quiet)
- einfo("Would send signal %d to PID %d",
- sig, pi->pid);
+ einfo("Would send signal %d to PID %d", sig, pi->pid);
nkilled++;
} else {
if (verbose)
@@ -417,7 +413,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
}
if (pidfile) {
- pid = get_pid(pidfile, quiet);
+ pid = get_pid(pidfile);
if (pid == -1)
return 0;
}
@@ -436,9 +432,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (tkilled == 0) {
if (progressed)
printf("\n");
- if (! quiet)
- eerror("%s: no matching "
- "processes found", applet);
+ eerror("%s: no matching processes found", applet);
}
return tkilled;
}
@@ -508,14 +502,10 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (progressed)
printf("\n");
- if (! quiet) {
- if (nrunning == 1)
- eerror("%s: %d process refused to stop",
- applet, nrunning);
- else
- eerror("%s: %d process(es) refused to stop",
- applet, nrunning);
- }
+ if (nrunning == 1)
+ eerror("%s: %d process refused to stop", applet, nrunning);
+ else
+ eerror("%s: %d process(es) refused to stop", applet, nrunning);
return -nrunning;
}
@@ -1089,7 +1079,7 @@ start_stop_daemon(int argc, char **argv)
}
if (pidfile)
- pid = get_pid(pidfile, true);
+ pid = get_pid(pidfile);
else
pid = 0;
@@ -1295,7 +1285,7 @@ start_stop_daemon(int argc, char **argv)
/* We don't redirect stdin as some daemons may need it */
if (background || quiet || redirect_stdout)
dup2(stdout_fd, STDOUT_FILENO);
- if (background || quiet || redirect_stderr)
+ if (background || redirect_stderr)
dup2(stderr_fd, STDERR_FILENO);
for (i = getdtablesize() - 1; i >= 3; --i)
@@ -1326,12 +1316,9 @@ start_stop_daemon(int argc, char **argv)
return -1;
}
} while (!WIFEXITED(i) && !WIFSIGNALED(i));
- if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) {
- if (!quiet)
- eerrorx("%s: failed to start `%s'",
- applet, exec);
- exit(EXIT_FAILURE);
- }
+ if (!WIFEXITED(i) || WEXITSTATUS(i) != 0)
+ eerrorx("%s: failed to start `%s'", applet, exec);
+
pid = spid;
}
@@ -1365,7 +1352,7 @@ start_stop_daemon(int argc, char **argv)
alive = true;
} else {
if (pidfile) {
- pid = get_pid(pidfile, true);
+ pid = get_pid(pidfile);
if (pid == -1) {
eerrorx("%s: did not "
"create a valid"
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-09-12 19:00 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-09-12 19:00 UTC (permalink / raw
To: gentoo-commits
commit: a06072b3959adc91ddf5157f69162977cbd48079
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 12 19:00:20 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Wed Sep 12 19:00:20 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a06072b3
Silence get_pid(), OpenRC will give the process some time to create the PID file and the first get__pid() call may fail.
---
src/rc/_usage.h | 2 +-
src/rc/start-stop-daemon.c | 14 ++++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/rc/_usage.h b/src/rc/_usage.h
index 84b66b9..0882c22 100644
--- a/src/rc/_usage.h
+++ b/src/rc/_usage.h
@@ -38,7 +38,7 @@
"Disable color output", \
"Display software version", \
"Run verbosely", \
- "Run quietly"
+ "Run quietly (Does not affect errors)"
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index a3d887a..7c24ead 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -305,7 +305,7 @@ parse_schedule(const char *string, int timeout)
}
static pid_t
-get_pid(const char *pidfile)
+get_pid(const char *pidfile, bool quiet)
{
FILE *fp;
pid_t pid;
@@ -314,12 +314,14 @@ get_pid(const char *pidfile)
return -1;
if ((fp = fopen(pidfile, "r")) == NULL) {
- eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
+ if(!quiet)
+ eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
return -1;
}
if (fscanf(fp, "%d", &pid) != 1) {
- eerror("%s: no pid found in `%s'", applet, pidfile);
+ if(!quiet)
+ eerror("%s: no pid found in `%s'", applet, pidfile);
fclose(fp);
return -1;
}
@@ -413,7 +415,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
}
if (pidfile) {
- pid = get_pid(pidfile);
+ pid = get_pid(pidfile, false);
if (pid == -1)
return 0;
}
@@ -1079,7 +1081,7 @@ start_stop_daemon(int argc, char **argv)
}
if (pidfile)
- pid = get_pid(pidfile);
+ pid = get_pid(pidfile, false);
else
pid = 0;
@@ -1352,7 +1354,7 @@ start_stop_daemon(int argc, char **argv)
alive = true;
} else {
if (pidfile) {
- pid = get_pid(pidfile);
+ pid = get_pid(pidfile, true);
if (pid == -1) {
eerrorx("%s: did not "
"create a valid"
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-09-12 19:36 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-09-12 19:36 UTC (permalink / raw
To: gentoo-commits
commit: 3cd293c515ddf44172ece36e785209084a11d3fc
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 12 19:35:55 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Wed Sep 12 19:35:55 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=3cd293c5
Silence the right get_pid() call
---
src/rc/start-stop-daemon.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 7c24ead..bd20e34 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -1081,7 +1081,7 @@ start_stop_daemon(int argc, char **argv)
}
if (pidfile)
- pid = get_pid(pidfile, false);
+ pid = get_pid(pidfile, true);
else
pid = 0;
@@ -1354,7 +1354,7 @@ start_stop_daemon(int argc, char **argv)
alive = true;
} else {
if (pidfile) {
- pid = get_pid(pidfile, true);
+ pid = get_pid(pidfile, false);
if (pid == -1) {
eerrorx("%s: did not "
"create a valid"
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-09-14 21:00 Christian Ruppert
0 siblings, 0 replies; 257+ messages in thread
From: Christian Ruppert @ 2012-09-14 21:00 UTC (permalink / raw
To: gentoo-commits
commit: 6b1e806c8bfb9b72cba99162bcf20deb47b8670d
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 14 20:59:01 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Fri Sep 14 20:59:01 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=6b1e806c
Typo: emtpy -> empty
Reported-by: Walter <walter <AT> pratyeka.org>
X-Gentoo-Bug: 430146
X-Gentoo-Bug-URL: https://bugs.gentoo.org/430146
---
src/rc/fstabinfo.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 91f2a56..475212a 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -282,7 +282,7 @@ fstabinfo(int argc, char **argv)
END_ENT;
if (!TAILQ_FIRST(files))
- eerrorx("%s: emtpy fstab", argv[0]);
+ eerrorx("%s: empty fstab", argv[0]);
}
if (!TAILQ_FIRST(files)) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-10-09 21:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-10-09 21:50 UTC (permalink / raw
To: gentoo-commits
commit: 6f345abe91a57ab64a447b20b3c701d14f23ef69
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Oct 9 21:44:01 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 9 21:44:01 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=6f345abe
checkpath: change the owner/group only when requested to do so
Fix checkpath so that it only changes the owner/group if -o is on the
command line.
Reported-by: <flameeyes <AT> gentoo.org>
X-Gentoo-Bug: 437560
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=437560
---
src/rc/checkpath.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 7ebbb64..f984da3 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -60,7 +60,8 @@ extern const char *applet;
* See systemd's src/label.c:label_mkdir
*/
static int
-do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc)
+do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type,
+ bool trunc, bool chowner)
{
struct stat st;
int fd, flags;
@@ -139,7 +140,7 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc
}
}
- if (st.st_uid != uid || st.st_gid != gid) {
+ if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
if (st.st_dev || st.st_ino)
einfo("%s: correcting owner", path);
if (chown(path, uid, gid)) {
@@ -223,6 +224,7 @@ checkpath(int argc, char **argv)
inode_t type = inode_unknown;
int retval = EXIT_SUCCESS;
bool trunc = 0;
+ bool chowner = 0;
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
@@ -247,6 +249,7 @@ checkpath(int argc, char **argv)
applet, optarg);
break;
case 'o':
+ chowner = 1;
if (parse_owner(&pw, &gr, optarg) != 0)
eerrorx("%s: owner `%s' not found",
applet, optarg);
@@ -272,7 +275,7 @@ checkpath(int argc, char **argv)
gid = gr->gr_gid;
while (optind < argc) {
- if (do_check(argv[optind], uid, gid, mode, type, trunc))
+ if (do_check(argv[optind], uid, gid, mode, type, trunc, chowner))
retval = EXIT_FAILURE;
optind++;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-10-09 23:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-10-09 23:56 UTC (permalink / raw
To: gentoo-commits
commit: b68d4b3580b6c3b38712e415ac5b874228103cd1
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Oct 9 23:55:09 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 9 23:55:09 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=b68d4b35
checkpath: fix bool values
Use true/false for bool values instead of 0/1.
Reported-by: <vapier <AT> gentoo.org>
---
src/rc/checkpath.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index f984da3..518d237 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -223,20 +223,20 @@ checkpath(int argc, char **argv)
struct group *gr = NULL;
inode_t type = inode_unknown;
int retval = EXIT_SUCCESS;
- bool trunc = 0;
- bool chowner = 0;
+ bool trunc = false;
+ bool chowner = false;
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
{
switch (opt) {
case 'D':
- trunc = 1;
+ trunc = true;
case 'd':
type = inode_dir;
break;
case 'F':
- trunc = 1;
+ trunc = true;
case 'f':
type = inode_file;
break;
@@ -249,7 +249,7 @@ checkpath(int argc, char **argv)
applet, optarg);
break;
case 'o':
- chowner = 1;
+ chowner = true;
if (parse_owner(&pw, &gr, optarg) != 0)
eerrorx("%s: owner `%s' not found",
applet, optarg);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-10-17 23:48 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-10-17 23:48 UTC (permalink / raw
To: gentoo-commits
commit: 20af890ac24214a21dc8ce88dc39f287901fb298
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Oct 17 23:47:36 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Oct 17 23:47:36 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=20af890a
Spacing fixes
---
src/rc/start-stop-daemon.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index bd20e34..bfa8852 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -314,13 +314,13 @@ get_pid(const char *pidfile, bool quiet)
return -1;
if ((fp = fopen(pidfile, "r")) == NULL) {
- if(!quiet)
+ if (!quiet)
eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
return -1;
}
if (fscanf(fp, "%d", &pid) != 1) {
- if(!quiet)
+ if (!quiet)
eerror("%s: no pid found in `%s'", applet, pidfile);
fclose(fp);
return -1;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-10-24 17:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-10-24 17:38 UTC (permalink / raw
To: gentoo-commits
commit: 978dbe028414fc44603d3be70f2a4b226eda9916
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Oct 24 17:29:29 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Oct 24 17:29:29 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=978dbe02
mountinfo: respect the -q command line option
Previously, we were setting the quiet flag before the command line was
parsed. Since the flag is only used once, we can just read the
environment variable which is set by the parsing process.
Reported-by: <devurandom <AT> gmx.net>
X-Gentoo-Bug: 439010
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=439010
---
src/rc/mountinfo.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index eaace13..43d9c83 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -390,11 +390,8 @@ mountinfo(int argc, char **argv)
char real_path[PATH_MAX + 1];
int opt;
int result;
- bool quiet;
char *this_path;
- quiet = rc_yesno(getenv("EINFO_QUIET"));
-
#define DO_REG(_var) \
if (_var) free(_var); \
_var = get_regex(optarg);
@@ -483,7 +480,7 @@ mountinfo(int argc, char **argv)
if (skip_point_regex &&
regexec(skip_point_regex, s->value, 0, NULL, 0) == 0)
continue;
- if (! quiet)
+ if (! rc_yesno(getenv("EINFO_QUIET")))
printf("%s\n", s->value);
result = EXIT_SUCCESS;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2012-10-27 18:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2012-10-27 18:12 UTC (permalink / raw
To: gentoo-commits
commit: e634376482e70e40aab460ca1f60a4e5a5522bba
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Oct 27 17:59:58 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Oct 27 17:59:58 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=e6343764
Checkpath: print the path when correcting the owner
Checkpath was printing the path it was working with unless it was
correcting the owner. In this case, it was printing "checkpath", which
is not very useful.
Reported-by: <devurandom <AT> gmx.net>
X-Gentoo-Bug: 439014
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439014
---
src/rc/checkpath.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 518d237..5aea597 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -133,7 +133,7 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type,
}
if (mode && (st.st_mode & 0777) != mode) {
- einfo("%s: correcting mode", applet);
+ einfo("%s: correcting mode", path);
if (chmod(path, mode)) {
eerror("%s: chmod: %s", applet, strerror(errno));
return -1;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-02-15 19:35 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-02-15 19:35 UTC (permalink / raw
To: gentoo-commits
commit: 970893adf3a2f0f7330c4839a716566de14171a3
Author: Alexander Mezin <mezin.alexander <AT> gmail <DOT> com>
AuthorDate: Sat Feb 2 21:15:19 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 15 19:28:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=970893ad
runscript: retry prefix flock if it is interrupted by a signal
Reported-by: Pacho Ramos <pacho2 <AT> gentoo.org>
X-Gentoo-Bug: 434800
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=434800
---
src/rc/runscript.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index e504e4a..0eea335 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -311,8 +311,12 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed)
lock_fd = open(PREFIX_LOCK, O_WRONLY | O_CREAT, 0664);
if (lock_fd != -1) {
- if (flock(lock_fd, LOCK_EX) != 0)
- eerror("flock() failed: %s", strerror(errno));
+ while (flock(lock_fd, LOCK_EX) != 0) {
+ if (errno != EINTR) {
+ eerror("flock() failed: %s", strerror(errno));
+ break;
+ }
+ }
}
#ifdef RC_DEBUG
else
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-02-25 20:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-02-25 20:50 UTC (permalink / raw
To: gentoo-commits
commit: 5872bf1333ae67e42e40ae181b0b5f024ccf6a99
Author: Andrew Gregory <andrew.gregory.8 <AT> gmail <DOT> com>
AuthorDate: Sun Feb 24 17:06:41 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 25 20:41:30 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=5872bf13
rc-update: improve usage message accuracy and consistency
The old message did not indicate that the runlevel argument was optional
for add and del or that it could be used with show.
Signed-off-by: Andrew Gregory <andrew.gregory.8 <AT> gmail.com>
---
src/rc/rc-update.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 3e51840..273f7ef 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -195,10 +195,10 @@ show(RC_STRINGLIST *runlevels, bool verbose)
}
#include "_usage.h"
-#define usagestring "" \
- "Usage: rc-update [options] add service <runlevel>\n" \
- " rc-update [options] del service <runlevel>\n" \
- " rc-update [options] show"
+#define usagestring "" \
+ "Usage: rc-update [options] add <service> [<runlevel>...]\n" \
+ " or: rc-update [options] del <service> [<runlevel>...]\n" \
+ " or: rc-update [options] [show [<runlevel>...]]"
#define getoptstring "su" getoptstring_COMMON
static const struct option longopts[] = {
{ "stack", 0, NULL, 's' },
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-02-25 20:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-02-25 20:50 UTC (permalink / raw
To: gentoo-commits
commit: 927207c1b793d601344d2bd3c8f3c04cefb6323e
Author: Andrew Gregory <andrew.gregory.8 <AT> gmail <DOT> com>
AuthorDate: Sun Feb 24 17:06:42 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 25 20:44:04 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=927207c1
rc-status: improve usage message accuracy and consistency
This makes it more clear that many of the options are used as an
alternative to a runlevel.
Signed-off-by: Andrew Gregory <andrew.gregory.8 <AT> gmail.com>
---
src/rc/rc-status.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 04e8bd3..f096851 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -172,7 +172,9 @@ print_services(const char *runlevel, RC_STRINGLIST *svcs)
}
#include "_usage.h"
-#define extraopts "[runlevel1] [runlevel2] ..."
+#define usagestring "" \
+ "Usage: rc-status [options] <runlevel>...\n" \
+ " or: rc-status [options] [-a | -c | -l | -r | -s | -u]"
#define getoptstring "aclrsu" getoptstring_COMMON
static const struct option longopts[] = {
{"all", 0, NULL, 'a'},
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-02-25 20:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-02-25 20:50 UTC (permalink / raw
To: gentoo-commits
commit: 67377cc09fb597e4e65fde52ca0c5cb269d00c15
Author: Andrew Gregory <andrew.gregory.8 <AT> gmail <DOT> com>
AuthorDate: Sun Feb 24 17:06:40 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 25 20:39:50 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=67377cc0
rc: add usage message
Signed-off-by: Andrew Gregory <andrew.gregory.8 <AT> gmail.com>
---
src/rc/rc.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 2590048..a5d7085 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -727,6 +727,8 @@ handle_bad_signal(int sig)
#endif
#include "_usage.h"
+#define usagestring "" \
+ "Usage: rc [options] [<runlevel>]"
#define getoptstring "a:o:s:S" getoptstring_COMMON
static const struct option longopts[] = {
{ "applet", 1, NULL, 'a' },
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-02-25 20:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-02-25 20:50 UTC (permalink / raw
To: gentoo-commits
commit: fb10b971722ca630314ac7bccb9480f277a56d31
Author: Andrew Gregory <andrew.gregory.8 <AT> gmail <DOT> com>
AuthorDate: Sun Feb 24 17:06:43 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 25 20:45:39 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=fb10b971
rc-service: add usage message
Signed-off-by: Andrew Gregory <andrew.gregory.8 <AT> gmail.com>
---
src/rc/rc-service.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c
index 2fbdd75..d35b36b 100644
--- a/src/rc/rc-service.c
+++ b/src/rc/rc-service.c
@@ -42,6 +42,11 @@
extern char *applet;
#include "_usage.h"
+#define usagestring "" \
+ "Usage: rc-service [options] [-i] <service> <cmd>...\n" \
+ " or: rc-service [options] -e <service>\n" \
+ " or: rc-service [options] -l\n" \
+ " or: rc-service [options] -r <service>"
#define getoptstring "e:ilr:" getoptstring_COMMON
static const struct option longopts[] = {
{ "exists", 1, NULL, 'e' },
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-05-01 23:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-05-01 23:24 UTC (permalink / raw
To: gentoo-commits
commit: 70628a875ba5ccf9fd3c9d702bc5c7471762270b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed May 1 23:20:01 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed May 1 23:20:01 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=70628a87
fix the build for non-selinux systems
The symlinks should be created only if MKSELINUX=yes, not if it just has
a value.
---
src/rc/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index fc6b9aa..dcd8e5a 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -51,7 +51,7 @@ include ${MK}/pam.mk
# $3 is the path where the links are created
define make-links
for x in $(1); do \
- if test -n "${MKSELINUX}"; then \
+ if [ "${MKSELINUX}" = yes ]; then \
printf '#!/bin/sh\nexec ${2} --applet %s "$$@"\n' $$x >${3}/$$x; \
chmod ${BINMODE} ${3}/$$x; \
else \
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-07-16 18:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-07-16 18:56 UTC (permalink / raw
To: gentoo-commits
commit: 0f70cd067f4941ce7d9ec817dcf102952a1e8d44
Author: Alexander V Vershilov <qnikst <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 06:55:24 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jul 16 17:53:03 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0f70cd06
rc-status: fix -a to show all services
We need to unset rc_svcname so that all of the services are added to the
list to display.
X-Gentoo-Bug: 409787
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=409787
---
src/rc/rc-status.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index f096851..aba192f 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -351,6 +351,9 @@ rc_status(int argc, char **argv)
rc_stringlist_free(tmp);
}
l->value = p;
+ /* we are unsetting RC_SVCNAME because last loaded service
+ wount be added to list */
+ unsetenv(RC_SVCNAME);
print_level("Dynamic", "needed");
print_services(NULL, nservices);
print_level("Dynamic", "manual");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-07-23 23:01 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-07-23 23:01 UTC (permalink / raw
To: gentoo-commits
commit: c18d623dc02728e39376239fedbee8e76a87208e
Author: Alexander V Vershilov <qnikst <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 18 16:14:42 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jul 19 20:30:28 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=c18d623d
rc-status: fix typo
X-Gentoo-Bug: 477318
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=477318
---
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 aba192f..d049216 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -353,7 +353,7 @@ rc_status(int argc, char **argv)
l->value = p;
/* we are unsetting RC_SVCNAME because last loaded service
wount be added to list */
- unsetenv(RC_SVCNAME);
+ unsetenv("RC_SVCNAME");
print_level("Dynamic", "needed");
print_services(NULL, nservices);
print_level("Dynamic", "manual");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-08-26 20:59 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-08-26 20:59 UTC (permalink / raw
To: gentoo-commits
commit: bb8a9c087d20ee6454e2b6bf4713ec0ce9db94f3
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Aug 26 02:27:50 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Aug 26 20:51:11 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=bb8a9c08
start-stop-daemon: fix --quiet switch
The --quiet switch wasn't really quiet, because we changed it to report
errors. I am changing it back due to discussions on the listed bugs.
X-Gentoo-Bug: 482396
X-Gentoo-Bug: 439174
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439174
---
src/rc/_usage.h | 2 +-
src/rc/start-stop-daemon.c | 25 +++++++++++++++----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/rc/_usage.h b/src/rc/_usage.h
index 0882c22..84b66b9 100644
--- a/src/rc/_usage.h
+++ b/src/rc/_usage.h
@@ -38,7 +38,7 @@
"Disable color output", \
"Display software version", \
"Run verbosely", \
- "Run quietly (Does not affect errors)"
+ "Run quietly"
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 5576d49..4b9fcdd 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -417,7 +417,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
}
if (pidfile) {
- pid = get_pid(pidfile, false);
+ pid = get_pid(pidfile, quiet);
if (pid == -1)
return 0;
}
@@ -436,6 +436,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (tkilled == 0) {
if (progressed)
printf("\n");
+ if (! quiet)
eerror("%s: no matching processes found", applet);
}
return tkilled;
@@ -506,10 +507,12 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (progressed)
printf("\n");
- if (nrunning == 1)
- eerror("%s: %d process refused to stop", applet, nrunning);
- else
- eerror("%s: %d process(es) refused to stop", applet, nrunning);
+ if (! quiet) {
+ if (nrunning == 1)
+ eerror("%s: %d process refused to stop", applet, nrunning);
+ else
+ eerror("%s: %d process(es) refused to stop", applet, nrunning);
+ }
return -nrunning;
}
@@ -1289,7 +1292,7 @@ start_stop_daemon(int argc, char **argv)
/* We don't redirect stdin as some daemons may need it */
if (background || quiet || redirect_stdout)
dup2(stdout_fd, STDOUT_FILENO);
- if (background || redirect_stderr)
+ if (background || quiet || redirect_stderr)
dup2(stderr_fd, STDERR_FILENO);
for (i = getdtablesize() - 1; i >= 3; --i)
@@ -1320,9 +1323,11 @@ start_stop_daemon(int argc, char **argv)
return -1;
}
} while (!WIFEXITED(i) && !WIFSIGNALED(i));
- if (!WIFEXITED(i) || WEXITSTATUS(i) != 0)
- eerrorx("%s: failed to start `%s'", applet, exec);
-
+ if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) {
+ if (!quiet)
+ eerrorx("%s: failed to start `%s'", applet, exec);
+ exit(EXIT_FAILURE);
+ }
pid = spid;
}
@@ -1356,7 +1361,7 @@ start_stop_daemon(int argc, char **argv)
alive = true;
} else {
if (pidfile) {
- pid = get_pid(pidfile, false);
+ pid = get_pid(pidfile, true);
if (pid == -1) {
eerrorx("%s: did not "
"create a valid"
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-08-26 22:26 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-08-26 22:26 UTC (permalink / raw
To: gentoo-commits
commit: 5c3e5d801b7ea536f6ea4a993076965c978f0e81
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Aug 26 22:09:18 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Aug 26 22:09:18 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=5c3e5d80
start-stop-daemon: remove redundant test of the quiet value
The einfo() function tests for the EINFO_QUIET environment variable
directly, and this is the variable that is set by the --quiet flag, so
there was no reason for this test to exist.
---
src/rc/start-stop-daemon.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 4b9fcdd..ca40da6 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -355,8 +355,7 @@ do_stop(const char *exec, const char *const *argv,
LIST_FOREACH_SAFE(pi, pids, entries, np) {
if (test) {
- if (!quiet)
- einfo("Would send signal %d to PID %d", sig, pi->pid);
+ einfo("Would send signal %d to PID %d", sig, pi->pid);
nkilled++;
} else {
if (verbose)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-09-04 0:46 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-09-04 0:46 UTC (permalink / raw
To: gentoo-commits
commit: 445b297360b85c03b4509458f194a0d964c1d71a
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Sep 1 22:36:37 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Sep 4 00:05:13 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=445b2973
rc: add support for suppressing error messages
Add support for suppressing error messages with --quiet specified twice
on the command line.
X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
---
src/rc/_usage.c | 15 +++++++++++++++
src/rc/_usage.h | 4 ++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/rc/_usage.c b/src/rc/_usage.c
index 96c2d1a..a95e93f 100644
--- a/src/rc/_usage.c
+++ b/src/rc/_usage.c
@@ -35,6 +35,21 @@
# define _noreturn
#endif
+static void set_quiet_options(void)
+{
+ static int qcount = 0;
+
+ qcount ++;
+ switch (qcount) {
+ case 1:
+ setenv ("EINFO_QUIET", "YES", 1);
+ break;
+ case 2:
+ setenv ("EERROR_QUIET", "YES", 1);
+ break;
+ }
+}
+
_noreturn static void
show_version(void)
{
diff --git a/src/rc/_usage.h b/src/rc/_usage.h
index 84b66b9..0560e89 100644
--- a/src/rc/_usage.h
+++ b/src/rc/_usage.h
@@ -38,13 +38,13 @@
"Disable color output", \
"Display software version", \
"Run verbosely", \
- "Run quietly"
+ "Run quietly (repeat to suppress errors)"
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version();
#define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1);
-#define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1);
+#define case_RC_COMMON_getopt_case_q set_quiet_options();
#define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
#define case_RC_COMMON_GETOPT \
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-09-23 18:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-09-23 18:38 UTC (permalink / raw
To: gentoo-commits
commit: 0ba14ae7205a4e6a8acc23a62a95f6c6ad8b591f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 23 17:40:26 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 17:40:26 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0ba14ae7
style fixes
---
src/rc/rc-status.c | 6 ++++--
src/rc/rc.c | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index d14dd63..e38ce11 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -360,8 +360,10 @@ rc_status(int argc, char **argv)
}
}
l->value = p;
- /* we are unsetting RC_SVCNAME because last loaded service
- wount be added to list */
+ /*
+ * we are unsetting RC_SVCNAME because last loaded service will not
+ * be added to the list
+ */
unsetenv("RC_SVCNAME");
print_level("Dynamic", "needed");
print_services(NULL, nservices);
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 0c98372..c1c1629 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -1115,7 +1115,7 @@ main(int argc, char **argv)
/* Wait for our services to finish */
wait_for_services();
-
+
/* Free the list of services, we're done with it. */
rc_stringlist_free(run_services);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-09-23 18:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-09-23 18:38 UTC (permalink / raw
To: gentoo-commits
commit: 4480f1f395d6b83f3a5d63f2df32efb4a590bc88
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 23 18:37:21 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 18:37:21 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=4480f1f3
rc: add service to ignore patterns
---
src/rc/.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/.gitignore b/src/rc/.gitignore
index 94b1b20..469070f 100644
--- a/src/rc/.gitignore
+++ b/src/rc/.gitignore
@@ -3,6 +3,7 @@ rc-status
rc-service
rc-update
runscript
+service
start-stop-daemon
einfon
einfo
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-09-23 22:59 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-09-23 22:59 UTC (permalink / raw
To: gentoo-commits
commit: d6436bed09c0ccf07bdd32dd3374761a7187ab74
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 23 21:48:30 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 22:28:39 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d6436bed
start-stop-daemon: remove the quiet variable
The suppression of output is controlled in the e* functions themselves,
so there is no need for a variable to test in start-stop-daemon.
X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
---
src/rc/start-stop-daemon.c | 51 +++++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 30 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index ca40da6..0672eed 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -307,7 +307,7 @@ parse_schedule(const char *string, int timeout)
}
static pid_t
-get_pid(const char *pidfile, bool quiet)
+get_pid(const char *pidfile)
{
FILE *fp;
pid_t pid;
@@ -316,14 +316,12 @@ get_pid(const char *pidfile, bool quiet)
return -1;
if ((fp = fopen(pidfile, "r")) == NULL) {
- if (!quiet)
- eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
+ eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
return -1;
}
if (fscanf(fp, "%d", &pid) != 1) {
- if (!quiet)
- eerror("%s: no pid found in `%s'", applet, pidfile);
+ eerror("%s: no pid found in `%s'", applet, pidfile);
fclose(fp);
return -1;
}
@@ -337,7 +335,7 @@ get_pid(const char *pidfile, bool quiet)
static int
do_stop(const char *exec, const char *const *argv,
pid_t pid, uid_t uid,int sig,
- bool quiet, bool verbose, bool test)
+ bool verbose, bool test)
{
RC_PIDLIST *pids;
RC_PID *pi;
@@ -385,7 +383,7 @@ do_stop(const char *exec, const char *const *argv,
static int
run_stop_schedule(const char *exec, const char *const *argv,
const char *pidfile, uid_t uid,
- bool quiet, bool verbose, bool test, bool progress)
+ bool verbose, bool test, bool progress)
{
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
int nkilled = 0;
@@ -416,7 +414,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
}
if (pidfile) {
- pid = get_pid(pidfile, quiet);
+ pid = get_pid(pidfile);
if (pid == -1)
return 0;
}
@@ -430,12 +428,11 @@ run_stop_schedule(const char *exec, const char *const *argv,
case SC_SIGNAL:
nrunning = 0;
nkilled = do_stop(exec, argv, pid, uid, item->value,
- quiet, verbose, test);
+ verbose, test);
if (nkilled == 0) {
if (tkilled == 0) {
if (progressed)
printf("\n");
- if (! quiet)
eerror("%s: no matching processes found", applet);
}
return tkilled;
@@ -460,8 +457,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
nloops++)
{
if ((nrunning = do_stop(exec, argv,
- pid, uid, 0, true, false,
- true)) == 0)
+ pid, uid, 0, false, true)) == 0)
return 0;
@@ -506,12 +502,10 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (progressed)
printf("\n");
- if (! quiet) {
- if (nrunning == 1)
- eerror("%s: %d process refused to stop", applet, nrunning);
- else
- eerror("%s: %d process(es) refused to stop", applet, nrunning);
- }
+ if (nrunning == 1)
+ eerror("%s: %d process refused to stop", applet, nrunning);
+ else
+ eerror("%s: %d process(es) refused to stop", applet, nrunning);
return -nrunning;
}
@@ -680,7 +674,6 @@ start_stop_daemon(int argc, char **argv)
bool stop = false;
bool oknodo = false;
bool test = false;
- bool quiet;
bool verbose = false;
char *exec = NULL;
char *startas = NULL;
@@ -918,7 +911,6 @@ start_stop_daemon(int argc, char **argv)
endpwent();
argc -= optind;
argv += optind;
- quiet = rc_yesno(getenv("EINFO_QUIET"));
verbose = rc_yesno(getenv("EINFO_VERBOSE"));
/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
@@ -1063,7 +1055,7 @@ start_stop_daemon(int argc, char **argv)
else
parse_schedule(NULL, sig);
i = run_stop_schedule(exec, (const char *const *)margv,
- pidfile, uid, quiet, verbose, test, progress);
+ pidfile, uid, verbose, test, progress);
if (i < 0)
/* We failed to stop something */
@@ -1085,16 +1077,16 @@ start_stop_daemon(int argc, char **argv)
}
if (pidfile)
- pid = get_pid(pidfile, true);
+ pid = get_pid(pidfile);
else
pid = 0;
if (do_stop(exec, (const char * const *)margv, pid, uid,
- 0, true, false, true) > 0)
+ 0, false, true) > 0)
eerrorx("%s: %s is already running", applet, exec);
if (test) {
- if (quiet)
+ if (rc_yesno(getenv("EINFO_QUIET")))
exit (EXIT_SUCCESS);
einfon("Would start");
@@ -1289,9 +1281,9 @@ start_stop_daemon(int argc, char **argv)
}
/* We don't redirect stdin as some daemons may need it */
- if (background || quiet || redirect_stdout)
+ if (background || redirect_stdout || rc_yesno(getenv("EINFO_QUIET")))
dup2(stdout_fd, STDOUT_FILENO);
- if (background || quiet || redirect_stderr)
+ if (background || redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
dup2(stderr_fd, STDERR_FILENO);
for (i = getdtablesize() - 1; i >= 3; --i)
@@ -1323,8 +1315,7 @@ start_stop_daemon(int argc, char **argv)
}
} while (!WIFEXITED(i) && !WIFSIGNALED(i));
if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) {
- if (!quiet)
- eerrorx("%s: failed to start `%s'", applet, exec);
+ eerror("%s: failed to start `%s'", applet, exec);
exit(EXIT_FAILURE);
}
pid = spid;
@@ -1360,7 +1351,7 @@ start_stop_daemon(int argc, char **argv)
alive = true;
} else {
if (pidfile) {
- pid = get_pid(pidfile, true);
+ pid = get_pid(pidfile);
if (pid == -1) {
eerrorx("%s: did not "
"create a valid"
@@ -1370,7 +1361,7 @@ start_stop_daemon(int argc, char **argv)
} else
pid = 0;
if (do_stop(exec, (const char *const *)margv,
- pid, uid, 0, true, false, true) > 0)
+ pid, uid, 0, false, true) > 0)
alive = true;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-09-24 6:52 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-09-24 6:52 UTC (permalink / raw
To: gentoo-commits
commit: 9e989227ab51cd880405958a0b11c63fa461ea7e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Sep 24 06:47:17 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Sep 24 06:47:17 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9e989227
start-stop-daemon: remove the verbose variable
Along the same lines as the quiet variable, this is controlled by an
environment variable for the einfo code, so we do not need a separate
boolean flag.
---
src/rc/start-stop-daemon.c | 53 +++++++++++++++++++---------------------------
1 file changed, 22 insertions(+), 31 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 0672eed..3a72a13 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -334,8 +334,7 @@ get_pid(const char *pidfile)
/* return number of processed killed, -1 on error */
static int
do_stop(const char *exec, const char *const *argv,
- pid_t pid, uid_t uid,int sig,
- bool verbose, bool test)
+ pid_t pid, uid_t uid,int sig, bool test)
{
RC_PIDLIST *pids;
RC_PID *pi;
@@ -356,16 +355,13 @@ do_stop(const char *exec, const char *const *argv,
einfo("Would send signal %d to PID %d", sig, pi->pid);
nkilled++;
} else {
- if (verbose)
- ebegin("Sending signal %d to PID %d",
- sig, pi->pid);
+ ebeginv("Sending signal %d to PID %d", sig, pi->pid);
errno = 0;
killed = (kill(pi->pid, sig) == 0 ||
errno == ESRCH ? true : false);
- if (verbose)
- eend(killed ? 0 : 1,
- "%s: failed to send signal %d to PID %d: %s",
- applet, sig, pi->pid, strerror(errno));
+ eendv(killed ? 0 : 1,
+ "%s: failed to send signal %d to PID %d: %s",
+ applet, sig, pi->pid, strerror(errno));
if (!killed) {
nkilled = -1;
} else {
@@ -383,7 +379,7 @@ do_stop(const char *exec, const char *const *argv,
static int
run_stop_schedule(const char *exec, const char *const *argv,
const char *pidfile, uid_t uid,
- bool verbose, bool test, bool progress)
+ bool test, bool progress)
{
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
int nkilled = 0;
@@ -395,15 +391,15 @@ run_stop_schedule(const char *exec, const char *const *argv,
const char *const *p;
bool progressed = false;
- if (verbose) {
- if (exec)
- einfo ("Will stop %s", exec);
- if (pidfile)
- einfo("Will stop PID in pidfile `%s'", pidfile);
- if (uid)
- einfo("Will stop processes owned by UID %d", uid);
- if (argv && *argv) {
- einfon("Will stop processes of `");
+ if (exec)
+ einfov("Will stop %s", exec);
+ if (pidfile)
+ einfov("Will stop PID in pidfile `%s'", pidfile);
+ if (uid)
+ einfov("Will stop processes owned by UID %d", uid);
+ if (argv && *argv) {
+ einfovn("Will stop processes of `");
+ if (rc_yesno(getenv("EINFO_VERBOSE"))) {
for (p = argv; p && *p; p++) {
if (p != argv)
printf(" ");
@@ -427,8 +423,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
case SC_SIGNAL:
nrunning = 0;
- nkilled = do_stop(exec, argv, pid, uid, item->value,
- verbose, test);
+ nkilled = do_stop(exec, argv, pid, uid, item->value, test);
if (nkilled == 0) {
if (tkilled == 0) {
if (progressed)
@@ -457,7 +452,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
nloops++)
{
if ((nrunning = do_stop(exec, argv,
- pid, uid, 0, false, true)) == 0)
+ pid, uid, 0, true)) == 0)
return 0;
@@ -674,7 +669,6 @@ start_stop_daemon(int argc, char **argv)
bool stop = false;
bool oknodo = false;
bool test = false;
- bool verbose = false;
char *exec = NULL;
char *startas = NULL;
char *name = NULL;
@@ -911,7 +905,6 @@ start_stop_daemon(int argc, char **argv)
endpwent();
argc -= optind;
argv += optind;
- verbose = rc_yesno(getenv("EINFO_VERBOSE"));
/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
* instead of forcing --stop --oknodo as well */
@@ -1055,7 +1048,7 @@ start_stop_daemon(int argc, char **argv)
else
parse_schedule(NULL, sig);
i = run_stop_schedule(exec, (const char *const *)margv,
- pidfile, uid, verbose, test, progress);
+ pidfile, uid, test, progress);
if (i < 0)
/* We failed to stop something */
@@ -1082,7 +1075,7 @@ start_stop_daemon(int argc, char **argv)
pid = 0;
if (do_stop(exec, (const char * const *)margv, pid, uid,
- 0, false, true) > 0)
+ 0, true) > 0)
eerrorx("%s: %s is already running", applet, exec);
if (test) {
@@ -1110,10 +1103,8 @@ start_stop_daemon(int argc, char **argv)
exit(EXIT_SUCCESS);
}
- if (verbose) {
- ebegin("Detaching to start `%s'", exec);
- eindent();
- }
+ ebeginv("Detaching to start `%s'", exec);
+ eindentv();
/* Remove existing pidfile */
if (pidfile)
@@ -1361,7 +1352,7 @@ start_stop_daemon(int argc, char **argv)
} else
pid = 0;
if (do_stop(exec, (const char *const *)margv,
- pid, uid, 0, false, true) > 0)
+ pid, uid, 0, true) > 0)
alive = true;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-10-04 16:23 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-10-04 16:23 UTC (permalink / raw
To: gentoo-commits
commit: 56d592866c7734c42c0b2c0a41376e299fa3a0c2
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 30 21:55:25 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 30 21:55:25 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=56d59286
start-stop-daemon: fix eerorr calls in get_pid
The eerror calls in this function make it too verbose, so change them to
ewarnv() calls instead. This means that they will only print if the
--verbose option is used or EINFO_VERBOSE=yes is set in the environment.
---
src/rc/start-stop-daemon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 3a72a13..cceb041 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -316,12 +316,12 @@ get_pid(const char *pidfile)
return -1;
if ((fp = fopen(pidfile, "r")) == NULL) {
- eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
+ ewarnv("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
return -1;
}
if (fscanf(fp, "%d", &pid) != 1) {
- eerror("%s: no pid found in `%s'", applet, pidfile);
+ ewarnv("%s: no pid found in `%s'", applet, pidfile);
fclose(fp);
return -1;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-10-06 17:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-10-06 17:36 UTC (permalink / raw
To: gentoo-commits
commit: 82378bd92dc5569c1c06f291b6f3c048044baafa
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Oct 5 22:19:06 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Oct 6 17:00:37 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=82378bd9
start-stop-daemon: fix do_stop calls
Several calls to do_stop were forcing the test parameter to be true,
which was causing extra output to the terminal, such as:
* Would send signal 0 to pid xxxxx
This should only happen if the --test command line option was used.
---
src/rc/start-stop-daemon.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index cceb041..cc47c0b 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -452,7 +452,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
nloops++)
{
if ((nrunning = do_stop(exec, argv,
- pid, uid, 0, true)) == 0)
+ pid, uid, 0, test)) == 0)
return 0;
@@ -1075,7 +1075,7 @@ start_stop_daemon(int argc, char **argv)
pid = 0;
if (do_stop(exec, (const char * const *)margv, pid, uid,
- 0, true) > 0)
+ 0, test) > 0)
eerrorx("%s: %s is already running", applet, exec);
if (test) {
@@ -1352,7 +1352,7 @@ start_stop_daemon(int argc, char **argv)
} else
pid = 0;
if (do_stop(exec, (const char *const *)margv,
- pid, uid, 0, true) > 0)
+ pid, uid, 0, test) > 0)
alive = true;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-10-12 14:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-10-12 14:50 UTC (permalink / raw
To: gentoo-commits
commit: f751e14416066fa0290c76c1f675d4093bb1d436
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Oct 11 17:55:27 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Oct 12 14:38:09 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f751e144
convert flock() messages to verbose warnings
Convert these messages to warnings that are only displayed if
EINFO_VERBOSE is set to yes in the environment.
This is based on a suggestion from Patrick Lauer <patrick <AT> gentoo.org>.
X-Gentoo-Bug: 487588
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=487588
---
src/rc/runscript.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 0eea335..3ecb6b5 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -313,15 +313,13 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed)
if (lock_fd != -1) {
while (flock(lock_fd, LOCK_EX) != 0) {
if (errno != EINTR) {
- eerror("flock() failed: %s", strerror(errno));
+ ewarnv("flock() failed: %s", strerror(errno));
break;
}
}
}
-#ifdef RC_DEBUG
else
- ewarn("Couldn't open the prefix lock, please make sure you have enough permissions");
-#endif
+ ewarnv("Couldn't open the prefix lock, please make sure you have enough permissions");
for (i = 0; i < bytes; i++) {
/* We don't prefix eend calls (cursor up) */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-12-01 17:25 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-12-01 17:25 UTC (permalink / raw
To: gentoo-commits
commit: 1fccf91df12c3c7f7e68f9fa9a99a71e85d9b98e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Dec 1 17:20:29 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Dec 1 17:20:29 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=1fccf91d
rc-update: make "service already installed" message informational
This message was being sent to stderr, and it should be sent to
stdout since it is informational. This change was requested by
zero_chaos.
---
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 273f7ef..8885637 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -62,7 +62,7 @@ add(const char *runlevel, const char *service)
eerror("%s: service `%s' does not exist",
applet, service);
} else if (rc_service_in_runlevel(service, runlevel)) {
- ewarn("%s: %s already installed in runlevel `%s'; skipping",
+ einfo("%s: %s already installed in runlevel `%s'; skipping",
applet, service, runlevel);
retval = 0;
} else if (rc_service_add(runlevel, service)) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-12-13 18:05 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-12-13 18:05 UTC (permalink / raw
To: gentoo-commits
commit: 7a35daeab7bf97bcd0ae4f9e0e053cb5c9bad40b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Dec 13 07:09:55 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Dec 13 07:09:55 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=7a35daea
runscript: clarify the message wrt scheduling
The message about a service being scheduled to start was confusing to
some of our users; I was told this wording is more clear.
X-Gentoo-Bug: 493070
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=493070
---
src/rc/runscript.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 7dc7593..e5cb62e 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -210,8 +210,7 @@ start_services(RC_STRINGLIST *list)
{
rc_service_schedule_start(service,
svc->value);
- ewarn("WARNING: %s is scheduled to started"
- " when %s has started",
+ ewarn("WARNING: %s will start when %s has started",
svc->value, applet);
} else
service_start(svc->value);
@@ -760,8 +759,7 @@ svc_start_deps(void)
}
rc_stringlist_free(tmplist);
tmplist = NULL;
- ewarnx("WARNING: %s is scheduled to start when "
- "%s has started", applet, tmp);
+ ewarnx("WARNING: %s will start when %s has started", applet, tmp);
free(tmp);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2013-12-13 18:20 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2013-12-13 18:20 UTC (permalink / raw
To: gentoo-commits
commit: c096ad63caba72684010f446ecee87751da78e65
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Dec 13 18:19:27 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Dec 13 18:19:27 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=c096ad63
add openrc binary to ignore patterns
---
src/rc/.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/.gitignore b/src/rc/.gitignore
index 469070f..e04e2f3 100644
--- a/src/rc/.gitignore
+++ b/src/rc/.gitignore
@@ -57,3 +57,4 @@ mark_service_hotplugged
mark_service_failed
rc-abort
rc
+openrc
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-01-18 20:02 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-01-18 20:02 UTC (permalink / raw
To: gentoo-commits
commit: de186401e5843e376cc12545c2ea35212f5e0490
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Jan 18 19:50:05 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 19:50:05 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=de186401
fstabinfo: fix mount and remount
The mount and remount options should always be processed. They were only
being processed if -q was not on the command line.
X-Gentoo-Bug: 498206
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=498206
---
src/rc/fstabinfo.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 475212a..99eb7bc 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -298,15 +298,8 @@ fstabinfo(int argc, char **argv)
continue;
}
- /* No point in outputting if quiet */
- if (rc_yesno(getenv("EINFO_QUIET")))
- continue;
-
+ /* mount or remount? */
switch (output) {
- case OUTPUT_BLOCKDEV:
- printf("%s\n", ENT_BLOCKDEVICE(ent));
- break;
-
case OUTPUT_MOUNT:
result += do_mount(ent, false);
break;
@@ -314,6 +307,16 @@ fstabinfo(int argc, char **argv)
case OUTPUT_REMOUNT:
result += do_mount(ent, true);
break;
+ }
+
+ /* No point in outputting if quiet */
+ if (rc_yesno(getenv("EINFO_QUIET")))
+ continue;
+
+ switch (output) {
+ case OUTPUT_BLOCKDEV:
+ printf("%s\n", ENT_BLOCKDEVICE(ent));
+ break;
case OUTPUT_MOUNTARGS:
printf("-o %s -t %s %s %s\n",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-11 20:19 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-11 20:19 UTC (permalink / raw
To: gentoo-commits
commit: d0040aff0aa033fd5d5c40480008e98ee5e1f11a
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jul 11 19:50:20 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jul 11 20:04:06 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d0040aff
checkpath: report an error if required options were not specified
Before this commit, not specifying -d, -f, -p or -W in a checkpath
command meant the command exited successfully but actually did nothing.
This is an error condition, so report it as such.
---
src/rc/checkpath.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 5aea597..6280fb6 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -267,6 +267,9 @@ checkpath(int argc, char **argv)
if (optind >= argc)
usage(EXIT_FAILURE);
+ if (type == inode_unknown)
+ eerrorx("%s: -d -f or -p must be specified.", applet);
+
if (pw) {
uid = pw->pw_uid;
gid = pw->pw_gid;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-11 20:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-11 20:24 UTC (permalink / raw
To: gentoo-commits
commit: d80482c2f4ec35a880ee099eeb3983b255d65e8f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jul 11 20:23:38 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jul 11 20:23:38 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d80482c2
checkpath: fix error message in previous commit
---
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 6280fb6..3c6c5ca 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -268,7 +268,7 @@ checkpath(int argc, char **argv)
usage(EXIT_FAILURE);
if (type == inode_unknown)
- eerrorx("%s: -d -f or -p must be specified.", applet);
+ eerrorx("%s: -d, -f, -p, or -W must be specified.", applet);
if (pw) {
uid = pw->pw_uid;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-13 19:16 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-13 19:16 UTC (permalink / raw
To: gentoo-commits
commit: 71d6d61b28c4c0f285ec51459551d900dfa4ea71
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Jul 13 19:12:36 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jul 13 19:12:36 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=71d6d61b
checkpath: fix logic for the writable option
The -W option does not need an argument of its own; it can take the
first path after all other options are processed on the command line.
Also, move the processing for the -W option out of the switch so it will
be in the same loop as the other processing.
---
src/rc/checkpath.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 3c6c5ca..6a0f893 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -187,7 +187,7 @@ parse_owner(struct passwd **user, struct group **group, const char *owner)
#include "_usage.h"
#define extraopts "path1 [path2] [...]"
-#define getoptstring "dDfFpm:o:W:" getoptstring_COMMON
+#define getoptstring "dDfFpm:o:W" getoptstring_COMMON
static const struct option longopts[] = {
{ "directory", 0, NULL, 'd'},
{ "directory-truncate", 0, NULL, 'D'},
@@ -196,7 +196,7 @@ static const struct option longopts[] = {
{ "pipe", 0, NULL, 'p'},
{ "mode", 1, NULL, 'm'},
{ "owner", 1, NULL, 'o'},
- { "writable", 1, NULL, 'W'},
+ { "writable", 0, NULL, 'W'},
longopts_COMMON
};
static const char * const longopts_help[] = {
@@ -225,6 +225,7 @@ checkpath(int argc, char **argv)
int retval = EXIT_SUCCESS;
bool trunc = false;
bool chowner = false;
+ bool writable = false;
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
@@ -255,9 +256,7 @@ checkpath(int argc, char **argv)
applet, optarg);
break;
case 'W':
- if (argv[optind] != NULL)
- ewarn("-W/--writable takes only one path, everything else will be ignored");
- exit(!is_writable(optarg));
+ writable = true;
break;
case_RC_COMMON_GETOPT
@@ -267,8 +266,8 @@ checkpath(int argc, char **argv)
if (optind >= argc)
usage(EXIT_FAILURE);
- if (type == inode_unknown)
- eerrorx("%s: -d, -f, -p, or -W must be specified.", applet);
+ if (writable && type != inode_unknown)
+ eerrorx("%s: -W cannot be specified along with -d, -f or -p", applet);
if (pw) {
uid = pw->pw_uid;
@@ -278,6 +277,8 @@ checkpath(int argc, char **argv)
gid = gr->gr_gid;
while (optind < argc) {
+ if (writable)
+ exit(!is_writable(argv[optind]));
if (do_check(argv[optind], uid, gid, mode, type, trunc, chowner))
retval = EXIT_FAILURE;
optind++;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-16 18:14 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-16 18:14 UTC (permalink / raw
To: gentoo-commits
commit: 9c689542c3246e793310db938374bc97600435e6
Author: Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Tue Jul 15 18:27:34 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 18:09:38 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9c689542
checkpath: restore the SELinux context
X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
---
src/rc/Makefile | 6 ++-
src/rc/checkpath.c | 28 ++++++++---
src/rc/rc-selinux-util.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++
src/rc/rc-selinux-util.h | 33 +++++++++++++
4 files changed, 186 insertions(+), 7 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index 5f5aa63..fb5265c 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -4,7 +4,11 @@ SRCS= checkpath.c fstabinfo.c mountinfo.c start-stop-daemon.c \
rc-misc.c rc-plugin.c rc-service.c rc-status.c rc-update.c \
runscript.c rc.c swclock.c
-CLEANFILES= version.h
+ifeq (${MKSELINUX},yes)
+SRCS+= rc-selinux-util.c
+endif
+
+CLEANFILES= version.h rc-selinux-util.o
BINDIR= ${PREFIX}/bin
SBINDIR= ${PREFIX}/sbin
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 6a0f893..6945b67 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -46,6 +46,10 @@
#include "einfo.h"
#include "rc-misc.h"
+#ifdef HAVE_SELINUX
+#include "rc-selinux-util.h"
+#endif
+
typedef enum {
inode_unknown = 0,
inode_file = 1,
@@ -55,13 +59,9 @@ typedef enum {
extern const char *applet;
-/* TODO: SELinux
- * This needs a LOT of SELinux loving
- * See systemd's src/label.c:label_mkdir
- */
static int
do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type,
- bool trunc, bool chowner)
+ bool trunc, bool chowner, bool selinux_on)
{
struct stat st;
int fd, flags;
@@ -149,6 +149,11 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type,
}
}
+#ifdef HAVE_SELINUX
+ if (selinux_on)
+ selinux_util_label(path);
+#endif
+
return 0;
}
@@ -226,6 +231,7 @@ checkpath(int argc, char **argv)
bool trunc = false;
bool chowner = false;
bool writable = false;
+ bool selinux_on = false;
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
@@ -276,13 +282,23 @@ checkpath(int argc, char **argv)
if (gr)
gid = gr->gr_gid;
+#ifdef HAVE_SELINUX
+ if (1 == selinux_util_open())
+ selinux_on = true;
+#endif
+
while (optind < argc) {
if (writable)
exit(!is_writable(argv[optind]));
- if (do_check(argv[optind], uid, gid, mode, type, trunc, chowner))
+ if (do_check(argv[optind], uid, gid, mode, type, trunc, chowner, selinux_on))
retval = EXIT_FAILURE;
optind++;
}
+#ifdef HAVE_SELINUX
+ if (selinux_on)
+ selinux_util_close();
+#endif
+
return retval;
}
diff --git a/src/rc/rc-selinux-util.c b/src/rc/rc-selinux-util.c
new file mode 100644
index 0000000..6cbb5db
--- /dev/null
+++ b/src/rc/rc-selinux-util.c
@@ -0,0 +1,126 @@
+/*
+ rc-selinux.c
+ SELinux helpers to get and set contexts.
+*/
+
+/*
+ * Copyright (c) 2014 Jason Zaman <jason@perfinion.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <errno.h>
+
+#include <sys/stat.h>
+
+#include <selinux/selinux.h>
+#include <selinux/label.h>
+
+#include "rc-selinux-util.h"
+
+static struct selabel_handle *hnd = NULL;
+
+int
+selinux_util_label(const char *path)
+{
+ int retval = 0;
+ int enforce;
+ struct stat st;
+ security_context_t con;
+
+ enforce = security_getenforce();
+ if (retval < 0)
+ return retval;
+
+ if (NULL == hnd)
+ return (enforce) ? -1 : 0;
+
+ retval = lstat(path, &st);
+ if (retval < 0) {
+ if (ENOENT == errno)
+ return 0;
+ return (enforce) ? -1 : 0;
+ }
+
+ /* lookup the context */
+ retval = selabel_lookup_raw(hnd, &con, path, st.st_mode);
+ if (retval < 0) {
+ if (ENOENT == errno)
+ return 0;
+ return (enforce) ? -1 : 0;
+ }
+
+ /* apply the context */
+ retval = lsetfilecon(path, con);
+ freecon(con);
+ if (retval < 0) {
+ if (ENOENT == errno)
+ return 0;
+ if (ENOTSUP == errno)
+ return 0;
+ return (enforce) ? -1 : 0;
+ }
+
+ return 0;
+}
+
+/*
+ * Open the label handle
+ * returns 1 on success, 0 if no selinux, negative on error
+ */
+int
+selinux_util_open(void)
+{
+ int retval = 0;
+
+ retval = is_selinux_enabled();
+ if (retval <= 0)
+ return retval;
+
+ hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
+ if (NULL == hnd)
+ return -2;
+
+ return 1;
+}
+
+/*
+ * Close the label handle
+ * returns 1 on success, 0 if no selinux, negative on error
+ */
+int
+selinux_util_close(void)
+{
+ int retval = 0;
+
+ retval = is_selinux_enabled();
+ if (retval <= 0)
+ return retval;
+
+ if (hnd) {
+ selabel_close(hnd);
+ hnd = NULL;
+ }
+
+ return 0;
+}
diff --git a/src/rc/rc-selinux-util.h b/src/rc/rc-selinux-util.h
new file mode 100644
index 0000000..69624b3
--- /dev/null
+++ b/src/rc/rc-selinux-util.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014 Jason Zaman <jason@perfinion.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef RC_SELINUX_UTIL_H
+#define RC_SELINUX_UTIL_H
+
+int selinux_util_open(void);
+int selinux_util_label(const char *path);
+int selinux_util_close(void);
+
+#endif
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-16 19:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-16 19:17 UTC (permalink / raw
To: gentoo-commits
commit: 010c2ab18b4be2068237cf0db97e9348bba65ac6
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jul 16 19:14:37 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 19:14:37 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=010c2ab1
Rename SELinux source files
The name rc-selinux-util.* is a bit long, so I renamed the source files
to rc-selinux.*
X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
---
src/rc/Makefile | 4 ++--
src/rc/checkpath.c | 2 +-
src/rc/{rc-selinux-util.c => rc-selinux.c} | 2 +-
src/rc/{rc-selinux-util.h => rc-selinux.h} | 0
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index fb5265c..609794a 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -5,10 +5,10 @@ SRCS= checkpath.c fstabinfo.c mountinfo.c start-stop-daemon.c \
runscript.c rc.c swclock.c
ifeq (${MKSELINUX},yes)
-SRCS+= rc-selinux-util.c
+SRCS+= rc-selinux.c
endif
-CLEANFILES= version.h rc-selinux-util.o
+CLEANFILES= version.h rc-selinux.o
BINDIR= ${PREFIX}/bin
SBINDIR= ${PREFIX}/sbin
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 6945b67..b0384bd 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -47,7 +47,7 @@
#include "rc-misc.h"
#ifdef HAVE_SELINUX
-#include "rc-selinux-util.h"
+#include "rc-selinux.h"
#endif
typedef enum {
diff --git a/src/rc/rc-selinux-util.c b/src/rc/rc-selinux.c
similarity index 99%
rename from src/rc/rc-selinux-util.c
rename to src/rc/rc-selinux.c
index 6cbb5db..8e780c9 100644
--- a/src/rc/rc-selinux-util.c
+++ b/src/rc/rc-selinux.c
@@ -36,7 +36,7 @@
#include <selinux/selinux.h>
#include <selinux/label.h>
-#include "rc-selinux-util.h"
+#include "rc-selinux.h"
static struct selabel_handle *hnd = NULL;
diff --git a/src/rc/rc-selinux-util.h b/src/rc/rc-selinux.h
similarity index 100%
rename from src/rc/rc-selinux-util.h
rename to src/rc/rc-selinux.h
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-16 19:48 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-16 19:48 UTC (permalink / raw
To: gentoo-commits
commit: 8b8edc29705b843988b97242942a409241c182eb
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jul 16 19:48:03 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 19:48:03 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8b8edc29
style fixes
---
src/rc/rc-selinux.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index 8e780c9..7c1ee80 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -40,8 +40,7 @@
static struct selabel_handle *hnd = NULL;
-int
-selinux_util_label(const char *path)
+int selinux_util_label(const char *path)
{
int retval = 0;
int enforce;
@@ -52,12 +51,12 @@ selinux_util_label(const char *path)
if (retval < 0)
return retval;
- if (NULL == hnd)
+ if (!hnd)
return (enforce) ? -1 : 0;
retval = lstat(path, &st);
if (retval < 0) {
- if (ENOENT == errno)
+ if (errno == ENOENT)
return 0;
return (enforce) ? -1 : 0;
}
@@ -65,7 +64,7 @@ selinux_util_label(const char *path)
/* lookup the context */
retval = selabel_lookup_raw(hnd, &con, path, st.st_mode);
if (retval < 0) {
- if (ENOENT == errno)
+ if (errno == ENOENT)
return 0;
return (enforce) ? -1 : 0;
}
@@ -74,9 +73,9 @@ selinux_util_label(const char *path)
retval = lsetfilecon(path, con);
freecon(con);
if (retval < 0) {
- if (ENOENT == errno)
+ if (errno == ENOENT)
return 0;
- if (ENOTSUP == errno)
+ if (errno == ENOTSUP)
return 0;
return (enforce) ? -1 : 0;
}
@@ -88,8 +87,7 @@ selinux_util_label(const char *path)
* Open the label handle
* returns 1 on success, 0 if no selinux, negative on error
*/
-int
-selinux_util_open(void)
+int selinux_util_open(void)
{
int retval = 0;
@@ -98,7 +96,7 @@ selinux_util_open(void)
return retval;
hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0);
- if (NULL == hnd)
+ if (!hnd)
return -2;
return 1;
@@ -108,8 +106,7 @@ selinux_util_open(void)
* Close the label handle
* returns 1 on success, 0 if no selinux, negative on error
*/
-int
-selinux_util_close(void)
+int selinux_util_close(void)
{
int retval = 0;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-16 23:01 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-16 23:01 UTC (permalink / raw
To: gentoo-commits
commit: a94a9740d545817294cc431180db0f22fc923b13
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jul 16 20:03:11 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 20:03:11 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a94a9740
checkpath: style fixes
---
src/rc/checkpath.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index b0384bd..ecd845f 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -59,9 +59,8 @@ typedef enum {
extern const char *applet;
-static int
-do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type,
- bool trunc, bool chowner, bool selinux_on)
+static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
+ inode_t type, bool trunc, bool chowner, bool selinux_on)
{
struct stat st;
int fd, flags;
@@ -157,8 +156,8 @@ do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type,
return 0;
}
-static int
-parse_owner(struct passwd **user, struct group **group, const char *owner)
+static int parse_owner(struct passwd **user, struct group **group,
+ const char *owner)
{
char *u = xstrdup (owner);
char *g = strchr (u, ':');
@@ -217,8 +216,7 @@ static const char * const longopts_help[] = {
};
#include "_usage.c"
-int
-checkpath(int argc, char **argv)
+int checkpath(int argc, char **argv)
{
int opt;
uid_t uid = geteuid();
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-16 23:01 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-16 23:01 UTC (permalink / raw
To: gentoo-commits
commit: 89907b60bac51db2cda1afe4555676577ef498a8
Author: Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Wed Jul 16 20:46:25 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jul 16 22:59:25 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=89907b60
move the selinux_setup function into rc-selinux
X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
---
src/rc/rc-selinux.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/rc/rc-selinux.h | 2 ++
src/rc/runscript.c | 45 +++++----------------------------------------
3 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index 7c1ee80..eae030d 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -30,14 +30,24 @@
#include <stddef.h>
#include <errno.h>
+#include <dlfcn.h>
#include <sys/stat.h>
#include <selinux/selinux.h>
#include <selinux/label.h>
+#include "einfo.h"
+#include "rc.h"
+#include "rc-misc.h"
+#include "rc-plugin.h"
#include "rc-selinux.h"
+#define SELINUX_LIB RC_LIBDIR "/runscript_selinux.so"
+
+static void (*selinux_run_init_old) (void);
+static void (*selinux_run_init_new) (int argc, char **argv);
+
static struct selabel_handle *hnd = NULL;
int selinux_util_label(const char *path)
@@ -121,3 +131,34 @@ int selinux_util_close(void)
return 0;
}
+
+void selinux_setup(int argc, char **argv)
+{
+ void *lib_handle = NULL;
+
+ if (!exists(SELINUX_LIB))
+ return;
+
+ lib_handle = dlopen(SELINUX_LIB, RTLD_NOW | RTLD_GLOBAL);
+ if (!lib_handle) {
+ eerror("dlopen: %s", dlerror());
+ return;
+ }
+
+ selinux_run_init_old = (void (*)(void))
+ dlfunc(lib_handle, "selinux_runscript");
+ selinux_run_init_new = (void (*)(int, char **))
+ dlfunc(lib_handle, "selinux_runscript2");
+
+ /* Use new run_init if it exists, else fall back to old */
+ if (selinux_run_init_new)
+ selinux_run_init_new(argc, argv);
+ else if (selinux_run_init_old)
+ selinux_run_init_old();
+ else
+ /* This shouldnt happen... probably corrupt lib */
+ eerrorx
+ ("run_init is missing from runscript_selinux.so!");
+
+ dlclose(lib_handle);
+}
diff --git a/src/rc/rc-selinux.h b/src/rc/rc-selinux.h
index 69624b3..8cf73b0 100644
--- a/src/rc/rc-selinux.h
+++ b/src/rc/rc-selinux.h
@@ -30,4 +30,6 @@ int selinux_util_open(void);
int selinux_util_label(const char *path);
int selinux_util_close(void);
+void selinux_setup(int argc, char **argv);
+
#endif
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 981e606..03d851e 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -36,7 +36,6 @@
#include <sys/wait.h>
#include <ctype.h>
-#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
@@ -66,7 +65,9 @@
#include "rc-misc.h"
#include "rc-plugin.h"
-#define SELINUX_LIB RC_LIBDIR "/runscript_selinux.so"
+#ifdef HAVE_SELINUX
+#include "rc-selinux.h"
+#endif
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
@@ -88,42 +89,6 @@ static int signal_pipe[2] = { -1, -1 };
static RC_STRINGLIST *types_b, *types_n, *types_nu, *types_nua, *types_m;
static RC_STRINGLIST *types_mua = NULL;
-#ifdef __linux__
-static void (*selinux_run_init_old)(void);
-static void (*selinux_run_init_new)(int argc, char **argv);
-
-static void
-setup_selinux(int argc, char **argv)
-{
- void *lib_handle = NULL;
-
- if (! exists(SELINUX_LIB))
- return;
-
- lib_handle = dlopen(SELINUX_LIB, RTLD_NOW | RTLD_GLOBAL);
- if (! lib_handle) {
- eerror("dlopen: %s", dlerror());
- return;
- }
-
- selinux_run_init_old = (void (*)(void))
- dlfunc(lib_handle, "selinux_runscript");
- selinux_run_init_new = (void (*)(int, char **))
- dlfunc(lib_handle, "selinux_runscript2");
-
- /* Use new run_init if it exists, else fall back to old */
- if (selinux_run_init_new)
- selinux_run_init_new(argc, argv);
- else if (selinux_run_init_old)
- selinux_run_init_old();
- else
- /* This shouldnt happen... probably corrupt lib */
- eerrorx("run_init is missing from runscript_selinux.so!");
-
- dlclose(lib_handle);
-}
-#endif
-
static void
handle_signal(int sig)
{
@@ -1224,9 +1189,9 @@ openrc_run(int argc, char **argv)
eprefix(prefix);
}
-#ifdef __linux__
+#ifdef HAVE_SELINUX
/* Ok, we are ready to go, so setup selinux if applicable */
- setup_selinux(argc, argv);
+ selinux_setup(argc, argv);
#endif
deps = true;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-18 4:47 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-18 4:47 UTC (permalink / raw
To: gentoo-commits
commit: 40f42ced21b1c0c99780b801d28fafd91a858f90
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jul 18 04:10:28 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jul 18 04:10:28 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=40f42ced
rc-status: fix infinite loop when using stacked runlevels
Remove the recursive call in print_stacked_services which was causing an
infinite loop when using stacked runlevels.
I would like to thank Doug Freed and Jason Zaman for assisting with
tracking this down.
X-Gentoo-Bug: 514972
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=514972
---
src/rc/rc-status.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index e38ce11..62591da 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -185,7 +185,6 @@ print_stacked_services(const char *runlevel)
servicelist = rc_services_in_runlevel(stackedlevel->value);
print_services(stackedlevel->value, servicelist);
rc_stringlist_free(servicelist);
- print_stacked_services(stackedlevel->value);
}
rc_stringlist_free(stackedlevels);
stackedlevels = NULL;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-19 18:06 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-19 18:06 UTC (permalink / raw
To: gentoo-commits
commit: cc1bc6a4cec772c50a1b5232655ff34370d204b1
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Jul 19 17:59:35 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Jul 19 17:59:35 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=cc1bc6a4
src/rc/Makefile: typo fix
---
src/rc/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index 609794a..bd8b942 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -95,5 +95,5 @@ install: all
check test::
-links: $PROG
- $(call make-links,${ALL_LINKS},$PROG,.)
+links: ${PROG}
+ $(call make-links,${ALL_LINKS},${PROG},.)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
2014-08-22 19:10 William Hubbs
@ 2014-07-25 16:06 ` William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-07-25 16:06 UTC (permalink / raw
To: gentoo-commits
commit: 275714bdc74c363ca1612b2b6b97f74f7a62b50c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jul 25 16:04:57 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jul 25 16:04:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=275714bd
checkpath: style fix
---
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index ecd845f..a65dbc2 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -281,7 +281,7 @@ int checkpath(int argc, char **argv)
gid = gr->gr_gid;
#ifdef HAVE_SELINUX
- if (1 == selinux_util_open())
+ if (selinux_util_open() == 1)
selinux_on = true;
#endif
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-07-28 15:51 William Hubbs
2014-08-22 19:10 ` William Hubbs
0 siblings, 1 reply; 257+ messages in thread
From: William Hubbs @ 2014-07-28 15:51 UTC (permalink / raw
To: gentoo-commits
commit: 2624a8c8a7030180f9548a6e2fba5b0a82c5f046
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Jul 28 15:41:24 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jul 28 15:41:24 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=2624a8c8
checkpath: apply ownership to all paths given on command line
The stat structure was not being initialized correctly in do_check. This
was causing the owner adjustment to be skipped if the first path had the
correct owner.
Also, the "correcting owner" message should always be printed when the
owner is being changed.
X-Gentoo-Bug: 518042
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=518042
---
src/rc/checkpath.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index a65dbc2..94ab474 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -67,6 +67,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
int r;
int u;
+ memset(&st, 0, sizeof(st));
if (stat(path, &st) || trunc) {
if (type == inode_file) {
einfo("%s: creating file", path);
@@ -140,8 +141,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
- if (st.st_dev || st.st_ino)
- einfo("%s: correcting owner", path);
+ einfo("%s: correcting owner", path);
if (chown(path, uid, gid)) {
eerror("%s: chown: %s", applet, strerror(errno));
return -1;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
2014-08-22 19:10 William Hubbs
@ 2014-08-11 18:18 ` William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-08-11 18:18 UTC (permalink / raw
To: gentoo-commits
commit: d1e71b07afd4b900894ce4ea45f94010c70e32cc
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Aug 11 17:29:04 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Aug 11 17:32:44 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d1e71b07
Show rc and runscript deprecation warnings in verbose mode
These messages are being changed for this release to show in verbose
mode because of the number of times they display.
---
src/rc/rc-applets.c | 2 +-
src/rc/runscript.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index b4f61d9..8fe2d22 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -539,7 +539,7 @@ run_applets(int argc, char **argv)
* "openrc", so output a warning.
*/
if (strcmp(applet, "rc") == 0)
- ewarn("The 'rc' applet is deprecated; please use 'openrc' instead.");
+ ewarnv("The 'rc' applet is deprecated; please use 'openrc' instead.");
/* Bug 351712: We need an extra way to explicitly select an applet OTHER
* than trusting argv[0], as argv[0] is not going to be the applet value if
* we are doing SELinux context switching. For this, we allow calls such as
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 03d851e..de18f90 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1389,6 +1389,6 @@ openrc_run(int argc, char **argv)
int
runscript(int argc, char **argv)
{
- ewarn("runscript is deprecated; please use openrc-run instead.");
+ ewarnv("runscript is deprecated; please use openrc-run instead.");
return (openrc_run(argc, argv));
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-08-22 19:10 William Hubbs
2014-08-11 18:18 ` William Hubbs
0 siblings, 1 reply; 257+ messages in thread
From: William Hubbs @ 2014-08-22 19:10 UTC (permalink / raw
To: gentoo-commits
commit: d1e71b07afd4b900894ce4ea45f94010c70e32cc
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Aug 11 17:29:04 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Aug 11 17:32:44 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d1e71b07
Show rc and runscript deprecation warnings in verbose mode
These messages are being changed for this release to show in verbose
mode because of the number of times they display.
---
src/rc/rc-applets.c | 2 +-
src/rc/runscript.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index b4f61d9..8fe2d22 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -539,7 +539,7 @@ run_applets(int argc, char **argv)
* "openrc", so output a warning.
*/
if (strcmp(applet, "rc") == 0)
- ewarn("The 'rc' applet is deprecated; please use 'openrc' instead.");
+ ewarnv("The 'rc' applet is deprecated; please use 'openrc' instead.");
/* Bug 351712: We need an extra way to explicitly select an applet OTHER
* than trusting argv[0], as argv[0] is not going to be the applet value if
* we are doing SELinux context switching. For this, we allow calls such as
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 03d851e..de18f90 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1389,6 +1389,6 @@ openrc_run(int argc, char **argv)
int
runscript(int argc, char **argv)
{
- ewarn("runscript is deprecated; please use openrc-run instead.");
+ ewarnv("runscript is deprecated; please use openrc-run instead.");
return (openrc_run(argc, argv));
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-08-22 19:10 William Hubbs
2014-07-25 16:06 ` William Hubbs
0 siblings, 1 reply; 257+ messages in thread
From: William Hubbs @ 2014-08-22 19:10 UTC (permalink / raw
To: gentoo-commits
commit: 275714bdc74c363ca1612b2b6b97f74f7a62b50c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jul 25 16:04:57 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jul 25 16:04:57 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=275714bd
checkpath: style fix
---
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index ecd845f..a65dbc2 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -281,7 +281,7 @@ int checkpath(int argc, char **argv)
gid = gr->gr_gid;
#ifdef HAVE_SELINUX
- if (1 == selinux_util_open())
+ if (selinux_util_open() == 1)
selinux_on = true;
#endif
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
2014-07-28 15:51 William Hubbs
@ 2014-08-22 19:10 ` William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-08-22 19:10 UTC (permalink / raw
To: gentoo-commits
commit: 2624a8c8a7030180f9548a6e2fba5b0a82c5f046
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Jul 28 15:41:24 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jul 28 15:41:24 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=2624a8c8
checkpath: apply ownership to all paths given on command line
The stat structure was not being initialized correctly in do_check. This
was causing the owner adjustment to be skipped if the first path had the
correct owner.
Also, the "correcting owner" message should always be printed when the
owner is being changed.
X-Gentoo-Bug: 518042
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=518042
---
src/rc/checkpath.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index a65dbc2..94ab474 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -67,6 +67,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
int r;
int u;
+ memset(&st, 0, sizeof(st));
if (stat(path, &st) || trunc) {
if (type == inode_file) {
einfo("%s: creating file", path);
@@ -140,8 +141,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
- if (st.st_dev || st.st_ino)
- einfo("%s: correcting owner", path);
+ einfo("%s: correcting owner", path);
if (chown(path, uid, gid)) {
eerror("%s: chown: %s", applet, strerror(errno));
return -1;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2014-09-20 21:52 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2014-09-20 21:52 UTC (permalink / raw
To: gentoo-commits
commit: 866501be1c554de074533ee98400124393d7fe9d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Sep 20 21:51:30 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Sep 20 21:51:30 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=866501be
typo fix
---
src/rc/rc-service.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c
index d35b36b..094848a 100644
--- a/src/rc/rc-service.c
+++ b/src/rc/rc-service.c
@@ -57,7 +57,7 @@ static const struct option longopts[] = {
};
static const char * const longopts_help[] = {
"tests if the service exists or not",
- "if the service exsits then run the command",
+ "if the service exists then run the command",
"list all available services",
"resolve the service name to an init script",
longopts_help_COMMON
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-01-22 18:54 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-01-22 18:54 UTC (permalink / raw
To: gentoo-commits
commit: cddb4aad08615420320f75050042d946b18d2bb5
Author: Will Miles <wmiles <AT> sgl <DOT> com>
AuthorDate: Sat Jan 10 00:34:26 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 22 18:53:41 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=cddb4aad
Fix off-by-one error in --test argument printout in start-stop-daemon.
Fixes #34.
---
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 6229bbf..3afbf2e 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -1075,7 +1075,7 @@ start_stop_daemon(int argc, char **argv)
exit (EXIT_SUCCESS);
einfon("Would start");
- while (argc-- >= 0)
+ while (argc-- > 0)
printf(" %s", *argv++);
printf("\n");
eindent();
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-02-15 22:10 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-02-15 22:10 UTC (permalink / raw
To: gentoo-commits
commit: b17af3c85fc94ecc12857146ba2133a3782ead52
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Feb 15 20:56:07 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Feb 15 22:04:43 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=b17af3c8
checkpath: security fix for -m and -o options
Do not change permissions on the target if it is a file and has multiple
hard links. This is necessary because a hard link can be an attack
vector to gain privilege escalation.
X-Gentoo-Bug: 540006
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540006
---
src/rc/checkpath.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 94ab474..b6f1d6a 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -133,6 +133,10 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (mode && (st.st_mode & 0777) != mode) {
+ if ((type != inode_dir) && (st.st_nlink != 1)) {
+ eerror("%s: chown: %s %s", applet, "Too many hard links to", path);
+ return -1;
+ }
einfo("%s: correcting mode", path);
if (chmod(path, mode)) {
eerror("%s: chmod: %s", applet, strerror(errno));
@@ -141,6 +145,10 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
+ if ((type != inode_dir) && (st.st_nlink != 1)) {
+ eerror("%s: chown: %s %s", applet, "Too many hard links to", path);
+ return -1;
+ }
einfo("%s: correcting owner", path);
if (chown(path, uid, gid)) {
eerror("%s: chown: %s", applet, strerror(errno));
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-02-15 22:15 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-02-15 22:15 UTC (permalink / raw
To: gentoo-commits
commit: 6781667641580fef852ccffc2f42d060f791b354
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Feb 15 22:15:18 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Feb 15 22:15:18 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=67816676
typo fix
---
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index b6f1d6a..4e36242 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -134,7 +134,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
if (mode && (st.st_mode & 0777) != mode) {
if ((type != inode_dir) && (st.st_nlink != 1)) {
- eerror("%s: chown: %s %s", applet, "Too many hard links to", path);
+ eerror("%s: chmod: %s %s", applet, "Too many hard links to", path);
return -1;
}
einfo("%s: correcting mode", path);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-02-19 21:16 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-02-19 21:16 UTC (permalink / raw
To: gentoo-commits
commit: a0378f38713e630e1af9101c2ece5d27ca2130fe
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 19 18:44:21 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 19 20:39:04 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a0378f38
checkpath: do not chown or chmod symbolic links
This is another security fix. If you use chown() or chmod() on a
symbolic link, it affects the referenced file, not the symbolic link
itself.
X-Gentoo-Bug: 540006
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540006
---
src/rc/checkpath.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 4e36242..87115a4 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -68,7 +68,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
int u;
memset(&st, 0, sizeof(st));
- if (stat(path, &st) || trunc) {
+ if (lstat(path, &st) || trunc) {
if (type == inode_file) {
einfo("%s: creating file", path);
if (!mode) /* 664 */
@@ -133,10 +133,14 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (mode && (st.st_mode & 0777) != mode) {
- if ((type != inode_dir) && (st.st_nlink != 1)) {
+ if ((type != inode_dir) && (st.st_nlink > 1)) {
eerror("%s: chmod: %s %s", applet, "Too many hard links to", path);
return -1;
}
+ if (S_ISLNK(st.st_mode)) {
+ eerror("%s: chmod: %s %s", applet, path, " is a symbolic link");
+ return -1;
+ }
einfo("%s: correcting mode", path);
if (chmod(path, mode)) {
eerror("%s: chmod: %s", applet, strerror(errno));
@@ -145,10 +149,14 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
- if ((type != inode_dir) && (st.st_nlink != 1)) {
+ if ((type != inode_dir) && (st.st_nlink > 1)) {
eerror("%s: chown: %s %s", applet, "Too many hard links to", path);
return -1;
}
+ if (S_ISLNK(st.st_mode)) {
+ eerror("%s: chown: %s %s", applet, path, " is a symbolic link");
+ return -1;
+ }
einfo("%s: correcting owner", path);
if (chown(path, uid, gid)) {
eerror("%s: chown: %s", applet, strerror(errno));
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-03-24 20:40 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-03-24 20:40 UTC (permalink / raw
To: gentoo-commits
commit: d7a09327f76e94226ee324a6e70cf415aa96cf89
Author: Will Miles <wmiles <AT> sgl <DOT> com>
AuthorDate: Fri Mar 13 16:34:29 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Mar 24 20:35:47 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d7a09327
start-stop-daemon:Fix regression for --test
The previous fix to --test (PR #34) prevented reading one too many
arguments when --exec -or --name was not specified, but created a
regression where the last argument would not print if either of those
arguments was specified. This corrects the issue.
Fixes #41.
src/rc/start-stop-daemon.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 3afbf2e..7919835 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -919,10 +919,13 @@ start_stop_daemon(int argc, char **argv)
exec = name;
if (name && start)
*argv = name;
- } else if (name)
+ } else if (name) {
*--argv = name;
- else if (exec)
+ ++argc;
+ } else if (exec) {
*--argv = exec;
+ ++argc;
+ };
if (stop || sig != -1) {
if (sig == -1)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-03-24 20:53 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-03-24 20:53 UTC (permalink / raw
To: gentoo-commits
commit: c1faafcad8197a821282b8e56a10132e27eb5d9f
Author: Will Miles <wmiles <AT> sgl <DOT> com>
AuthorDate: Fri Mar 13 16:34:29 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Mar 24 20:52:19 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c1faafca
start-stop-daemon: Fix regression for --test
The previous fix to --test (PR #34) prevented reading one too many
arguments when --exec -or --name was not specified, but created a
regression where the last argument would not print if either of those
arguments was specified. This corrects the issue.
Fixes #41.
src/rc/start-stop-daemon.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 3afbf2e..7919835 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -919,10 +919,13 @@ start_stop_daemon(int argc, char **argv)
exec = name;
if (name && start)
*argv = name;
- } else if (name)
+ } else if (name) {
*--argv = name;
- else if (exec)
+ ++argc;
+ } else if (exec) {
*--argv = exec;
+ ++argc;
+ };
if (stop || sig != -1) {
if (sig == -1)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-03-25 4:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-03-25 4:38 UTC (permalink / raw
To: gentoo-commits
commit: d38cc8f2210e839c4935208917138e4809ece758
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Mar 25 04:17:35 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Mar 25 04:18:15 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d38cc8f2
checkpath: fix warning about selinux_on being unused
src/rc/checkpath.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 87115a4..034cb4d 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -164,10 +164,8 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
}
-#ifdef HAVE_SELINUX
if (selinux_on)
selinux_util_label(path);
-#endif
return 0;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-03-25 6:10 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-03-25 6:10 UTC (permalink / raw
To: gentoo-commits
commit: a4cf61e8bf827dc405a547c314e840dab11fc979
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Mar 25 05:57:05 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Mar 25 06:01:38 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a4cf61e8
selinux: unconditionally include the header and provide stub methods
If selinux is disabled, then stub methods will be provided instead of
calling the real methods. This removes some warnings about unused
parameters which used to be covered up with #ifdef HAVE_SELINUX.
Signed-off-by: Jason Zaman <jason <AT> perfinion.com>
src/rc/checkpath.c | 9 ++-------
src/rc/rc-selinux.h | 14 ++++++++++++++
src/rc/runscript.c | 5 -----
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 034cb4d..3acb040 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -45,10 +45,7 @@
#include "builtins.h"
#include "einfo.h"
#include "rc-misc.h"
-
-#ifdef HAVE_SELINUX
#include "rc-selinux.h"
-#endif
typedef enum {
inode_unknown = 0,
@@ -164,8 +161,10 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
}
+#ifdef HAVE_SELINUX
if (selinux_on)
selinux_util_label(path);
+#endif
return 0;
}
@@ -294,10 +293,8 @@ int checkpath(int argc, char **argv)
if (gr)
gid = gr->gr_gid;
-#ifdef HAVE_SELINUX
if (selinux_util_open() == 1)
selinux_on = true;
-#endif
while (optind < argc) {
if (writable)
@@ -307,10 +304,8 @@ int checkpath(int argc, char **argv)
optind++;
}
-#ifdef HAVE_SELINUX
if (selinux_on)
selinux_util_close();
-#endif
return retval;
}
diff --git a/src/rc/rc-selinux.h b/src/rc/rc-selinux.h
index e28f333..039890b 100644
--- a/src/rc/rc-selinux.h
+++ b/src/rc/rc-selinux.h
@@ -26,10 +26,24 @@
#ifndef RC_SELINUX_UTIL_H
#define RC_SELINUX_UTIL_H
+#ifdef HAVE_SELINUX
+
int selinux_util_open(void);
int selinux_util_label(const char *path);
int selinux_util_close(void);
void selinux_setup(char **argv);
+#else
+
+/* always return false for selinux_util_open() */
+#define selinux_util_open() (0)
+#define selinux_util_label(x) do { } while(0)
+#define selinux_util_close() do { } while(0)
+
+#define selinux_setup(x) do { } while(0)
+
+#endif
+
+
#endif
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 0ac1966..e59c6ae 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -66,10 +66,7 @@
#include "rc.h"
#include "rc-misc.h"
#include "rc-plugin.h"
-
-#ifdef HAVE_SELINUX
#include "rc-selinux.h"
-#endif
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
@@ -1191,10 +1188,8 @@ openrc_run(int argc, char **argv)
eprefix(prefix);
}
-#ifdef HAVE_SELINUX
/* Ok, we are ready to go, so setup selinux if applicable */
selinux_setup(argv);
-#endif
deps = true;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-03-25 13:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-03-25 13:36 UTC (permalink / raw
To: gentoo-commits
commit: b8ab99b5d3ee1a93f215157c36fb120857afde64
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Mar 25 13:33:42 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Mar 25 13:33:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b8ab99b5
checkpath: Remove the last HAVE_SELINUX test
src/rc/checkpath.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 3acb040..a8a1c75 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -161,10 +161,8 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
}
-#ifdef HAVE_SELINUX
if (selinux_on)
selinux_util_label(path);
-#endif
return 0;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-04-24 18:13 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-04-24 18:13 UTC (permalink / raw
To: gentoo-commits
commit: 03803ae8e966755e8bf6d52b61209792cb830cf4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Apr 24 16:20:26 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Apr 24 17:24:09 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=03803ae8
start-stop-daemon: redirect stdin if --background option is used
X-Gentoo-Bug: 498684
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=498684
src/rc/start-stop-daemon.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 7919835..7d2aba3 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -678,6 +678,7 @@ start_stop_daemon(int argc, char **argv)
int tid = 0;
char *redirect_stderr = NULL;
char *redirect_stdout = NULL;
+ int stdin_fd;
int stdout_fd;
int stderr_fd;
pid_t pid, spid;
@@ -1247,6 +1248,7 @@ start_stop_daemon(int argc, char **argv)
setenv("PATH", newpath, 1);
}
+ stdin_fd = devnull_fd;
stdout_fd = devnull_fd;
stderr_fd = devnull_fd;
if (redirect_stdout) {
@@ -1266,7 +1268,8 @@ start_stop_daemon(int argc, char **argv)
applet, redirect_stderr, strerror(errno));
}
- /* We don't redirect stdin as some daemons may need it */
+ if (background)
+ dup2(stdin_fd, STDIN_FILENO);
if (background || redirect_stdout || rc_yesno(getenv("EINFO_QUIET")))
dup2(stdout_fd, STDOUT_FILENO);
if (background || redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-07-23 17:48 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-07-23 17:48 UTC (permalink / raw
To: gentoo-commits
commit: eeadca0b8a5b87c26e60a58563251604350a7a3b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jul 23 17:25:25 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jul 23 17:44:10 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=eeadca0b
Add EERROR_QUIET and EINFO_QUIET to environment whitelist
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 f187158..27d9f81 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -66,6 +66,7 @@ static const char *const env_whitelist[] = {
"LC_MONETARY", "LC_MESSAGES", "LC_PAPER", "LC_NAME", "LC_ADDRESS",
"LC_TELEPHONE", "LC_MEASUREMENT", "LC_IDENTIFICATION", "LC_ALL",
"IN_HOTPLUG", "IN_BACKGROUND", "RC_INTERFACE_KEEP_CONFIG",
+ "EERROR_QUIET", "EINFO_QUIET",
NULL
};
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-08-02 14:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-08-02 14:12 UTC (permalink / raw
To: gentoo-commits
commit: f69833a1e17d1cf65e96a34fcc0e48caf9d90d64
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Aug 1 20:08:31 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Aug 2 12:39:58 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f69833a1
mountinfo: fix -e and -E options
Add the -e and -E options to getoptstring so they are recognized.
src/rc/mountinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 8790dfe..52e47f8 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -347,7 +347,7 @@ get_regex(const char *string)
#include "_usage.h"
#define extraopts "[mount1] [mount2] ..."
-#define getoptstring "f:F:n:N:o:O:p:P:ist" getoptstring_COMMON
+#define getoptstring "f:F:n:N:o:O:p:P:iste:E:" getoptstring_COMMON
static const struct option longopts[] = {
{ "fstype-regex", 1, NULL, 'f'},
{ "skip-fstype-regex", 1, NULL, 'F'},
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-09-18 17:45 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-09-18 17:45 UTC (permalink / raw
To: gentoo-commits
commit: 3b6a6df4b5b818e576a88444632d5c73cffd1c57
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Sep 17 20:02:30 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Sep 17 20:02:30 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3b6a6df4
openrc-run: rename some dependency variables and a function for clarity
All of the dependency type lists had the types_ prefix in their names;
this has been changed to deptypes_ to make them more self documenting.
Along the same lines, the setup_types function was renamed
setup_deptypes.
src/rc/openrc-run.c | 76 ++++++++++++++++++++++++++++-------------------------
1 file changed, 40 insertions(+), 36 deletions(-)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index 989779b..f3a009e 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -85,8 +85,12 @@ static bool sighup, in_background, deps, dry_run;
static pid_t service_pid;
static int signal_pipe[2] = { -1, -1 };
-static RC_STRINGLIST *types_b, *types_n, *types_nu, *types_nua, *types_m;
-static RC_STRINGLIST *types_mua = NULL;
+static RC_STRINGLIST *deptypes_b;
+static RC_STRINGLIST *deptypes_n;
+static RC_STRINGLIST *deptypes_nu;
+static RC_STRINGLIST *deptypes_nua;
+static RC_STRINGLIST *deptypes_m;
+static RC_STRINGLIST *deptypes_mua;
static void
handle_signal(int sig)
@@ -231,12 +235,12 @@ cleanup(void)
rc_plugin_unload();
#ifdef DEBUG_MEMORY
- rc_stringlist_free(types_b);
- rc_stringlist_free(types_n);
- rc_stringlist_free(types_nu);
- rc_stringlist_free(types_nua);
- rc_stringlist_free(types_m);
- rc_stringlist_free(types_mua);
+ rc_stringlist_free(deptypes_b);
+ rc_stringlist_free(deptypes_n);
+ rc_stringlist_free(deptypes_nu);
+ rc_stringlist_free(deptypes_nua);
+ rc_stringlist_free(deptypes_m);
+ rc_stringlist_free(deptypes_mua);
rc_deptree_free(deptree);
rc_stringlist_free(restart_services);
rc_stringlist_free(need_services);
@@ -518,30 +522,30 @@ get_started_services(void)
}
static void
-setup_types(void)
+setup_deptypes(void)
{
- types_b = rc_stringlist_new();
- rc_stringlist_add(types_b, "broken");
+ deptypes_b = rc_stringlist_new();
+ rc_stringlist_add(deptypes_b, "broken");
- types_n = rc_stringlist_new();
- rc_stringlist_add(types_n, "ineed");
+ deptypes_n = rc_stringlist_new();
+ rc_stringlist_add(deptypes_n, "ineed");
- types_nu = rc_stringlist_new();
- rc_stringlist_add(types_nu, "ineed");
- rc_stringlist_add(types_nu, "iuse");
+ deptypes_nu = rc_stringlist_new();
+ rc_stringlist_add(deptypes_nu, "ineed");
+ rc_stringlist_add(deptypes_nu, "iuse");
- types_nua = rc_stringlist_new();
- rc_stringlist_add(types_nua, "ineed");
- rc_stringlist_add(types_nua, "iuse");
- rc_stringlist_add(types_nua, "iafter");
+ deptypes_nua = rc_stringlist_new();
+ rc_stringlist_add(deptypes_nua, "ineed");
+ rc_stringlist_add(deptypes_nua, "iuse");
+ rc_stringlist_add(deptypes_nua, "iafter");
- types_m = rc_stringlist_new();
- rc_stringlist_add(types_m, "needsme");
+ deptypes_m = rc_stringlist_new();
+ rc_stringlist_add(deptypes_m, "needsme");
- types_mua = rc_stringlist_new();
- rc_stringlist_add(types_mua, "needsme");
- rc_stringlist_add(types_mua, "usesme");
- rc_stringlist_add(types_mua, "beforeme");
+ deptypes_mua = rc_stringlist_new();
+ rc_stringlist_add(deptypes_mua, "needsme");
+ rc_stringlist_add(deptypes_mua, "usesme");
+ rc_stringlist_add(deptypes_mua, "beforeme");
}
static void
@@ -604,10 +608,10 @@ svc_start_deps(void)
if (!deptree && ((deptree = _rc_deptree_load(0, NULL)) == NULL))
eerrorx("failed to load deptree");
- if (!types_b)
- setup_types();
+ if (!deptypes_b)
+ setup_deptypes();
- services = rc_deptree_depends(deptree, types_b, applet_list,
+ services = rc_deptree_depends(deptree, deptypes_b, applet_list,
runlevel, 0);
if (TAILQ_FIRST(services)) {
eerrorn("ERROR: %s needs service(s) ", applet);
@@ -625,9 +629,9 @@ svc_start_deps(void)
rc_stringlist_free(services);
services = NULL;
- need_services = rc_deptree_depends(deptree, types_n,
+ need_services = rc_deptree_depends(deptree, deptypes_n,
applet_list, runlevel, depoptions);
- use_services = rc_deptree_depends(deptree, types_nu,
+ use_services = rc_deptree_depends(deptree, deptypes_nu,
applet_list, runlevel, depoptions);
if (!rc_runlevel_starting()) {
@@ -655,7 +659,7 @@ svc_start_deps(void)
return;
/* Now wait for them to start */
- services = rc_deptree_depends(deptree, types_nua, applet_list,
+ services = rc_deptree_depends(deptree, deptypes_nua, applet_list,
runlevel, depoptions);
/* We use tmplist to hold our scheduled by list */
tmplist = rc_stringlist_new();
@@ -860,10 +864,10 @@ svc_stop_deps(RC_SERVICE state)
if (!deptree && ((deptree = _rc_deptree_load(0, NULL)) == NULL))
eerrorx("failed to load deptree");
- if (!types_m)
- setup_types();
+ if (!deptypes_m)
+ setup_deptypes();
- services = rc_deptree_depends(deptree, types_m, applet_list,
+ services = rc_deptree_depends(deptree, deptypes_m, applet_list,
runlevel, depoptions);
tmplist = rc_stringlist_new();
TAILQ_FOREACH_REVERSE(svc, services, rc_stringlist, entries) {
@@ -923,7 +927,7 @@ svc_stop_deps(RC_SERVICE state)
/* We now wait for other services that may use us and are
* stopping. This is important when a runlevel stops */
- services = rc_deptree_depends(deptree, types_mua, applet_list,
+ services = rc_deptree_depends(deptree, deptypes_mua, applet_list,
runlevel, depoptions);
TAILQ_FOREACH(svc, services, entries) {
if (rc_service_state(svc->value) & RC_SERVICE_STOPPED)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-10-04 20:37 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-10-04 20:37 UTC (permalink / raw
To: gentoo-commits
commit: b3f7ff901f7d3ed00b9f73c601193ac507f62eaf
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Oct 4 20:35:33 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Oct 4 20:35:33 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b3f7ff90
mountinfo: read /proc/self/mounts instead of /proc/mounts on Linux
src/rc/mountinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 52e47f8..3972a77 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -298,7 +298,7 @@ find_mounts(struct args *args)
int netdev;
RC_STRINGLIST *list;
- if ((fp = fopen("/proc/mounts", "r")) == NULL)
+ if ((fp = fopen("/proc/self/mounts", "r")) == NULL)
eerrorx("getmntinfo: %s", strerror(errno));
list = rc_stringlist_new();
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-10-05 15:27 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-10-05 15:27 UTC (permalink / raw
To: gentoo-commits
commit: 5f4f2420364098835522da868a9e75205c9e4f9c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Oct 5 15:18:00 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 5 15:18:00 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5f4f2420
mountinfo: fix --netdev and --nonetdev on Linux
On Linux, the --netdev and --nonetdev switches were not working. They
were both returning false. After this change, they operate based on the
presence or abscence of the _netdev option in mount options.
src/rc/mountinfo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 3972a77..53f2890 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -305,7 +305,6 @@ find_mounts(struct args *args)
buffer = xmalloc(sizeof(char) * PATH_MAX * 3);
while (fgets(buffer, PATH_MAX * 3, fp)) {
- netdev = -1;
p = buffer;
from = strsep(&p, " ");
to = strsep(&p, " ");
@@ -315,6 +314,8 @@ find_mounts(struct args *args)
if ((ent = getmntfile(to))) {
if (strstr(ent->mnt_opts, "_netdev"))
netdev = 0;
+ else
+ netdev = 1;
}
process_mount(list, args, from, to, fst, opts, netdev);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-10-13 13:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-10-13 13:36 UTC (permalink / raw
To: gentoo-commits
commit: b81317bdf8e3eed8b8ff2bef757ba29f362ed297
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Oct 13 13:27:43 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 13 13:27:43 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b81317bd
mountinfo: make sure the netdev variable is initialized on Linux
This fixes the following regression:
X-Gentoo-Bug: 562668
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=562668
src/rc/mountinfo.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 53f2890..3f1dfb6 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -305,6 +305,7 @@ find_mounts(struct args *args)
buffer = xmalloc(sizeof(char) * PATH_MAX * 3);
while (fgets(buffer, PATH_MAX * 3, fp)) {
+ netdev = -1;
p = buffer;
from = strsep(&p, " ");
to = strsep(&p, " ");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-12-02 21:46 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-12-02 21:46 UTC (permalink / raw
To: gentoo-commits
commit: f5cf1136e70502ee530f20f0434f312611b12b51
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Dec 2 21:44:35 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Dec 2 21:44:35 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f5cf1136
Use systype variable for rc_sys call
src/rc/rc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index d96aa45..8f69333 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -752,6 +752,7 @@ main(int argc, char **argv)
{
const char *bootlevel = NULL;
char *newlevel = NULL;
+ const char *systype = NULL;
static RC_STRINGLIST *hotplugged_services;
static RC_STRINGLIST *stop_services;
static RC_STRINGLIST *start_services;
@@ -845,9 +846,9 @@ main(int argc, char **argv)
eerrorx("%s: %s", applet, strerror(errno));
/* NOTREACHED */
case 'S':
- bootlevel = rc_sys();
- if (bootlevel)
- printf("%s\n", bootlevel);
+ systype = rc_sys();
+ if (systype)
+ printf("%s\n", systype);
exit(EXIT_SUCCESS);
/* NOTREACHED */
case_RC_COMMON_GETOPT
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2015-12-06 0:14 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2015-12-06 0:14 UTC (permalink / raw
To: gentoo-commits
commit: 83cd7145e3e7c3ac453b6a87214cf5704e3875ce
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Dec 5 23:47:47 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Dec 5 23:47:47 2015 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=83cd7145
Rename bootlevel variable in _usage.c
In src/rc/_usage.c, we were using bootlevel as the variable to hold the
return value of rc_sys.
This changes the variable name to systype because this function returns
a system type, not a runlevel.
src/rc/_usage.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rc/_usage.c b/src/rc/_usage.c
index a95e93f..2ab0fa6 100644
--- a/src/rc/_usage.c
+++ b/src/rc/_usage.c
@@ -53,11 +53,11 @@ static void set_quiet_options(void)
_noreturn static void
show_version(void)
{
- const char *bootlevel = NULL;
+ const char *systype = NULL;
printf("%s (OpenRC", applet);
- if ((bootlevel = rc_sys()))
- printf(" [%s]", bootlevel);
+ if ((systype = rc_sys()))
+ printf(" [%s]", systype);
printf(") %s", VERSION);
#ifdef BRANDING
printf(" (%s)", BRANDING);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-12 20:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-12 20:12 UTC (permalink / raw
To: gentoo-commits
commit: 53bc986ce5f9725d7117356e28224ac898f9c9bf
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Jan 4 18:32:16 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 4 21:14:15 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=53bc986c
Clean default env_whitelist
The whitelist of environment variables we pass to service scripts
included several unnecessary variables.
The default whitelist now includes EERROR_QUIET, EINFO_QUIET,
IN_BACKGROUND and IN_HOTPLUG.
X-Gentoo-Bug: 569542
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=569542
src/rc/rc-misc.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index bb401e1..dbdac68 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -48,12 +48,8 @@ rc_conf_yesno(const char *setting)
}
static const char *const env_whitelist[] = {
- "CONSOLE", "PATH", "SHELL", "USER", "HOME", "TERM",
- "LANG", "LC_CTYPE", "LC_NUMERIC", "LC_TIME", "LC_COLLATE",
- "LC_MONETARY", "LC_MESSAGES", "LC_PAPER", "LC_NAME", "LC_ADDRESS",
- "LC_TELEPHONE", "LC_MEASUREMENT", "LC_IDENTIFICATION", "LC_ALL",
- "IN_HOTPLUG", "IN_BACKGROUND", "RC_INTERFACE_KEEP_CONFIG",
"EERROR_QUIET", "EINFO_QUIET",
+ "IN_BACKGROUND", "IN_HOTPLUG",
NULL
};
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-14 17:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-14 17:33 UTC (permalink / raw
To: gentoo-commits
commit: 6da0abc0850dfc99df0ba50cbd0092929ec0107b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jan 14 16:53:03 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 14 17:29:24 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6da0abc0
fix selinux build
X-Gentoo-Bug: 571798
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=571798
src/rc/Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index da1e5ee..ed0733e 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -105,12 +105,12 @@ mountinfo: mountinfo.o _usage.o rc-misc.o
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
-ifeq (${MKSELINUX},yes)
-openrc rc: rc-selinux.o
-endif
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
+ifeq (${MKSELINUX},yes)
+openrc-run runscript: rc-selinux.o
+endif
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
rc-abort: rc-abort.o
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-14 17:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-14 17:33 UTC (permalink / raw
To: gentoo-commits
commit: b34df9dd817069ade7e0526a59aaa9d3f2beb806
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jan 14 02:11:06 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 14 02:11:06 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b34df9dd
fix selinux build
src/rc/Makefile | 10 ++++++++--
src/rc/rc-selinux.c | 4 ----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index 1df26d8..da1e5ee 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -75,7 +75,10 @@ check test::
all: ${ALL_PROGS}
-checkpath: checkpath.o _usage.o rc-misc.o rc-selinux.o
+checkpath: checkpath.o _usage.o rc-misc.o
+ifeq (${MKSELINUX},yes)
+checkpath: rc-selinux.o
+endif
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
@@ -101,7 +104,10 @@ mark_service_hotplugged mark_service_failed: do_mark_service.o rc-misc.o
mountinfo: mountinfo.o _usage.o rc-misc.o
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
-openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o rc-selinux.o _usage.o
+openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
+ifeq (${MKSELINUX},yes)
+openrc rc: rc-selinux.o
+endif
${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/rc-selinux.c b/src/rc/rc-selinux.c
index 3e484a6..ed89be1 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -15,8 +15,6 @@
* except according to the terms contained in the LICENSE file.
*/
-#ifdef HAVE_SELINUX
-
#include <stddef.h>
#include <errno.h>
#include <dlfcn.h>
@@ -386,5 +384,3 @@ out:
free(run_init_t);
free(curr_t);
}
-
-#endif
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-14 17:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-14 17:33 UTC (permalink / raw
To: gentoo-commits
commit: d4c7207ef3906daf6f8646e8deb6d968fe76cb36
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jan 14 01:29:11 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 14 01:30:19 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d4c7207e
fix seg fault
src/rc/rc-misc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index 6dfa423..f01d1f8 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -179,6 +179,8 @@ env_config(void)
sys = detect_container();
if (!sys)
sys = detect_vm();
+
+ if (sys)
setenv("RC_SYS", sys, 1);
#ifdef PREFIX
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-14 17:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-14 17:33 UTC (permalink / raw
To: gentoo-commits
commit: 6f02069746f4d8a2331ab7e000abdca9bbdd622d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jan 14 01:34:22 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 14 01:34:22 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6f020697
Add LANG, LC_MESSAGES and TERM to the environment whitelist
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 f01d1f8..2c6c388 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -53,6 +53,7 @@ rc_conf_yesno(const char *setting)
static const char *const env_whitelist[] = {
"EERROR_QUIET", "EINFO_QUIET",
"IN_BACKGROUND", "IN_HOTPLUG",
+ "LANG", "LC_MESSAGES", "TERM",
NULL
};
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-19 6:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-19 6:12 UTC (permalink / raw
To: gentoo-commits
commit: 79359f77cc786e18695368bccb6b6186ecfe38c0
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Jan 16 21:34:17 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 22:06:39 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=79359f77
fix bsd build
X-Gentoo-Bug: 572068
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572068
src/rc/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index a940102..71ae503 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -2,7 +2,7 @@ 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-selinux.c rc-service.c rc-status.c rc-update.c \
+ rc-service.c rc-status.c rc-update.c \
shell_var.c start-stop-daemon.c swclock.c _usage.c
ifeq (${MKSELINUX},yes)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-19 6:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-19 6:12 UTC (permalink / raw
To: gentoo-commits
commit: 62b49b2a3ad1c13012305b4d7281d7f6543c70d7
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jan 18 06:57:26 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 19 06:09:20 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=62b49b2a
rc: remove use of magic constant and allow OpenVZ to drop to shell
OpenVZ has had console support for a long time now; allow them to use it
to drop to a shell during interactive boot.
src/rc/rc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 1aae45f..7836341 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -283,9 +283,8 @@ open_shell(void)
#ifdef __linux__
const char *sys = rc_sys();
- /* VSERVER and OPENVZ systems cannot really drop to shells */
- if (sys &&
- (strcmp(sys, "VSERVER") == 0 || strcmp(sys, "OPENVZ") == 0))
+ /* 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",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-19 6:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-19 6:12 UTC (permalink / raw
To: gentoo-commits
commit: 0910c455d3723ac4d4b793afb61cd82f660547f4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jan 14 19:33:05 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 14 19:33:05 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0910c455
src/rc/Makefile: fix make depend target
src/rc/Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index ed0733e..a940102 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -1,4 +1,9 @@
-SRCS= rc.c rc-logger.c rc-misc.c rc-plugin.c
+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-selinux.c rc-service.c rc-status.c rc-update.c \
+ shell_var.c start-stop-daemon.c swclock.c _usage.c
ifeq (${MKSELINUX},yes)
SRCS+= rc-selinux.c
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-20 17:29 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-20 17:29 UTC (permalink / raw
To: gentoo-commits
commit: e4eacf02cae10eca48f6906592981d701b0c1973
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jan 20 17:19:01 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jan 20 17:20:40 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e4eacf02
openrc-run: in verbose mode, log execution of the shell script
This is to show when openrc-run runs the openrc-run.sh script; it is
used for debugging.
src/rc/openrc-run.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index 757412a..2a4b90d 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -390,6 +390,14 @@ svc_exec(const char *arg1, const char *arg2)
}
if (exists(RC_SVCDIR "/openrc-run.sh")) {
+ if (arg2)
+ einfov("Executing: %s %s %s %s %s",
+ RC_SVCDIR "/openrc-run.sh", RC_SVCDIR "/openrc-run.sh",
+ service, arg1, arg2);
+ else
+ einfov("Executing: %s %s %s %s",
+ RC_SVCDIR "/openrc-run.sh", RC_SVCDIR "/openrc-run.sh",
+ service, arg1);
execl(RC_SVCDIR "/openrc-run.sh",
RC_SVCDIR "/openrc-run.sh",
service, arg1, arg2, (char *) NULL);
@@ -397,6 +405,16 @@ svc_exec(const char *arg1, const char *arg2)
service, strerror(errno));
_exit(EXIT_FAILURE);
} else {
+ if (arg2)
+ einfov("Executing: %s %s %s %s %s",
+ RC_LIBEXECDIR "/sh/openrc-run.sh",
+ RC_LIBEXECDIR "/sh/openrc-run.sh",
+ service, arg1, arg2);
+ else
+ einfov("Executing: %s %s %s %s",
+ RC_LIBEXECDIR "/sh/openrc-run.sh",
+ RC_LIBEXECDIR "/sh/openrc-run.sh",
+ service, arg1);
execl(RC_LIBEXECDIR "/sh/openrc-run.sh",
RC_LIBEXECDIR "/sh/openrc-run.sh",
service, arg1, arg2, (char *) NULL);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-01-22 18:53 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-01-22 18:53 UTC (permalink / raw
To: gentoo-commits
commit: 47dd5e37cbf372df3ee0fad2c87226dce5b51587
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jan 22 18:46:29 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jan 22 18:46:29 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=47dd5e37
add back deprecation warnings lost during refactoring
src/rc/openrc-run.c | 4 ++++
src/rc/rc.c | 2 ++
2 files changed, 6 insertions(+)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index 2a4b90d..5e3ba67 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -1121,6 +1121,10 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
+ applet = basename_c(argv[0]);
+ if (strcmp(applet, "runscript") == 0)
+ ewarnv("runscript is deprecated, please use openrc-run instead.");
+
if (stat(argv[1], &stbuf) != 0) {
fprintf(stderr, "openrc-run `%s': %s\n",
argv[1], strerror(errno));
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 4efa0cf..11170b4 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -830,6 +830,8 @@ int main(int argc, char **argv)
}
}
+ if (strcmp(applet, "rc") == 0)
+ ewarnv("rc is deprecated, please use openrc instead.");
newlevel = argv[optind++];
/* To make life easier, we only have the shutdown runlevel as
* nothing really needs to know that we're rebooting.
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-02-12 18:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-02-12 18:58 UTC (permalink / raw
To: gentoo-commits
commit: 7eaf71176b87ae69bfa622aa621341a19a9d32b0
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Feb 12 18:40:55 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 12 18:44:52 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7eaf7117
Fix rc_env_allow wildcard usage
Before this commit, using * in rc_env_allow did not work.
This fixes #60.
src/rc/rc-misc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index f2967dd..82f1b78 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -68,6 +68,12 @@ env_filter(void)
/* Add the user defined list of vars */
env_allow = rc_stringlist_split(rc_conf_value("rc_env_allow"), " ");
+ /*
+ * If '*' is an entry in rc_env_allow, do nothing as we are to pass
+ * through all environment variables.
+ */
+ if (rc_stringlist_find(env_allow, "*"))
+ return;
profile = rc_config_load(RC_PROFILE_ENV);
/* Copy the env and work from this so we can manipulate it safely */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-04-11 16:18 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-04-11 16:18 UTC (permalink / raw
To: gentoo-commits
commit: 171e856ec8a0a64504b4b4a47ab6181d37fc3dbe
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 16 14:25:27 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 16:11:59 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=171e856e
start-stop-daemon: Allow group read/write when creating output files
This allows for better interaction with inherited ACL entries.
This fixes #84.
X-Gentoo-Bug: 577362
X-Gentoo-Bug-URL: https://bugs.gentoo.org/577362
src/rc/start-stop-daemon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 775bd7d..8ed3e92 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -1242,7 +1242,7 @@ int main(int argc, char **argv)
if (redirect_stdout) {
if ((stdout_fd = open(redirect_stdout,
O_WRONLY | O_CREAT | O_APPEND,
- S_IRUSR | S_IWUSR)) == -1)
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) == -1)
eerrorx("%s: unable to open the logfile"
" for stdout `%s': %s",
applet, redirect_stdout, strerror(errno));
@@ -1250,7 +1250,7 @@ int main(int argc, char **argv)
if (redirect_stderr) {
if ((stderr_fd = open(redirect_stderr,
O_WRONLY | O_CREAT | O_APPEND,
- S_IRUSR | S_IWUSR)) == -1)
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) == -1)
eerrorx("%s: unable to open the logfile"
" for stderr `%s': %s",
applet, redirect_stderr, strerror(errno));
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-05-04 23:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-05-04 23:24 UTC (permalink / raw
To: gentoo-commits
commit: ad23d5b8dbee70815c02271c78f415bcd7088076
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed May 4 23:17:58 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed May 4 23:17:58 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ad23d5b8
openrc-run: clean up runscript deprecation message
src/rc/openrc-run.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index 5e3ba67..dfb4c6f 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -1106,6 +1106,7 @@ service_plugable(void)
int main(int argc, char **argv)
{
bool doneone = false;
+ bool runscript = false;
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
char path[PATH_MAX], lnk[PATH_MAX];
@@ -1123,7 +1124,7 @@ int main(int argc, char **argv)
applet = basename_c(argv[0]);
if (strcmp(applet, "runscript") == 0)
- ewarnv("runscript is deprecated, please use openrc-run instead.");
+ runscript = true;
if (stat(argv[1], &stbuf) != 0) {
fprintf(stderr, "openrc-run `%s': %s\n",
@@ -1172,6 +1173,9 @@ int main(int argc, char **argv)
if (argc < 3)
usage(EXIT_FAILURE);
+ if (runscript)
+ ewarnv("%s uses runscript, please convert to openrc-run.", service);
+
/* Change dir to / to ensure all init scripts don't use stuff in pwd */
if (chdir("/") == -1)
eerror("chdir: %s", strerror(errno));
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-05-13 17:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-05-13 17:12 UTC (permalink / raw
To: gentoo-commits
commit: 3b5a8b331e81ecd9a9362553c16f4527291d5528
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri May 13 17:05:23 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri May 13 17:05:23 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3b5a8b33
supervise-daemon: add pam service file
src/rc/Makefile | 1 +
src/rc/supervise-daemon.c | 2 +-
src/rc/supervise-daemon.pam | 6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index d4759e7..74d74a0 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -75,6 +75,7 @@ install: all
if test "${MKPAM}" = pam; then \
${INSTALL} -d ${DESTDIR}${PAMDIR}; \
${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \
+ ${INSTALL} -m ${PAMMODE} supervise-daemon.pam ${DESTDIR}${PAMDIR}/supervise-daemon; \
fi
check test::
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 6bb75f3..2d8287f 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -202,7 +202,7 @@ static void child_process(char *exec, char **argv)
#ifdef HAVE_PAM
if (changeuser != NULL) {
- pamr = pam_start("start-stop-daemon",
+ pamr = pam_start("supervise-daemon",
changeuser, &conv, &pamh);
if (pamr == PAM_SUCCESS)
diff --git a/src/rc/supervise-daemon.pam b/src/rc/supervise-daemon.pam
new file mode 100644
index 0000000..a1bada2
--- /dev/null
+++ b/src/rc/supervise-daemon.pam
@@ -0,0 +1,6 @@
+#%PAM-1.0
+
+auth required pam_permit.so
+account required pam_permit.so
+password required pam_deny.so
+session optional pam_limits.so
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-05-13 18:00 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-05-13 18:00 UTC (permalink / raw
To: gentoo-commits
commit: 3fa9015b8e5610d38366f781a08789e34159b0dc
Author: Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Sun Mar 6 08:22:51 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri May 13 17:52:21 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3fa9015b
rc-selinux: access check was backwards
src/rc/rc-selinux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index ed89be1..a792fe2 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -370,7 +370,7 @@ void selinux_setup(char **argv)
* which will open the pty with initrc_devpts_t, if it doesnt exist,
* fall back to plain exec
*/
- if (access("/usr/sbin/open_init_pty", X_OK)) {
+ if (!access("/usr/sbin/open_init_pty", X_OK)) {
if (execvp("/usr/sbin/open_init_pty", argv)) {
perror("execvp");
exit(-1);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-05-24 16:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-05-24 16:43 UTC (permalink / raw
To: gentoo-commits
commit: 94077d264e14783e6ca5603d64e9d579fb206c20
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 23 16:06:40 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 23 16:10:51 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=94077d26
supervise-daemon: log the exit code or signal when a child process dies
src/rc/supervise-daemon.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 2d8287f..c1ef169 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -702,8 +702,12 @@ int main(int argc, char **argv)
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
kill(child_pid, SIGTERM);
} else {
- syslog(LOG_INFO, "%s, pid %d, terminated unexpectedly",
- exec, child_pid);
+ if (WIFEXITED(i))
+ syslog(LOG_INFO, "%s, pid %d, exited with return code %d",
+ exec, child_pid, WEXITSTATUS(i));
+ else if (WIFSIGNALED(i))
+ syslog(LOG_INFO, "%s, pid %d, terminated by signal %d",
+ exec, child_pid, WTERMSIG(i));
child_pid = fork();
if (child_pid == -1)
eerrorx("%s: fork: %s", applet, strerror(errno));
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-05-24 16:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-05-24 16:43 UTC (permalink / raw
To: gentoo-commits
commit: 87884db66767eba6317b506a4d7270dd22721831
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 24 16:24:10 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 24 16:24:10 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=87884db6
Make deprecation warnings for rc and runscript more visible
These warnings were inserted in verbose only mode in OpenRC-0.13.A
Now, we are making them more visible in preparation for removing these
compatibility binaries in the future.
src/rc/openrc-run.c | 2 +-
src/rc/rc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index dfb4c6f..275cb32 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -1174,7 +1174,7 @@ int main(int argc, char **argv)
usage(EXIT_FAILURE);
if (runscript)
- ewarnv("%s uses runscript, please convert to openrc-run.", service);
+ ewarn("%s uses runscript, please convert to openrc-run.", service);
/* Change dir to / to ensure all init scripts don't use stuff in pwd */
if (chdir("/") == -1)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 11170b4..ed06bf7 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -831,7 +831,7 @@ int main(int argc, char **argv)
}
if (strcmp(applet, "rc") == 0)
- ewarnv("rc is deprecated, please use openrc instead.");
+ ewarn("rc is deprecated, please use openrc instead.");
newlevel = argv[optind++];
/* To make life easier, we only have the shutdown runlevel as
* nothing really needs to know that we're rebooting.
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-06-10 22:45 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-06-10 22:45 UTC (permalink / raw
To: gentoo-commits
commit: b2c92b88cc6ce6d81444667efbc6d44542db1788
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 7 09:31:48 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jun 10 22:16:37 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b2c92b88
fstabinfo/mountinfo: ensure /etc/fstab exists before calling setmntent
This is based on a patch by A. Wilcox <awilfox.gentoo <AT> foxkit.us>.
X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226
X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226
src/rc/fstabinfo.c | 3 +++
src/rc/mountinfo.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index bd2372d..75c8bc2 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -178,6 +178,9 @@ int main(int argc, char **argv)
FILE *fp;
#endif
+ /* fail if there is no /etc/fstab */
+ if (!exists("/etc/fstab"))
+ eerrorx("/etc/fstab does not exist");
/* Ensure that we are only quiet when explicitly told to be */
unsetenv("EINFO_QUIET");
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 10e3238..29eb160 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -297,6 +297,9 @@ getmntfile(const char *file)
struct mntent *ent = NULL;
FILE *fp;
+ if (!exists("/etc/fstab"))
+ return NULL;
+
fp = setmntent("/etc/fstab", "r");
while ((ent = getmntent(fp)))
if (strcmp(file, ent->mnt_dir) == 0)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-07-14 17:25 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-07-14 17:25 UTC (permalink / raw
To: gentoo-commits
commit: 20035210bdf5d5729734457f35f5f32a53a5b3ad
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jul 14 17:13:17 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 17:13:17 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=20035210
make variable aflag a boolean show_all
src/rc/rc-status.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 5018662..a0a2fce 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -176,9 +176,9 @@ print_stacked_services(const char *runlevel)
int main(int argc, char **argv)
{
RC_STRING *s, *l, *t, *level;
-
+ bool show_all = false;
char *p, *runlevel = NULL;
- int opt, aflag = 0, retval = 0;
+ int opt, retval = 0;
test_crashed = _rc_can_find_pids();
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
(int *) 0)) != -1)
switch (opt) {
case 'a':
- aflag++;
+ show_all = true;
levels = rc_runlevel_list();
break;
case 'c':
@@ -265,7 +265,7 @@ int main(int argc, char **argv)
services = NULL;
}
- if (aflag || argc < 2) {
+ if (show_all || argc < 2) {
/* Show hotplugged services */
print_level("Dynamic", "hotplugged");
services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
@@ -274,7 +274,7 @@ int main(int argc, char **argv)
services = NULL;
/* Show manually started and unassigned depended services */
- if (aflag) {
+ if (show_all) {
rc_stringlist_free(levels);
levels = rc_stringlist_new();
if (!runlevel)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-07-16 20:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-07-16 20:17 UTC (permalink / raw
To: gentoo-commits
commit: c962678dd6ab1314b55c2a3bcdae03902bda39b8
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Sat Jul 16 20:10:37 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Jul 16 20:10:37 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c962678d
rc: Rename some static variables to kill warnings
src/rc/rc.c | 80 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 45f57b3..2c517f2 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -86,12 +86,12 @@ const char *usagestring = "" \
#define DEVBOOT "/dev/.rcboot"
const char *applet = NULL;
-static RC_STRINGLIST *hotplugged_services;
-static RC_STRINGLIST *stop_services;
-static RC_STRINGLIST *start_services;
-static RC_STRINGLIST *types_nw;
-static RC_STRINGLIST *types_nwua;
-static RC_DEPTREE *deptree;
+static RC_STRINGLIST *main_hotplugged_services;
+static RC_STRINGLIST *main_stop_services;
+static RC_STRINGLIST *main_start_services;
+static RC_STRINGLIST *main_types_nw;
+static RC_STRINGLIST *main_types_nwua;
+static RC_DEPTREE *main_deptree;
static char *runlevel;
static RC_HOOK hook_out;
@@ -162,12 +162,12 @@ cleanup(void)
p1 = p2;
}
- rc_stringlist_free(hotplugged_services);
- rc_stringlist_free(stop_services);
- rc_stringlist_free(start_services);
- rc_stringlist_free(types_nw);
- rc_stringlist_free(types_nwua);
- rc_deptree_free(deptree);
+ rc_stringlist_free(main_hotplugged_services);
+ rc_stringlist_free(main_stop_services);
+ rc_stringlist_free(main_start_services);
+ rc_stringlist_free(main_types_nw);
+ rc_stringlist_free(main_types_nwua);
+ rc_deptree_free(main_deptree);
free(runlevel);
}
@@ -939,7 +939,7 @@ int main(int argc, char **argv)
}
/* Load our deptree */
- if ((deptree = _rc_deptree_load(0, ®en)) == NULL)
+ if ((main_deptree = _rc_deptree_load(0, ®en)) == NULL)
eerrorx("failed to load deptree");
if (exists(RC_DEPTREE_SKEWED))
ewarn("WARNING: clock skew detected!");
@@ -961,27 +961,27 @@ int main(int argc, char **argv)
* in the new or current runlevel so we won't actually be stopping
* them all.
*/
- stop_services = rc_services_in_state(RC_SERVICE_STARTED);
+ main_stop_services = rc_services_in_state(RC_SERVICE_STARTED);
tmplist = rc_services_in_state(RC_SERVICE_INACTIVE);
- TAILQ_CONCAT(stop_services, tmplist, entries);
+ TAILQ_CONCAT(main_stop_services, tmplist, entries);
free(tmplist);
tmplist = rc_services_in_state(RC_SERVICE_STARTING);
- TAILQ_CONCAT(stop_services, tmplist, entries);
+ TAILQ_CONCAT(main_stop_services, tmplist, entries);
free(tmplist);
- if (stop_services)
- rc_stringlist_sort(&stop_services);
+ if (main_stop_services)
+ rc_stringlist_sort(&main_stop_services);
- types_nwua = rc_stringlist_new();
- rc_stringlist_add(types_nwua, "ineed");
- rc_stringlist_add(types_nwua, "iwant");
- rc_stringlist_add(types_nwua, "iuse");
- rc_stringlist_add(types_nwua, "iafter");
+ main_types_nwua = rc_stringlist_new();
+ rc_stringlist_add(main_types_nwua, "ineed");
+ rc_stringlist_add(main_types_nwua, "iwant");
+ rc_stringlist_add(main_types_nwua, "iuse");
+ rc_stringlist_add(main_types_nwua, "iafter");
- if (stop_services) {
- tmplist = rc_deptree_depends(deptree, types_nwua, stop_services,
+ if (main_stop_services) {
+ tmplist = rc_deptree_depends(main_deptree, main_types_nwua, main_stop_services,
runlevel, depoptions | RC_DEP_STOP);
- rc_stringlist_free(stop_services);
- stop_services = tmplist;
+ rc_stringlist_free(main_stop_services);
+ main_stop_services = tmplist;
}
/* Create a list of all services which should be started for the new or
@@ -989,14 +989,14 @@ int main(int argc, char **argv)
* runlevels. Clearly, some of these will already be started so we
* won't actually be starting them all.
*/
- hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
- start_services = rc_services_in_runlevel_stacked(newlevel ?
+ main_hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
+ main_start_services = rc_services_in_runlevel_stacked(newlevel ?
newlevel : runlevel);
if (strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SYSINIT) != 0)
{
tmplist = rc_services_in_runlevel(RC_LEVEL_SYSINIT);
- TAILQ_CONCAT(start_services, tmplist, entries);
+ TAILQ_CONCAT(main_start_services, tmplist, entries);
free(tmplist);
/* If we are NOT headed for the single-user runlevel... */
if (strcmp(newlevel ? newlevel : runlevel,
@@ -1007,13 +1007,13 @@ int main(int argc, char **argv)
bootlevel) != 0)
{
tmplist = rc_services_in_runlevel(bootlevel);
- TAILQ_CONCAT(start_services, tmplist, entries);
+ TAILQ_CONCAT(main_start_services, tmplist, entries);
free(tmplist);
}
- if (hotplugged_services) {
- TAILQ_FOREACH(service, hotplugged_services,
+ if (main_hotplugged_services) {
+ TAILQ_FOREACH(service, main_hotplugged_services,
entries)
- rc_stringlist_addu(start_services,
+ rc_stringlist_addu(main_start_services,
service->value);
}
}
@@ -1022,8 +1022,8 @@ int main(int argc, char **argv)
parallel = rc_conf_yesno("rc_parallel");
/* Now stop the services that shouldn't be running */
- if (stop_services && !nostop)
- do_stop_services(types_nw, start_services, stop_services, deptree, newlevel, parallel, going_down);
+ if (main_stop_services && !nostop)
+ do_stop_services(main_types_nw, main_start_services, main_stop_services, main_deptree, newlevel, parallel, going_down);
/* Wait for our services to finish */
wait_for_services();
@@ -1055,8 +1055,8 @@ int main(int argc, char **argv)
hook_out = RC_HOOK_RUNLEVEL_START_OUT;
/* Re-add our hotplugged services if they stopped */
- if (hotplugged_services)
- TAILQ_FOREACH(service, hotplugged_services, entries)
+ if (main_hotplugged_services)
+ TAILQ_FOREACH(service, main_hotplugged_services, entries)
rc_service_mark(service->value, RC_SERVICE_HOTPLUGGED);
#ifdef __linux__
@@ -1072,7 +1072,7 @@ int main(int argc, char **argv)
#endif
/* If we have a list of services to start then... */
- if (start_services) {
+ if (main_start_services) {
/* Get a list of the chained runlevels which compose the target runlevel */
RC_STRINGLIST *runlevel_chain = rc_runlevel_stacks(runlevel);
@@ -1085,7 +1085,7 @@ int main(int argc, char **argv)
/* Start those services. */
rc_stringlist_sort(&run_services);
- deporder = rc_deptree_depends(deptree, types_nwua, run_services, rlevel->value, depoptions | RC_DEP_START);
+ deporder = rc_deptree_depends(main_deptree, main_types_nwua, run_services, rlevel->value, depoptions | RC_DEP_START);
rc_stringlist_free(run_services);
run_services = deporder;
do_start_services(run_services, parallel);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-07-25 18:54 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-07-25 18:54 UTC (permalink / raw
To: gentoo-commits
commit: 3adb8fb389caaafbed1be13c5ac4d96214c8eed3
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Sun Jul 24 02:27:53 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jul 24 02:27:53 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3adb8fb3
rc-logger: refuse to cat TMPLOG into itself
This prevents an infinite loop in case somebody decides to set
rc_log_path to match TMPLOG.
src/rc/rc-logger.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 06f3398..b4bd0ea 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -247,6 +247,10 @@ rc_logger_open(const char *level)
logfile = rc_conf_value("rc_log_path");
if (logfile == NULL)
logfile = DEFAULTLOG;
+ if (!strcmp(logfile, TMPLOG)) {
+ eerror("Cowardly refusing to concatenate a logfile into itself.");
+ eerrorx("Please change rc_log_path to something other than %s to get rid of this message", TMPLOG);
+ }
if ((plog = fopen(logfile, "ae"))) {
if ((log = fopen(TMPLOG, "re"))) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-08-25 16:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-08-25 16:17 UTC (permalink / raw
To: gentoo-commits
commit: 69ac78d76a31d843c004717eb6aa6a77bb4c9a8e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Aug 25 16:04:48 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Aug 25 16:04:48 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=69ac78d7
openrc-run: make runscript warning respect quiet option
X-Gentoo-Bug: 591414
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=591414
src/rc/openrc-run.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index ff884c4..e3b4fbb 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -1169,9 +1169,6 @@ int main(int argc, char **argv)
if (argc < 3)
usage(EXIT_FAILURE);
- if (runscript)
- ewarn("%s uses runscript, please convert to openrc-run.", service);
-
/* Change dir to / to ensure all init scripts don't use stuff in pwd */
if (chdir("/") == -1)
eerror("chdir: %s", strerror(errno));
@@ -1291,6 +1288,9 @@ int main(int argc, char **argv)
applet_list = rc_stringlist_new();
rc_stringlist_add(applet_list, applet);
+ if (runscript)
+ ewarn("%s uses runscript, please convert to openrc-run.", service);
+
/* Now run each option */
retval = EXIT_SUCCESS;
while (optind < argc) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-09-16 13:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-09-16 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 1edb5f6fd9c4827e5d4ed5c854bc322ba8a7df73
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Thu Sep 15 02:48:56 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 02:48:56 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1edb5f6f
rc-misc: Allow EINFO_COLOR through env_filter()
This allows rc-service -C <service> <action> to properly not print color
messages.
Fixes #93
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 85a0db7..508e116 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -53,6 +53,7 @@ static const char *const env_whitelist[] = {
"EERROR_QUIET", "EINFO_QUIET",
"IN_BACKGROUND", "IN_HOTPLUG",
"LANG", "LC_MESSAGES", "TERM",
+ "EINFO_COLOR",
NULL
};
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-09-16 13:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-09-16 13:58 UTC (permalink / raw
To: gentoo-commits
commit: 6cabaf274defa11773094a2c85b3d0a9f0bd9b08
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Fri Sep 16 13:51:03 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Sep 16 13:51:03 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6cabaf27
rc-misc: allow EINFO_VERBOSE through too
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 508e116..250b369 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -53,7 +53,7 @@ static const char *const env_whitelist[] = {
"EERROR_QUIET", "EINFO_QUIET",
"IN_BACKGROUND", "IN_HOTPLUG",
"LANG", "LC_MESSAGES", "TERM",
- "EINFO_COLOR",
+ "EINFO_COLOR", "EINFO_VERBOSE",
NULL
};
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-09-19 17:10 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-09-19 17:10 UTC (permalink / raw
To: gentoo-commits
commit: 83bb827edf5b9be04a326d1970d6f55db239281f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 19 17:07:04 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 19 17:09:05 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=83bb827e
Revert "Disable parallel startup in interactive mode"
This reverts commit 8b4fc05ff2645b2ecb0f153492f72dd8b39ba431.
The original commit did not explain why this feature was disabled, and I
now have a request to enable it.
This fixes #24.
src/rc/rc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 2c517f2..118c2d1 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -664,7 +664,6 @@ do_start_services(const RC_STRINGLIST *start_services, bool parallel)
interactive = want_interactive();
if (interactive) {
- parallel = false;
interactive_retry:
printf("\n");
einfo("About to start the service %s",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-09-30 22:10 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-09-30 22:10 UTC (permalink / raw
To: gentoo-commits
commit: 6710316a18c33601e780282e72c60f09b5175280
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Fri Sep 30 21:29:56 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Sep 30 21:29:56 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6710316a
openrc-run: fix double free
src/rc/openrc-run.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index e3b4fbb..bb79f42 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -1344,6 +1344,7 @@ int main(int argc, char **argv)
applet_list,
runlevel, depoptions);
rc_stringlist_free(tmplist);
+ tmplist = NULL;
TAILQ_FOREACH(svc, services, entries)
printf("%s ", svc->value);
printf ("\n");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-10-11 15:31 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-10-11 15:31 UTC (permalink / raw
To: gentoo-commits
commit: 78146b0e14cb57dda8a3aed3d4f8d6b1db7a3c7e
Author: Sven Wegener <swegener <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 4 09:30:02 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 11 15:30:02 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=78146b0e
do_service: Initialize idx to 0
If index is not explicitly specified for service_started_daemon, it will
look for daemons by random index.
This fixes #100.
src/rc/do_service.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/do_service.c b/src/rc/do_service.c
index 3c39d35..a36a09c 100644
--- a/src/rc/do_service.c
+++ b/src/rc/do_service.c
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
bool ok = false;
char *service;
char *exec;
- int idx;
+ int idx = 0;
RC_SERVICE state, bit;
applet = basename_c(argv[0]);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-10-24 17:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-10-24 17:43 UTC (permalink / raw
To: gentoo-commits
commit: 9d5f321acf4d090cb3a79e23e06af8d1add8fe43
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Oct 24 17:39:14 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 17:39:14 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=9d5f321a
src/rc/rc-misc.c: report error if call to flock() fails
X-Gentoo-Bug: 597390
X-Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=597390
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 250b369..8afff0a 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -228,6 +228,7 @@ svc_lock(const char *applet)
if (fd == -1)
return -1;
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
+ eerror("Call to flock failed: %s", strerror(errno));
close(fd);
return -1;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-10-24 17:48 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-10-24 17:48 UTC (permalink / raw
To: gentoo-commits
commit: 4fd144c0a6526963c70f18cb34a65354c2f0a48c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Oct 24 17:39:14 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 17:47:49 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4fd144c0
src/rc/rc-misc.c: report error if call to flock() fails
X-Gentoo-Bug: 597390
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=597390
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 250b369..8afff0a 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -228,6 +228,7 @@ svc_lock(const char *applet)
if (fd == -1)
return -1;
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
+ eerror("Call to flock failed: %s", strerror(errno));
close(fd);
return -1;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-11-03 16:13 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-11-03 16:13 UTC (permalink / raw
To: gentoo-commits
commit: be06cd250e12e63b8eb704bb2508e06fb9791251
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Nov 1 22:31:35 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Nov 1 22:31:57 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=be06cd25
src/rc/rc: do not try to start services if fork fails
src/rc/rc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 118c2d1..110591e 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -683,6 +683,8 @@ do_start_services(const RC_STRINGLIST *start_services, bool parallel)
}
pid = service_start(service->value);
+ if (pid == -1)
+ break;
/* Remember the pid if we're running in parallel */
if (pid > 0) {
add_pid(pid);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2016-11-30 22:49 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2016-11-30 22:49 UTC (permalink / raw
To: gentoo-commits
commit: 6414c3bc394f86a5d6a5f02c934469e21bbbc923
Author: Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Wed Nov 16 04:55:49 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov 17 18:03:12 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6414c3bc
selinux: fix SIGSEGV with invalid contexts
Fixes: https://github.com/openrc/openrc/issues/104
src/rc/rc-selinux.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index a792fe2..2eb631a 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -334,7 +334,19 @@ void selinux_setup(char **argv)
/* extract the type from the context */
curr_con = context_new(curr_context);
- curr_t = xstrdup(context_type_get(curr_con));
+ if (!curr_con) {
+ free(curr_context);
+ goto out;
+ }
+
+ curr_t = context_type_get(curr_con);
+ if (!curr_t) {
+ context_free(curr_con);
+ free(curr_context);
+ goto out;
+ }
+
+ curr_t = xstrdup(curr_t);
/* dont need them anymore so free() now */
context_free(curr_con);
free(curr_context);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-01-04 23:23 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-01-04 23:23 UTC (permalink / raw
To: gentoo-commits
commit: 92325b44ba58a7ca04d88ae8ca202b402b032b43
Author: Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 4 22:56:09 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jan 4 22:59:38 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=92325b44
Indentation fixes
X-Gentoo-Bug: 604666
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
src/rc/start-stop-daemon.c | 24 ++++++++++++------------
src/rc/supervise-daemon.c | 2 +-
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 188169f..eb5b4f7 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -468,7 +468,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (tkilled == 0) {
if (progressed)
printf("\n");
- eerror("%s: no matching processes found", applet);
+ eerror("%s: no matching processes found", applet);
}
return tkilled;
}
@@ -696,17 +696,17 @@ int main(int argc, char **argv)
if (sscanf(tmp, "%d", &nicelevel) != 1)
eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)",
applet, tmp);
- if ((tmp = getenv("SSD_IONICELEVEL"))) {
- int n = sscanf(tmp, "%d:%d", &ionicec, &ioniced);
- if (n != 1 && n != 2)
- eerror("%s: invalid ionice level `%s' (SSD_IONICELEVEL)",
- applet, tmp);
- if (ionicec == 0)
- ioniced = 0;
- else if (ionicec == 3)
- ioniced = 7;
- ionicec <<= 13; /* class shift */
- }
+ if ((tmp = getenv("SSD_IONICELEVEL"))) {
+ int n = sscanf(tmp, "%d:%d", &ionicec, &ioniced);
+ if (n != 1 && n != 2)
+ eerror("%s: invalid ionice level `%s' (SSD_IONICELEVEL)",
+ applet, tmp);
+ if (ionicec == 0)
+ ioniced = 0;
+ else if (ionicec == 3)
+ ioniced = 7;
+ ionicec <<= 13; /* class shift */
+ }
/* Get our user name and initial dir */
p = getenv("USER");
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index c1ef169..a47e47d 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -662,7 +662,7 @@ int main(int argc, char **argv)
fp = fopen(pidfile, "w");
if (! fp)
eerrorx("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
- fclose(fp);
+ fclose(fp);
child_pid = fork();
if (child_pid == -1)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-01-05 0:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-01-05 0:24 UTC (permalink / raw
To: gentoo-commits
commit: b73941f0c3020e3dbd1684d09685e114c678b520
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jan 5 00:18:27 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 5 00:18:37 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b73941f0
mountinfo: make the path to /proc/mounts a constant
This path should not be hard coded in the open call.
Linux prior to 2.4.19 did not have /proc/self/mounts, so for now I'm
making this value /proc/mounts everywhere, but that may change to
/proc/self/mounts on linux; I'm not sure we should care about <2.4.19.
X-Gentoo-Bug: 604646
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604646
src/rc/mountinfo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 29eb160..d9c25a3 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -46,6 +46,7 @@
#include "_usage.h"
const char *applet = NULL;
+const char *procmounts = "/proc/mounts";
const char *extraopts = "[mount1] [mount2] ...";
const char *getoptstring = "f:F:n:N:o:O:p:P:iste:E:" getoptstring_COMMON;
const struct option longopts[] = {
@@ -323,7 +324,7 @@ find_mounts(struct args *args)
int netdev;
RC_STRINGLIST *list;
- if ((fp = fopen("/proc/self/mounts", "r")) == NULL)
+ if ((fp = fopen(procmounts, "r")) == NULL)
eerrorx("getmntinfo: %s", strerror(errno));
list = rc_stringlist_new();
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-01-25 23:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-01-25 23:58 UTC (permalink / raw
To: gentoo-commits
commit: 6dcb6929869c2f81c1f8d0930191f74fc6dfaa3e
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Sun Jan 8 10:48:53 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jan 25 23:48:52 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6dcb6929
start-stop-daemon: allow all standard signals
Also we define the signalpair_item macro.
This fixes #113.
X-Gentoo-Bug: 604986
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604986
src/rc/start-stop-daemon.c | 57 ++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 19 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index b1c6e73..e9f9848 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -197,26 +197,45 @@ parse_signal(const char *sig)
int signal;
} SIGNALPAIR;
+#define signalpair_item(name) { #name, SIG##name },
+
static const SIGNALPAIR signallist[] = {
- { "ABRT", SIGABRT },
- { "ALRM", SIGALRM },
- { "FPE", SIGFPE },
- { "HUP", SIGHUP },
- { "ILL", SIGILL },
- { "INT", SIGINT },
- { "KILL", SIGKILL },
- { "PIPE", SIGPIPE },
- { "QUIT", SIGQUIT },
- { "SEGV", SIGSEGV },
- { "TERM", SIGTERM },
- { "USR1", SIGUSR1 },
- { "USR2", SIGUSR2 },
- { "CHLD", SIGCHLD },
- { "CONT", SIGCONT },
- { "STOP", SIGSTOP },
- { "TSTP", SIGTSTP },
- { "TTIN", SIGTTIN },
- { "TTOU", SIGTTOU },
+ signalpair_item(HUP)
+ signalpair_item(INT)
+ signalpair_item(QUIT)
+ signalpair_item(ILL)
+ signalpair_item(TRAP)
+ signalpair_item(ABRT)
+ signalpair_item(BUS)
+ signalpair_item(FPE)
+ signalpair_item(KILL)
+ signalpair_item(USR1)
+ signalpair_item(SEGV)
+ signalpair_item(USR2)
+ signalpair_item(PIPE)
+ signalpair_item(ALRM)
+ signalpair_item(TERM)
+ signalpair_item(CHLD)
+ signalpair_item(CONT)
+ signalpair_item(STOP)
+ signalpair_item(TSTP)
+ signalpair_item(TTIN)
+ signalpair_item(TTOU)
+ signalpair_item(URG)
+ signalpair_item(XCPU)
+ signalpair_item(XFSZ)
+ signalpair_item(VTALRM)
+ signalpair_item(PROF)
+#ifdef SIGWINCH
+ signalpair_item(WINCH)
+#endif
+#ifdef SIGIO
+ signalpair_item(IO)
+#endif
+#ifdef SIGPWR
+ signalpair_item(PWR)
+#endif
+ signalpair_item(SYS)
{ "NULL", 0 },
};
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-03 15:45 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-03 15:45 UTC (permalink / raw
To: gentoo-commits
commit: 9eb669591e16c5ee0ca07babe058d0b7b2396077
Author: Austin English <austinenglish <AT> gmail <DOT> com>
AuthorDate: Fri Mar 31 18:59:38 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Apr 3 15:43:40 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=9eb66959
start-stop-daemon: warn if calling --start with --retry or --stop with --wait
This fixes #122
src/rc/start-stop-daemon.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index e9f9848c..c88bc962 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -960,6 +960,9 @@ int main(int argc, char **argv)
if (redirect_stdout || redirect_stderr)
eerrorx("%s: --stdout and --stderr are only relevant"
" with --start", applet);
+ if (start_wait)
+ ewarn("using --wait with --stop has no effect,"
+ " use --retry instead");
} else {
if (!exec)
eerrorx("%s: nothing to start", applet);
@@ -1012,7 +1015,11 @@ int main(int argc, char **argv)
eerror("%s: %s does not exist", applet,
*exec_file ? exec_file : exec);
exit(EXIT_FAILURE);
+
}
+ if (start && retry)
+ ewarn("using --retry with --start has no effect,"
+ " use --wait instead");
/* If we don't have a pidfile we should check if it's interpreted
* or not. If it we, we need to pass the interpreter through
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-07 12:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-07 12:43 UTC (permalink / raw
To: gentoo-commits
commit: cc51bdca3bac963878141da047e92f125772e14f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Apr 7 12:39:12 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Apr 7 12:39:12 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=cc51bdca
Add attribution to openrc-init.c and openrc-shutdown.c
src/rc/openrc-init.c | 3 +++
src/rc/openrc-shutdown.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index e7d62432..fb3347a4 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -1,6 +1,9 @@
/*
* openrc-init.c
* This is the init process (pid 1) for OpenRC.
+ *
+ * This is based on code written by James Hammons <jlhamm@acm.org>, so
+ * I would like to publically thank him for his work.
*/
/*
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c
index b68ffd36..978e8a68 100644
--- a/src/rc/openrc-shutdown.c
+++ b/src/rc/openrc-shutdown.c
@@ -2,6 +2,9 @@
* openrc-shutdown.c
* If you are using OpenRC's provided init, this will shut down or
* reboot your system.
+ *
+ * This is based on code written by James Hammons <jlhamm@acm.org>, so
+ * I would like to publically thank him for his work.
*/
/*
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-13 17:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-13 17:56 UTC (permalink / raw
To: gentoo-commits
commit: 4694900190a9078397bb9083328b68b489af92f4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Apr 13 17:54:18 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Apr 13 17:54:30 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=46949001
init: fix signal handling
The only signals we handle are SIGINT and SIGCHLD, so block all others
and unblock them in the child process before we start a rurnlevel.
src/rc/openrc-init.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index 61052806..621c81ea 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -39,6 +39,7 @@ static const char *rc_default_runlevel = "default";
static pid_t do_openrc(const char *runlevel)
{
pid_t pid;
+ sigset_t signals;
pid = fork();
switch(pid) {
@@ -47,6 +48,9 @@ static pid_t do_openrc(const char *runlevel)
break;
case 0:
setsid();
+ /* unblock all signals */
+ sigemptyset(&signals);
+ sigprocmask(SIG_SETMASK, &signals, NULL);
printf("Starting %s runlevel\n", runlevel);
execl("/sbin/openrc", "/sbin/openrc", runlevel, NULL);
perror("exec");
@@ -135,11 +139,14 @@ int main(int argc, char **argv)
int count;
FILE *fifo;
bool reexec = false;
+ sigset_t signals;
struct sigaction sa;
if (getpid() != 1)
return 1;
+ printf("OpenRC init version %s starting\n", VERSION);
+
if (argc > 1)
default_runlevel = argv[1];
else
@@ -148,15 +155,22 @@ int main(int argc, char **argv)
if (default_runlevel && strcmp(default_runlevel, "reexec") == 0)
reexec = true;
- printf("OpenRC init version %s starting\n", VERSION);
- if (! reexec)
- init(default_runlevel);
+ /* block all signals we do not handle */
+ sigfillset(&signals);
+ sigdelset(&signals, SIGCHLD);
+ sigdelset(&signals, SIGINT);
+ sigprocmask(SIG_SETMASK, &signals, NULL);
+
+ /* install signal handler */
memset(&sa, 0, sizeof(sa));
sa.sa_handler = signal_handler;
sigaction(SIGCHLD, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
reboot(RB_DISABLE_CAD);
+ if (! reexec)
+ init(default_runlevel);
+
if (mkfifo(RC_INIT_FIFO, 0600) == -1 && errno != EEXIST)
perror("mkfifo");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-17 17:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-17 17:24 UTC (permalink / raw
To: gentoo-commits
commit: 0e3f8720984d7d5752a78a4135cd268e4f83b3d7
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Apr 17 17:23:45 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Apr 17 17:23:45 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0e3f8720
init: send term/kill signals as final step of shutdown
src/rc/openrc-init.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index 621c81ea..8abe0dd6 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -96,6 +96,11 @@ static void handle_shutdown(const char *runlevel, int cmd)
pid = do_openrc(runlevel);
while (waitpid(pid, NULL, 0) != pid);
+ printf("Sending the final term signal\n");
+ kill(-1, SIGTERM);
+ sleep(3);
+ printf("Sending the final kill signal\n");
+ kill(-1, SIGKILL);
sync();
reboot(cmd);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-29 14:44 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-29 14:44 UTC (permalink / raw
To: gentoo-commits
commit: 5de3798afc55ce147e65926f863ec9c9cef60e79
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Apr 29 14:41:07 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Apr 29 14:41:07 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5de3798a
supervise-daemon: mark the service started when the supervisor is active
src/rc/supervise-daemon.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 57d55194..5636eaab 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -694,6 +694,10 @@ int main(int argc, char **argv)
fprintf(fp, "%d\n", getpid());
fclose(fp);
+ if (svcname)
+ rc_service_daemon_set(svcname, exec,
+ (const char * const *) argv, pidfile, true);
+
/*
* Supervisor main loop
*/
@@ -718,10 +722,6 @@ int main(int argc, char **argv)
}
}
- if (svcname)
- rc_service_daemon_set(svcname, exec,
- (const char * const *) argv, pidfile, true);
-
exit(EXIT_SUCCESS);
} else if (child_pid == 0)
child_process(exec, argv);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-29 22:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-29 22:56 UTC (permalink / raw
To: gentoo-commits
commit: 96c8ba2fb5f91a711ef5bfcfd8affe0b74ad18fe
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Apr 29 18:48:45 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Apr 29 18:48:45 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=96c8ba2f
supervise-daemon: mark all open file descriptors FD_CLOEXEC
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 2a24799c..2080e4a6 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -322,7 +322,7 @@ static void child_process(char *exec, char **argv)
dup2(stderr_fd, STDERR_FILENO);
for (i = getdtablesize() - 1; i >= 3; --i)
- close(i);
+ fcntl(i, F_SETFD, FD_CLOEXEC);
*cmdline = '\0';
c = argv;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-29 22:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-29 22:56 UTC (permalink / raw
To: gentoo-commits
commit: 06a6a27e441372164872c7712b80728527a6ec05
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Apr 29 15:12:16 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Apr 29 15:12:16 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=06a6a27e
supervise-daemon: fix access to tty_fd and devnull_fd
Both the child and supervisor need access to these file descriptors.
src/rc/supervise-daemon.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 5636eaab..b13ec9e8 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -674,6 +674,10 @@ int main(int argc, char **argv)
if (child_pid != 0)
exit(EXIT_SUCCESS);
+#ifdef TIOCNOTTY
+ tty_fd = open("/dev/tty", O_RDWR);
+#endif
+ devnull_fd = open("/dev/null", O_RDWR);
child_pid = fork();
if (child_pid == -1)
eerrorx("%s: fork: %s", applet, strerror(errno));
@@ -682,12 +686,6 @@ int main(int argc, char **argv)
/* this is the supervisor */
umask(numask);
-#ifdef TIOCNOTTY
- tty_fd = open("/dev/tty", O_RDWR);
-#endif
-
- devnull_fd = open("/dev/null", O_RDWR);
-
fp = fopen(pidfile, "w");
if (! fp)
eerrorx("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-04-29 22:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-04-29 22:56 UTC (permalink / raw
To: gentoo-commits
commit: 47cf1d0c707dc88d216bebc15be3f39d5eb47fa9
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Apr 29 17:04:15 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Apr 29 17:04:15 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=47cf1d0c
supervise-daemon:remove the controlling tty in the supervisor
src/rc/supervise-daemon.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index b13ec9e8..2a24799c 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -226,6 +226,7 @@ static void child_process(char *exec, char **argv)
/* Close any fd's to the passwd database */
endpwent();
+ /* remove the controlling tty */
#ifdef TIOCNOTTY
ioctl(tty_fd, TIOCNOTTY, 0);
close(tty_fd);
@@ -696,6 +697,12 @@ int main(int argc, char **argv)
rc_service_daemon_set(svcname, exec,
(const char * const *) argv, pidfile, true);
+ /* remove the controlling tty */
+#ifdef TIOCNOTTY
+ ioctl(tty_fd, TIOCNOTTY, 0);
+ close(tty_fd);
+#endif
+
/*
* Supervisor main loop
*/
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-11 16:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-11 16:38 UTC (permalink / raw
To: gentoo-commits
commit: df027ca4722c8755b23a65db75728b835ccca807
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu May 11 16:32:24 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu May 11 16:36:42 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=df027ca4
supervise-daemon: fix our status when we give up on the child process
src/rc/supervise-daemon.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 76c9d426..13aba1a3 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -676,10 +676,12 @@ int main(int argc, char **argv)
* result would be the same. */
if (pidfile && exists(pidfile))
unlink(pidfile);
- if (svcname)
+ if (svcname) {
rc_service_daemon_set(svcname, exec,
(const char *const *)argv,
pidfile, false);
+ rc_service_mark(svcname, RC_SERVICE_STOPPED);
+ }
exit(EXIT_SUCCESS);
}
@@ -780,6 +782,14 @@ int main(int argc, char **argv)
}
}
+ if (pidfile && exists(pidfile))
+ unlink(pidfile);
+ if (svcname) {
+ rc_service_daemon_set(svcname, exec,
+ (const char *const *)argv,
+ pidfile, false);
+ rc_service_mark(svcname, RC_SERVICE_STOPPED);
+ }
exit(EXIT_SUCCESS);
} else if (child_pid == 0)
child_process(exec, argv);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-12 2:42 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-12 2:42 UTC (permalink / raw
To: gentoo-commits
commit: 82e12e309247bc84abf29aca04b3a2dd845fa11b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri May 12 02:38:55 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri May 12 02:39:03 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=82e12e30
rc-status: show uptimes and respawn counts for supervised daemons
src/rc/rc-status.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 8a591db1..a314bb1d 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -76,10 +76,55 @@ print_level(const char *prefix, const char *level)
printf("%s\n", level);
}
+static void get_uptime(const char *service, char *uptime, int uptime_size)
+{
+ RC_SERVICE state = rc_service_state(service);
+ char *start_count;
+ time_t now;
+ char *start_time_string;
+ time_t start_time;
+ double time_diff;
+ double diff_tmp;
+ double diff_days;
+ double diff_hours;
+ double diff_mins;
+
+ 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");
+ if (start_count && start_time_string) {
+ start_time = to_time_t(start_time_string);
+ now = time(NULL);
+ time_diff = difftime(now, start_time);
+ diff_tmp = time_diff;
+ if (diff_tmp > 86400.0) {
+ diff_days = diff_tmp / 86400.0;
+ diff_tmp -= diff_days * 86400.0;
+ }
+ if (diff_tmp > 3600.0) {
+ diff_hours = diff_tmp / 3600.0;
+ diff_tmp -= diff_hours * 3600.0;
+ }
+ if (diff_tmp > 60.0) {
+ diff_mins = diff_tmp / 60.0;
+ diff_tmp -= diff_mins * 60.0;
+ }
+ if ((int) diff_days > 0)
+ snprintf(uptime, uptime_size, "%.0f days %02.0f:%02.0f (%s)",
+ diff_days, diff_hours, diff_mins, start_count);
+ else
+ snprintf(uptime, uptime_size, "%02.0f:%02.0f (%s)",
+ diff_hours, diff_mins, start_count);
+ }
+ }
+}
+
static void
print_service(const char *service)
{
- char status[10];
+ char status[60];
+ char uptime [40];
int cols = printf(" %s", service);
const char *c = ecolor(ECOLOR_GOOD);
RC_SERVICE state = rc_service_state(service);
@@ -101,7 +146,8 @@ print_service(const char *service)
{
snprintf(status, sizeof(status), " crashed ");
} else {
- snprintf(status, sizeof(status), " started ");
+ get_uptime(service, uptime, 40);
+ snprintf(status, sizeof(status), " started %s", uptime);
color = ECOLOR_GOOD;
}
} else if (state & RC_SERVICE_SCHEDULED) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-12 2:42 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-12 2:42 UTC (permalink / raw
To: gentoo-commits
commit: a3250e77d412f2290e381b9e7569930d95e4fc5b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu May 11 18:52:22 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu May 11 18:54:20 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a3250e77
supervise-daemon: save start time and respawn count
This will allow rc-status to display an uptime and restart count for
supervised processes.
src/rc/supervise-daemon.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 13aba1a3..bc5fd3d0 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -171,7 +171,8 @@ static pid_t get_pid(const char *pidfile)
return pid;
}
-static void child_process(char *exec, char **argv)
+static void child_process(char *exec, char **argv, char *svcname,
+ int start_count)
{
RC_STRINGLIST *env_list;
RC_STRING *env;
@@ -183,6 +184,9 @@ static void child_process(char *exec, char **argv)
char *np;
char **c;
char cmdline[PATH_MAX];
+ time_t start_time;
+ char start_time_string[20];
+ char start_count_string[20];
#ifdef HAVE_PAM
pam_handle_t *pamh = NULL;
@@ -338,6 +342,13 @@ static void child_process(char *exec, char **argv)
c++;
}
syslog(LOG_INFO, "Running command line: %s", cmdline);
+ if (svcname) {
+start_time = time(NULL);
+strftime(start_time_string, 20, "%Y-%m-%d %H:%M:%S", localtime(&start_time));
+ rc_service_value_set(svcname, "start_time", start_time_string);
+sprintf(start_count_string, "%i", start_count);
+ rc_service_value_set(svcname, "start_count", start_count_string);
+ }
execvp(exec, argv);
#ifdef HAVE_PAM
@@ -778,7 +789,7 @@ int main(int argc, char **argv)
if (child_pid == -1)
eerrorx("%s: fork: %s", applet, strerror(errno));
if (child_pid == 0)
- child_process(exec, argv);
+ child_process(exec, argv, svcname, respawn_count);
}
}
@@ -792,5 +803,5 @@ int main(int argc, char **argv)
}
exit(EXIT_SUCCESS);
} else if (child_pid == 0)
- child_process(exec, argv);
+ child_process(exec, argv, svcname, respawn_count);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-12 2:42 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-12 2:42 UTC (permalink / raw
To: gentoo-commits
commit: 1ebef0d7a38ec0a9635418b75c3aabb564c1577e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu May 11 23:13:13 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu May 11 23:13:13 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1ebef0d7
fix to_time_t to honor dst
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 1a98537c..a6cc788e 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -469,6 +469,7 @@ time_t to_time_t(char *timestring)
breakdown.tm_hour = hour;
breakdown.tm_min = min;
breakdown.tm_sec = sec;
+ breakdown.tm_isdst = -1;
result = mktime(&breakdown);
}
return result;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-16 0:00 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-16 0:00 UTC (permalink / raw
To: gentoo-commits
commit: cbf96967f1b6dc72ae16203dfbbb844bd08e8b6b
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri May 12 22:14:56 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri May 12 22:15:55 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=cbf96967
supervise-daemon: save start time and respawn count before dropping privs
src/rc/supervise-daemon.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index f3335fa2..dc6d6c12 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -196,6 +196,14 @@ static void child_process(char *exec, char **argv, char *svcname,
setsid();
+ if (svcname) {
+start_time = time(NULL);
+from_time_t(start_time_string, start_time);
+ rc_service_value_set(svcname, "start_time", start_time_string);
+sprintf(start_count_string, "%i", start_count);
+ rc_service_value_set(svcname, "start_count", start_count_string);
+ }
+
if (nicelevel) {
if (setpriority(PRIO_PROCESS, getpid(), nicelevel) == -1)
eerrorx("%s: setpriority %d: %s", applet, nicelevel,
@@ -342,13 +350,6 @@ static void child_process(char *exec, char **argv, char *svcname,
c++;
}
syslog(LOG_INFO, "Running command line: %s", cmdline);
- if (svcname) {
-start_time = time(NULL);
-from_time_t(start_time_string, start_time);
- rc_service_value_set(svcname, "start_time", start_time_string);
-sprintf(start_count_string, "%i", start_count);
- rc_service_value_set(svcname, "start_count", start_count_string);
- }
execvp(exec, argv);
#ifdef HAVE_PAM
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-16 0:00 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-16 0:00 UTC (permalink / raw
To: gentoo-commits
commit: a2055af90054f5125cc07d4851b1dc9d16815e7c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 15 23:55:35 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 15 23:55:47 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a2055af9
rc_status: calculate time differences in time_t and display seconds in uptime
src/rc/rc-status.c | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index a314bb1d..9a094d47 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -83,11 +83,11 @@ static void get_uptime(const char *service, char *uptime, int uptime_size)
time_t now;
char *start_time_string;
time_t start_time;
- double time_diff;
- double diff_tmp;
- double diff_days;
- double diff_hours;
- double diff_mins;
+ time_t time_diff;
+ time_t diff_days = (time_t) 0;
+ time_t diff_hours = (time_t) 0;
+ time_t diff_mins = (time_t) 0;
+ time_t diff_secs = (time_t) 0;
uptime[0] = '\0';
if (state & RC_SERVICE_STARTED) {
@@ -96,26 +96,29 @@ static void get_uptime(const char *service, char *uptime, int uptime_size)
if (start_count && start_time_string) {
start_time = to_time_t(start_time_string);
now = time(NULL);
- time_diff = difftime(now, start_time);
- diff_tmp = time_diff;
- if (diff_tmp > 86400.0) {
- diff_days = diff_tmp / 86400.0;
- diff_tmp -= diff_days * 86400.0;
+ time_diff = (time_t) difftime(now, start_time);
+ diff_secs = time_diff;
+ if (diff_secs > (time_t) 86400) {
+ diff_days = diff_secs / (time_t) 86400;
+ diff_secs %= diff_days * (time_t) 86400;
}
- if (diff_tmp > 3600.0) {
- diff_hours = diff_tmp / 3600.0;
- diff_tmp -= diff_hours * 3600.0;
+ if (diff_secs > (time_t) 3600) {
+ diff_hours = diff_secs / (time_t) 3600;
+ diff_secs %= diff_hours * (time_t) 3600;
}
- if (diff_tmp > 60.0) {
- diff_mins = diff_tmp / 60.0;
- diff_tmp -= diff_mins * 60.0;
+ if (diff_secs > (time_t) 60) {
+ diff_mins = diff_secs / (time_t) 60;
+ diff_secs %= diff_mins * (time_t) 60;
}
- if ((int) diff_days > 0)
- snprintf(uptime, uptime_size, "%.0f days %02.0f:%02.0f (%s)",
- diff_days, diff_hours, diff_mins, start_count);
+ if (diff_days > 0)
+ snprintf(uptime, uptime_size,
+ "%ld day(s) %02ld:%02ld:%02ld (%s)",
+ diff_days, diff_hours, diff_mins, diff_secs,
+ start_count);
else
- snprintf(uptime, uptime_size, "%02.0f:%02.0f (%s)",
- diff_hours, diff_mins, start_count);
+ snprintf(uptime, uptime_size,
+ "%02ld:%02ld:%02ld (%s)",
+ diff_hours, diff_mins, diff_secs, start_count);
}
}
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-19 23:30 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-19 23:30 UTC (permalink / raw
To: gentoo-commits
commit: 49b8a573a195f4b2cee992cd10678694da0a6f4f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri May 19 18:37:30 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri May 19 23:13:39 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=49b8a573
add kill_all helper
This is similar to the sysvinit killall5 utility. It should only be used
in service scripts, so it will not be installed in the path.
This closes #129.
src/rc/.gitignore | 1 +
src/rc/Makefile | 6 +-
src/rc/kill_all.c | 250 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 256 insertions(+), 1 deletion(-)
diff --git a/src/rc/.gitignore b/src/rc/.gitignore
index c3e7b3f6..91d57075 100644
--- a/src/rc/.gitignore
+++ b/src/rc/.gitignore
@@ -62,3 +62,4 @@ openrc
openrc-init
openrc-run
openrc-shutdown
+kill_all
diff --git a/src/rc/Makefile b/src/rc/Makefile
index 2bc03f76..5874ed17 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -14,7 +14,7 @@ SRCS+= rc-selinux.c
endif
ifeq (${OS},Linux)
-SRCS+= openrc-init.c openrc-shutdown.c
+SRCS+= kill_all.c openrc-init.c openrc-shutdown.c
endif
CLEANFILES= version.h rc-selinux.o
@@ -44,6 +44,7 @@ RC_SBINPROGS= mark_service_starting mark_service_started \
rc-abort swclock
ifeq (${OS},Linux)
+RC_BINPROGS+= kill_all
SBINPROGS+= openrc-init openrc-shutdown
endif
@@ -99,6 +100,9 @@ checkpath: rc-selinux.o
endif
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
+kill_all: kill_all.o _usage.o
+ ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
+
einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
eindent eoutdent esyslog eval_ecolors ewaitfile \
veinfo vewarn vebegin veend vewend veindent veoutdent: do_e.o rc-misc.o
diff --git a/src/rc/kill_all.c b/src/rc/kill_all.c
new file mode 100644
index 00000000..a4b15c87
--- /dev/null
+++ b/src/rc/kill_all.c
@@ -0,0 +1,250 @@
+/*
+ * kill_all.c
+ * Sends a signal to all processes on the system.
+ */
+
+/*
+ * Copyright (c) 2017 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 <dirent.h>
+#include <errno.h>
+#include <getopt.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "einfo.h"
+#include "rc.h"
+#include "rc-misc.h"
+#include "_usage.h"
+
+const char *applet = NULL;
+const char *extraopts = "[signal number]";
+const char *getoptstring = "do:" getoptstring_COMMON;
+const struct option longopts[] = {
+ { "dry-run", 0, NULL, 'd' },
+ { "omit", 1, NULL, 'o' },
+ longopts_COMMON
+};
+const char * const longopts_help[] = {
+ "print what would be done",
+ "omit this pid (can be repeated)",
+ longopts_help_COMMON
+};
+const char *usagestring = NULL;
+
+static int mount_proc(void)
+{
+ pid_t pid;
+ pid_t rc;
+ int status;
+
+ if (exists("/proc/version"))
+ return 0;
+ pid = fork();
+ switch(pid) {
+ case -1:
+ syslog(LOG_ERR, "Unable to fork");
+ return -1;
+ break;
+ case 0:
+ /* attempt to mount /proc */
+ execl("mount", "mount", "-t", "proc", "proc", "/proc", NULL);
+ syslog(LOG_ERR, "Unable to execute mount");
+ exit(1);
+ break;
+ default:
+ /* wait for child process */
+ while ((rc = wait(&status)) != pid)
+ if (rc < 0 && errno == ECHILD)
+ break;
+ if (rc != pid || WEXITSTATUS(status) != 0)
+ syslog(LOG_ERR, "mount returned non-zero exit status");
+ break;
+ }
+ if (! exists("/proc/version")) {
+ syslog(LOG_ERR, "Could not mount /proc");
+ return -1;
+ }
+ return 0;
+}
+
+static bool is_user_process(pid_t pid)
+{
+ char buf[PATH_MAX+1];
+ FILE *fp;
+ char path[PATH_MAX+1];
+ pid_t temp_pid;
+ bool user_process = true;
+
+ while (pid >0 && user_process) {
+ if (pid == 2) {
+ user_process = false;
+ continue;
+ }
+ snprintf(path, sizeof(path), "/proc/%d/status", pid);
+ fp = fopen(path, "r");
+ /*
+ * if we could not open the file, the process disappeared, which
+ * leaves us no way to determine for sure whether it was a user
+ * process or kernel thread, so we say it is a kernel thread to
+ * avoid accidentally killing it.
+ */
+ if (!fp) {
+ user_process = false;
+ continue;
+ }
+ temp_pid = -1;
+ while (! feof(fp)) {
+ buf[0] = 0;
+ if (fgets(buf, sizeof(buf), fp))
+ sscanf(buf, "PPid: %d", &temp_pid);
+ else
+ break;
+ }
+ fclose(fp);
+ if (temp_pid == -1) {
+ syslog(LOG_ERR, "Unable to read pid from /proc/%d/status", pid);
+ user_process = false;
+ continue;
+ }
+ pid = temp_pid;
+ }
+ return user_process;
+}
+
+static int signal_processes(int sig, RC_STRINGLIST *omits, bool dryrun)
+{
+ sigset_t signals;
+ sigset_t oldsigs;
+ DIR *dir;
+ struct dirent *d;
+ char buf[PATH_MAX+1];
+ pid_t pid;
+ int sendcount = 0;
+
+ kill(-1, SIGSTOP);
+ sigfillset(&signals);
+ sigemptyset(&oldsigs);
+ sigprocmask(SIG_SETMASK, &signals, &oldsigs);
+ /*
+ * Open the /proc directory.
+ * CWD must be /proc to avoid problems if / is affected by the killing
+ * (i.e. depends on fuse).
+ */
+ if (chdir("/proc") == -1) {
+ syslog(LOG_ERR, "chdir /proc failed");
+ sigprocmask(SIG_SETMASK, &oldsigs, NULL);
+ kill(-1, SIGCONT);
+ return -1;
+ }
+ dir = opendir(".");
+ if (!dir) {
+ syslog(LOG_ERR, "cannot opendir(/proc)");
+ sigprocmask(SIG_SETMASK, &oldsigs, NULL);
+ kill(-1, SIGCONT);
+ return -1;
+ }
+
+ /* Walk through the directory. */
+ while ((d = readdir(dir)) != NULL) {
+ /* Is this a process? */
+ pid = (pid_t) atoi(d->d_name);
+ if (pid == 0)
+ continue;
+
+ /* Is this a process we have been requested to omit? */
+ sprintf(buf, "%d", pid);
+ if (rc_stringlist_find(omits, buf))
+ continue;
+
+ /* Is this process in our session? */
+ if (getsid(getpid()) == getsid(pid))
+ continue;
+
+ /* Is this a kernel thread? */
+ if (!is_user_process(pid))
+ continue;
+
+ if (dryrun)
+ einfo("Would send signal %d to process %d", sig, pid);
+ else if (kill(pid, sig) == 0)
+ sendcount++;
+ }
+ closedir(dir);
+ sigprocmask(SIG_SETMASK, &oldsigs, NULL);
+ kill(-1, SIGCONT);
+ return sendcount;
+}
+
+int main(int argc, char **argv)
+{
+ char *arg = NULL;
+ int opt;
+ bool dryrun = false;
+ RC_STRINGLIST *omits = rc_stringlist_new();
+ int sig = SIGKILL;
+ char *here;
+ char *token;
+
+ /* Ensure that we are only quiet when explicitly told to be */
+ unsetenv("EINFO_QUIET");
+
+ applet = basename_c(argv[0]);
+ rc_stringlist_addu(omits, "1");
+ while ((opt = getopt_long(argc, argv, getoptstring,
+ longopts, (int *) 0)) != -1)
+ {
+ switch (opt) {
+ case 'd':
+ dryrun = true;
+ break;
+ case 'o':
+ here = optarg;
+ while ((token = strsep(&here, ",;:"))) {
+ if ((pid_t) atoi(token) > 0)
+ rc_stringlist_addu(omits, token);
+ else {
+ eerror("Invalid omit pid value %s", token);
+ usage(EXIT_FAILURE);
+ }
+ }
+ break;
+ case_RC_COMMON_GETOPT
+ }
+ }
+
+ if (argc > optind) {
+ arg = argv[optind];
+ sig = atoi(arg);
+ if (sig <= 0 || sig > 31) {
+ rc_stringlist_free(omits);
+ eerror("Invalid signal %s", arg);
+ usage(EXIT_FAILURE);
+ }
+ }
+
+ openlog(applet, LOG_CONS|LOG_PID, LOG_DAEMON);
+ if (mount_proc() != 0) {
+ rc_stringlist_free(omits);
+ eerrorx("Unable to mount /proc file system");
+ }
+ signal_processes(sig, omits, dryrun);
+ rc_stringlist_free(omits);
+ return 0;
+}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-22 16:30 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-22 16:30 UTC (permalink / raw
To: gentoo-commits
commit: a77ee2e94191ba1a286b8a6835f76556481566ba
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 22 16:29:14 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 22 16:29:23 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a77ee2e9
init: add ability to switch to single user mode
src/rc/openrc-init.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index 8abe0dd6..398259cc 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -105,6 +105,14 @@ static void handle_shutdown(const char *runlevel, int cmd)
reboot(cmd);
}
+static void handle_single(void)
+{
+ pid_t pid;
+
+ pid = do_openrc("single");
+ while (waitpid(pid, NULL, 0) != pid);
+}
+
static void reap_zombies(void)
{
pid_t pid;
@@ -201,6 +209,8 @@ int main(int argc, char **argv)
handle_shutdown("reboot", RB_AUTOBOOT);
else if (strcmp(buf, "reexec") == 0)
handle_reexec(argv[0]);
+ else if (strcmp(buf, "single") == 0)
+ handle_single();
}
return 0;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-30 21:25 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-30 21:25 UTC (permalink / raw
To: gentoo-commits
commit: 7185e242ffaa8cd1b672fe4726502a196fd779c2
Author: Sergei Trofimovich <slyfox <AT> inbox <DOT> ru>
AuthorDate: Tue May 30 07:47:55 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 30 07:47:55 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7185e242
rc-logger.c: fix crash on fclose(NULL) (#137)
Only close the log if we successfully opened it.
Reported-by: Brian Evans <grknight <AT> gentoo.org>
Tested-by: Brian Evans <grknight <AT> gentoo.org>
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
src/rc/rc-logger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index b4bd0eae..062ce3d9 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -261,12 +261,12 @@ rc_logger_open(const char *level)
break;
}
}
+ fclose(log);
} else {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", TMPLOG, strerror(errno));
}
- fclose(log);
fclose(plog);
} else {
/*
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-05-30 21:25 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-05-30 21:25 UTC (permalink / raw
To: gentoo-commits
commit: 0ddee9b7d2b8dea810e252ca6a95c457876df120
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue May 30 20:58:32 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 30 21:21:23 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0ddee9b7
openrc-init: fix buffer overflow in init.ctl
How to reproduce 1-byte overflow:
```
$ FEATURES=-test CFLAGS="-fsanitize=address -O0 -ggdb3" emerge -1 openrc
=================================================================
==1==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff0efd8710
at pc 0x000000402076 bp 0x7fff0efd7d50 sp 0x7fff0efd7d40
WRITE of size 1 at 0x7fff0efd8710 thread T0
#0 0x402075 (/sbin/openrc-init+0x402075)
#1 0x3cf6e2070f in __libc_start_main (/lib64/libc.so.6+0x3cf6e2070f)
#2 0x4013b8 (/sbin/openrc-init+0x4013b8)
Address 0x7fff0efd8710 is located in stack of thread T0 at offset 2432 in frame
#0 0x401cfb (/sbin/openrc-init+0x401cfb)
This frame has 3 object(s):
[32, 160) 'signals'
[192, 344) 'sa'
[384, 2432) 'buf' <== Memory access at offset 2432 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow ??:0 ??
```
The problem here is in the code handling reads from 'init.ctl':
```
int main(int argc, char **argv) {
...
char buf[2048];
for (;;) {
/* This will block until a command is sent down the pipe... */
fifo = fopen(RC_INIT_FIFO, "r");
count = fread(buf, 1, 2048, fifo);
buf[count] = 0;
...
}
```
`buf[count] = 0;` writes outside the buffer when `fread()` returns non-truncated read.
This fixes #138.
src/rc/openrc-init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index 398259cc..003ce31f 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -195,7 +195,7 @@ int main(int argc, char **argv)
perror("fopen");
continue;
}
- count = fread(buf, 1, 2048, fifo);
+ count = fread(buf, 1, sizeof(buf) - 1, fifo);
buf[count] = 0;
fclose(fifo);
printf("PID1: Received \"%s\" from FIFO...\n", buf);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-06-07 16:34 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-06-07 16:34 UTC (permalink / raw
To: gentoo-commits
commit: ee886c44824b1dd892eaff2c6da666286e61bc73
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Jun 5 20:49:22 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jun 5 20:49:22 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ee886c44
openrc-shutdown: add --single option and clean up option processing
src/rc/openrc-shutdown.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c
index 4ba619c5..b17a63d8 100644
--- a/src/rc/openrc-shutdown.c
+++ b/src/rc/openrc-shutdown.c
@@ -37,7 +37,7 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "dDHKpRrw" getoptstring_COMMON;
+const char *getoptstring = "dDHKpRrsw" getoptstring_COMMON;
const struct option longopts[] = {
{ "no-write", no_argument, NULL, 'd'},
{ "dry-run", no_argument, NULL, 'D'},
@@ -46,6 +46,7 @@ const struct option longopts[] = {
{ "poweroff", no_argument, NULL, 'p'},
{ "reexec", no_argument, NULL, 'R'},
{ "reboot", no_argument, NULL, 'r'},
+ { "single", no_argument, NULL, 's'},
{ "write-only", no_argument, NULL, 'w'},
longopts_COMMON
};
@@ -57,12 +58,13 @@ const char * const longopts_help[] = {
"power off the system",
"re-execute init (use after upgrading)",
"reboot the system",
+ "single user mode",
"write wtmp boot record and exit",
longopts_help_COMMON
};
const char *usagestring = NULL;
const char *exclusive = "Select one of "
-"--halt, --kexec, --poweroff, --reexec or --reboot";
+"--halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only";
static bool do_dryrun = false;
static bool do_halt = false;
@@ -70,6 +72,7 @@ static bool do_kexec = false;
static bool do_poweroff = false;
static bool do_reboot = false;
static bool do_reexec = false;
+static bool do_single = false;
static bool do_wtmp = true;
static bool do_wtmp_only = false;
@@ -132,15 +135,20 @@ int main(int argc, char **argv)
do_reboot = true;
cmd_count++;
break;
+ case 's':
+ do_single = true;
+ cmd_count++;
+ break;
case 'w':
do_wtmp_only = true;
+ cmd_count++;
break;
case_RC_COMMON_GETOPT
}
}
if (geteuid() != 0 && ! do_dryrun)
eerrorx("%s: you must be root\n", applet);
- if (cmd_count > 1) {
+ if (cmd_count != 1) {
eerror("%s: %s\n", applet, exclusive);
usage(EXIT_FAILURE);
}
@@ -156,7 +164,7 @@ int main(int argc, char **argv)
send_cmd("reexec");
else if (do_wtmp_only)
log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
- else
+ else if (do_single)
send_cmd("single");
return 0;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-06-12 15:41 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-06-12 15:41 UTC (permalink / raw
To: gentoo-commits
commit: 11243f85b67e5f450ddf50346ffd4a1b2c6faeb5
Author: Jory A. Pratt <anarchy <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 8 14:14:10 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jun 8 15:04:19 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=11243f85
kill_all: include limits.h for PATH_MAX
src/rc/kill_all.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/kill_all.c b/src/rc/kill_all.c
index a4b15c87..f3500227 100644
--- a/src/rc/kill_all.c
+++ b/src/rc/kill_all.c
@@ -19,6 +19,7 @@
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
+#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-06-12 15:41 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-06-12 15:41 UTC (permalink / raw
To: gentoo-commits
commit: 560d874d2fee63bf7ca11f17cf9933021b639a1d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jun 8 13:43:42 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jun 8 13:43:42 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=560d874d
fix compile issue for musl
src/rc/rc-wtmp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/rc-wtmp.c b/src/rc/rc-wtmp.c
index 913fa06b..8d494303 100644
--- a/src/rc/rc-wtmp.c
+++ b/src/rc/rc-wtmp.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-07-24 23:27 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-07-24 23:27 UTC (permalink / raw
To: gentoo-commits
commit: 6d4e8433974fd8567885635ae0454031290f96b1
Author: Jason Graham <jgraha8 <AT> gmail <DOT> com>
AuthorDate: Mon Jul 24 23:22:46 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jul 24 23:24:18 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6d4e8433
fix ENT macro usage
X-Gentoo-Bug: 624796
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=624796
src/rc/fstabinfo.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 75c8bc2b..a2e707aa 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -35,11 +35,11 @@
# define GET_ENT getmntent (fp)
# define GET_ENT_FILE(_name) getmntfile (_name)
# define END_ENT endmntent (fp)
-# define ENT_BLOCKDEVICE(_ent) ent->mnt_fsname
-# define ENT_FILE(_ent) ent->mnt_dir
-# define ENT_TYPE(_ent) ent->mnt_type
-# define ENT_OPTS(_ent) ent->mnt_opts
-# define ENT_PASS(_ent) ent->mnt_passno
+# define ENT_BLOCKDEVICE(_ent) (_ent)->mnt_fsname
+# define ENT_FILE(_ent) (_ent)->mnt_dir
+# define ENT_TYPE(_ent) (_ent)->mnt_type
+# define ENT_OPTS(_ent) (_ent)->mnt_opts
+# define ENT_PASS(_ent) (_ent)->mnt_passno
#else
# define HAVE_GETFSENT
# include <fstab.h>
@@ -48,11 +48,11 @@
# define GET_ENT getfsent ()
# define GET_ENT_FILE(_name) getfsfile (_name)
# define END_ENT endfsent ()
-# define ENT_BLOCKDEVICE(_ent) ent->fs_spec
-# define ENT_TYPE(_ent) ent->fs_vfstype
-# define ENT_FILE(_ent) ent->fs_file
-# define ENT_OPTS(_ent) ent->fs_mntops
-# define ENT_PASS(_ent) ent->fs_passno
+# define ENT_BLOCKDEVICE(_ent) (_ent)->fs_spec
+# define ENT_TYPE(_ent) (_ent)->fs_vfstype
+# define ENT_FILE(_ent) (_ent)->fs_file
+# define ENT_OPTS(_ent) (_ent)->fs_mntops
+# define ENT_PASS(_ent) (_ent)->fs_passno
#endif
#include "einfo.h"
@@ -114,24 +114,24 @@ do_mount(struct ENT *ent, bool remount)
argv[0] = UNCONST("mount");
argv[1] = UNCONST("-o");
- argv[2] = ENT_OPTS(*ent);
+ argv[2] = ENT_OPTS(ent);
argv[3] = UNCONST("-t");
- argv[4] = ENT_TYPE(*ent);
+ argv[4] = ENT_TYPE(ent);
if (!remount) {
- argv[5] = ENT_BLOCKDEVICE(*ent);
- argv[6] = ENT_FILE(*ent);
+ argv[5] = ENT_BLOCKDEVICE(ent);
+ argv[6] = ENT_FILE(ent);
argv[7] = NULL;
} else {
#ifdef __linux__
argv[5] = UNCONST("-o");
argv[6] = UNCONST("remount");
- argv[7] = ENT_BLOCKDEVICE(*ent);
- argv[8] = ENT_FILE(*ent);
+ argv[7] = ENT_BLOCKDEVICE(ent);
+ argv[8] = ENT_FILE(ent);
argv[9] = NULL;
#else
argv[5] = UNCONST("-u");
- argv[6] = ENT_BLOCKDEVICE(*ent);
- argv[7] = ENT_FILE(*ent);
+ argv[6] = ENT_BLOCKDEVICE(ent);
+ argv[7] = ENT_FILE(ent);
argv[8] = NULL;
#endif
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-08-24 16:45 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-08-24 16:45 UTC (permalink / raw
To: gentoo-commits
commit: d7938f54f29193251e083ad35a7d464949829096
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Aug 24 16:34:18 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Aug 24 16:34:18 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d7938f54
start-stop-daemon: move --retry processing code to a shared module
This was part of start-stop-daemon; however, it needs to be shared in
order to be used by supervise-daemon.
src/rc/Makefile | 2 +-
src/rc/rc-schedules.c | 425 +++++++++++++++++++++++++++++++++++++++++++++
src/rc/rc-schedules.h | 27 +++
src/rc/start-stop-daemon.c | 402 +-----------------------------------------
4 files changed, 461 insertions(+), 395 deletions(-)
diff --git a/src/rc/Makefile b/src/rc/Makefile
index 19adcafb..e6c9f4a2 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -156,7 +156,7 @@ rc-service 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}
-start-stop-daemon: start-stop-daemon.o _usage.o rc-misc.o
+start-stop-daemon: start-stop-daemon.o _usage.o rc-misc.o rc-schedules.o
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
supervise-daemon: supervise-daemon.o _usage.o rc-misc.o
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
new file mode 100644
index 00000000..0390ef9c
--- /dev/null
+++ b/src/rc/rc-schedules.c
@@ -0,0 +1,425 @@
+/*
+ * The functions in this file control the stopping of daemons by
+ * start-stop-daemon and supervise-daemon.
+ */
+
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/* nano seconds */
+#define POLL_INTERVAL 20000000
+#define WAIT_PIDFILE 500000000
+#define ONE_SECOND 1000000000
+#define ONE_MS 1000000
+
+#include <ctype.h>
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "einfo.h"
+#include "queue.h"
+#include "rc.h"
+#include "rc-misc.h"
+#include "rc-schedules.h"
+#include "helpers.h"
+
+typedef struct scheduleitem {
+ enum {
+ SC_TIMEOUT,
+ SC_SIGNAL,
+ SC_GOTO,
+ SC_FOREVER,
+ } type;
+ int value;
+ struct scheduleitem *gotoitem;
+ TAILQ_ENTRY(scheduleitem) entries;
+} SCHEDULEITEM;
+
+static TAILQ_HEAD(, scheduleitem) schedule;
+
+void initialize_schedulelist(void)
+{
+ TAILQ_INIT(&schedule);
+}
+
+void free_schedulelist(void)
+{
+ SCHEDULEITEM *s1 = TAILQ_FIRST(&schedule);
+ SCHEDULEITEM *s2;
+
+ while (s1) {
+ s2 = TAILQ_NEXT(s1, entries);
+ free(s1);
+ s1 = s2;
+ }
+ TAILQ_INIT(&schedule);
+}
+
+int parse_signal(const char *applet, const char *sig)
+{
+ typedef struct signalpair
+ {
+ const char *name;
+ int signal;
+ } SIGNALPAIR;
+
+#define signalpair_item(name) { #name, SIG##name },
+
+ static const SIGNALPAIR signallist[] = {
+ signalpair_item(HUP)
+ signalpair_item(INT)
+ signalpair_item(QUIT)
+ signalpair_item(ILL)
+ signalpair_item(TRAP)
+ signalpair_item(ABRT)
+ signalpair_item(BUS)
+ signalpair_item(FPE)
+ signalpair_item(KILL)
+ signalpair_item(USR1)
+ signalpair_item(SEGV)
+ signalpair_item(USR2)
+ signalpair_item(PIPE)
+ signalpair_item(ALRM)
+ signalpair_item(TERM)
+ signalpair_item(CHLD)
+ signalpair_item(CONT)
+ signalpair_item(STOP)
+ signalpair_item(TSTP)
+ signalpair_item(TTIN)
+ signalpair_item(TTOU)
+ signalpair_item(URG)
+ signalpair_item(XCPU)
+ signalpair_item(XFSZ)
+ signalpair_item(VTALRM)
+ signalpair_item(PROF)
+#ifdef SIGWINCH
+ signalpair_item(WINCH)
+#endif
+#ifdef SIGIO
+ signalpair_item(IO)
+#endif
+#ifdef SIGPWR
+ signalpair_item(PWR)
+#endif
+ signalpair_item(SYS)
+ { "NULL", 0 },
+ };
+
+ unsigned int i = 0;
+ const char *s;
+
+ if (!sig || *sig == '\0')
+ return -1;
+
+ if (sscanf(sig, "%u", &i) == 1) {
+ if (i < NSIG)
+ return i;
+ eerrorx("%s: `%s' is not a valid signal", applet, sig);
+ }
+
+ if (strncmp(sig, "SIG", 3) == 0)
+ s = sig + 3;
+ else
+ s = NULL;
+
+ for (i = 0; i < ARRAY_SIZE(signallist); ++i)
+ if (strcmp(sig, signallist[i].name) == 0 ||
+ (s && strcmp(s, signallist[i].name) == 0))
+ return signallist[i].signal;
+
+ eerrorx("%s: `%s' is not a valid signal", applet, sig);
+ /* NOTREACHED */
+}
+
+static SCHEDULEITEM *parse_schedule_item(const char *applet, const char *string)
+{
+ const char *after_hyph;
+ int sig;
+ SCHEDULEITEM *item = xmalloc(sizeof(*item));
+
+ item->value = 0;
+ item->gotoitem = NULL;
+ if (strcmp(string,"forever") == 0)
+ item->type = SC_FOREVER;
+ else if (isdigit((unsigned char)string[0])) {
+ item->type = SC_TIMEOUT;
+ errno = 0;
+ if (sscanf(string, "%d", &item->value) != 1)
+ eerrorx("%s: invalid timeout value in schedule `%s'",
+ applet, string);
+ } else if ((after_hyph = string + (string[0] == '-')) &&
+ ((sig = parse_signal(applet, after_hyph)) != -1))
+ {
+ item->type = SC_SIGNAL;
+ item->value = (int)sig;
+ } else
+ eerrorx("%s: invalid schedule item `%s'", applet, string);
+
+ return item;
+}
+
+void parse_schedule(const char *applet, const char *string, int timeout)
+{
+ char buffer[20];
+ const char *slash;
+ int count = 0;
+ SCHEDULEITEM *repeatat = NULL;
+ size_t len;
+ SCHEDULEITEM *item;
+
+ if (string)
+ for (slash = string; *slash; slash++)
+ if (*slash == '/')
+ count++;
+
+ free_schedulelist();
+
+ if (count == 0) {
+ item = xmalloc(sizeof(*item));
+ item->type = SC_SIGNAL;
+ item->value = timeout;
+ item->gotoitem = NULL;
+ TAILQ_INSERT_TAIL(&schedule, item, entries);
+
+ item = xmalloc(sizeof(*item));
+ item->type = SC_TIMEOUT;
+ item->gotoitem = NULL;
+ TAILQ_INSERT_TAIL(&schedule, item, entries);
+ if (string) {
+ if (sscanf(string, "%d", &item->value) != 1)
+ eerrorx("%s: invalid timeout in schedule",
+ applet);
+ } else
+ item->value = 5;
+
+ return;
+ }
+
+ while (string != NULL) {
+ if ((slash = strchr(string, '/')))
+ len = slash - string;
+ else
+ len = strlen(string);
+
+ if (len >= (ptrdiff_t)sizeof(buffer))
+ eerrorx("%s: invalid schedule item, far too long",
+ applet);
+
+ memcpy(buffer, string, len);
+ buffer[len] = 0;
+ string = slash ? slash + 1 : NULL;
+
+ item = parse_schedule_item(applet, buffer);
+ TAILQ_INSERT_TAIL(&schedule, item, entries);
+ if (item->type == SC_FOREVER) {
+ if (repeatat)
+ eerrorx("%s: invalid schedule, `forever' "
+ "appears more than once", applet);
+
+ repeatat = item;
+ continue;
+ }
+ }
+
+ if (repeatat) {
+ item = xmalloc(sizeof(*item));
+ item->type = SC_GOTO;
+ item->value = 0;
+ item->gotoitem = repeatat;
+ TAILQ_INSERT_TAIL(&schedule, item, entries);
+ }
+
+ return;
+}
+
+/* return number of processes killed, -1 on error */
+int do_stop(const char *applet, const char *exec, const char *const *argv,
+ pid_t pid, uid_t uid,int sig, bool test)
+{
+ RC_PIDLIST *pids;
+ RC_PID *pi;
+ RC_PID *np;
+ bool killed;
+ int nkilled = 0;
+
+ if (pid)
+ pids = rc_find_pids(NULL, NULL, 0, pid);
+ else
+ pids = rc_find_pids(exec, argv, uid, pid);
+
+ if (!pids)
+ return 0;
+
+ LIST_FOREACH_SAFE(pi, pids, entries, np) {
+ if (test) {
+ einfo("Would send signal %d to PID %d", sig, pi->pid);
+ nkilled++;
+ } else {
+ ebeginv("Sending signal %d to PID %d", sig, pi->pid);
+ errno = 0;
+ killed = (kill(pi->pid, sig) == 0 ||
+ errno == ESRCH ? true : false);
+ eendv(killed ? 0 : 1,
+ "%s: failed to send signal %d to PID %d: %s",
+ applet, sig, pi->pid, strerror(errno));
+ if (!killed) {
+ nkilled = -1;
+ } else {
+ if (nkilled != -1)
+ nkilled++;
+ }
+ }
+ free(pi);
+ }
+
+ free(pids);
+ return nkilled;
+}
+
+int run_stop_schedule(const char *applet,
+ const char *exec, const char *const *argv,
+ const char *pidfile, uid_t uid,
+ bool test, bool progress)
+{
+ SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
+ int nkilled = 0;
+ int tkilled = 0;
+ int nrunning = 0;
+ long nloops, nsecs;
+ struct timespec ts;
+ pid_t pid = 0;
+ const char *const *p;
+ bool progressed = false;
+
+ if (exec)
+ einfov("Will stop %s", exec);
+ if (pidfile)
+ einfov("Will stop PID in pidfile `%s'", pidfile);
+ if (uid)
+ einfov("Will stop processes owned by UID %d", uid);
+ if (argv && *argv) {
+ einfovn("Will stop processes of `");
+ if (rc_yesno(getenv("EINFO_VERBOSE"))) {
+ for (p = argv; p && *p; p++) {
+ if (p != argv)
+ printf(" ");
+ printf("%s", *p);
+ }
+ printf("'\n");
+ }
+ }
+
+ if (pidfile) {
+ pid = get_pid(applet, pidfile);
+ if (pid == -1)
+ return 0;
+ }
+
+ while (item) {
+ switch (item->type) {
+ case SC_GOTO:
+ item = item->gotoitem;
+ continue;
+
+ case SC_SIGNAL:
+ nrunning = 0;
+ nkilled = do_stop(applet, exec, argv, pid, uid, item->value, test);
+ if (nkilled == 0) {
+ if (tkilled == 0) {
+ if (progressed)
+ printf("\n");
+ eerror("%s: no matching processes found", applet);
+ }
+ return tkilled;
+ }
+ else if (nkilled == -1)
+ return 0;
+
+ tkilled += nkilled;
+ break;
+ case SC_TIMEOUT:
+ if (item->value < 1) {
+ item = NULL;
+ break;
+ }
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = POLL_INTERVAL;
+
+ for (nsecs = 0; nsecs < item->value; nsecs++) {
+ for (nloops = 0;
+ nloops < ONE_SECOND / POLL_INTERVAL;
+ nloops++)
+ {
+ if ((nrunning = do_stop(applet, exec, argv,
+ pid, uid, 0, test)) == 0)
+ return 0;
+
+
+ if (nanosleep(&ts, NULL) == -1) {
+ if (progressed) {
+ printf("\n");
+ progressed = false;
+ }
+ if (errno == EINTR)
+ eerror("%s: caught an"
+ " interrupt", applet);
+ else {
+ eerror("%s: nanosleep: %s",
+ applet, strerror(errno));
+ return 0;
+ }
+ }
+ }
+ if (progress) {
+ printf(".");
+ fflush(stdout);
+ progressed = true;
+ }
+ }
+ break;
+ default:
+ if (progressed) {
+ printf("\n");
+ progressed = false;
+ }
+ eerror("%s: invalid schedule item `%d'",
+ applet, item->type);
+ return 0;
+ }
+
+ if (item)
+ item = TAILQ_NEXT(item, entries);
+ }
+
+ if (test || (tkilled > 0 && nrunning == 0))
+ return nkilled;
+
+ if (progressed)
+ printf("\n");
+ if (nrunning == 1)
+ eerror("%s: %d process refused to stop", applet, nrunning);
+ else
+ eerror("%s: %d process(es) refused to stop", applet, nrunning);
+
+ return -nrunning;
+}
diff --git a/src/rc/rc-schedules.h b/src/rc/rc-schedules.h
new file mode 100644
index 00000000..6bed7916
--- /dev/null
+++ b/src/rc/rc-schedules.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 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_SCHEDULES_H
+#define __RC_SCHEDULES_H
+
+void initialize_schedulelist(void);
+void free_schedulelist(void);
+int parse_signal(const char *applet, const char *sig);
+void parse_schedule(const char *applet, const char *string, int timeout);
+int do_stop(const char *applet, const char *exec, const char *const *argv,
+ pid_t pid, uid_t uid,int sig, bool test);
+int run_stop_schedule(const char *applet,
+ const char *exec, const char *const *argv,
+ const char *pidfile, uid_t uid,
+ bool test, bool progress);
+
+#endif
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 451d4a5c..df5b3184 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -19,10 +19,6 @@
* except according to the terms contained in the LICENSE file.
*/
-/* nano seconds */
-#define POLL_INTERVAL 20000000
-#define WAIT_PIDFILE 500000000
-#define ONE_SECOND 1000000000
#define ONE_MS 1000000
#include <sys/types.h>
@@ -63,6 +59,7 @@ static struct pam_conv conv = { NULL, NULL};
#include "queue.h"
#include "rc.h"
#include "rc-misc.h"
+#include "rc-schedules.h"
#include "_usage.h"
#include "helpers.h"
@@ -130,20 +127,6 @@ const char * const longopts_help[] = {
};
const char *usagestring = NULL;
-typedef struct scheduleitem
-{
- enum
- {
- SC_TIMEOUT,
- SC_SIGNAL,
- SC_GOTO,
- SC_FOREVER
- } type;
- int value;
- struct scheduleitem *gotoitem;
- TAILQ_ENTRY(scheduleitem) entries;
-} SCHEDULEITEM;
-TAILQ_HEAD(, scheduleitem) schedule;
static char **nav;
static char *changeuser, *ch_root, *ch_dir;
@@ -167,20 +150,6 @@ static inline int ioprio_set(int which _unused,
#endif
static void
-free_schedulelist(void)
-{
- SCHEDULEITEM *s1 = TAILQ_FIRST(&schedule);
- SCHEDULEITEM *s2;
-
- while (s1) {
- s2 = TAILQ_NEXT(s1, entries);
- free(s1);
- s1 = s2;
- }
- TAILQ_INIT(&schedule);
-}
-
-static void
cleanup(void)
{
free(changeuser);
@@ -188,360 +157,6 @@ cleanup(void)
free_schedulelist();
}
-static int
-parse_signal(const char *sig)
-{
- typedef struct signalpair
- {
- const char *name;
- int signal;
- } SIGNALPAIR;
-
-#define signalpair_item(name) { #name, SIG##name },
-
- static const SIGNALPAIR signallist[] = {
- signalpair_item(HUP)
- signalpair_item(INT)
- signalpair_item(QUIT)
- signalpair_item(ILL)
- signalpair_item(TRAP)
- signalpair_item(ABRT)
- signalpair_item(BUS)
- signalpair_item(FPE)
- signalpair_item(KILL)
- signalpair_item(USR1)
- signalpair_item(SEGV)
- signalpair_item(USR2)
- signalpair_item(PIPE)
- signalpair_item(ALRM)
- signalpair_item(TERM)
- signalpair_item(CHLD)
- signalpair_item(CONT)
- signalpair_item(STOP)
- signalpair_item(TSTP)
- signalpair_item(TTIN)
- signalpair_item(TTOU)
- signalpair_item(URG)
- signalpair_item(XCPU)
- signalpair_item(XFSZ)
- signalpair_item(VTALRM)
- signalpair_item(PROF)
-#ifdef SIGWINCH
- signalpair_item(WINCH)
-#endif
-#ifdef SIGIO
- signalpair_item(IO)
-#endif
-#ifdef SIGPWR
- signalpair_item(PWR)
-#endif
- signalpair_item(SYS)
- { "NULL", 0 },
- };
-
- unsigned int i = 0;
- const char *s;
-
- if (!sig || *sig == '\0')
- return -1;
-
- if (sscanf(sig, "%u", &i) == 1) {
- if (i < NSIG)
- return i;
- eerrorx("%s: `%s' is not a valid signal", applet, sig);
- }
-
- if (strncmp(sig, "SIG", 3) == 0)
- s = sig + 3;
- else
- s = NULL;
-
- for (i = 0; i < ARRAY_SIZE(signallist); ++i)
- if (strcmp(sig, signallist[i].name) == 0 ||
- (s && strcmp(s, signallist[i].name) == 0))
- return signallist[i].signal;
-
- eerrorx("%s: `%s' is not a valid signal", applet, sig);
- /* NOTREACHED */
-}
-
-static SCHEDULEITEM *
-parse_schedule_item(const char *string)
-{
- const char *after_hyph;
- int sig;
- SCHEDULEITEM *item = xmalloc(sizeof(*item));
-
- item->value = 0;
- item->gotoitem = NULL;
- if (strcmp(string,"forever") == 0)
- item->type = SC_FOREVER;
- else if (isdigit((unsigned char)string[0])) {
- item->type = SC_TIMEOUT;
- errno = 0;
- if (sscanf(string, "%d", &item->value) != 1)
- eerrorx("%s: invalid timeout value in schedule `%s'",
- applet, string);
- } else if ((after_hyph = string + (string[0] == '-')) &&
- ((sig = parse_signal(after_hyph)) != -1))
- {
- item->type = SC_SIGNAL;
- item->value = (int)sig;
- } else
- eerrorx("%s: invalid schedule item `%s'", applet, string);
-
- return item;
-}
-
-static void
-parse_schedule(const char *string, int timeout)
-{
- char buffer[20];
- const char *slash;
- int count = 0;
- SCHEDULEITEM *repeatat = NULL;
- size_t len;
- SCHEDULEITEM *item;
-
- if (string)
- for (slash = string; *slash; slash++)
- if (*slash == '/')
- count++;
-
- free_schedulelist();
-
- if (count == 0) {
- item = xmalloc(sizeof(*item));
- item->type = SC_SIGNAL;
- item->value = timeout;
- item->gotoitem = NULL;
- TAILQ_INSERT_TAIL(&schedule, item, entries);
-
- item = xmalloc(sizeof(*item));
- item->type = SC_TIMEOUT;
- item->gotoitem = NULL;
- TAILQ_INSERT_TAIL(&schedule, item, entries);
- if (string) {
- if (sscanf(string, "%d", &item->value) != 1)
- eerrorx("%s: invalid timeout in schedule",
- applet);
- } else
- item->value = 5;
-
- return;
- }
-
- while (string != NULL) {
- if ((slash = strchr(string, '/')))
- len = slash - string;
- else
- len = strlen(string);
-
- if (len >= (ptrdiff_t)sizeof(buffer))
- eerrorx("%s: invalid schedule item, far too long",
- applet);
-
- memcpy(buffer, string, len);
- buffer[len] = 0;
- string = slash ? slash + 1 : NULL;
-
- item = parse_schedule_item(buffer);
- TAILQ_INSERT_TAIL(&schedule, item, entries);
- if (item->type == SC_FOREVER) {
- if (repeatat)
- eerrorx("%s: invalid schedule, `forever' "
- "appears more than once", applet);
-
- repeatat = item;
- continue;
- }
- }
-
- if (repeatat) {
- item = xmalloc(sizeof(*item));
- item->type = SC_GOTO;
- item->value = 0;
- item->gotoitem = repeatat;
- TAILQ_INSERT_TAIL(&schedule, item, entries);
- }
-
- return;
-}
-
-/* return number of processed killed, -1 on error */
-static int
-do_stop(const char *exec, const char *const *argv,
- pid_t pid, uid_t uid,int sig, bool test)
-{
- RC_PIDLIST *pids;
- RC_PID *pi;
- RC_PID *np;
- bool killed;
- int nkilled = 0;
-
- if (pid)
- pids = rc_find_pids(NULL, NULL, 0, pid);
- else
- pids = rc_find_pids(exec, argv, uid, pid);
-
- if (!pids)
- return 0;
-
- LIST_FOREACH_SAFE(pi, pids, entries, np) {
- if (test) {
- einfo("Would send signal %d to PID %d", sig, pi->pid);
- nkilled++;
- } else {
- ebeginv("Sending signal %d to PID %d", sig, pi->pid);
- errno = 0;
- killed = (kill(pi->pid, sig) == 0 ||
- errno == ESRCH ? true : false);
- eendv(killed ? 0 : 1,
- "%s: failed to send signal %d to PID %d: %s",
- applet, sig, pi->pid, strerror(errno));
- if (!killed) {
- nkilled = -1;
- } else {
- if (nkilled != -1)
- nkilled++;
- }
- }
- free(pi);
- }
-
- free(pids);
- return nkilled;
-}
-
-static int
-run_stop_schedule(const char *exec, const char *const *argv,
- const char *pidfile, uid_t uid,
- bool test, bool progress)
-{
- SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
- int nkilled = 0;
- int tkilled = 0;
- int nrunning = 0;
- long nloops, nsecs;
- struct timespec ts;
- pid_t pid = 0;
- const char *const *p;
- bool progressed = false;
-
- if (exec)
- einfov("Will stop %s", exec);
- if (pidfile)
- einfov("Will stop PID in pidfile `%s'", pidfile);
- if (uid)
- einfov("Will stop processes owned by UID %d", uid);
- if (argv && *argv) {
- einfovn("Will stop processes of `");
- if (rc_yesno(getenv("EINFO_VERBOSE"))) {
- for (p = argv; p && *p; p++) {
- if (p != argv)
- printf(" ");
- printf("%s", *p);
- }
- printf("'\n");
- }
- }
-
- if (pidfile) {
- pid = get_pid(applet, pidfile);
- if (pid == -1)
- return 0;
- }
-
- while (item) {
- switch (item->type) {
- case SC_GOTO:
- item = item->gotoitem;
- continue;
-
- case SC_SIGNAL:
- nrunning = 0;
- nkilled = do_stop(exec, argv, pid, uid, item->value, test);
- if (nkilled == 0) {
- if (tkilled == 0) {
- if (progressed)
- printf("\n");
- eerror("%s: no matching processes found", applet);
- }
- return tkilled;
- }
- else if (nkilled == -1)
- return 0;
-
- tkilled += nkilled;
- break;
- case SC_TIMEOUT:
- if (item->value < 1) {
- item = NULL;
- break;
- }
-
- ts.tv_sec = 0;
- ts.tv_nsec = POLL_INTERVAL;
-
- for (nsecs = 0; nsecs < item->value; nsecs++) {
- for (nloops = 0;
- nloops < ONE_SECOND / POLL_INTERVAL;
- nloops++)
- {
- if ((nrunning = do_stop(exec, argv,
- pid, uid, 0, test)) == 0)
- return 0;
-
-
- if (nanosleep(&ts, NULL) == -1) {
- if (progressed) {
- printf("\n");
- progressed = false;
- }
- if (errno == EINTR)
- eerror("%s: caught an"
- " interrupt", applet);
- else {
- eerror("%s: nanosleep: %s",
- applet, strerror(errno));
- return 0;
- }
- }
- }
- if (progress) {
- printf(".");
- fflush(stdout);
- progressed = true;
- }
- }
- break;
- default:
- if (progressed) {
- printf("\n");
- progressed = false;
- }
- eerror("%s: invalid schedule item `%d'",
- applet, item->type);
- return 0;
- }
-
- if (item)
- item = TAILQ_NEXT(item, entries);
- }
-
- if (test || (tkilled > 0 && nrunning == 0))
- return nkilled;
-
- if (progressed)
- printf("\n");
- if (nrunning == 1)
- eerror("%s: %d process refused to stop", applet, nrunning);
- else
- eerror("%s: %d process(es) refused to stop", applet, nrunning);
-
- return -nrunning;
-}
-
static void
handle_signal(int sig)
{
@@ -682,7 +297,6 @@ int main(int argc, char **argv)
unsigned int start_wait = 0;
applet = basename_c(argv[0]);
- TAILQ_INIT(&schedule);
atexit(cleanup);
signal_setup(SIGINT, handle_signal);
@@ -851,7 +465,7 @@ int main(int argc, char **argv)
break;
case 's': /* --signal <signal> */
- sig = parse_signal(optarg);
+ sig = parse_signal(applet, optarg);
break;
case 't': /* --test */
@@ -1037,12 +651,12 @@ int main(int argc, char **argv)
if (!stop)
oknodo = true;
if (retry)
- parse_schedule(retry, sig);
+ parse_schedule(applet, retry, sig);
else if (test || oknodo)
- parse_schedule("0", sig);
+ parse_schedule(applet, "0", sig);
else
- parse_schedule(NULL, sig);
- i = run_stop_schedule(exec, (const char *const *)margv,
+ parse_schedule(applet, NULL, sig);
+ i = run_stop_schedule(applet, exec, (const char *const *)margv,
pidfile, uid, test, progress);
if (i < 0)
@@ -1069,7 +683,7 @@ int main(int argc, char **argv)
else
pid = 0;
- if (do_stop(exec, (const char * const *)margv, pid, uid,
+ if (do_stop(applet, exec, (const char * const *)margv, pid, uid,
0, test) > 0)
eerrorx("%s: %s is already running", applet, exec);
@@ -1349,7 +963,7 @@ int main(int argc, char **argv)
}
} else
pid = 0;
- if (do_stop(exec, (const char *const *)margv,
+ if (do_stop(applet, exec, (const char *const *)margv,
pid, uid, 0, test) > 0)
alive = true;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-08-25 16:48 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-08-25 16:48 UTC (permalink / raw
To: gentoo-commits
commit: 36a0ab9054512ade413226fb8e8b28060045e9a4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Aug 25 16:36:45 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Aug 25 16:36:45 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=36a0ab90
make run_stop_schedule accept a pid instead of a pid file
src/rc/rc-schedules.c | 13 +++----------
src/rc/rc-schedules.h | 2 +-
src/rc/start-stop-daemon.c | 2 +-
3 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index 0390ef9c..7eb28372 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -297,7 +297,7 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
int run_stop_schedule(const char *applet,
const char *exec, const char *const *argv,
- const char *pidfile, uid_t uid,
+ pid_t pid, uid_t uid,
bool test, bool progress)
{
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
@@ -306,14 +306,13 @@ int run_stop_schedule(const char *applet,
int nrunning = 0;
long nloops, nsecs;
struct timespec ts;
- pid_t pid = 0;
const char *const *p;
bool progressed = false;
if (exec)
einfov("Will stop %s", exec);
- if (pidfile)
- einfov("Will stop PID in pidfile `%s'", pidfile);
+ if (pid > 0)
+ einfov("Will stop PID %d", pid);
if (uid)
einfov("Will stop processes owned by UID %d", uid);
if (argv && *argv) {
@@ -328,12 +327,6 @@ int run_stop_schedule(const char *applet,
}
}
- if (pidfile) {
- pid = get_pid(applet, pidfile);
- if (pid == -1)
- return 0;
- }
-
while (item) {
switch (item->type) {
case SC_GOTO:
diff --git a/src/rc/rc-schedules.h b/src/rc/rc-schedules.h
index 6bed7916..0a10b381 100644
--- a/src/rc/rc-schedules.h
+++ b/src/rc/rc-schedules.h
@@ -21,7 +21,7 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
pid_t pid, uid_t uid,int sig, bool test);
int run_stop_schedule(const char *applet,
const char *exec, const char *const *argv,
- const char *pidfile, uid_t uid,
+ pid_t pid, uid_t uid,
bool test, bool progress);
#endif
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index df5b3184..4cda6102 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -657,7 +657,7 @@ int main(int argc, char **argv)
else
parse_schedule(applet, NULL, sig);
i = run_stop_schedule(applet, exec, (const char *const *)margv,
- pidfile, uid, test, progress);
+ get_pid(applet, pidfile), uid, test, progress);
if (i < 0)
/* We failed to stop something */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-06 22:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-06 22:33 UTC (permalink / raw
To: gentoo-commits
commit: 382efdbfcb99703d03211efacd800c9575e64230
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Sep 6 21:43:28 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Sep 6 22:22:35 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=382efdbf
add quiet parameter to run_stop_schedule
src/rc/rc-schedules.c | 11 ++++++-----
src/rc/rc-schedules.h | 2 +-
src/rc/start-stop-daemon.c | 2 +-
src/rc/supervise-daemon.c | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index 7eb28372..1b235a8d 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -298,7 +298,7 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
int run_stop_schedule(const char *applet,
const char *exec, const char *const *argv,
pid_t pid, uid_t uid,
- bool test, bool progress)
+ bool test, bool progress, bool quiet)
{
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
int nkilled = 0;
@@ -409,10 +409,11 @@ int run_stop_schedule(const char *applet,
if (progressed)
printf("\n");
- if (nrunning == 1)
- eerror("%s: %d process refused to stop", applet, nrunning);
- else
- eerror("%s: %d process(es) refused to stop", applet, nrunning);
+ if (! quiet)
+ if (nrunning == 1)
+ eerror("%s: %d process refused to stop", applet, nrunning);
+ else
+ eerror("%s: %d process(es) refused to stop", applet, nrunning);
return -nrunning;
}
diff --git a/src/rc/rc-schedules.h b/src/rc/rc-schedules.h
index 0a10b381..a42ea0e3 100644
--- a/src/rc/rc-schedules.h
+++ b/src/rc/rc-schedules.h
@@ -22,6 +22,6 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
int run_stop_schedule(const char *applet,
const char *exec, const char *const *argv,
pid_t pid, uid_t uid,
- bool test, bool progress);
+ bool test, bool progress, bool quiet);
#endif
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 4cda6102..46784b26 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -657,7 +657,7 @@ int main(int argc, char **argv)
else
parse_schedule(applet, NULL, sig);
i = run_stop_schedule(applet, exec, (const char *const *)margv,
- get_pid(applet, pidfile), uid, test, progress);
+ get_pid(applet, pidfile), uid, test, progress, false);
if (i < 0)
/* We failed to stop something */
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 3923dab5..a702a25c 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -755,7 +755,7 @@ int main(int argc, char **argv)
if (exiting) {
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
nkilled = run_stop_schedule(applet, exec, NULL, child_pid,
- 0, false, false);
+ 0, false, false, true);
if (nkilled > 0)
syslog(LOG_INFO, "killed %d processes", nkilled);
} else {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-15 18:31 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-15 18:31 UTC (permalink / raw
To: gentoo-commits
commit: b0a077a35f85e266fdb82a245dcbda18664a8567
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Sep 14 23:24:31 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Sep 14 23:24:39 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b0a077a3
add quiet switch to do_stop in src-schedules.c
This allows supervise-daemon to run this code without attempting to
print some status messages used by start-stop-daemon.
src/rc/rc-schedules.c | 13 ++++++++-----
src/rc/rc-schedules.h | 2 +-
src/rc/start-stop-daemon.c | 4 ++--
src/rc/supervise-daemon.c | 7 ++-----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index 1b235a8d..13f615ee 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -253,7 +253,7 @@ void parse_schedule(const char *applet, const char *string, int timeout)
/* return number of processes killed, -1 on error */
int do_stop(const char *applet, const char *exec, const char *const *argv,
- pid_t pid, uid_t uid,int sig, bool test)
+ pid_t pid, uid_t uid,int sig, bool test, bool quiet)
{
RC_PIDLIST *pids;
RC_PID *pi;
@@ -274,11 +274,13 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
einfo("Would send signal %d to PID %d", sig, pi->pid);
nkilled++;
} else {
- ebeginv("Sending signal %d to PID %d", sig, pi->pid);
+ if (!quiet)
+ ebeginv("Sending signal %d to PID %d", sig, pi->pid);
errno = 0;
killed = (kill(pi->pid, sig) == 0 ||
errno == ESRCH ? true : false);
- eendv(killed ? 0 : 1,
+ if (! quiet)
+ eendv(killed ? 0 : 1,
"%s: failed to send signal %d to PID %d: %s",
applet, sig, pi->pid, strerror(errno));
if (!killed) {
@@ -335,7 +337,8 @@ int run_stop_schedule(const char *applet,
case SC_SIGNAL:
nrunning = 0;
- nkilled = do_stop(applet, exec, argv, pid, uid, item->value, test);
+ nkilled = do_stop(applet, exec, argv, pid, uid, item->value, test,
+ quiet);
if (nkilled == 0) {
if (tkilled == 0) {
if (progressed)
@@ -364,7 +367,7 @@ int run_stop_schedule(const char *applet,
nloops++)
{
if ((nrunning = do_stop(applet, exec, argv,
- pid, uid, 0, test)) == 0)
+ pid, uid, 0, test, quiet)) == 0)
return 0;
diff --git a/src/rc/rc-schedules.h b/src/rc/rc-schedules.h
index a42ea0e3..234e62df 100644
--- a/src/rc/rc-schedules.h
+++ b/src/rc/rc-schedules.h
@@ -18,7 +18,7 @@ void free_schedulelist(void);
int parse_signal(const char *applet, const char *sig);
void parse_schedule(const char *applet, const char *string, int timeout);
int do_stop(const char *applet, const char *exec, const char *const *argv,
- pid_t pid, uid_t uid,int sig, bool test);
+ pid_t pid, uid_t uid,int sig, bool test, bool quiet);
int run_stop_schedule(const char *applet,
const char *exec, const char *const *argv,
pid_t pid, uid_t uid,
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 46784b26..dab8b3b1 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -684,7 +684,7 @@ int main(int argc, char **argv)
pid = 0;
if (do_stop(applet, exec, (const char * const *)margv, pid, uid,
- 0, test) > 0)
+ 0, test, false) > 0)
eerrorx("%s: %s is already running", applet, exec);
if (test) {
@@ -964,7 +964,7 @@ int main(int argc, char **argv)
} else
pid = 0;
if (do_stop(applet, exec, (const char *const *)margv,
- pid, uid, 0, test) > 0)
+ pid, uid, 0, test, false) > 0)
alive = true;
}
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index a702a25c..7b894e7b 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -440,11 +440,6 @@ int main(int argc, char **argv)
applet = basename_c(argv[0]);
atexit(cleanup);
- signal_setup(SIGINT, handle_signal);
- signal_setup(SIGQUIT, handle_signal);
- signal_setup(SIGTERM, handle_signal);
- openlog(applet, LOG_PID, LOG_DAEMON);
-
if ((tmp = getenv("SSD_NICELEVEL")))
if (sscanf(tmp, "%d", &nicelevel) != 1)
eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)",
@@ -729,6 +724,8 @@ int main(int argc, char **argv)
if (child_pid != 0) {
/* this is the supervisor */
umask(numask);
+ openlog(applet, LOG_PID, LOG_DAEMON);
+ signal_setup(SIGTERM, handle_signal);
fp = fopen(pidfile, "w");
if (! fp)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:07 UTC (permalink / raw
To: gentoo-commits
commit: b1c3422f453921e838d419640fe39144dbf8d13d
Author: Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Sun Sep 17 13:15:13 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Sep 17 16:40:07 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b1c3422f
selinux: use openrc contexts path to get contexts
The minimum requirement for libselinux is now >=2.6
The refpolicy and the gentoo policy contain the
contexts since version 2.20170204-r4
src/rc/rc-selinux.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index 2eb631a6..514ca5e5 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -39,7 +39,6 @@
#include "rc-selinux.h"
/* the context files for selinux */
-#define RUN_INIT_FILE "run_init_type"
#define INITRC_FILE "initrc_context"
#ifdef HAVE_AUDIT
@@ -299,6 +298,26 @@ static int read_context_file(const char *filename, char **context)
return ret;
}
+static int read_run_init_context(char **context)
+{
+ int ret = -1;
+ RC_STRINGLIST *list;
+ char *value = NULL;
+
+ list = rc_config_list(selinux_openrc_contexts_path());
+ if (list == NULL)
+ return ret;
+
+ value = rc_config_value(list, "run_init");
+ if (value != NULL && strlen(value) > 0) {
+ *context = xstrdup(value);
+ ret = 0;
+ }
+
+ rc_stringlist_free(list);
+ return ret;
+}
+
void selinux_setup(char **argv)
{
char *new_context = NULL;
@@ -312,7 +331,7 @@ void selinux_setup(char **argv)
return;
}
- if (read_context_file(RUN_INIT_FILE, &run_init_t) != 0) {
+ if (read_run_init_context(&run_init_t) != 0) {
/* assume a reasonable default, rather than bailing out */
run_init_t = xstrdup("run_init_t");
ewarn("Assuming SELinux run_init type is %s", run_init_t);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:07 UTC (permalink / raw
To: gentoo-commits
commit: 0eb47b9af340dd07209a3920944ed085fe7bd359
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 18 15:36:17 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 18 15:36:17 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0eb47b9a
initialize the stop schedule
src/rc/rc-schedules.c | 6 +-----
src/rc/rc-schedules.h | 1 -
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index 164581d6..9568e51d 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -56,11 +56,6 @@ typedef struct scheduleitem {
static TAILQ_HEAD(, scheduleitem) schedule;
-void initialize_schedulelist(void)
-{
- TAILQ_INIT(&schedule);
-}
-
void free_schedulelist(void)
{
SCHEDULEITEM *s1 = TAILQ_FIRST(&schedule);
@@ -186,6 +181,7 @@ void parse_schedule(const char *applet, const char *string, int timeout)
size_t len;
SCHEDULEITEM *item;
+ TAILQ_INIT(&schedule);
if (string)
for (slash = string; *slash; slash++)
if (*slash == '/')
diff --git a/src/rc/rc-schedules.h b/src/rc/rc-schedules.h
index 234e62df..e5dd64c2 100644
--- a/src/rc/rc-schedules.h
+++ b/src/rc/rc-schedules.h
@@ -13,7 +13,6 @@
#ifndef __RC_SCHEDULES_H
#define __RC_SCHEDULES_H
-void initialize_schedulelist(void);
void free_schedulelist(void);
int parse_signal(const char *applet, const char *sig);
void parse_schedule(const char *applet, const char *string, int timeout);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:07 UTC (permalink / raw
To: gentoo-commits
commit: 4ab60ff10935122277bbaed437f82a765279cd19
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Sep 17 19:20:05 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Sep 17 19:20:05 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4ab60ff1
rc-schedules.c: pass the correct pid to rc_find_pids
This is for #163.
src/rc/rc-schedules.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index 13f615ee..164581d6 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -261,10 +261,10 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
bool killed;
int nkilled = 0;
- if (pid)
+ if (pid > 0)
pids = rc_find_pids(NULL, NULL, 0, pid);
else
- pids = rc_find_pids(exec, argv, uid, pid);
+ pids = rc_find_pids(exec, argv, uid, 0);
if (!pids)
return 0;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:07 UTC (permalink / raw
To: gentoo-commits
commit: db4a578273dbfa15b8b96686391bcc9ecc04b646
Author: Jason Zaman <jason <AT> perfinion <DOT> com>
AuthorDate: Sun Sep 17 15:52:52 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Sep 17 16:41:24 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=db4a5782
selinux: fix const qualifier warning
rc-selinux.c: In function ‘selinux_setup’:
rc-selinux.c:361:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
curr_t = context_type_get(curr_con);
^
src/rc/rc-selinux.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index 514ca5e5..bfaf1556 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -358,14 +358,13 @@ void selinux_setup(char **argv)
goto out;
}
- curr_t = context_type_get(curr_con);
+ curr_t = xstrdup(context_type_get(curr_con));
if (!curr_t) {
context_free(curr_con);
free(curr_context);
goto out;
}
- curr_t = xstrdup(curr_t);
/* dont need them anymore so free() now */
context_free(curr_con);
free(curr_context);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:07 UTC (permalink / raw
To: gentoo-commits
commit: 3cf19b0f30a90157d23d09ded304439f1eb42d4a
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 18 17:25:37 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 18 17:25:37 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3cf19b0f
supervise-daemon: code cleanup
Clean up the process for killing an active supervisor when stopping.
src/rc/supervise-daemon.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 7b894e7b..2800d1a2 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -432,6 +432,7 @@ int main(int argc, char **argv)
int respawn_period = 5;
time_t respawn_now= 0;
time_t first_spawn= 0;
+ struct timespec ts;
struct passwd *pw;
struct group *gr;
FILE *fp;
@@ -658,17 +659,18 @@ int main(int argc, char **argv)
if (stop) {
pid = get_pid(applet, pidfile);
- if (pid == -1)
- i = pid;
- else
+ if (pid != -1) {
i = kill(pid, SIGTERM);
- if (i != 0)
- /* We failed to send the signal */
- exit(EXIT_FAILURE);
-
- /* wait for the supervisor to go down */
- while (kill(pid, 0) == 0)
- sleep(1);
+ if (i != 0)
+ /* We failed to send the signal */
+ exit(EXIT_FAILURE);
+
+ /* wait for the supervisor to go down */
+ while (kill(pid, 0) == 0)
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1;
+ nanosleep(&ts, NULL);
+ }
/* Even if we have not actually killed anything, we should
* remove information about it as it may have unexpectedly
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:07 UTC (permalink / raw
To: gentoo-commits
commit: b28c0d6f66e42b1e6d2a39c286a18c8d92881790
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 18 18:03:34 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 18 18:03:34 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b28c0d6f
typo fix
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 2800d1a2..3d39906e 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -666,7 +666,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
/* wait for the supervisor to go down */
- while (kill(pid, 0) == 0)
+ while (kill(pid, 0) == 0) {
ts.tv_sec = 0;
ts.tv_nsec = 1;
nanosleep(&ts, NULL);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-18 18:31 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-18 18:31 UTC (permalink / raw
To: gentoo-commits
commit: b58194ef63ec8c0a7e0ea3c291da9c19aa83cb1a
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 18 18:30:56 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 18 18:30:56 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b58194ef
typo fix
src/rc/supervise-daemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 3d39906e..09db1912 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -670,6 +670,7 @@ int main(int argc, char **argv)
ts.tv_sec = 0;
ts.tv_nsec = 1;
nanosleep(&ts, NULL);
+ }
}
/* Even if we have not actually killed anything, we should
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-09-22 22:25 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-09-22 22:25 UTC (permalink / raw
To: gentoo-commits
commit: 1cac8b080c16f9aab19c7a3ae1ca155c20dfa14d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 18 21:59:18 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Sep 18 21:59:18 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1cac8b08
ignore sigchld when shutting down the supervised process
We need to do this to skip the zombie state for the child process since
we are not easily able to wait() for it.
src/rc/supervise-daemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 09db1912..a781ad9d 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -753,6 +753,7 @@ int main(int argc, char **argv)
while (!exiting) {
wait(&i);
if (exiting) {
+ signal_setup(SIGCHLD, SIG_IGN);
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
nkilled = run_stop_schedule(applet, exec, NULL, child_pid,
0, false, false, true);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-05 23:31 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-05 23:31 UTC (permalink / raw
To: gentoo-commits
commit: 1e9af2cd421423404ffe1491bd35af76c2885f1f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 5 23:31:07 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 5 23:31:07 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1e9af2cd
fix compiler warning
src/rc/rc-schedules.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index 9568e51d..d60c2822 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -408,11 +408,12 @@ int run_stop_schedule(const char *applet,
if (progressed)
printf("\n");
- if (! quiet)
+ if (! quiet) {
if (nrunning == 1)
eerror("%s: %d process refused to stop", applet, nrunning);
else
eerror("%s: %d process(es) refused to stop", applet, nrunning);
+ }
return -nrunning;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-18 23:09 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-18 23:09 UTC (permalink / raw
To: gentoo-commits
commit: 35b1996704f6635bb29ea3604410e133209e6432
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Oct 18 23:07:50 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Oct 18 23:07:50 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=35b19967
supervise-daemon: elevate some log messages to warnings
Prior to this change, we were logging unexpected terminations of daemons
we were supervising at the info level. This change moves the logs to
warnings.
src/rc/supervise-daemon.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index a781ad9d..f1e8ea16 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -771,17 +771,17 @@ int main(int argc, char **argv)
} else
respawn_count++;
if (respawn_count >= respawn_max) {
- syslog(LOG_INFO, "respawned \"%s\" too many times, "
+ syslog(LOG_WARNING, "respawned \"%s\" too many times, "
"exiting", exec);
exiting = true;
continue;
}
}
if (WIFEXITED(i))
- syslog(LOG_INFO, "%s, pid %d, exited with return code %d",
+ syslog(LOG_WARNING, "%s, pid %d, exited with return code %d",
exec, child_pid, WEXITSTATUS(i));
else if (WIFSIGNALED(i))
- syslog(LOG_INFO, "%s, pid %d, terminated by signal %d",
+ syslog(LOG_WARNING, "%s, pid %d, terminated by signal %d",
exec, child_pid, WTERMSIG(i));
child_pid = fork();
if (child_pid == -1)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-25 20:10 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-25 20:10 UTC (permalink / raw
To: gentoo-commits
commit: 3219ecd6085231d7cc1268323a5be6a69f8c9143
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Oct 24 21:47:53 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 24 21:47:53 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3219ecd6
supervise-daemon: fix build issue for >=glibc-2.26
X-Gentoo-Bug: 635334
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=635334
src/rc/supervise-daemon.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index df59eb67..998a01bc 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -447,7 +447,9 @@ static void supervisor(char *exec, char **argv)
#endif
signal_setup_restart(SIGIO, handle_signal);
signal_setup_restart(SIGPWR, handle_signal);
+#ifdef SIGUNUSED
signal_setup_restart(SIGUNUSED, handle_signal);
+#endif
#ifdef SIGRTMIN
for (i = SIGRTMIN; i <= SIGRTMAX; i++)
signal_setup_restart(i, handle_signal);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-26 18:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-26 18:58 UTC (permalink / raw
To: gentoo-commits
commit: 667a09983ca5311824aa88c42d39a495c540fc4c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 26 17:58:59 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 17:58:59 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=667a0998
supervise-daemon: remove child_pid from saved options during shutdown
This allows us to detect when the supervisor dies unexpectedly because
in that case child_pid will still exist.
src/rc/supervise-daemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 998a01bc..b232e215 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -523,6 +523,7 @@ static void supervisor(char *exec, char **argv)
rc_service_daemon_set(svcname, exec, (const char *const *)argv,
pidfile, false);
rc_service_mark(svcname, RC_SERVICE_STOPPED);
+ rc_service_value_set(svcname, "child_pid", NULL);
}
exit(EXIT_SUCCESS);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-26 18:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-26 18:58 UTC (permalink / raw
To: gentoo-commits
commit: d019f34a83b0ad5e890f685b1263b281ab54ce54
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 26 18:57:04 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 18:57:04 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=d019f34a
supervise-daemon: log the command line we run to spawn the child process
src/rc/supervise-daemon.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 6c3c55bf..abb4a59e 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -556,6 +556,7 @@ int main(int argc, char **argv)
int child_argc = 0;
char **child_argv = NULL;
char *str = NULL;
+ char cmdline[PATH_MAX];
applet = basename_c(argv[0]);
atexit(cleanup);
@@ -721,6 +722,13 @@ int main(int argc, char **argv)
if (!pidfile && !reexec)
eerrorx("%s: --pidfile must be specified", applet);
+ *cmdline = '\0';
+ c = argv;
+ while (c && *c) {
+ strcat(cmdline, *c);
+ strcat(cmdline, " ");
+ c++;
+ }
endpwent();
argc -= optind;
argv += optind;
@@ -818,6 +826,7 @@ int main(int argc, char **argv)
parse_schedule(applet, NULL, sig);
einfov("Detaching to start `%s'", exec);
+ syslog(LOG_INFO, "Running command line: %s", cmdline);
/* Remove existing pidfile */
if (pidfile)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-26 18:58 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-26 18:58 UTC (permalink / raw
To: gentoo-commits
commit: bb9c481f02cb1843e00bf32e98caf18b6b56bb4d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 26 18:36:41 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 18:36:41 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=bb9c481f
supervise-daemon: log with the service name instead of "supervise-daemon"
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 b232e215..6c3c55bf 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -420,7 +420,6 @@ static void supervisor(char *exec, char **argv)
time_t respawn_now= 0;
time_t first_spawn= 0;
- openlog(applet, LOG_PID, LOG_DAEMON);
#ifndef RC_DEBUG
signal_setup_restart(SIGHUP, handle_signal);
signal_setup_restart(SIGINT, handle_signal);
@@ -561,6 +560,7 @@ int main(int argc, char **argv)
applet = basename_c(argv[0]);
atexit(cleanup);
svcname = getenv("RC_SVCNAME");
+ openlog(svcname, LOG_PID, LOG_DAEMON);
if ((tmp = getenv("SSD_NICELEVEL")))
if (sscanf(tmp, "%d", &nicelevel) != 1)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-10-26 22:01 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-10-26 22:01 UTC (permalink / raw
To: gentoo-commits
commit: f32d8e1bfe16caf233d1180921f4aeed77d7476d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 26 19:15:40 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 22:01:17 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f32d8e1b
supervise-daemon: clarify a log message
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 abb4a59e..3c3d7c7e 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -826,7 +826,7 @@ int main(int argc, char **argv)
parse_schedule(applet, NULL, sig);
einfov("Detaching to start `%s'", exec);
- syslog(LOG_INFO, "Running command line: %s", cmdline);
+ syslog(LOG_INFO, "Supervisor command line: %s", cmdline);
/* Remove existing pidfile */
if (pidfile)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-07 21:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-07 21:33 UTC (permalink / raw
To: gentoo-commits
commit: a3d1c8a0e7d5586be13e2cd9b5029fd729bc1594
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Oct 30 23:21:39 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 30 23:21:39 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a3d1c8a0
fix issue with --reexec call
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 3989cbc7..f3f51ff0 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -162,7 +162,8 @@ static void cleanup(void)
static void re_exec(void)
{
syslog(LOG_WARNING, "Re-executing for %s", svcname);
- execlp("supervise-daemon", "supervise-daemon", "--reexec", (char *) NULL);
+ execlp("supervise-daemon", "supervise-daemon", svcname, "--reexec",
+ (char *) NULL);
syslog(LOG_ERR, "Unable to execute supervise-daemon: %s",
strerror(errno));
exit(EXIT_FAILURE);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-07 21:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-07 21:33 UTC (permalink / raw
To: gentoo-commits
commit: 27b8183de2f2bfd7411c14c1ec28543ca8a36602
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Oct 27 20:32:26 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Oct 27 20:33:47 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=27b8183d
log as supervise-daemon not the service
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 3c3d7c7e..bf27ad18 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -561,7 +561,7 @@ int main(int argc, char **argv)
applet = basename_c(argv[0]);
atexit(cleanup);
svcname = getenv("RC_SVCNAME");
- openlog(svcname, LOG_PID, LOG_DAEMON);
+ openlog(applet, LOG_PID, LOG_DAEMON);
if ((tmp = getenv("SSD_NICELEVEL")))
if (sscanf(tmp, "%d", &nicelevel) != 1)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-07 21:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-07 21:33 UTC (permalink / raw
To: gentoo-commits
commit: 90d9ea656ff7c6b5d618df4e4261ebfa4033f1a8
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Nov 7 21:30:21 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Nov 7 21:30:34 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=90d9ea65
start-stop-daemon: do not use do_stop to verify whether a daemon is running
X-Gentoo-Bug: 636574
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=636574
src/rc/start-stop-daemon.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index dab8b3b1..e98f8ba3 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -279,6 +279,7 @@ int main(int argc, char **argv)
int stdout_fd;
int stderr_fd;
pid_t pid, spid;
+ RC_PIDLIST *pids;
int i;
char *svcname = getenv("RC_SVCNAME");
RC_STRINGLIST *env_list;
@@ -683,10 +684,14 @@ int main(int argc, char **argv)
else
pid = 0;
- if (do_stop(applet, exec, (const char * const *)margv, pid, uid,
- 0, test, false) > 0)
+ if (pid)
+ pids = rc_find_pids(NULL, NULL, 0, pid);
+ else
+ pids = rc_find_pids(exec, (const char * const *) argv, uid, 0);
+ if (pids)
eerrorx("%s: %s is already running", applet, exec);
+ free(pids);
if (test) {
if (rc_yesno(getenv("EINFO_QUIET")))
exit (EXIT_SUCCESS);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-07 21:33 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-07 21:33 UTC (permalink / raw
To: gentoo-commits
commit: 3fe99c8b8264269dd935d52a1a52581cc0f14e8e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Oct 27 22:34:29 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Oct 27 22:34:29 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3fe99c8b
supervise-daemon: fix logging for reexec and the child command line
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 bf27ad18..1d0c3407 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -161,7 +161,7 @@ static void cleanup(void)
static void re_exec(void)
{
- syslog(LOG_WARNING, "Re-executing supervise-daemon");
+ syslog(LOG_WARNING, "Re-executing for %s", svcname);
execlp("supervise-daemon", "supervise-daemon", "--reexec", (char *) NULL);
syslog(LOG_ERR, "Unable to execute supervise-daemon: %s",
strerror(errno));
@@ -402,7 +402,7 @@ static void child_process(char *exec, char **argv)
strcat(cmdline, " ");
c++;
}
- syslog(LOG_INFO, "Running command line: %s", cmdline);
+ syslog(LOG_INFO, "Child command line: %s", cmdline);
execvp(exec, argv);
#ifdef HAVE_PAM
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-28 23:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-28 23:17 UTC (permalink / raw
To: gentoo-commits
commit: 6bb7ebec483a96e258c64ea3fea18358d7893fee
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Nov 27 17:09:43 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Nov 27 17:10:00 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6bb7ebec
fix FreeBSD build
This is for #186.
src/rc/supervise-daemon.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index f3f51ff0..06d0bdb3 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -159,7 +159,7 @@ static void cleanup(void)
free(changeuser);
}
-static void re_exec(void)
+static void re_exec_supervisor(void)
{
syslog(LOG_WARNING, "Re-executing for %s", svcname);
execlp("supervise-daemon", "supervise-daemon", svcname, "--reexec",
@@ -180,7 +180,7 @@ static void handle_signal(int sig)
/* Restore errno */
errno = serrno;
if (! exiting)
- re_exec();
+ re_exec_supervisor();
}
static char * expand_home(const char *home, const char *path)
@@ -435,7 +435,9 @@ static void supervisor(char *exec, char **argv)
signal_setup_restart(SIGUSR1, handle_signal);
signal_setup_restart(SIGUSR2, handle_signal);
signal_setup_restart(SIGBUS, handle_signal);
+#ifdef SIGPOLL
signal_setup_restart(SIGPOLL, handle_signal);
+#endif
signal_setup_restart(SIGPROF, handle_signal);
signal_setup_restart(SIGSYS, handle_signal);
signal_setup_restart(SIGTRAP, handle_signal);
@@ -446,7 +448,9 @@ static void supervisor(char *exec, char **argv)
signal_setup_restart(SIGEMT, handle_signal);
#endif
signal_setup_restart(SIGIO, handle_signal);
+#ifdef SIGPWR
signal_setup_restart(SIGPWR, handle_signal);
+#endif
#ifdef SIGUNUSED
signal_setup_restart(SIGUNUSED, handle_signal);
#endif
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-28 23:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-28 23:17 UTC (permalink / raw
To: gentoo-commits
commit: a192caf88f527e09508e32baa623ef85549612ae
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Sun Nov 19 16:05:30 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Nov 19 16:05:30 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a192caf8
rc-schedules: if given nothing to look for, stop
This avoids trying to kill everything.
X-Gentoo-Bug: 631958
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=631958
src/rc/rc-schedules.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/rc/rc-schedules.c b/src/rc/rc-schedules.c
index d60c2822..8f36f073 100644
--- a/src/rc/rc-schedules.c
+++ b/src/rc/rc-schedules.c
@@ -307,6 +307,9 @@ int run_stop_schedule(const char *applet,
const char *const *p;
bool progressed = false;
+ if (!(pid > 0 || exec || uid || (argv && *argv)))
+ return 0;
+
if (exec)
einfov("Will stop %s", exec);
if (pid > 0)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2017-11-29 21:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2017-11-29 21:12 UTC (permalink / raw
To: gentoo-commits
commit: c84ebb94d19ca856fe064e15d2068d5671e360c9
Author: Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Wed Nov 29 20:10:39 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Nov 29 20:10:39 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c84ebb94
start-stop-daemon: properly handle missing pidfile
X-Gentoo-Bug: 639218
X-Gentoo-Bug-URL: https://bugs.gentoo.org/639218
src/rc/start-stop-daemon.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index e98f8ba3..54b89b2a 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -657,8 +657,15 @@ int main(int argc, char **argv)
parse_schedule(applet, "0", sig);
else
parse_schedule(applet, NULL, sig);
+ if (pidfile) {
+ pid = get_pid(applet, pidfile);
+ if (pid == -1)
+ exit(EXIT_FAILURE);
+ } else {
+ pid = 0;
+ }
i = run_stop_schedule(applet, exec, (const char *const *)margv,
- get_pid(applet, pidfile), uid, test, progress, false);
+ pid, uid, test, progress, false);
if (i < 0)
/* We failed to stop something */
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-01-09 23:35 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-01-09 23:35 UTC (permalink / raw
To: gentoo-commits
commit: 918d955fd2de1f594b83508f5ddd5271534e3591
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jan 9 23:20:39 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 9 23:25:28 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=918d955f
checkpath: use lchown instead of chown
Checkpath should never follow symbolic links when changing ownership of a file.
This is for https://github.com/openrc/openrc/issues/195.
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index b1509940..8846761b 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -168,7 +168,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
return -1;
}
einfo("%s: correcting owner", path);
- if (chown(path, uid, gid)) {
+ if (lchown(path, uid, gid)) {
eerror("%s: chown: %s", applet, strerror(errno));
return -1;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-01-16 19:14 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-01-16 19:14 UTC (permalink / raw
To: gentoo-commits
commit: 4af5a80b0c516773286cc30e743dc90a2d19df23
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jan 16 19:11:22 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 16 19:11:22 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4af5a80b
_rc_deptree_load - return NULL if the stat() call is not successful
X-Gentoo-Bug: 643084
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=643084
src/rc/rc-misc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index 33a17b35..21c06fc5 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -380,7 +380,10 @@ RC_DEPTREE * _rc_deptree_load(int force, int *regen)
eend (retval, "Failed to update the dependency tree");
if (retval == 0) {
- stat(RC_DEPTREE_CACHE, &st);
+ if (stat(RC_DEPTREE_CACHE, &st) != 0) {
+ eerror("stat(%s): %s", RC_DEPTREE_CACHE, strerror(errno));
+ return NULL;
+ }
if (st.st_mtime < t) {
eerror("Clock skew detected with `%s'", file);
eerrorn("Adjusting mtime of `" RC_DEPTREE_CACHE
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-01-16 19:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-01-16 19:36 UTC (permalink / raw
To: gentoo-commits
commit: 87c98ebb01873120eecc1757e615b3a4c14a2f1f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jan 16 19:34:37 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 16 19:34:37 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=87c98ebb
checkpath: fix lchown error message
X-Gentoo-Bug: 643084
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=643084
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 8846761b..39e7ce4d 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -169,7 +169,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
}
einfo("%s: correcting owner", path);
if (lchown(path, uid, gid)) {
- eerror("%s: chown: %s", applet, strerror(errno));
+ eerror("%s: lchown: %s", applet, strerror(errno));
return -1;
}
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-01-23 23:08 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-01-23 23:08 UTC (permalink / raw
To: gentoo-commits
commit: 1771bc2a83fe65bfe6ec3e93ea7632609e697a38
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jan 23 22:56:06 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 23 22:56:06 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1771bc2a
checkpath: use fchown and fchmod to handle ownership and mode changes
This is related to #195.
This is an attempt to shorten the window for the first two issues
discussed by using a file descriptor which does not follow symbolic
links and using the fchmod and fchown calls instead of chown and chmod.
with.
src/rc/checkpath.c | 124 ++++++++++++++++++++++++++++++++++-------------------
1 file changed, 79 insertions(+), 45 deletions(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 39e7ce4d..2e2b4ee3 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -73,25 +73,32 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
inode_t type, bool trunc, bool chowner, bool selinux_on)
{
struct stat st;
- int fd, flags;
+ int fd;
+ int flags;
int r;
+ int readfd;
+ int readflags;
int u;
memset(&st, 0, sizeof(st));
- if (lstat(path, &st) || trunc) {
- if (type == inode_file) {
- einfo("%s: creating file", path);
- if (!mode) /* 664 */
- mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
- flags = O_CREAT|O_NDELAY|O_WRONLY|O_NOCTTY;
+ flags = O_CREAT|O_NDELAY|O_WRONLY|O_NOCTTY;
+ readflags = O_NDELAY|O_NOCTTY|O_RDONLY;
#ifdef O_CLOEXEC
- flags |= O_CLOEXEC;
+ flags |= O_CLOEXEC;
+ readflags |= O_CLOEXEC;
#endif
#ifdef O_NOFOLLOW
- flags |= O_NOFOLLOW;
+ flags |= O_NOFOLLOW;
+ readflags |= O_NOFOLLOW;
#endif
- if (trunc)
- flags |= O_TRUNC;
+ if (trunc)
+ flags |= O_TRUNC;
+ readfd = open(path, readflags);
+ if (readfd == -1 || (type == inode_file && trunc)) {
+ if (type == inode_file) {
+ einfo("%s: creating file", path);
+ if (!mode) /* 664 */
+ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
u = umask(0);
fd = open(path, flags, mode);
umask(u);
@@ -99,7 +106,9 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
eerror("%s: open: %s", applet, strerror(errno));
return -1;
}
- close (fd);
+ if (readfd != -1 && trunc)
+ close(readfd);
+ readfd = fd;
} else if (type == inode_dir) {
einfo("%s: creating directory", path);
if (!mode) /* 775 */
@@ -113,7 +122,12 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
strerror (errno));
return -1;
}
- mode = 0;
+ readfd = open(path, readflags);
+ if (readfd == -1) {
+ eerror("%s: unable to open directory: %s", applet,
+ strerror(errno));
+ return -1;
+ }
} else if (type == inode_fifo) {
einfo("%s: creating fifo", path);
if (!mode) /* 600 */
@@ -126,56 +140,76 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
strerror (errno));
return -1;
}
+ readfd = open(path, readflags);
+ if (readfd == -1) {
+ eerror("%s: unable to open fifo: %s", applet,
+ strerror(errno));
+ return -1;
+ }
}
- } else {
+ }
+ if (fstat(readfd, &st) != -1) {
if (type != inode_dir && S_ISDIR(st.st_mode)) {
eerror("%s: is a directory", path);
+ close(readfd);
return 1;
}
if (type != inode_file && S_ISREG(st.st_mode)) {
eerror("%s: is a file", path);
+ close(readfd);
return 1;
}
if (type != inode_fifo && S_ISFIFO(st.st_mode)) {
eerror("%s: is a fifo", path);
+ close(readfd);
return -1;
}
- }
- if (mode && (st.st_mode & 0777) != mode) {
- if ((type != inode_dir) && (st.st_nlink > 1)) {
- eerror("%s: chmod: %s %s", applet, "Too many hard links to", path);
- return -1;
- }
- if (S_ISLNK(st.st_mode)) {
- eerror("%s: chmod: %s %s", applet, path, " is a symbolic link");
- return -1;
- }
- einfo("%s: correcting mode", path);
- if (chmod(path, mode)) {
- eerror("%s: chmod: %s", applet, strerror(errno));
- return -1;
+ if (mode && (st.st_mode & 0777) != mode) {
+ if ((type != inode_dir) && (st.st_nlink > 1)) {
+ eerror("%s: chmod: %s %s", applet, "Too many hard links to", path);
+ close(readfd);
+ return -1;
+ }
+ if (S_ISLNK(st.st_mode)) {
+ eerror("%s: chmod: %s %s", applet, path, " is a symbolic link");
+ close(readfd);
+ return -1;
+ }
+ einfo("%s: correcting mode", path);
+ if (fchmod(readfd, mode)) {
+ eerror("%s: chmod: %s", applet, strerror(errno));
+ close(readfd);
+ return -1;
+ }
}
- }
- if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
- if ((type != inode_dir) && (st.st_nlink > 1)) {
- eerror("%s: chown: %s %s", applet, "Too many hard links to", path);
- return -1;
- }
- if (S_ISLNK(st.st_mode)) {
- eerror("%s: chown: %s %s", applet, path, " is a symbolic link");
- return -1;
- }
- einfo("%s: correcting owner", path);
- if (lchown(path, uid, gid)) {
- eerror("%s: lchown: %s", applet, strerror(errno));
- return -1;
+ if (chowner && (st.st_uid != uid || st.st_gid != gid)) {
+ if ((type != inode_dir) && (st.st_nlink > 1)) {
+ eerror("%s: chown: %s %s", applet, "Too many hard links to", path);
+ close(readfd);
+ return -1;
+ }
+ if (S_ISLNK(st.st_mode)) {
+ eerror("%s: chown: %s %s", applet, path, " is a symbolic link");
+ close(readfd);
+ return -1;
+ }
+ einfo("%s: correcting owner", path);
+ if (fchown(readfd, uid, gid)) {
+ eerror("%s: chown: %s", applet, strerror(errno));
+ close(readfd);
+ return -1;
+ }
}
+ if (selinux_on)
+ selinux_util_label(path);
+ } else {
+ eerror(fstat: %s: %s", path, strerror(errno));
+ close(readfd);
+ return -1;
}
-
- if (selinux_on)
- selinux_util_label(path);
+ close(readfd);
return 0;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-01-24 23:44 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-01-24 23:44 UTC (permalink / raw
To: gentoo-commits
commit: 5dd1d39d20c118064d31ed65dc7ae2de75dd7908
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jan 24 16:56:33 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jan 24 16:56:33 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5dd1d39d
typo fix
src/rc/checkpath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 2e2b4ee3..07e5f78a 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -205,7 +205,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
if (selinux_on)
selinux_util_label(path);
} else {
- eerror(fstat: %s: %s", path, strerror(errno));
+ eerror("fstat: %s: %s", path, strerror(errno));
close(readfd);
return -1;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-14 23:37 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-14 23:37 UTC (permalink / raw
To: gentoo-commits
commit: 7b4879cb72e907414b70553663bd9b6fda8d4408
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Feb 14 22:56:19 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Feb 14 22:56:19 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7b4879cb
mountinfo: create strings with xasprintf
src/rc/mountinfo.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index d9c25a38..5bf97386 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -248,7 +248,6 @@ find_mounts(struct args *args)
struct opt *o;
int netdev;
char *tmp;
- size_t l;
if ((nmnts = getmntinfo(&mnts, MNT_NOWAIT)) == 0)
eerrorx("getmntinfo: %s", strerror (errno));
@@ -264,11 +263,7 @@ find_mounts(struct args *args)
if (! options)
options = xstrdup(o->o_name);
else {
- l = strlen(options) +
- strlen(o->o_name) + 2;
- tmp = xmalloc(sizeof (char) * l);
- snprintf(tmp, l, "%s,%s", options,
- o->o_name);
+ xasprintf(&tmp, "%s,%s", options, o->o_name);
free(options);
options = tmp;
}
@@ -315,6 +310,7 @@ find_mounts(struct args *args)
{
FILE *fp;
char *buffer;
+ size_t size;
char *p;
char *from;
char *to;
@@ -329,8 +325,8 @@ find_mounts(struct args *args)
list = rc_stringlist_new();
- buffer = xmalloc(sizeof(char) * PATH_MAX * 3);
- while (fgets(buffer, PATH_MAX * 3, fp)) {
+ buffer = NULL;
+ while (getline(&buffer, &size, fp) != -1) {
netdev = -1;
p = buffer;
from = strsep(&p, " ");
@@ -346,6 +342,8 @@ find_mounts(struct args *args)
}
process_mount(list, args, from, to, fst, opts, netdev);
+ free(buffer);
+ buffer = NULL;
}
free(buffer);
fclose(fp);
@@ -380,7 +378,7 @@ int main(int argc, char **argv)
regex_t *skip_point_regex = NULL;
RC_STRINGLIST *nodes;
RC_STRING *s;
- char real_path[PATH_MAX + 1];
+ char *real_path = NULL;
int opt;
int result;
char *this_path;
@@ -450,9 +448,12 @@ int main(int argc, char **argv)
eerrorx("%s: `%s' is not a mount point",
argv[0], argv[optind]);
this_path = argv[optind++];
- if (realpath(this_path, real_path))
+ real_path = realpath(this_path, NULL);
+ if (real_path)
this_path = real_path;
rc_stringlist_add(args.mounts, this_path);
+ free(real_path);
+ real_path = NULL;
}
nodes = find_mounts(&args);
rc_stringlist_free(args.mounts);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-14 23:37 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-14 23:37 UTC (permalink / raw
To: gentoo-commits
commit: 74cfb455c59298f86849541e724ae346ff205c3d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Feb 14 22:50:24 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Feb 14 22:50:24 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=74cfb455
kill_all: create strings with xasprintf
src/rc/kill_all.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/rc/kill_all.c b/src/rc/kill_all.c
index f3500227..d6ce354b 100644
--- a/src/rc/kill_all.c
+++ b/src/rc/kill_all.c
@@ -87,10 +87,11 @@ static int mount_proc(void)
static bool is_user_process(pid_t pid)
{
- char buf[PATH_MAX+1];
+ char *buf = NULL;
FILE *fp;
- char path[PATH_MAX+1];
+ char *path = NULL;
pid_t temp_pid;
+ size_t size;
bool user_process = true;
while (pid >0 && user_process) {
@@ -98,8 +99,9 @@ static bool is_user_process(pid_t pid)
user_process = false;
continue;
}
- snprintf(path, sizeof(path), "/proc/%d/status", pid);
+ xasprintf(&path, "/proc/%d/status", pid);
fp = fopen(path, "r");
+ free(path);
/*
* if we could not open the file, the process disappeared, which
* leaves us no way to determine for sure whether it was a user
@@ -112,11 +114,14 @@ static bool is_user_process(pid_t pid)
}
temp_pid = -1;
while (! feof(fp)) {
- buf[0] = 0;
- if (fgets(buf, sizeof(buf), fp))
+ buf = NULL;
+ if (getline(&buf, &size, fp) != -1) {
sscanf(buf, "PPid: %d", &temp_pid);
- else
+ free(buf);
+ } else {
+ free(buf);
break;
+ }
}
fclose(fp);
if (temp_pid == -1) {
@@ -135,7 +140,7 @@ static int signal_processes(int sig, RC_STRINGLIST *omits, bool dryrun)
sigset_t oldsigs;
DIR *dir;
struct dirent *d;
- char buf[PATH_MAX+1];
+ char *buf = NULL;
pid_t pid;
int sendcount = 0;
@@ -170,7 +175,11 @@ static int signal_processes(int sig, RC_STRINGLIST *omits, bool dryrun)
continue;
/* Is this a process we have been requested to omit? */
- sprintf(buf, "%d", pid);
+ if (buf) {
+ free(buf);
+ buf = NULL;
+ }
+ xasprintf(&buf, "%d", pid);
if (rc_stringlist_find(omits, buf))
continue;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-16 20:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-16 20:07 UTC (permalink / raw
To: gentoo-commits
commit: 9e14b35da8942bd8fa552363617c3415887f485f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 15 18:23:39 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 15 18:23:39 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=9e14b35d
rc-update: remove reference to PATH_MAX
src/rc/rc-update.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 9bc1fe5b..abe40b88 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -166,7 +166,7 @@ show(RC_STRINGLIST *runlevels, bool verbose)
RC_STRING *runlevel;
RC_STRINGLIST *in;
bool inone;
- char buffer[PATH_MAX];
+ char *buffer = NULL;
size_t l;
rc_stringlist_sort(&services);
@@ -182,9 +182,11 @@ show(RC_STRINGLIST *runlevels, bool verbose)
inone = true;
} else {
l = strlen(runlevel->value);
+ buffer = xmalloc(l+1);
memset (buffer, ' ', l);
buffer[l] = 0;
rc_stringlist_add (in, buffer);
+ free(buffer);
}
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-16 20:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-16 20:07 UTC (permalink / raw
To: gentoo-commits
commit: 488d8989c518d9256f183899aac02024c679b93e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 15 21:10:24 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 15 21:26:40 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=488d8989
openrc-run: clean up string handling
- remove references to PATH_MAX
- use xasprintf to create strings
src/rc/openrc-run.c | 61 ++++++++++++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 24 deletions(-)
diff --git a/src/rc/openrc-run.c b/src/rc/openrc-run.c
index bb79f42f..7e8d2e50 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -109,7 +109,7 @@ static void
handle_signal(int sig)
{
int serrno = errno;
- char signame[10] = { '\0' };
+ char *signame = NULL;
struct winsize ws;
switch (sig) {
@@ -134,20 +134,22 @@ 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");
/* Send the signal to our children too */
if (service_pid > 0)
kill(service_pid, sig);
- eerrorx("%s: caught %s, aborting", applet, signame);
+ eerror("%s: caught %s, aborting", applet, signame);
+ free(signame);
+ exit(EXIT_FAILURE);
/* NOTREACHED */
default:
@@ -161,11 +163,12 @@ handle_signal(int sig)
static void
unhotplug()
{
- char file[PATH_MAX];
+ char *file = NULL;
- snprintf(file, sizeof(file), RC_SVCDIR "/hotplugged/%s", applet);
+ xasprintf(&file, RC_SVCDIR "/hotplugged/%s", applet);
if (exists(file) && unlink(file) != 0)
eerror("%s: unlink `%s': %s", applet, file, strerror(errno));
+ free(file);
}
static void
@@ -485,7 +488,7 @@ svc_exec(const char *arg1, const char *arg2)
static bool
svc_wait(const char *svc)
{
- char file[PATH_MAX];
+ char *file = NULL;
int fd;
bool forever = false;
RC_STRINGLIST *keywords;
@@ -498,8 +501,7 @@ svc_wait(const char *svc)
forever = true;
rc_stringlist_free(keywords);
- snprintf(file, sizeof(file), RC_SVCDIR "/exclusive/%s",
- basename_c(svc));
+ xasprintf(&file, RC_SVCDIR "/exclusive/%s", basename_c(svc));
interval.tv_sec = 0;
interval.tv_nsec = WAIT_INTERVAL;
@@ -512,23 +514,29 @@ svc_wait(const char *svc)
if (fd != -1) {
if (flock(fd, LOCK_SH | LOCK_NB) == 0) {
close(fd);
+ free(file);
return true;
}
close(fd);
}
- if (errno == ENOENT)
+ if (errno == ENOENT) {
+ free(file);
return true;
- if (errno != EWOULDBLOCK)
- eerrorx("%s: open `%s': %s", applet, file,
+ }
+ if (errno != EWOULDBLOCK) {
+ eerror("%s: open `%s': %s", applet, file,
strerror(errno));
+ free(file);
+ exit(EXIT_FAILURE);
+ }
if (nanosleep(&interval, NULL) == -1) {
if (errno != EINTR)
- return false;
+ goto finish;
}
if (!forever) {
timespecsub(&timeout, &interval, &timeout);
if (timeout.tv_sec <= 0)
- return false;
+ goto finish;
timespecsub(&warn, &interval, &warn);
if (warn.tv_sec <= 0) {
ewarn("%s: waiting for %s (%d seconds)",
@@ -538,6 +546,8 @@ svc_wait(const char *svc)
}
}
}
+finish:
+ free(file);
return false;
}
@@ -1105,9 +1115,10 @@ int main(int argc, char **argv)
bool runscript = false;
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
- char path[PATH_MAX], lnk[PATH_MAX];
+ char *path = NULL;
+ char *lnk = NULL;
char *dir, *save = NULL, *saveLnk = NULL;
- char pidstr[10];
+ char *pidstr = NULL;
size_t l = 0, ll;
const char *file;
struct stat stbuf;
@@ -1134,10 +1145,12 @@ int main(int argc, char **argv)
* This works fine, provided that we ONLY allow multiplexed services
* to exist in the same directory as the master link.
* Also, the master link as to be a real file in the init dir. */
- if (!realpath(argv[1], path)) {
+ path = realpath(argv[1], NULL);
+ if (!path) {
fprintf(stderr, "realpath: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
+ lnk = xmalloc(4096);
memset(lnk, 0, sizeof(lnk));
if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
dir = dirname(path);
@@ -1153,8 +1166,7 @@ int main(int argc, char **argv)
} else
file = basename_c(argv[1]);
ll = strlen(dir) + strlen(file) + 2;
- service = xmalloc(ll);
- snprintf(service, ll, "%s/%s", dir, file);
+ xasprintf(&service, "%s/%s", dir, file);
if (stat(service, &stbuf) != 0) {
free(service);
service = xstrdup(lnk);
@@ -1162,6 +1174,7 @@ int main(int argc, char **argv)
free(save);
free(saveLnk);
}
+ free(lnk);
if (!service)
service = xstrdup(path);
applet = basename_c(service);
@@ -1185,7 +1198,7 @@ int main(int argc, char **argv)
/* Set an env var so that we always know our pid regardless of any
subshells the init script may create so that our mark_service_*
functions can always instruct us of this change */
- snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid());
+ xasprintf(&pidstr, "%d", (int) getpid());
setenv("RC_OPENRC_PID", pidstr, 1);
/*
* RC_RUNSCRIPT_PID is deprecated, but we will keep it for a while
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-16 20:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-16 20:07 UTC (permalink / raw
To: gentoo-commits
commit: 8dbdabcc5e0df8ac36722a4ba7bfe30664cc9919
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Feb 16 20:04:40 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 16 20:04:40 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=8dbdabcc
start-stop-daemon: clean up string handling
src/rc/start-stop-daemon.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 54b89b2a..88b1e091 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -254,6 +254,7 @@ int main(int argc, char **argv)
#endif
int opt;
+ size_t size = 0;
bool start = false;
bool stop = false;
bool oknodo = false;
@@ -287,10 +288,10 @@ int main(int argc, char **argv)
char *tmp, *newpath, *np;
char *p;
char *token;
- char exec_file[PATH_MAX];
+ char *exec_file = NULL;
struct passwd *pw;
struct group *gr;
- char line[130];
+ char *line = NULL;
FILE *fp;
size_t len;
mode_t numask = 022;
@@ -577,26 +578,22 @@ int main(int argc, char **argv)
if (*exec == '/' || *exec == '.') {
/* Full or relative path */
if (ch_root)
- snprintf(exec_file, sizeof(exec_file),
- "%s/%s", ch_root, exec);
+ xasprintf(&exec_file, "%s/%s", ch_root, exec);
else
- snprintf(exec_file, sizeof(exec_file),
- "%s", exec);
+ xasprintf(&exec_file, "%s", exec);
} else {
/* Something in $PATH */
p = tmp = xstrdup(getenv("PATH"));
- *exec_file = '\0';
+ exec_file = NULL;
while ((token = strsep(&p, ":"))) {
if (ch_root)
- snprintf(exec_file, sizeof(exec_file),
- "%s/%s/%s",
- ch_root, token, exec);
+ xasprintf(&exec_file, "%s/%s/%s", ch_root, token, exec);
else
- snprintf(exec_file, sizeof(exec_file),
- "%s/%s", token, exec);
- if (exists(exec_file))
+ xasprintf(&exec_file, "%s/%s", token, exec);
+ if (exec_file && exists(exec_file))
break;
- *exec_file = '\0';
+ free(exec_file);
+ exec_file = NULL;
}
free(tmp);
}
@@ -604,6 +601,7 @@ int main(int argc, char **argv)
if (start && !exists(exec_file)) {
eerror("%s: %s does not exist", applet,
*exec_file ? exec_file : exec);
+ free(exec_file);
exit(EXIT_FAILURE);
}
@@ -617,7 +615,9 @@ int main(int argc, char **argv)
if (interpreted && !pidfile) {
fp = fopen(exec_file, "r");
if (fp) {
- p = fgets(line, sizeof(line), fp);
+ line = NULL;
+ getline(&line, &size, fp);
+ p = line;
fclose(fp);
if (p != NULL && line[0] == '#' && line[1] == '!') {
p = line + 2;
@@ -629,7 +629,8 @@ int main(int argc, char **argv)
if (p[len] == '\n')
p[len] = '\0';
token = strsep(&p, " ");
- strncpy(exec_file, token, sizeof(exec_file));
+ free(exec_file);
+ xasprintf(&exec_file, "%s", token);
opt = 0;
for (nav = argv; *nav; nav++)
opt++;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-20 22:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-20 22:36 UTC (permalink / raw
To: gentoo-commits
commit: 3c031ca9780c555817fe9ccb8b23ceb231129724
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Feb 20 22:01:15 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 20 22:01:15 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3c031ca9
rc-plubin.c: remove references to PATH_MAX
src/rc/rc-plugin.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c
index e4650b1d..31ccd341 100644
--- a/src/rc/rc-plugin.c
+++ b/src/rc/rc-plugin.c
@@ -68,7 +68,7 @@ rc_plugin_load(void)
DIR *dp;
struct dirent *d;
PLUGIN *plugin;
- char file[PATH_MAX];
+ char *file = NULL;
void *h;
int (*fptr)(RC_HOOK, const char *);
@@ -85,8 +85,9 @@ rc_plugin_load(void)
if (d->d_name[0] == '.')
continue;
- snprintf(file, sizeof(file), RC_PLUGINDIR "/%s", d->d_name);
+ xasprintf(&file, RC_PLUGINDIR "/%s", d->d_name);
h = dlopen(file, RTLD_LAZY);
+ free(file);
if (h == NULL) {
eerror("dlopen: %s", dlerror());
continue;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-20 22:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-20 22:36 UTC (permalink / raw
To: gentoo-commits
commit: 8e02406d8fbf92167c30431987d5de8de72cd7df
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Feb 20 20:22:29 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 20 20:22:29 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=8e02406d
rc-misc.c: remove references to PATH_MAX
src/rc/rc-misc.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
index 21c06fc5..2c9903c3 100644
--- a/src/rc/rc-misc.c
+++ b/src/rc/rc-misc.c
@@ -131,7 +131,8 @@ env_config(void)
char *npp;
char *tok;
const char *sys = rc_sys();
- char buffer[PATH_MAX];
+ char *buffer = NULL;
+ size_t size = 0;
/* Ensure our PATH is prefixed with the system locations first
for a little extra security */
@@ -170,8 +171,7 @@ env_config(void)
free(e);
if ((fp = fopen(RC_KRUNLEVEL, "r"))) {
- memset(buffer, 0, sizeof (buffer));
- if (fgets(buffer, sizeof (buffer), fp)) {
+ if (getline(&buffer, &size, fp) != -1) {
l = strlen (buffer) - 1;
if (buffer[l] == '\n')
buffer[l] = 0;
@@ -181,6 +181,7 @@ env_config(void)
} else
setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1);
+ free(buffer);
if (sys)
setenv("RC_SYS", sys, 1);
@@ -232,11 +233,12 @@ signal_setup_restart(int sig, void (*handler)(int))
int
svc_lock(const char *applet)
{
- char file[PATH_MAX];
+ char *file = NULL;
int fd;
- snprintf(file, sizeof(file), RC_SVCDIR "/exclusive/%s", applet);
+ xasprintf(&file, RC_SVCDIR "/exclusive/%s", applet);
fd = open(file, O_WRONLY | O_CREAT | O_NONBLOCK, 0664);
+ free(file);
if (fd == -1)
return -1;
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
@@ -250,11 +252,12 @@ svc_lock(const char *applet)
int
svc_unlock(const char *applet, int fd)
{
- char file[PATH_MAX];
+ char *file = NULL;
- snprintf(file, sizeof(file), RC_SVCDIR "/exclusive/%s", applet);
+ xasprintf(&file, RC_SVCDIR "/exclusive/%s", applet);
close(fd);
unlink(file);
+ free(file);
return -1;
}
@@ -358,7 +361,7 @@ RC_DEPTREE * _rc_deptree_load(int force, int *regen)
int serrno = errno;
int merrno;
time_t t;
- char file[PATH_MAX];
+ char *file = NULL;
struct stat st;
struct utimbuf ut;
FILE *fp;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-20 22:36 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-20 22:36 UTC (permalink / raw
To: gentoo-commits
commit: c1178c8eebb92c9f3702e981cd4af9ef41f51884
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Feb 20 22:35:50 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 20 22:35:50 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c1178c8e
rc-selinux.c: remove references to path_max
src/rc/rc-selinux.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index bfaf1556..2c9673cc 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -256,19 +256,19 @@ static int read_context_file(const char *filename, char **context)
{
int ret = -1;
FILE *fp;
- char filepath[PATH_MAX];
+ char *filepath = NULL;
char *line = NULL;
char *p;
char *p2;
size_t len = 0;
ssize_t read;
- memset(filepath, '\0', PATH_MAX);
- snprintf(filepath, PATH_MAX - 1, "%s/%s", selinux_contexts_path(), filename);
+ xasprintf(&filepath, "%s/%s", selinux_contexts_path(), filename);
fp = fopen(filepath, "r");
if (fp == NULL) {
eerror("Failed to open context file: %s", filename);
+ free(filepath);
return -1;
}
@@ -294,6 +294,7 @@ static int read_context_file(const char *filename, char **context)
}
free(line);
+ free(filepath);
fclose(fp);
return ret;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-21 19:50 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-21 19:50 UTC (permalink / raw
To: gentoo-commits
commit: a6cc7f06cf3807a0e0590697e1f14e6ab9055271
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Feb 21 19:49:41 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Feb 21 19:49:41 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a6cc7f06
rc.c: remove PATH_MAX references
src/rc/rc.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 110591e4..1f462c66 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -336,26 +336,26 @@ set_krunlevel(const char *level)
return true;
}
-static size_t
-get_krunlevel(char *buffer, int buffer_len)
+static char *get_krunlevel(void)
{
+ char *buffer = NULL;
FILE *fp;
size_t i = 0;
if (!exists(RC_KRUNLEVEL))
- return 0;
+ return NULL;
if (!(fp = fopen(RC_KRUNLEVEL, "r"))) {
eerror("fopen `%s': %s", RC_KRUNLEVEL, strerror(errno));
- return 0;
+ return NULL;
}
- if (fgets(buffer, buffer_len, fp)) {
+ if (getline(&buffer, &i, fp) != -1) {
i = strlen(buffer);
if (buffer[i - 1] == '\n')
buffer[i - 1] = 0;
}
fclose(fp);
- return i;
+ return buffer;
}
static void
@@ -743,7 +743,7 @@ int main(int argc, char **argv)
RC_STRING *service;
bool going_down = false;
int depoptions = RC_DEP_STRICT | RC_DEP_TRACE;
- char krunlevel [PATH_MAX];
+ char *krunlevel = NULL;
char pidstr[10];
int opt;
bool parallel;
@@ -892,7 +892,8 @@ int main(int argc, char **argv)
(strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 &&
strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0))
{
- if (get_krunlevel(krunlevel, sizeof(krunlevel))) {
+ krunlevel = get_krunlevel();
+ if (krunlevel) {
newlevel = krunlevel;
set_krunlevel(NULL);
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-22 0:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-22 0:17 UTC (permalink / raw
To: gentoo-commits
commit: 5868abe97babcc287794dcb36ad8e77989b6ddcf
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 22 00:16:56 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 00:16:56 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=5868abe9
start-stop-daemon: compiler warning cleanup
src/rc/start-stop-daemon.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 88b1e091..1b565829 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -616,7 +616,8 @@ int main(int argc, char **argv)
fp = fopen(exec_file, "r");
if (fp) {
line = NULL;
- getline(&line, &size, fp);
+ if (getline(&line, &size, fp) == -1)
+ eerrorx("%s: %s", applet, strerror(errno));
p = line;
fclose(fp);
if (p != NULL && line[0] == '#' && line[1] == '!') {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-22 0:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-22 0:17 UTC (permalink / raw
To: gentoo-commits
commit: e275da84de1589253da5ff6a7c272cf1c82f8567
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 22 00:14:56 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 00:14:56 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e275da84
supervise-daemon: remove references to PATH_MAX
src/rc/supervise-daemon.c | 102 +++++++++++++++++++++++++---------------------
1 file changed, 56 insertions(+), 46 deletions(-)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 06d0bdb3..a858cf46 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -224,6 +224,22 @@ static char * expand_home(const char *home, const char *path)
return nh;
}
+static char *make_cmdline(char **argv)
+{
+ char **c;
+ char *cmdline = NULL;
+ size_t len = 0;
+
+ for (c = argv; c && *c; c++)
+ len += (strlen(*c) + 1);
+ cmdline = xmalloc(len);
+ for (c = argv; c && *c; c++) {
+ strcat(cmdline, *c);
+ strcat(cmdline, " ");
+ }
+ return cmdline;
+}
+
static void child_process(char *exec, char **argv)
{
RC_STRINGLIST *env_list;
@@ -234,8 +250,7 @@ static void child_process(char *exec, char **argv)
size_t len;
char *newpath;
char *np;
- char **c;
- char cmdline[PATH_MAX];
+ char *cmdline = NULL;
time_t start_time;
char start_count_string[20];
char start_time_string[20];
@@ -395,15 +410,9 @@ static void child_process(char *exec, char **argv)
for (i = getdtablesize() - 1; i >= 3; --i)
fcntl(i, F_SETFD, FD_CLOEXEC);
-
- *cmdline = '\0';
- c = argv;
- while (c && *c) {
- strcat(cmdline, *c);
- strcat(cmdline, " ");
- c++;
- }
+ cmdline = make_cmdline(argv);
syslog(LOG_INFO, "Child command line: %s", cmdline);
+ free(cmdline);
execvp(exec, argv);
#ifdef HAVE_PAM
@@ -551,8 +560,8 @@ int main(int argc, char **argv)
char *token;
int i;
int n;
- char exec_file[PATH_MAX];
- char name[PATH_MAX];
+ char *exec_file = NULL;
+ char *varbuf = NULL;
struct timespec ts;
struct passwd *pw;
struct group *gr;
@@ -561,7 +570,7 @@ int main(int argc, char **argv)
int child_argc = 0;
char **child_argv = NULL;
char *str = NULL;
- char cmdline[PATH_MAX];
+ char *cmdline = NULL;
applet = basename_c(argv[0]);
atexit(cleanup);
@@ -593,13 +602,7 @@ int main(int argc, char **argv)
}
}
- *cmdline = '\0';
- c = argv;
- while (c && *c) {
- strcat(cmdline, *c);
- strcat(cmdline, " ");
- c++;
- }
+ cmdline = make_cmdline(argv);
if (svcname) {
argc--;
argv++;
@@ -761,9 +764,11 @@ int main(int argc, char **argv)
child_argv = xmalloc((child_argc + 1) * sizeof(char *));
memset(child_argv, 0, (child_argc + 1) * sizeof(char *));
for (x = 0; x < child_argc; x++) {
- sprintf(name, "argv_%d", x);
- str = rc_service_value_get(svcname, name);
+ xasprintf(&varbuf, "argv_%d", x);
+ str = rc_service_value_get(svcname, varbuf);
child_argv[x] = str;
+ free(varbuf);
+ varbuf = NULL;
}
free(str);
str = rc_service_value_get(svcname, "child_pid");
@@ -792,32 +797,31 @@ int main(int argc, char **argv)
if (*exec == '/' || *exec == '.') {
/* Full or relative path */
if (ch_root)
- snprintf(exec_file, sizeof(exec_file),
- "%s/%s", ch_root, exec);
+ xasprintf(&exec_file, "%s/%s", ch_root, exec);
else
- snprintf(exec_file, sizeof(exec_file),
- "%s", exec);
+ xasprintf(&exec_file, "%s", exec);
} else {
/* Something in $PATH */
p = tmp = xstrdup(getenv("PATH"));
- *exec_file = '\0';
+ exec_file = NULL;
while ((token = strsep(&p, ":"))) {
if (ch_root)
- snprintf(exec_file, sizeof(exec_file),
- "%s/%s/%s",
- ch_root, token, exec);
+ xasprintf(&exec_file, "%s/%s/%s", ch_root, token, exec);
else
- snprintf(exec_file, sizeof(exec_file),
- "%s/%s", token, exec);
- if (exists(exec_file))
+ xasprintf(&exec_file, "%s/%s", token, exec);
+ if (exec_file && exists(exec_file))
break;
- *exec_file = '\0';
+ free(exec_file);
+ exec_file = NULL;
}
free(tmp);
}
- if ( !exists(exec_file))
- eerrorx("%s: %s does not exist", applet,
+ if (!exists(exec_file)) {
+ eerror("%s: %s does not exist", applet,
*exec_file ? exec_file : exec);
+ free(exec_file);
+ exit(EXIT_FAILURE);
+ }
} else
eerrorx("%s: nothing to start", applet);
@@ -840,6 +844,8 @@ int main(int argc, char **argv)
einfov("Detaching to start `%s'", exec);
syslog(LOG_INFO, "Supervisor command line: %s", cmdline);
+ free(cmdline);
+ cmdline = NULL;
/* Remove existing pidfile */
if (pidfile)
@@ -852,12 +858,13 @@ int main(int argc, char **argv)
fclose(fp);
rc_service_value_set(svcname, "pidfile", pidfile);
- sprintf(name, "%i", respawn_delay);
- rc_service_value_set(svcname, "respawn_delay", name);
- sprintf(name, "%i", respawn_max);
- rc_service_value_set(svcname, "respawn_max", name);
- sprintf(name, "%i", respawn_period);
- rc_service_value_set(svcname, "respawn_period", name);
+ varbuf = NULL;
+ xasprintf(&varbuf, "%i", respawn_delay);
+ rc_service_value_set(svcname, "respawn_delay", varbuf);
+ xasprintf(&varbuf, "%i", respawn_max);
+ rc_service_value_set(svcname, "respawn_max", varbuf);
+ xasprintf(&varbuf, "%i", respawn_period);
+ rc_service_value_set(svcname, "respawn_period", varbuf);
child_pid = fork();
if (child_pid == -1)
eerrorx("%s: fork: %s", applet, strerror(errno));
@@ -875,13 +882,16 @@ int main(int argc, char **argv)
c = argv;
x = 0;
while (c && *c) {
- snprintf(name, sizeof(name), "argv_%-d",x);
- rc_service_value_set(svcname, name, *c);
+ varbuf = NULL;
+ xasprintf(&varbuf, "argv_%-d",x);
+ rc_service_value_set(svcname, varbuf, *c);
+ free(varbuf);
+ varbuf = NULL;
x++;
c++;
}
- sprintf(name, "%d", x);
- rc_service_value_set(svcname, "argc", name);
+ xasprintf(&varbuf, "%d", x);
+ rc_service_value_set(svcname, "argc", varbuf);
rc_service_value_set(svcname, "exec", exec);
supervisor(exec, argv);
} else
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-22 0:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-22 0:17 UTC (permalink / raw
To: gentoo-commits
commit: 71aad16256604e0e9e146221957a9b00cfe67b99
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 22 00:15:35 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 00:15:35 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=71aad162
openrc-run: clean up a compiler warning
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 7e8d2e50..daeafc52 100644
--- a/src/rc/openrc-run.c
+++ b/src/rc/openrc-run.c
@@ -1151,7 +1151,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
lnk = xmalloc(4096);
- memset(lnk, 0, sizeof(lnk));
+ memset(lnk, 0, 4096);
if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
dir = dirname(path);
if (strchr(lnk, '/')) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-22 18:55 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-22 18:55 UTC (permalink / raw
To: gentoo-commits
commit: 98262647a9d2f3c65a7ceb1aaa81095522c1ef06
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 22 18:54:21 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 18:54:21 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=98262647
supervise-daemon: zero out the cmdline buffer when it is allocated
src/rc/supervise-daemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index a858cf46..6d36a5aa 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -233,6 +233,7 @@ static char *make_cmdline(char **argv)
for (c = argv; c && *c; c++)
len += (strlen(*c) + 1);
cmdline = xmalloc(len);
+ memset(cmdline, 0, len);
for (c = argv; c && *c; c++) {
strcat(cmdline, *c);
strcat(cmdline, " ");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-22 22:17 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-22 22:17 UTC (permalink / raw
To: gentoo-commits
commit: aa7d3a7911b658c550e7ce76cd6d7d46541fc323
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Feb 22 22:16:07 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 22:16:07 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=aa7d3a79
openrc: force deptree update for sysinit runlevel
src/rc/rc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 1f462c66..3054f6c2 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -505,6 +505,9 @@ do_sysinit()
* sys */
if ((sys = rc_sys()))
setenv("RC_SYS", sys, 1);
+ /* force an update of the dependency tree */
+ if ((main_deptree = _rc_deptree_load(1, NULL)) == NULL)
+ eerrorx("failed to load deptree");
}
static bool
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-24 23:03 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-24 23:03 UTC (permalink / raw
To: gentoo-commits
commit: f383fd87b121492a04362ca9041f686d981718f1
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Feb 24 23:02:02 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Feb 24 23:02:02 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f383fd87
kill_all: change execl call to execlp
src/rc/kill_all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rc/kill_all.c b/src/rc/kill_all.c
index d6ce354b..3aeaa262 100644
--- a/src/rc/kill_all.c
+++ b/src/rc/kill_all.c
@@ -65,7 +65,7 @@ static int mount_proc(void)
break;
case 0:
/* attempt to mount /proc */
- execl("mount", "mount", "-t", "proc", "proc", "/proc", NULL);
+ execlp("mount", "mount", "-t", "proc", "proc", "/proc", NULL);
syslog(LOG_ERR, "Unable to execute mount");
exit(1);
break;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-24 23:03 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-24 23:03 UTC (permalink / raw
To: gentoo-commits
commit: cfded513cd9b7febe4b7cf39a80411e4303f0655
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Feb 24 22:24:08 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Feb 24 22:24:08 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=cfded513
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.
src/rc/openrc-init.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index eb346f59..de570e56 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -35,6 +35,7 @@
#include "rc-wtmp.h"
#include "version.h"
+static const char *path_default = "/sbin:/usr/sbin:/bin:/usr/bin";
static const char *rc_default_runlevel = "default";
static pid_t do_openrc(const char *runlevel)
@@ -183,6 +184,9 @@ int main(int argc, char **argv)
sigaction(SIGINT, &sa, NULL);
reboot(RB_DISABLE_CAD);
+ /* set default path */
+ setenv("PATH", path_default, 1);
+
if (! reexec)
init(default_runlevel);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-26 18:23 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-26 18:23 UTC (permalink / raw
To: gentoo-commits
commit: acf1e43f815898c4a4957db352f71f3fb629edf3
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Feb 26 18:21:14 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 26 18:21:14 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-26 19:15 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-26 19:15 UTC (permalink / raw
To: gentoo-commits
commit: c3d666acaf51c771671b0fa54bd8ec0f5d29859e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Feb 26 19:14:31 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 26 19:14:31 2018 +0000
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"
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-26 19:15 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-26 19:15 UTC (permalink / raw
To: gentoo-commits
commit: e93b1d76d150c4477015052fc3df9b94647e5b5d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Feb 26 19:13:44 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 26 19:13:44 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-26 20:34 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-26 20:34 UTC (permalink / raw
To: gentoo-commits
commit: 0506d68427e342366d826aae4bfbbc6cc0adecc2
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Feb 26 19:46:47 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Feb 26 19:46:47 2018 +0000
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:
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-02-28 18:45 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-02-28 18:45 UTC (permalink / raw
To: gentoo-commits
commit: 038c03bef315314ddb1e460c67d29b2599b494ad
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Feb 27 22:02:20 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 27 22:02:20 2018 +0000
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)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-03-12 2:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-03-12 2:43 UTC (permalink / raw
To: gentoo-commits
commit: b46123f2e19a5eb8dc02b898e8c20a2ccc211615
Author: Chris Cromer <cromerc <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Fri Mar 2 00:31:33 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Mar 2 00:31:33 2018 +0000
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);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-03-15 1:43 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-03-15 1:43 UTC (permalink / raw
To: gentoo-commits
commit: 5346fbf2c90b33b3abc01588e4727d4402f8db62
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Mar 15 01:05:45 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Mar 15 01:05:45 2018 +0000
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, " ");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-07 23:21 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-07 23:21 UTC (permalink / raw
To: gentoo-commits
commit: 2ae60ca0419d60c86904a8e15e71e902549e18d4
Author: Scall <Scall <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Wed Mar 21 12:33:33 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Mar 21 12:33:33 2018 +0000
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",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-07 23:21 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-07 23:21 UTC (permalink / raw
To: gentoo-commits
commit: 0200002b8cbd061ac79b6aed4024220cd0386d2c
Author: Andrey Utkin <andrey_utkin <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 21 22:13:15 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed May 2 18:42:59 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0200002b
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;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-09 22:35 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-09 22:35 UTC (permalink / raw
To: gentoo-commits
commit: 2b1392af2fe9e5dfc8eda2f19d896efdc41840bf
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed May 9 22:30:08 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed May 9 22:30:08 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-11 18:19 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-11 18:19 UTC (permalink / raw
To: gentoo-commits
commit: b35e03b6b1acc841ac33f601dd39c1152523621e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri May 11 00:35:24 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri May 11 00:35:24 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-15 0:11 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-15 0:11 UTC (permalink / raw
To: gentoo-commits
commit: 414a9aae6ce066d2a6ad42e7e24d1c12a7b46409
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 15 00:04:42 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 15 00:04:42 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-15 0:11 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-15 0:11 UTC (permalink / raw
To: gentoo-commits
commit: d980798d6444bbfc508796a233e962bf4dd61275
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 15 00:08:19 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 15 00:08:19 2018 +0000
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);
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-15 22:11 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-15 22:11 UTC (permalink / raw
To: gentoo-commits
commit: 04886efd85328988657c34440da9ba6aa2841cfd
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 15 21:18:19 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 15 21:18:19 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-15 22:11 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-15 22:11 UTC (permalink / raw
To: gentoo-commits
commit: 958f57d895b6573b39e62097e5e9881f16174715
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 15 21:27:42 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 15 21:27:42 2018 +0000
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 &&
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-22 22:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-22 22:12 UTC (permalink / raw
To: gentoo-commits
commit: 0f4fa41574a4ebf8117493e5411f8ab522010467
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 22 16:08:35 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 22 17:20:38 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-22 22:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-22 22:12 UTC (permalink / raw
To: gentoo-commits
commit: 5d6dd97bba3559b57fb1c1de35e644c6dbd6baa7
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 21 23:16:12 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 22 17:20:38 2018 +0000
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)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-05-22 22:12 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-05-22 22:12 UTC (permalink / raw
To: gentoo-commits
commit: 7e56a49e23c810673b83e48eb9ca36229bb4016e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 22 22:11:43 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 22 22:11:43 2018 +0000
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;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-13 21:28 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-13 21:28 UTC (permalink / raw
To: gentoo-commits
commit: ec8abea4605395a2a59b26906ce4677a578e3c60
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 13 18:49:42 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jun 13 18:49:42 2018 +0000
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 00000000..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 <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#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 00000000..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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-14 19:56 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-14 19:56 UTC (permalink / raw
To: gentoo-commits
commit: d4501a9f06c807f87be04f128e535a74b370fdb4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Jun 14 19:55:42 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jun 14 19:55:42 2018 +0000
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 <unistd.h>
#include <sys/types.h>
-#include "rc-pipe-command.h"
+#include "rc-pipes.h"
static const int pipe_read_end = 0;
static const int pipe_write_end = 1;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 21:34 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 21:34 UTC (permalink / raw
To: gentoo-commits
commit: 04721ece03b15503aa220f60e7c6159d01ee75e1
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 20:32:10 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 20:32:10 2018 +0000
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 <username>|<uid> */
/* DEPRECATED */
ewarn("WARNING: -c/--chuid is deprecated and will be removed in the future, please use -u/--user instead");
+ /* falls through */
case 'u': /* --user <username>|<uid> */
{
p = optarg;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 21:34 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 21:34 UTC (permalink / raw
To: gentoo-commits
commit: c7e8f1133a42152cc293e6b637985f81bcf8b310
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 19:01:54 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 19:01:54 2018 +0000
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;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 21:34 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 21:34 UTC (permalink / raw
To: gentoo-commits
commit: 47e4bfae57402eedd017d6098b432c2c411cd374
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 18:59:16 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 18:59:16 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 21:34 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 21:34 UTC (permalink / raw
To: gentoo-commits
commit: a6165168953b9c7a62c089ce946476b23b73fb12
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 21:15:22 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 21:18:48 2018 +0000
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) {
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 22:07 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 22:07 UTC (permalink / raw
To: gentoo-commits
commit: be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 22:06:33 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 22:06:33 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 23:00 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 23:00 UTC (permalink / raw
To: gentoo-commits
commit: e14edd765fdc4ed43356d2eef35fa99228e5d461
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 22:57:10 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 22:57:10 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-19 23:00 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-19 23:00 UTC (permalink / raw
To: gentoo-commits
commit: f9d41243d8499c5d7027177d5aa716d5b5859cd6
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jun 19 22:46:12 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jun 19 22:46:12 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-20 14:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-20 14:38 UTC (permalink / raw
To: gentoo-commits
commit: 64354831da2adeba5cb2f91a81fa0f56e1ce4ed9
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jun 20 14:37:20 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jun 20 14:37:20 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-28 18:03 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-28 18:03 UTC (permalink / raw
To: gentoo-commits
commit: 56ddda54b5aa01474bf563d5a662075c35152858
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jun 27 22:37:11 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jun 27 22:37:11 2018 +0000
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
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-06-29 20:32 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-06-29 20:32 UTC (permalink / raw
To: gentoo-commits
commit: 79648ac1c6355975abca6acf6076e7022037523f
Author: Holger Hoffstätte <holger <AT> applied-asynchrony <DOT> com>
AuthorDate: Thu Jun 28 21:08:57 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jun 29 13:49:13 2018 +0000
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");
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-10-06 18:03 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-10-06 18:03 UTC (permalink / raw
To: gentoo-commits
commit: 7ee3e5b2d6dbb9c279011b59ec132d27d04f843e
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Oct 6 17:49:44 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Oct 6 17:49:44 2018 +0000
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -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();
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-10-06 18:03 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-10-06 18:03 UTC (permalink / raw
To: gentoo-commits
commit: eca4357892315ca7340bbfc2b373d7660a34142f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Oct 6 17:51:04 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Oct 6 17:51:04 2018 +0000
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)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-10-09 16:35 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-10-09 16:35 UTC (permalink / raw
To: gentoo-commits
commit: 67e2d6033dd7ac6db0269ee060ed20484825ff9f
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Oct 9 16:34:52 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 9 16:34:52 2018 +0000
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++)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-10-15 16:52 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-10-15 16:52 UTC (permalink / raw
To: gentoo-commits
commit: 07908be0903229a69b9e0f733ed13eeff0b55a44
Author: Austin English <austinenglish <AT> gmail <DOT> com>
AuthorDate: Fri Oct 12 22:16:33 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Oct 13 16:53:54 2018 +0000
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;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-10-15 16:52 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-10-15 16:52 UTC (permalink / raw
To: gentoo-commits
commit: 710c874e6e3bc57b1561eb8f2108244bf24ed32e
Author: Zac Medico <zmedico <AT> gmail <DOT> com>
AuthorDate: Sat Oct 13 19:32:45 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 15 16:50:42 2018 +0000
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;
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-11-02 23:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-11-02 23:24 UTC (permalink / raw
To: gentoo-commits
commit: e2416d089396e2b9a72cc56ef9f57886ffb0f1c8
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Oct 24 20:24:29 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Oct 24 20:24:40 2018 +0000
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;
}
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-11-02 23:24 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-11-02 23:24 UTC (permalink / raw
To: gentoo-commits
commit: ee3c4afdb75b98cd472b7ffbb46adc9d8a1e1b15
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Nov 2 23:22:11 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Nov 2 23:22:11 2018 +0000
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 <sys/reboot.h>
#include <sys/wait.h>
+#ifdef HAVE_SELINUX
+# include <selinux/selinux.h>
+#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)
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-11-06 3:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-11-06 3:38 UTC (permalink / raw
To: gentoo-commits
commit: 025c9693ccab9c6220520ace47aa81553e7ea600
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Nov 5 17:39:39 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Nov 5 17:39:39 2018 +0000
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)",
^ permalink raw reply related [flat|nested] 257+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: src/rc/
@ 2018-11-06 3:38 William Hubbs
0 siblings, 0 replies; 257+ messages in thread
From: William Hubbs @ 2018-11-06 3:38 UTC (permalink / raw
To: gentoo-commits
commit: 008c9d0036e348242e323c0b5a66f3724b4a839d
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Nov 6 03:35:00 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Nov 6 03:35:00 2018 +0000
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);
^ permalink raw reply related [flat|nested] 257+ messages in thread
end of thread, other threads:[~2018-11-06 3:38 UTC | newest]
Thread overview: 257+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-07 21:33 [gentoo-commits] proj/openrc:master commit in: src/rc/ William Hubbs
-- strict thread matches above, loose matches on Subject: below --
2018-11-06 3:38 William Hubbs
2018-11-06 3:38 William Hubbs
2018-11-02 23:24 William Hubbs
2018-11-02 23:24 William Hubbs
2018-10-15 16:52 William Hubbs
2018-10-15 16:52 William Hubbs
2018-10-09 16:35 William Hubbs
2018-10-06 18:03 William Hubbs
2018-10-06 18:03 William Hubbs
2018-06-29 20:32 William Hubbs
2018-06-28 18:03 William Hubbs
2018-06-20 14:38 William Hubbs
2018-06-19 23:00 William Hubbs
2018-06-19 23:00 William Hubbs
2018-06-19 22:07 William Hubbs
2018-06-19 21:34 William Hubbs
2018-06-19 21:34 William Hubbs
2018-06-19 21:34 William Hubbs
2018-06-19 21:34 William Hubbs
2018-06-14 19:56 William Hubbs
2018-06-13 21:28 William Hubbs
2018-05-22 22:12 William Hubbs
2018-05-22 22:12 William Hubbs
2018-05-22 22:12 William Hubbs
2018-05-15 22:11 William Hubbs
2018-05-15 22:11 William Hubbs
2018-05-15 0:11 William Hubbs
2018-05-15 0:11 William Hubbs
2018-05-11 18:19 William Hubbs
2018-05-09 22:35 William Hubbs
2018-05-07 23:21 William Hubbs
2018-05-07 23:21 William Hubbs
2018-03-15 1:43 William Hubbs
2018-03-12 2:43 William Hubbs
2018-02-28 18:45 William Hubbs
2018-02-26 20:34 William Hubbs
2018-02-26 19:15 William Hubbs
2018-02-26 19:15 William Hubbs
2018-02-26 18:23 William Hubbs
2018-02-24 23:03 William Hubbs
2018-02-24 23:03 William Hubbs
2018-02-22 22:17 William Hubbs
2018-02-22 18:55 William Hubbs
2018-02-22 0:17 William Hubbs
2018-02-22 0:17 William Hubbs
2018-02-22 0:17 William Hubbs
2018-02-21 19:50 William Hubbs
2018-02-20 22:36 William Hubbs
2018-02-20 22:36 William Hubbs
2018-02-20 22:36 William Hubbs
2018-02-16 20:07 William Hubbs
2018-02-16 20:07 William Hubbs
2018-02-16 20:07 William Hubbs
2018-02-14 23:37 William Hubbs
2018-02-14 23:37 William Hubbs
2018-01-24 23:44 William Hubbs
2018-01-23 23:08 William Hubbs
2018-01-16 19:36 William Hubbs
2018-01-16 19:14 William Hubbs
2018-01-09 23:35 William Hubbs
2017-11-29 21:12 William Hubbs
2017-11-28 23:17 William Hubbs
2017-11-28 23:17 William Hubbs
2017-11-07 21:33 William Hubbs
2017-11-07 21:33 William Hubbs
2017-11-07 21:33 William Hubbs
2017-10-26 22:01 William Hubbs
2017-10-26 18:58 William Hubbs
2017-10-26 18:58 William Hubbs
2017-10-26 18:58 William Hubbs
2017-10-25 20:10 William Hubbs
2017-10-18 23:09 William Hubbs
2017-10-05 23:31 William Hubbs
2017-09-22 22:25 William Hubbs
2017-09-18 18:31 William Hubbs
2017-09-18 18:07 William Hubbs
2017-09-18 18:07 William Hubbs
2017-09-18 18:07 William Hubbs
2017-09-18 18:07 William Hubbs
2017-09-18 18:07 William Hubbs
2017-09-18 18:07 William Hubbs
2017-09-15 18:31 William Hubbs
2017-09-06 22:33 William Hubbs
2017-08-25 16:48 William Hubbs
2017-08-24 16:45 William Hubbs
2017-07-24 23:27 William Hubbs
2017-06-12 15:41 William Hubbs
2017-06-12 15:41 William Hubbs
2017-06-07 16:34 William Hubbs
2017-05-30 21:25 William Hubbs
2017-05-30 21:25 William Hubbs
2017-05-22 16:30 William Hubbs
2017-05-19 23:30 William Hubbs
2017-05-16 0:00 William Hubbs
2017-05-16 0:00 William Hubbs
2017-05-12 2:42 William Hubbs
2017-05-12 2:42 William Hubbs
2017-05-12 2:42 William Hubbs
2017-05-11 16:38 William Hubbs
2017-04-29 22:56 William Hubbs
2017-04-29 22:56 William Hubbs
2017-04-29 22:56 William Hubbs
2017-04-29 14:44 William Hubbs
2017-04-17 17:24 William Hubbs
2017-04-13 17:56 William Hubbs
2017-04-07 12:43 William Hubbs
2017-04-03 15:45 William Hubbs
2017-01-25 23:58 William Hubbs
2017-01-05 0:24 William Hubbs
2017-01-04 23:23 William Hubbs
2016-11-30 22:49 William Hubbs
2016-11-03 16:13 William Hubbs
2016-10-24 17:48 William Hubbs
2016-10-24 17:43 William Hubbs
2016-10-11 15:31 William Hubbs
2016-09-30 22:10 William Hubbs
2016-09-19 17:10 William Hubbs
2016-09-16 13:58 William Hubbs
2016-09-16 13:58 William Hubbs
2016-08-25 16:17 William Hubbs
2016-07-25 18:54 William Hubbs
2016-07-16 20:17 William Hubbs
2016-07-14 17:25 William Hubbs
2016-06-10 22:45 William Hubbs
2016-05-24 16:43 William Hubbs
2016-05-24 16:43 William Hubbs
2016-05-13 18:00 William Hubbs
2016-05-13 17:12 William Hubbs
2016-05-04 23:24 William Hubbs
2016-04-11 16:18 William Hubbs
2016-02-12 18:58 William Hubbs
2016-01-22 18:53 William Hubbs
2016-01-20 17:29 William Hubbs
2016-01-19 6:12 William Hubbs
2016-01-19 6:12 William Hubbs
2016-01-19 6:12 William Hubbs
2016-01-14 17:33 William Hubbs
2016-01-14 17:33 William Hubbs
2016-01-14 17:33 William Hubbs
2016-01-14 17:33 William Hubbs
2016-01-12 20:12 William Hubbs
2015-12-06 0:14 William Hubbs
2015-12-02 21:46 William Hubbs
2015-10-13 13:36 William Hubbs
2015-10-05 15:27 William Hubbs
2015-10-04 20:37 William Hubbs
2015-09-18 17:45 William Hubbs
2015-08-02 14:12 William Hubbs
2015-07-23 17:48 William Hubbs
2015-04-24 18:13 William Hubbs
2015-03-25 13:36 William Hubbs
2015-03-25 6:10 William Hubbs
2015-03-25 4:38 William Hubbs
2015-03-24 20:53 William Hubbs
2015-03-24 20:40 William Hubbs
2015-02-19 21:16 William Hubbs
2015-02-15 22:15 William Hubbs
2015-02-15 22:10 William Hubbs
2015-01-22 18:54 William Hubbs
2014-09-20 21:52 William Hubbs
2014-08-22 19:10 William Hubbs
2014-08-11 18:18 ` William Hubbs
2014-08-22 19:10 William Hubbs
2014-07-25 16:06 ` William Hubbs
2014-07-28 15:51 William Hubbs
2014-08-22 19:10 ` William Hubbs
2014-07-19 18:06 William Hubbs
2014-07-18 4:47 William Hubbs
2014-07-16 23:01 William Hubbs
2014-07-16 23:01 William Hubbs
2014-07-16 19:48 William Hubbs
2014-07-16 19:17 William Hubbs
2014-07-16 18:14 William Hubbs
2014-07-13 19:16 William Hubbs
2014-07-11 20:24 William Hubbs
2014-07-11 20:19 William Hubbs
2014-01-18 20:02 William Hubbs
2013-12-13 18:20 William Hubbs
2013-12-13 18:05 William Hubbs
2013-12-01 17:25 William Hubbs
2013-10-12 14:50 William Hubbs
2013-10-06 17:36 William Hubbs
2013-10-04 16:23 William Hubbs
2013-09-24 6:52 William Hubbs
2013-09-23 22:59 William Hubbs
2013-09-23 18:38 William Hubbs
2013-09-23 18:38 William Hubbs
2013-09-04 0:46 William Hubbs
2013-08-26 22:26 William Hubbs
2013-08-26 20:59 William Hubbs
2013-07-23 23:01 William Hubbs
2013-07-16 18:56 William Hubbs
2013-05-01 23:24 William Hubbs
2013-02-25 20:50 William Hubbs
2013-02-25 20:50 William Hubbs
2013-02-25 20:50 William Hubbs
2013-02-25 20:50 William Hubbs
2013-02-15 19:35 William Hubbs
2012-10-27 18:12 William Hubbs
2012-10-24 17:38 William Hubbs
2012-10-17 23:48 William Hubbs
2012-10-09 23:56 William Hubbs
2012-10-09 21:50 William Hubbs
2012-09-14 21:00 Christian Ruppert
2012-09-12 19:36 Christian Ruppert
2012-09-12 19:00 Christian Ruppert
2012-08-18 22:26 Christian Ruppert
2012-08-18 21:26 Christian Ruppert
2012-05-23 23:31 Mike Frysinger
2012-05-16 22:16 Mike Frysinger
2012-05-06 5:16 Mike Frysinger
2012-04-24 3:32 Christian Ruppert
2012-02-24 2:38 William Hubbs
2012-02-21 2:09 William Hubbs
2012-02-21 1:08 Jory Pratt
2012-02-12 1:23 Christian Ruppert
2012-02-10 23:25 Christian Ruppert
2012-01-31 22:59 William Hubbs
2012-01-28 18:05 Christian Ruppert
2012-01-28 15:45 Christian Ruppert
2012-01-24 18:41 Christian Ruppert
2012-01-23 10:27 Robin H. Johnson
2012-01-23 10:27 Robin H. Johnson
2012-01-23 5:27 Robin H. Johnson
2012-01-22 20:46 William Hubbs
2011-12-31 2:36 Christian Ruppert
2011-12-30 15:03 Christian Ruppert
2011-12-30 15:03 Christian Ruppert
2011-12-29 12:59 Christian Ruppert
2011-12-29 2:18 Christian Ruppert
2011-12-29 2:10 Christian Ruppert
2011-12-29 1:50 Christian Ruppert
2011-12-11 20:43 William Hubbs
2011-11-19 8:11 Mike Frysinger
2011-11-19 8:11 Mike Frysinger
2011-11-19 8:11 Mike Frysinger
2011-11-17 22:10 William Hubbs
2011-11-15 21:26 William Hubbs
2011-11-09 5:10 Mike Frysinger
2011-09-08 17:22 Christian Ruppert
2011-09-08 17:22 Christian Ruppert
2011-09-02 16:47 William Hubbs
2011-09-01 22:14 William Hubbs
2011-07-26 21:59 William Hubbs
2011-07-20 19:40 William Hubbs
2011-07-05 22:52 Christian Ruppert
2011-07-04 22:54 Christian Ruppert
2011-06-30 18:21 Christian Ruppert
2011-06-27 21:21 Christian Ruppert
2011-06-05 14:52 Christian Ruppert
2011-05-28 16:12 Mike Frysinger
2011-05-28 15:42 Mike Frysinger
2011-05-23 19:25 William Hubbs
2011-02-16 15:02 William Hubbs
2011-02-15 0:50 William Hubbs
2011-02-07 8:30 William Hubbs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox