public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-04-09 19:56 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2011-04-09 19:56 UTC (permalink / raw
  To: gentoo-commits

commit:     07db27d2201a1462e36bb34f37b9c1d4e8b048a3
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  9 18:00:44 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 18:00:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=07db27d2

typo fix

X-Gentoo-Bug: 217999
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=217999

---
 src/librc/librc-depend.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 54cd72a..2e39267 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -924,7 +924,7 @@ rc_deptree_update(void)
 					if (strcmp(deptype->type, "ineed") == 0) {
 						fprintf (stderr,
 							 "Service `%s' needs non"
-							 " existant service `%s'\n",
+							 " existent service `%s'\n",
 							 depinfo->service, s->value);
 						dt = get_deptype(depinfo, "broken");
 						if (!dt) {



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-04-28  0:18 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2011-04-28  0:18 UTC (permalink / raw
  To: gentoo-commits

commit:     8fcaba9a22ac0deda7dc6a8d5f270d1df08f9966
Author:     James Le Cuirot <chewi <AT> aura-online <DOT> co <DOT> uk>
AuthorDate: Wed Apr 20 10:55:06 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 20:27:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8fcaba9a

fix rc_service_extra_commands return value

If there were no extra commands, rc_service_extra_commands returned a
list containing a single empty string. This changes that to return an
empty list, which is more consistent with what you would expect.

X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013

---
 src/librc/librc.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index f2f694d..5feb5d7 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -550,14 +550,16 @@ rc_service_extra_commands(const char *service)
 	if ((fp = popen(cmd, "r"))) {
 		rc_getline(&buffer, &len, fp);
 		p = buffer;
-		while ((token = strsep(&p, " "))) {
-			if (!commands)
-				commands = rc_stringlist_new();
-			rc_stringlist_add(commands, token);
-		}
+		commands = rc_stringlist_new();
+
+		while ((token = strsep(&p, " ")))
+			if (token[0] != '\0')
+				rc_stringlist_add(commands, token);
+
 		pclose(fp);
 		free(buffer);
 	}
+
 	free(cmd);
 	return commands;
 }



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-04-28  0:18 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2011-04-28  0:18 UTC (permalink / raw
  To: gentoo-commits

commit:     04e256e3b82ed36f61c375d83f8631a7b58bf28c
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Apr 27 19:46:59 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 19:46:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=04e256e3

fix list returned by rc_service_extra_commands

This function was returning the setting of the variable $opts, which is
not correct. $opts was used in baselayout-1, but it is replaced by
$extra_commands and $extra_started_commands in openrc.

This does not appear to break backward compatibility since this function
does not appear to be used anywhere in the openrc code.

Thanks to James Le Cuirot for the original patch.

X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013

---
 src/librc/librc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index e134547..f2f694d 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -525,7 +525,7 @@ rc_service_exists(const char *service)
 }
 librc_hidden_def(rc_service_exists)
 
-#define OPTSTR ". '%s'; echo $opts"
+#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands"
 RC_STRINGLIST *
 rc_service_extra_commands(const char *service)
 {



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-05-28 16:02 Mike Frysinger
  0 siblings, 0 replies; 48+ messages in thread
From: Mike Frysinger @ 2011-05-28 16:02 UTC (permalink / raw
  To: gentoo-commits

commit:     fe18c7bb632671457c3c261d36dece3fd09a4f69
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat May 28 15:53:29 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat May 28 15:53:29 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=fe18c7bb

librc: tweak style: foo () -> foo()

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 src/librc/librc-daemon.c     |    6 +++---
 src/librc/librc-depend.c     |   12 ++++++------
 src/librc/librc-stringlist.c |   10 +++++-----
 src/librc/librc.c            |    6 +++---
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index dde62f9..c6b8782 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -308,10 +308,10 @@ _match_list(const char *exec, const char *const *argv, const char *pidfile)
 
 	if (pidfile) {
 		l = strlen(pidfile) + 9;
-		m = xmalloc(sizeof (char) * l);
+		m = xmalloc(sizeof(char) * l);
 		snprintf(m, l, "pidfile=%s", pidfile);
 		rc_stringlist_add(match, m);
-		free (m);
+		free(m);
 	}
 
 	return match;
@@ -508,7 +508,7 @@ rc_service_daemons_crashed(const char *service)
 			if ((fp = fopen(pidfile, "r"))) {
 				if (fscanf(fp, "%d", &pid) == 1)
 					retval = false;
-				fclose (fp);
+				fclose(fp);
 			}
 			free(pidfile);
 			pidfile = NULL;

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 2e39267..5d6167e 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -144,7 +144,7 @@ rc_deptree_load_file(const char *deptree_file)
 		e = strsep(&p, "_");
 		if (!e || strcmp(e, "depinfo") != 0)
 			continue;
-		e = strsep (&p, "_");
+		e = strsep(&p, "_");
 		if (!e || sscanf(e, "%d", &i) != 1)
 			continue;
 		if (!(type = strsep(&p, "_=")))
@@ -425,8 +425,8 @@ visit_service(const RC_DEPTREE *deptree,
 				continue;
 			provided = get_provided(di, runlevel, options);
 			TAILQ_FOREACH(p, provided, entries)
-				if (strcmp (p->value, depinfo->service) == 0) {
-					visit_service (deptree, types, sorted, visited, di,
+				if (strcmp(p->value, depinfo->service) == 0) {
+					visit_service(deptree, types, sorted, visited, di,
 						       runlevel, options | RC_DEP_TRACE);
 					break;
 				}
@@ -681,7 +681,7 @@ rc_deptree_update_needed(time_t *newest, char *file)
 	/* Create base directories if needed */
 	for (i = 0; depdirs[i]; i++)
 		if (mkdir(depdirs[i], 0755) != 0 && errno != EEXIST)
-			fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror (errno));
+			fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror(errno));
 
 	/* Quick test to see if anything we use has changed and we have
 	 * data in our deptree */
@@ -922,7 +922,7 @@ rc_deptree_update(void)
 				di = get_depinfo(deptree, s->value);
 				if (!di) {
 					if (strcmp(deptype->type, "ineed") == 0) {
-						fprintf (stderr,
+						fprintf(stderr,
 							 "Service `%s' needs non"
 							 " existent service `%s'\n",
 							 depinfo->service, s->value);
@@ -1032,7 +1032,7 @@ rc_deptree_update(void)
 	if (TAILQ_FIRST(config)) {
 		if ((fp = fopen(RC_DEPCONFIG, "w"))) {
 			TAILQ_FOREACH(s, config, entries)
-				fprintf (fp, "%s\n", s->value);
+				fprintf(fp, "%s\n", s->value);
 			fclose(fp);
 		} else {
 			fprintf(stderr, "fopen `%s': %s\n",

diff --git a/src/librc/librc-stringlist.c b/src/librc/librc-stringlist.c
index 818a31c..22b823b 100644
--- a/src/librc/librc-stringlist.c
+++ b/src/librc/librc-stringlist.c
@@ -41,7 +41,7 @@ rc_stringlist_new(void)
 librc_hidden_def(rc_stringlist_new)
 
 RC_STRING *
-rc_stringlist_add (RC_STRINGLIST *list, const char *value)
+rc_stringlist_add(RC_STRINGLIST *list, const char *value)
 {
 	RC_STRING *s = xmalloc(sizeof(*s));
 
@@ -52,7 +52,7 @@ rc_stringlist_add (RC_STRINGLIST *list, const char *value)
 librc_hidden_def(rc_stringlist_add)
 
 RC_STRING *
-rc_stringlist_addu (RC_STRINGLIST *list, const char *value)
+rc_stringlist_addu(RC_STRINGLIST *list, const char *value)
 {
 	RC_STRING *s;
 
@@ -74,8 +74,8 @@ rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
 	TAILQ_FOREACH(s, list, entries)
 	    if (strcmp(s->value, value) == 0) {
 		    TAILQ_REMOVE(list, s, entries);
-		    free (s->value);
-		    free (s);
+		    free(s->value);
+		    free(s);
 		    return true;
 	    }
 
@@ -127,7 +127,7 @@ rc_stringlist_sort(RC_STRINGLIST **list)
 		TAILQ_REMOVE(l, s, entries);
 		last = NULL;
 		TAILQ_FOREACH(n, new, entries) {
-			if (strcmp (s->value, n->value) < 0)
+			if (strcmp(s->value, n->value) < 0)
 				break;
 			last = n;
 		}

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 5feb5d7..d769eea 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -749,7 +749,7 @@ rc_service_state(const char *service)
 
 	if (state & RC_SERVICE_STOPPED) {
 		dirs = ls_dir(RC_SVCDIR "/scheduled", 0);
-		TAILQ_FOREACH (dir, dirs, entries) {
+		TAILQ_FOREACH(dir, dirs, entries) {
 			snprintf(file, sizeof(file),
 			    RC_SVCDIR "/scheduled/%s/%s",
 			    dir->value, service);
@@ -892,7 +892,7 @@ rc_services_in_runlevel_stacked(const char *runlevel)
 
 	list = rc_services_in_runlevel(runlevel);
 	stacks = rc_runlevel_stacks(runlevel);
-	TAILQ_FOREACH (stack, stacks, entries) {
+	TAILQ_FOREACH(stack, stacks, entries) {
 		sl = rc_services_in_runlevel(stack->value);
 		if (list != NULL) {
 			TAILQ_CONCAT(list, sl, entries);
@@ -1008,7 +1008,7 @@ rc_services_scheduled_by(const char *service)
 	RC_STRING *dir;
 	char file[PATH_MAX];
 
-	TAILQ_FOREACH (dir, dirs, entries) {
+	TAILQ_FOREACH(dir, dirs, entries) {
 		snprintf(file, sizeof(file), RC_SVCDIR "/scheduled/%s/%s",
 		    dir->value, service);
 		if (exists(file))



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-06-28 16:47 Christian Ruppert
  0 siblings, 0 replies; 48+ messages in thread
From: Christian Ruppert @ 2011-06-28 16:47 UTC (permalink / raw
  To: gentoo-commits

commit:     b6766c25442bf75a4cf8e65b53a252831c356022
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 28 16:45:39 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Jun 28 16:45:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=b6766c25

Use RC_CONF instead of the hardcoded /etc/rc.conf

---
 src/librc/librc-depend.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 5d6167e..102790d 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -707,7 +707,7 @@ rc_deptree_update_needed(time_t *newest, char *file)
 	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_CONFDIR, newest, file))
 		newer = true;
 #endif
-	if (!rc_newer_than(RC_DEPTREE_CACHE, "/etc/rc.conf", newest, file))
+	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_CONF, newest, file))
 		newer = true;
 
 	/* Some init scripts dependencies change depending on config files



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-07-09 21:15 Christian Ruppert
  0 siblings, 0 replies; 48+ messages in thread
From: Christian Ruppert @ 2011-07-09 21:15 UTC (permalink / raw
  To: gentoo-commits

commit:     ef22868f3668fe833cdf297e619afe5b721f7716
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  9 21:05:11 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Jul  9 21:15:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=ef22868f

Do not skip similar config options

OpenRC goes through the config and checks each option for duplicates.
Lets say we're on "rc_logger" currently and its the last option in the config
file and we previously defined rc_logger_path.

It now goes through all previous config options and compares those against the
current one "rc_logger" *but* it compares only the first N bytes, in this
case strlen("rc_logger"). So it strips the _path from "rc_logger_path" which
ends up into "rc_logger" and it compares that against the current one (also
		"rc_logger"), it would then simply override the previous definition.

This patch fixes this behaviour to always compare the full option / variable
names.

---
 src/librc/librc-misc.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 15105c5..7244dee 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -173,10 +173,8 @@ rc_config_load(const char *file)
 		/* In shells the last item takes precedence, so we need to remove
 		   any prior values we may already have */
 		TAILQ_FOREACH(cline, config, entries) {
-			p = strchr(cline->value, '=');
-			if (p && strncmp(entry, cline->value,
-				(size_t)(p - cline->value)) == 0)
-			{
+			i = strlen(entry);
+			if (strncmp(entry, cline->value, i) == 0 && cline->value[i] == '=') {
 				/* We have a match now - to save time we directly replace it */
 				free(cline->value);
 				cline->value = newline;
@@ -202,15 +200,13 @@ rc_config_value(RC_STRINGLIST *list, const char *entry)
 {
 	RC_STRING *line;
 	char *p;
-	size_t len, dif;
+	size_t len;
 
 	len = strlen(entry);
 	TAILQ_FOREACH(line, list, entries) {
 		p = strchr(line->value, '=');
 		if (p != NULL) {
-			dif = (p - line->value);
-			if (dif == len &&
-			    strncmp(entry, line->value, dif) == 0)
+			if (strncmp(entry, line->value, len) == 0 && line->value[len] == '=')
 				return ++p;
 		}
 	}



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-07-13 19:39 Christian Ruppert
  0 siblings, 0 replies; 48+ messages in thread
From: Christian Ruppert @ 2011-07-13 19:39 UTC (permalink / raw
  To: gentoo-commits

commit:     a74382d9cb3d7f024efca46f2befb49e35c40758
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 13 19:32:13 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Wed Jul 13 19:32:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a74382d9

Fix rc_service_value_get() to return multiple lines as well

As introduced in bug 372547 using service_get_value() in the init scripts
or using rc_service_value_get() directly will only return one line.
This patch fixes it by using the new rc_getfile() function, it returns even
multiple lines. We're still using a char *, so the lines will be appended
instead of added into new element.

X-Gentoo-Bug: 372547
X-Gentoo-Bug-URL: http://bugs.gentoo.org/372547

---
 src/librc/librc.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index a6ff0fe..98765d8 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -767,19 +767,15 @@ librc_hidden_def(rc_service_state)
 char *
 rc_service_value_get(const char *service, const char *option)
 {
-	FILE *fp;
-	char *line = NULL;
+	char *buffer = NULL;
 	size_t len = 0;
 	char file[PATH_MAX];
 
 	snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
 	    service, option);
-	if ((fp = fopen(file, "r"))) {
-		rc_getline(&line, &len, fp);
-		fclose(fp);
-	}
+	rc_getfile(file, &buffer, &len);
 
-	return line;
+	return buffer;
 }
 librc_hidden_def(rc_service_value_get)
 



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2011-11-07 15:58 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2011-11-07 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     f46626dcfc4ea06d4e4171fc8904a379f40b293f
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 27 18:56:40 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Nov  7 14:39:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f46626dc

add auto detection for lxc

Reported-by: Francesco Riosa <francesco+gentoo_bugzilla <AT> pnpitalia.it>
X-Gentoo-Bug: 384151
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=384151

---
 src/librc/librc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 98765d8..c66c944 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -281,6 +281,8 @@ rc_sys_v1(void)
 	else if (file_regex("/proc/self/status",
 		"envID:[[:space:]]*[1-9]"))
 		return RC_SYS_OPENVZ; /* old test */
+	else if (file_regex("/proc/1/environ", "container=lxc"))
+		return RC_SYS_LXC;
 #endif
 
 	return NULL;



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-01-15  0:05 Christian Ruppert
  0 siblings, 0 replies; 48+ messages in thread
From: Christian Ruppert @ 2012-01-15  0:05 UTC (permalink / raw
  To: gentoo-commits

commit:     14625346c07a2a66fe77ce578c9423918bec1d97
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 23:38:47 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 00:02:11 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=14625346

Allow overriding of rc.conf options via kernel cmdline

This adds a new function that allows us to override some specific rc.conf
options via the kernel cmdline aka /proc/cmdline.
This makes esp. sense in cases where a rc_parallel enabled system has boot
issues. Simply disable rc_parallel by appending rc_parallel=no to your kernel
cmdline.

---
 src/librc/librc-misc.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index cebc9e8..a5daa07 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -214,6 +214,60 @@ rc_config_list(const char *file)
 }
 librc_hidden_def(rc_config_list)
 
+/*
+ * Override some specific rc.conf options via kernel cmdline
+ */
+#ifdef __linux__
+static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config) {
+	RC_STRINGLIST *overrides;
+	RC_STRING *cline, *override, *config_np;
+	char *tmp = NULL;
+	char *value = NULL;
+	size_t varlen = 0;
+	size_t len = 0;
+
+	overrides = rc_stringlist_new();
+
+	/* A list of variables which may be overriden through cmdline */
+	rc_stringlist_add(overrides, "rc_parallel");
+
+	TAILQ_FOREACH(override, overrides, entries) {
+		varlen = strlen(override->value);
+		value = rc_proc_getent(override->value);
+
+		/* No need to continue if there's nothing to override */
+		if (!value) {
+			free(value);
+			continue;
+		}
+
+		if (value != NULL) {
+			len = (varlen + strlen(value) + 2);
+			tmp = xmalloc(sizeof(char) * len);
+			snprintf(tmp, len, "%s=%s", override->value, value);
+		}
+
+		/* Whenever necessary remove the old config entry first to prevent duplicates */
+		TAILQ_FOREACH_SAFE(cline, config, entries, config_np) {
+			if (strncmp(override->value, cline->value, varlen) == 0 && cline->value[varlen] == '=') {
+				rc_stringlist_delete(config, cline->value);
+				break;
+			}
+		}
+
+		/* Add the option (var/value) to the current config */
+		rc_stringlist_add(config, tmp);
+
+		free(tmp);
+		free(value);
+	}
+
+	rc_stringlist_free(overrides);
+
+	return config;
+}
+#endif
+
 RC_STRINGLIST *
 rc_config_load(const char *file)
 {
@@ -287,6 +341,10 @@ rc_config_load(const char *file)
 	}
 	rc_stringlist_free(list);
 
+#ifdef __linux__
+	config = rc_config_override(config);
+#endif
+
 	return config;
 }
 librc_hidden_def(rc_config_load)



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-01-16 18:16 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2012-01-16 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     d729f9d0f2d773c3cddc2f3004364d831081f692
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 16 18:11:29 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 16 18:11:29 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=d729f9d0

style fixes

---
 src/librc/librc-misc.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index a5daa07..3b91e48 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -215,10 +215,11 @@ rc_config_list(const char *file)
 librc_hidden_def(rc_config_list)
 
 /*
- * Override some specific rc.conf options via kernel cmdline
+ * Override some specific rc.conf options on the kernel command line
  */
 #ifdef __linux__
-static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config) {
+static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config)
+{
 	RC_STRINGLIST *overrides;
 	RC_STRING *cline, *override, *config_np;
 	char *tmp = NULL;
@@ -228,7 +229,7 @@ static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config) {
 
 	overrides = rc_stringlist_new();
 
-	/* A list of variables which may be overriden through cmdline */
+	/* A list of variables which may be overridden on the kernel command line */
 	rc_stringlist_add(overrides, "rc_parallel");
 
 	TAILQ_FOREACH(override, overrides, entries) {
@@ -242,14 +243,18 @@ static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config) {
 		}
 
 		if (value != NULL) {
-			len = (varlen + strlen(value) + 2);
+			len = varlen + strlen(value) + 2;
 			tmp = xmalloc(sizeof(char) * len);
 			snprintf(tmp, len, "%s=%s", override->value, value);
 		}
 
-		/* Whenever necessary remove the old config entry first to prevent duplicates */
+		/*
+		 * Whenever necessary remove the old config entry first to prevent
+		 * duplicates
+		 */
 		TAILQ_FOREACH_SAFE(cline, config, entries, config_np) {
-			if (strncmp(override->value, cline->value, varlen) == 0 && cline->value[varlen] == '=') {
+			if (strncmp(override->value, cline->value, varlen) == 0
+				&& cline->value[varlen] == '=') {
 				rc_stringlist_delete(config, cline->value);
 				break;
 			}
@@ -261,9 +266,7 @@ static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config) {
 		free(tmp);
 		free(value);
 	}
-
 	rc_stringlist_free(overrides);
-
 	return config;
 }
 #endif



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-01-21  3:41 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2012-01-21  3:41 UTC (permalink / raw
  To: gentoo-commits

commit:     85c90f9a1d6163c97e22570b7405be78b556626c
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 21 03:38:13 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Jan 21 03:38:13 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=85c90f9a

small style fix

---
 src/librc/librc-misc.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 3b91e48..8b00e36 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -266,6 +266,7 @@ static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config)
 		free(tmp);
 		free(value);
 	}
+
 	rc_stringlist_free(overrides);
 	return config;
 }



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-01-24 18:41 Christian Ruppert
  0 siblings, 0 replies; 48+ messages in thread
From: Christian Ruppert @ 2012-01-24 18:41 UTC (permalink / raw
  To: gentoo-commits

commit:     ced60319e315f4f12418c116b8823817d20839d6
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 24 18:40:59 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=ced60319

Override rc.conf options only

---
 src/librc/librc-misc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 8b00e36..6a5f598 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -346,7 +346,10 @@ rc_config_load(const char *file)
 	rc_stringlist_free(list);
 
 #ifdef __linux__
-	config = rc_config_override(config);
+	/* Only override rc.conf settings */
+	if(strcmp(file, RC_CONF) == 0) {
+		config = rc_config_override(config);
+	}
 #endif
 
 	return config;



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-01-30 19:33 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2012-01-30 19:33 UTC (permalink / raw
  To: gentoo-commits

commit:     7da8394a8edc068e1cd2e04eaf179d1d6e1c1cb7
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 30 19:12:40 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 30 19:24:54 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=7da8394a

Complain about loading /etc/conf.d/rc

Openrc was quietly loading this file if it existed and this was causing
some issues, so now openrc loads the file and complains about it.

Hopefully the warning message will convince everyone to remove this file
and migrate the settings to @SYSCONFDIR <AT> /rc.conf where they belong.

---
 src/librc/librc-misc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 7e9a109..6e9fce6 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -392,10 +392,13 @@ rc_conf_value(const char *setting)
 		atexit(_free_rc_conf);
 #endif
 
-		/* Support old configs */
+		/* Support old configs, but complain about it. */
 		if (exists(RC_CONF_OLD)) {
 			old = rc_config_load(RC_CONF_OLD);
 			TAILQ_CONCAT(rc_conf, old, entries);
+			ewarn("Your system still has %s", RC_CONF_OLD);
+			ewarn("Please migrate to the appropriate settings in %s", RC_CONF);
+			ewarn("and delete %s.", RC_CONF_OLD);
 #ifdef DEBUG_MEMORY
 			free(old);
 #endif



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-02-25 16:57 Christian Ruppert
  0 siblings, 0 replies; 48+ messages in thread
From: Christian Ruppert @ 2012-02-25 16:57 UTC (permalink / raw
  To: gentoo-commits

commit:     de6323ba51fb8525fb1e48b0331c15daf86d5916
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 25 16:53:43 2012 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Feb 25 16:56:24 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=de6323ba

Fix rc_proc_getent() undeclared on BSD

X-Gentoo-Bug: 405713
X-Gentoo-Bug-URL: https://bugs.gentoo.org/405713
Reported-by: Dmitri Bogomolov <4glitch <AT> gmail.com>

---
 src/librc/librc.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/librc/librc.h b/src/librc/librc.h
index 54c9a1a..6d4cdc3 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -87,7 +87,9 @@ librc_hidden_proto(rc_find_pids)
 librc_hidden_proto(rc_getfile)
 librc_hidden_proto(rc_getline)
 librc_hidden_proto(rc_newer_than)
+#ifdef __linux__
 librc_hidden_proto(rc_proc_getent)
+#endif
 librc_hidden_proto(rc_older_than)
 librc_hidden_proto(rc_runlevel_exists)
 librc_hidden_proto(rc_runlevel_get)



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-02-25 21:02 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2012-02-25 21:02 UTC (permalink / raw
  To: gentoo-commits

commit:     582c8e986840158db3162a89cf85c29ec4bf7107
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 25 21:00:03 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Feb 25 21:00:03 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=582c8e98

librc: make rc_proc_getent available for all operating systems

This looks up an option on the kernel command line. For now, itworks on
linux and returns NULL on the bsds, but we are definitely open to
patches for that side.

---
 src/librc/librc-misc.c |    6 ++++--
 src/librc/librc.h      |    2 --
 src/librc/rc.h.in      |    2 --
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 6e9fce6..06f97e7 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -128,10 +128,10 @@ rc_getline(char **line, size_t *len, FILE *fp)
 }
 librc_hidden_def(rc_getline)
 
-#ifdef __linux__
 char *
 rc_proc_getent(const char *ent)
 {
+#ifdef __linux__
 	FILE *fp;
 	char *proc, *p, *value = NULL;
 	size_t i, len;
@@ -171,9 +171,11 @@ rc_proc_getent(const char *ent)
 	free(proc);
 
 	return value;
+#else
+	return NULL;
+#endif
 }
 librc_hidden_def(rc_proc_getent)
-#endif
 
 RC_STRINGLIST *
 rc_config_list(const char *file)

diff --git a/src/librc/librc.h b/src/librc/librc.h
index 6d4cdc3..54c9a1a 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -87,9 +87,7 @@ librc_hidden_proto(rc_find_pids)
 librc_hidden_proto(rc_getfile)
 librc_hidden_proto(rc_getline)
 librc_hidden_proto(rc_newer_than)
-#ifdef __linux__
 librc_hidden_proto(rc_proc_getent)
-#endif
 librc_hidden_proto(rc_older_than)
 librc_hidden_proto(rc_runlevel_exists)
 librc_hidden_proto(rc_runlevel_get)

diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 468990e..eaae25f 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -360,12 +360,10 @@ bool rc_newer_than(const char *, const char *, time_t *, char *);
  * @return true if source is older than target, otherwise false */
 bool rc_older_than(const char *, const char *, time_t *, char *);
 
-#ifdef __linux__
 /*! Read variables/values from /proc/cmdline
  * @param value
  * @return pointer to the value, otherwise NULL */
 char *rc_proc_getent(const char *);
-#endif
 
 /*! Update the cached dependency tree if it's older than any init script,
  * its configuration file or an external configuration file the init script



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2012-10-05  3:28 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2012-10-05  3:28 UTC (permalink / raw
  To: gentoo-commits

commit:     361f5ce2b82765aa38a16abaeb92c475220336d3
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Oct  5 03:01:33 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Oct  5 03:01:33 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=361f5ce2

set the RC_UNAME environment variable when updating dependencies

This is needed because the network script uses this variable in the
depend() function but it wasn't exported when this was run.

Reported-by: <aaly90 <AT> gmail.com>

---
 src/librc/librc-depend.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 5e99c1b..ac93716 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -28,6 +28,8 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/utsname.h>
+
 #include "librc.h"
 
 #define GENDEP          RC_LIBEXECDIR "/sh/gendepends.sh"
@@ -747,12 +749,15 @@ rc_deptree_update(void)
 	size_t i, k, l;
 	bool retval = true;
 	const char *sys = rc_sys();
+	struct utsname uts;
 
 	/* Some init scripts need RC_LIBEXECDIR to source stuff
 	   Ideally we should be setting our full env instead */
 	if (!getenv("RC_LIBEXECDIR"))
 		setenv("RC_LIBEXECDIR", RC_LIBEXECDIR, 0);
 
+	if (uname(&uts) == 0)
+		setenv("RC_UNAME", uts.sysname, 1);
 	/* Phase 1 - source all init scripts and print dependencies */
 	if (!(fp = popen(GENDEP, "r")))
 		return false;


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2013-04-14  3:45 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2013-04-14  3:45 UTC (permalink / raw
  To: gentoo-commits

commit:     e4668a5061de4f225d4e9d534ff6212e634e45d2
Author:     Natanael Copa <natanael.copa <AT> gmail <DOT> com>
AuthorDate: Thu Nov  8 15:51:00 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Apr  9 07:25:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=e4668a50

Fix autodetection of lxc

The /proc/1/environ contains various \0 terminated strings. The current
code will only work when the search string is in the first of those.

To fix this we look for strings in entire buffer.

Signed-off-by: Natanael Copa <ncopa <AT> alpinelinux.org>

---
 src/librc/librc.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index d82880f..40b975a 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -168,7 +168,7 @@ file_regex(const char *file, const char *regex)
 	char *line = NULL;
 	size_t len = 0;
 	regex_t re;
-	bool retval = false;
+	bool retval = true;
 	int result;
 
 	if (!(fp = fopen(file, "r")))
@@ -184,11 +184,21 @@ file_regex(const char *file, const char *regex)
 	}
 
 	while ((rc_getline(&line, &len, fp))) {
-		if (regexec(&re, line, 0, NULL, 0) == 0)
-			retval = true;
-		if (retval)
-			break;
+		char *str = line;
+		/* some /proc files have \0 separated content so we have to
+		   loop through the 'line' */
+		do {
+			if (regexec(&re, str, 0, NULL, 0) == 0)
+				goto found;
+			str += strlen(str) + 1;
+			/* len is the size of allocated buffer and we don't
+			   want call regexec BUFSIZE times. find next str */
+			while (*str == '\0' && str < line + len)
+				str++;
+		} while (str < line + len);
 	}
+	retval = false;
+found:
 	fclose(fp);
 	free(line);
 	regfree(&re);


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2013-10-04 19:07 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2013-10-04 19:07 UTC (permalink / raw
  To: gentoo-commits

commit:     03c67bcc2727a3e61a168c7dfac98a3dd49c7d79
Author:     Natanael Copa <natanael.copa <AT> gmail <DOT> com>
AuthorDate: Thu Sep 26 08:17:07 2013 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Oct  4 19:02:02 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=03c67bcc

librc: fix a read off-by-one bug

We should first check if we are within bounds and then read rather than
the opposite.

This makes valgrind happy.

Signed-off-by: Natanael Copa <ncopa <AT> alpinelinux.org>

---
 src/librc/librc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 839fcd8..cb4ce63 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -193,7 +193,7 @@ file_regex(const char *file, const char *regex)
 			str += strlen(str) + 1;
 			/* len is the size of allocated buffer and we don't
 			   want call regexec BUFSIZE times. find next str */
-			while (*str == '\0' && str < line + len)
+			while (str < line + len && *str == '\0')
 				str++;
 		} while (str < line + len);
 	}


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2013-10-04 19:07 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2013-10-04 19:07 UTC (permalink / raw
  To: gentoo-commits

commit:     681a37e7bd64a1cdc39613e7ded594dda8e98208
Author:     Natanael Copa <natanael.copa <AT> gmail <DOT> com>
AuthorDate: Thu Sep 26 07:59:29 2013 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Oct  4 19:01:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=681a37e7

librc: fix off-by-one bug

We need allocate space for both the added leading '-' and the trailing
'\0'.

Signed-off-by: Natanael Copa <ncopa <AT> alpinelinux.org>

---
 src/librc/librc-depend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index ac93716..c9df451 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -856,7 +856,7 @@ rc_deptree_update(void)
 	 * work for them. This doesn't stop them from being run directly. */
 	if (sys) {
 		len = strlen(sys);
-		nosys = xmalloc(len + 1);
+		nosys = xmalloc(len + 2);
 		nosys[0] = '-';
 		for (i = 0; i < len; i++)
 			nosys[i + 1] = (char)tolower((unsigned char)sys[i]);


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2013-10-21 19:53 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2013-10-21 19:53 UTC (permalink / raw
  To: gentoo-commits

commit:     aeb670f4e8f56bae72511b08f8b3b5fa732ce7fc
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Oct 21 19:21:22 2013 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 21 19:21:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=aeb670f4

librc: do not allow "." and ".." as runlevel names

The rc_runlevel_exists function was attempting to treat "." and ".." as
valid runlevels; however, this should not be allowed.

X-Gentoo-Bug: 488710
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=488710

---
 src/librc/librc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index cb4ce63..d7a4849 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -425,7 +425,7 @@ rc_runlevel_exists(const char *runlevel)
 	char path[PATH_MAX];
 	struct stat buf;
 
-	if (!runlevel)
+	if (!runlevel || strcmp(runlevel, ".") == 0 || strcmp(runlevel, "..") == 0)
 		return false;
 	snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel);
 	if (stat(path, &buf) == 0 && S_ISDIR(buf.st_mode))


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-06-20 21:22 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-06-20 21:22 UTC (permalink / raw
  To: gentoo-commits

commit:     9eb9b28d3e3b6725559fb38101ae869c1e4530ce
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jun 20 21:01:47 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jun 20 21:01:47 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9eb9b28d

librc: filter out container processes on OpenVZ host

Thanks to info and testing done by Daniel Robbins <drobbins <AT> funtoo.org>,
there is now a fix for this. Below is his description of the steps
OpenRC needed to use.

1) See if /proc/<pid>/status exists
2) If it does, see if it has a "envID:" field
3) If it does, see if "envID:" is set to "0"
4) If so, then it's one of the host's processes and should be a
candidate for the list. Otherwise, it is one of the container's
processes and should be ignored.

This should fix the bug and allow start-stop-daemon to work properly on
OpenVZ hosts.

X-Gentoo-Bug: 376817
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=376817

---
 src/librc/librc-daemon.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index e98b02c..a53e6e1 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -90,6 +90,11 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 {
 	DIR *procdir;
 	struct dirent *entry;
+	FILE *fp;
+	bool container_pid = false;
+	bool openvz_host = false;
+	char *line = NULL;
+	size_t len = 0;
 	pid_t p;
 	char buffer[PATH_MAX];
 	struct stat sb;
@@ -117,6 +122,26 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 			runscript_pid = 0;
 	}
 
+	/*
+	If /proc/self/status contains EnvID: 0, then we are an OpenVZ host,
+	and we will need to filter out processes that are inside containers
+	from our list of pids.
+	*/
+
+	if (exists("/proc/self/status")) {
+		fp = fopen("/proc/self/status", "r");
+		if (fp) {
+			while(! feof(fp)) {
+				rc_getline(&line, &len, fp);
+				if (strncmp(line, "envID:\t0", 8) == 0) {
+					openvz_host = true;
+					break;
+				}
+			}
+			fclose(fp);
+		}
+	}
+
 	while ((entry = readdir(procdir)) != NULL) {
 		if (sscanf(entry->d_name, "%d", &p) != 1)
 			continue;
@@ -134,6 +159,25 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 		if (argv &&
 		    !pid_is_argv(p, (const char *const *)argv))
 			continue;
+		/* If this is an OpenVZ host, filter out container processes */
+		if (openvz_host) {
+			snprintf(buffer, sizeof(buffer), "/proc/%d/status", p);
+			if (exists(buffer)) {
+				fp = fopen(buffer, "r");
+				if (! fp)
+					continue;
+				while (! feof(fp)) {
+					rc_getline(&line, &len, fp);
+					if (strncmp(line, "envID:", 6) == 0) {
+						container_pid = ! (strncmp(line, "envID:\t0", 8) == 0);
+						break;
+					}
+				}
+				fclose(fp);
+			}
+		}
+		if (container_pid)
+			continue;
 		if (!pids) {
 			pids = xmalloc(sizeof(*pids));
 			LIST_INIT(pids);
@@ -142,6 +186,8 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 		pi->pid = p;
 		LIST_INSERT_HEAD(pids, pi, entries);
 	}
+	if (line != NULL)
+		free(line);
 	closedir(procdir);
 	return pids;
 }


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-07-19 18:06 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-07-19 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     1f7582c78b2697c3f2617a4a89afabaf3550b0fb
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Jul 19 18:03:00 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Jul 19 18:03:00 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=1f7582c7

src/librc/librc-daemon.c: style fix

---
 src/librc/librc-daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index a53e6e1..8793075 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -131,7 +131,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 	if (exists("/proc/self/status")) {
 		fp = fopen("/proc/self/status", "r");
 		if (fp) {
-			while(! feof(fp)) {
+			while (! feof(fp)) {
 				rc_getline(&line, &len, fp);
 				if (strncmp(line, "envID:\t0", 8) == 0) {
 					openvz_host = true;


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-10-20 20:59 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-10-20 20:59 UTC (permalink / raw
  To: gentoo-commits

commit:     f9acd65497c6e561fbf5420386a99d681fede859
Author:     Alexander Vershilov <alexander.vershilov <AT> gmail <DOT> com>
AuthorDate: Mon Oct 20 00:41:36 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 20:44:19 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f9acd654

librc:look for the pid file in a chroot if defined

X-Gentoo-Bug: 524388
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524388

---
 src/librc/librc-daemon.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 8793075..04f25b1 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -553,16 +553,28 @@ rc_service_daemons_crashed(const char *service)
 		}
 		fclose(fp);
 
+		char *ch_root = rc_service_value_get(basename_c(service), "chroot");
+		char *spidfile = pidfile;
+		if (ch_root) {
+			spidfile = malloc(strlen(ch_root) + strlen(pidfile));
+			strcpy(spidfile, ch_root);
+			strcat(spidfile, pidfile);
+		}
+
 		pid = 0;
-		if (pidfile) {
+		if (spidfile) {
 			retval = true;
-			if ((fp = fopen(pidfile, "r"))) {
+			if ((fp = fopen(spidfile, "r"))) {
 				if (fscanf(fp, "%d", &pid) == 1)
 					retval = false;
 				fclose(fp);
 			}
-			free(pidfile);
-			pidfile = NULL;
+			free(spidfile);
+			spidfile = NULL;
+			if (ch_root) {
+				free(pidfile);
+				pidfile = NULL;
+			}
 
 			/* We have the pid, so no need to match
 			   on exec or name */


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-10-23 17:57 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-10-23 17:57 UTC (permalink / raw
  To: gentoo-commits

commit:     89c8a62a1078e770e12c47f06c8dbc9c2924e771
Author:     Gabriele Giacone <1o5g4r8o <AT> gmail <DOT> com>
AuthorDate: Wed Oct 22 02:17:52 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Oct 22 18:27:37 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=89c8a62a

Fix rc_svcdir for GNU/kFreeBSD

---
 src/librc/rc.h.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 5ef8d7f..8f0e889 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -42,7 +42,7 @@ extern "C" {
 #define RC_LIBEXECDIR           "@LIBEXECDIR@"
 #if defined(PREFIX)
 #define RC_SVCDIR               RC_LIBEXECDIR "/init.d"
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD_kernel__)
 #define RC_SVCDIR               "/run/openrc"
 #else
 #define RC_SVCDIR               RC_LIBEXECDIR "/init.d"


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-10-23 19:13 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-10-23 19:13 UTC (permalink / raw
  To: gentoo-commits

commit:     4ac289b5397a688393c596a9a01651c94d3b5711
Author:     Gabriele Giacone <1o5g4r8o <AT> gmail <DOT> com>
AuthorDate: Wed Oct 22 20:02:51 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 23 18:05:08 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=4ac289b5

Fix rc_svcdir for GNU/Hurd

---
 src/librc/rc.h.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 8f0e889..34f09f2 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -42,7 +42,7 @@ extern "C" {
 #define RC_LIBEXECDIR           "@LIBEXECDIR@"
 #if defined(PREFIX)
 #define RC_SVCDIR               RC_LIBEXECDIR "/init.d"
-#elif defined(__linux__) || defined(__FreeBSD_kernel__)
+#elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
 #define RC_SVCDIR               "/run/openrc"
 #else
 #define RC_SVCDIR               RC_LIBEXECDIR "/init.d"


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-10-24 15:45 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-10-24 15:45 UTC (permalink / raw
  To: gentoo-commits

commit:     7700e6fe796cabfa22eefddc024d66257a28d4dc
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Oct 24 15:44:14 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Oct 24 15:44:14 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=7700e6fe

Fix compile errors created by bundling queue.h

---
 src/librc/rc.h.in | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 62119e9..58d8eb5 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -77,6 +77,51 @@ extern "C" {
 #  define RC_LOCAL_CONFDIR      RC_LOCAL_PREFIX "/etc/conf.d"
 #endif
 
+#ifndef _SYS_QUEUE_H_
+
+/*
+ * The following are copied directly from our imported queue.h.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ TAILQ_END(head), &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+#endif /* _SYS_QUEUE_H_ */
+
 /* A doubly linked list using queue(3) for ease of use */
 typedef struct rc_string {
 	char *value;


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2014-11-01 22:05 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2014-11-01 22:05 UTC (permalink / raw
  To: gentoo-commits

commit:     be952bebb3647069fb93b9791ee3439698f697ca
Author:     Alexander Vershilov <alexander.vershilov <AT> gmail <DOT> com>
AuthorDate: Wed Oct 29 20:16:35 2014 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Nov  1 21:44:30 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=be952beb

Fix incorrect handling of chroot option.
Fixes #28.

X-Gentoo-Bug: #527370
X-Gentoo-Bug-Url: https://bugs.gentoo.org/show_bug.cgi?id=527370

---
 src/librc/librc-daemon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 190a014..02aff5a 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -556,8 +556,8 @@ rc_service_daemons_crashed(const char *service)
 
 		char *ch_root = rc_service_value_get(basename_c(service), "chroot");
 		char *spidfile = pidfile;
-		if (ch_root) {
-			spidfile = malloc(strlen(ch_root) + strlen(pidfile));
+		if (ch_root && pidfile) {
+			spidfile = xmalloc(strlen(ch_root) + strlen(pidfile) + 1);
 			strcpy(spidfile, ch_root);
 			strcat(spidfile, pidfile);
 		}


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2015-01-12 16:44 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2015-01-12 16:44 UTC (permalink / raw
  To: gentoo-commits

commit:     74478830a8d035c078e986b57efd40a5c48bc896
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jan 12 15:10:29 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 12 16:30:36 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=74478830

fix double free of pidfile

This fixes a double free of the pidfile variable. For discussion of this
issue, see the bug.

X-Gentoo-Bug: 531600
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=531600

---
 src/librc/librc-daemon.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 02aff5a..76fdd7b 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -560,22 +560,20 @@ rc_service_daemons_crashed(const char *service)
 			spidfile = xmalloc(strlen(ch_root) + strlen(pidfile) + 1);
 			strcpy(spidfile, ch_root);
 			strcat(spidfile, pidfile);
+			free(pidfile);
+			pidfile = spidfile;
 		}
 
 		pid = 0;
-		if (spidfile) {
+		if (pidfile) {
 			retval = true;
-			if ((fp = fopen(spidfile, "r"))) {
+			if ((fp = fopen(pidfile, "r"))) {
 				if (fscanf(fp, "%d", &pid) == 1)
 					retval = false;
 				fclose(fp);
 			}
-			free(spidfile);
-			spidfile = NULL;
-			if (ch_root) {
-				free(pidfile);
-				pidfile = NULL;
-			}
+			free(pidfile);
+			pidfile = NULL;
 
 			/* We have the pid, so no need to match
 			   on exec or name */


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2015-05-04 15:10 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2015-05-04 15:10 UTC (permalink / raw
  To: gentoo-commits

commit:     0b435ddd834bd18254c4d3341acdebf0829921f5
Author:     Jakob Drexel <jake42 <AT> rommel <DOT> stw <DOT> uni-erlangen <DOT> de>
AuthorDate: Sun May  3 09:06:45 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May  4 14:54:51 2015 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0b435ddd

librc: Fix crash if the service name is the same as the including runlevel

If a service has the same name as the runlevel it is in, openrc will
crash on changing to such runlevel. It goes in a recursive madness and
eventually gets a SEGV while in snprintf (don't know why).

This fixes two errors:
1. ls_dir stats files not with full path -> stat always returns != 0
2. ls_dir adds files to list if stat failed

This fixes #53.

X-Gentoo-Bug: 537304
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=537304

 src/librc/librc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 03448e7..8f04313 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -101,7 +101,9 @@ ls_dir(const char *dir, int options)
 					continue;
 			}
 			if (options & LS_DIR) {
-				if (stat(d->d_name, &buf) == 0 &&
+				snprintf(file, sizeof(file), "%s/%s",
+				    dir, d->d_name);
+				if (stat(file, &buf) != 0 ||
 				    !S_ISDIR(buf.st_mode))
 					continue;
 			}


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2015-11-05 18:53 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2015-11-05 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     591aea28215a8b5ad8660184dc6f6f15ff0c18b4
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Nov  5 15:29:33 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov  5 17:20:57 2015 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=591aea28

librc: Remove redundant code from rc_config_load

 src/librc/librc-misc.c | 61 +-------------------------------------------------
 1 file changed, 1 insertion(+), 60 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 1eedc96..2c73663 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -378,71 +378,12 @@ rc_config_load(const char *file)
 {
 	RC_STRINGLIST *list;
 	RC_STRINGLIST *config;
-	char *token;
 	RC_STRING *line;
-	RC_STRING *cline;
-	size_t i = 0;
-	bool replaced;
-	char *entry;
-	char *newline;
-	char *p;
 
 	list = rc_config_list(file);
 	config = rc_stringlist_new();
 	TAILQ_FOREACH(line, list, entries) {
-		/* Get entry */
-		p = line->value;
-		if (! p)
-			continue;
-		if (strncmp(p, "export ", 7) == 0)
-			p += 7;
-		if (! (token = strsep(&p, "=")))
-			continue;
-
-		entry = xstrdup(token);
-		/* Preserve shell coloring */
-		if (*p == '$')
-			token = line->value;
-		else
-			do {
-				/* Bash variables are usually quoted */
-				token = strsep(&p, "\"\'");
-			} while (token && *token == '\0');
-
-		/* Drop a newline if that's all we have */
-		if (token) {
-			i = strlen(token) - 1;
-			if (token[i] == '\n')
-				token[i] = 0;
-
-			i = strlen(entry) + strlen(token) + 2;
-			newline = xmalloc(sizeof(char) * i);
-			snprintf(newline, i, "%s=%s", entry, token);
-		} else {
-			i = strlen(entry) + 2;
-			newline = xmalloc(sizeof(char) * i);
-			snprintf(newline, i, "%s=", entry);
-		}
-
-		replaced = false;
-		/* In shells the last item takes precedence, so we need to remove
-		   any prior values we may already have */
-		TAILQ_FOREACH(cline, config, entries) {
-			i = strlen(entry);
-			if (strncmp(entry, cline->value, i) == 0 && cline->value[i] == '=') {
-				/* We have a match now - to save time we directly replace it */
-				free(cline->value);
-				cline->value = newline;
-				replaced = true;
-				break;
-			}
-		}
-
-		if (!replaced) {
-			rc_stringlist_add(config, newline);
-			free(newline);
-		}
-		free(entry);
+		rc_config_set_value(config, line->value);
 	}
 	rc_stringlist_free(list);
 


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2015-11-05 18:53 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2015-11-05 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     c831f1f994e187afd8edfff15e4063b99440bbcb
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Nov  5 17:08:29 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov  5 17:20:57 2015 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c831f1f9

librc: rework overriding rc.conf options from the kcl

Rename the rc_conf_override function to describe its purpose better,
drop one conditional compile by making it available everywhere, and move
the call to it after the optional rc.conf.d directory is processed.

 src/librc/librc-misc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 2c73663..98e6f20 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -280,11 +280,14 @@ static void rc_config_set_value(RC_STRINGLIST *config, char *value)
 }
 
 /*
- * Override some specific rc.conf options on the kernel command line
+ * Override some specific rc.conf options on the kernel command line.
+ * I only know how to do this in Linux, so if someone wants to supply
+ * a patch for this on *BSD or tell me how to write the code to do this,
+ * any suggestions are welcome.
  */
-#ifdef __linux__
-static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config)
+static RC_STRINGLIST *rc_config_kcl(RC_STRINGLIST *config)
 {
+#ifdef __linux__
 	RC_STRINGLIST *overrides;
 	RC_STRING *cline, *override, *config_np;
 	char *tmp = NULL;
@@ -333,9 +336,9 @@ static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config)
 	}
 
 	rc_stringlist_free(overrides);
+#endif
 	return config;
 }
-#endif
 
 static RC_STRINGLIST * rc_config_directory(RC_STRINGLIST *config)
 {
@@ -387,13 +390,6 @@ rc_config_load(const char *file)
 	}
 	rc_stringlist_free(list);
 
-#ifdef __linux__
-	/* Only override rc.conf settings */
-	if (strcmp(file, RC_CONF) == 0) {
-		config = rc_config_override(config);
-	}
-#endif
-
 	return config;
 }
 librc_hidden_def(rc_config_load)
@@ -444,6 +440,7 @@ rc_conf_value(const char *setting)
 		}
 
 		rc_conf = rc_config_directory(rc_conf);
+	rc_conf = rc_config_kcl(rc_conf);
 
 		/* Convert old uppercase to lowercase */
 		TAILQ_FOREACH(s, rc_conf, entries) {


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2015-12-08 18:53 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2015-12-08 18:53 UTC (permalink / raw
  To: gentoo-commits

commit:     f9bdb072e8d88079a20834fe921d43e326a9a18a
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Dec  8 18:50:47 2015 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Dec  8 18:50:47 2015 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f9bdb072

rc.map: remove references to rc_sys_v{1,2}

 src/librc/rc.map | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/librc/rc.map b/src/librc/rc.map
index 2aa58de..0012d8a 100644
--- a/src/librc/rc.map
+++ b/src/librc/rc.map
@@ -59,8 +59,6 @@ global:
 	rc_stringlist_sort;
 	rc_stringlist_free;
 	rc_sys;
-	rc_sys_v1;
-	rc_sys_v2;
 	rc_yesno;
 
 local:


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2016-01-19  6:12 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2016-01-19  6:12 UTC (permalink / raw
  To: gentoo-commits

commit:     4c814a0a285565bc09d662f602f93dbb938503c6
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jan 18 06:39:11 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=4c814a0a

librc: handle rc_sys="prefix" even if we weren't built with a prefix

This probably isn't needed, but it mimics old behavior.

 src/librc/librc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 8b4e8d4..3e1f0d8 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -220,6 +220,13 @@ detect_prefix(const char *systype)
 #ifdef PREFIX
 	return RC_SYS_PREFIX;
 #else
+	if (systype) {
+		if (strcmp(systype, RC_SYS_NONE) == 0)
+			return NULL;
+		if (strcmp(systype, RC_SYS_PREFIX) == 0)
+			return RC_SYS_PREFIX;
+	}
+
 	return NULL;
 #endif
 }


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2016-01-19  6:12 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2016-01-19  6:12 UTC (permalink / raw
  To: gentoo-commits

commit:     6c0942137572608d02eb4b34bad55c9bf418a6ba
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Jan 19 05:40:03 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Jan 19 05:40:03 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6c094213

Revert "librc: fix librc-depend functions to call rc_sys"

This reverts commit 73482cf13a338051606788957cbd0031ac850c70.

 src/librc/librc-depend.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index d64b2b2..991a871 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -740,7 +740,7 @@ rc_deptree_update(void)
 	char *depend, *depends, *service, *type, *nosys, *onosys;
 	size_t i, k, l;
 	bool retval = true;
-	const char *sys = rc_sys();
+	const char *sys = NULL;
 	struct utsname uts;
 
 	/* Some init scripts need RC_LIBEXECDIR to source stuff
@@ -847,6 +847,9 @@ rc_deptree_update(void)
 
 	/* Phase 2 - if we're a special system, remove services that don't
 	 * work for them. This doesn't stop them from being run directly. */
+	sys = detect_container();
+		if (!sys)
+			sys = detect_vm();
 	if (sys) {
 		len = strlen(sys);
 		nosys = xmalloc(len + 2);


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2016-01-19  6:12 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2016-01-19  6:12 UTC (permalink / raw
  To: gentoo-commits

commit:     36dde4e7f21afba36a96837aa86f2b5d2dae3807
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Jan 18 06:05:22 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=36dde4e7

librc: fix handling the nothing special case for rc_sys

 src/librc/librc.c | 15 +++++++++++++--
 src/librc/rc.h.in |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 5cf4898..8b4e8d4 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -228,8 +228,13 @@ static const char *
 detect_container(const char *systype)
 {
 #ifdef __FreeBSD__
-	if (systype && strcmp(systype, RC_SYS_JAIL) == 0)
-		return RC_SYS_JAIL;
+	if (systype) {
+		if (strcmp(systype, RC_SYS_NONE) == 0)
+		       return NULL;
+		if (strcmp(systype, RC_SYS_JAIL) == 0)
+			return RC_SYS_JAIL;
+	}
+
 	int jailed = 0;
 	size_t len = sizeof(jailed);
 
@@ -240,6 +245,8 @@ detect_container(const char *systype)
 
 #ifdef __linux__
 	if (systype) {
+		if (strcmp(systype, RC_SYS_NONE) == 0)
+			return NULL;
 		if (strcmp(systype, RC_SYS_UML) == 0)
 			return RC_SYS_UML;
 		if (strcmp(systype, RC_SYS_VSERVER) == 0)
@@ -283,6 +290,8 @@ detect_vm(const char *systype)
 {
 #ifdef __NetBSD__
 	if (systype) {
+		if (strcmp(systype, RC_SYS_NONE) == 0)
+			return NULL;
 		if (strcmp(systype, RC_SYS_XEN0) == 0)
 			return RC_SYS_XEN0;
 		if (strcmp(systype, RC_SYS_XENU) == 0)
@@ -296,6 +305,8 @@ detect_vm(const char *systype)
 
 #ifdef __linux__
 	if (systype) {
+		if (strcmp(systype, RC_SYS_NONE) == 0)
+			return NULL;
 		if (strcmp(systype, RC_SYS_XEN0) == 0)
 			return RC_SYS_XEN0;
 		if (strcmp(systype, RC_SYS_XENU) == 0)

diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 55fbc44..92ecbb4 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -318,6 +318,7 @@ bool rc_service_daemons_crashed(const char *);
  * Some services cannot work in these systems, or we do something else. */
 #define RC_SYS_DOCKER  "DOCKER"
 #define RC_SYS_JAIL    "JAIL"
+#define RC_SYS_NONE    ""
 #define RC_SYS_OPENVZ  "OPENVZ"
 #define RC_SYS_LXC     "LXC"
 #define RC_SYS_PREFIX  "PREFIX"


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2016-01-19  6:12 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2016-01-19  6:12 UTC (permalink / raw
  To: gentoo-commits

commit:     73482cf13a338051606788957cbd0031ac850c70
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Jan 18 21:09:31 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 21:09:31 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=73482cf1

librc: fix librc-depend functions to call rc_sys

 src/librc/librc-depend.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 991a871..d64b2b2 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -740,7 +740,7 @@ rc_deptree_update(void)
 	char *depend, *depends, *service, *type, *nosys, *onosys;
 	size_t i, k, l;
 	bool retval = true;
-	const char *sys = NULL;
+	const char *sys = rc_sys();
 	struct utsname uts;
 
 	/* Some init scripts need RC_LIBEXECDIR to source stuff
@@ -847,9 +847,6 @@ rc_deptree_update(void)
 
 	/* Phase 2 - if we're a special system, remove services that don't
 	 * work for them. This doesn't stop them from being run directly. */
-	sys = detect_container();
-		if (!sys)
-			sys = detect_vm();
 	if (sys) {
 		len = strlen(sys);
 		nosys = xmalloc(len + 2);


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2016-08-15 18:48 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2016-08-15 18:48 UTC (permalink / raw
  To: gentoo-commits

commit:     ca8c29ee60b0e8ca89091aaf801725bd71e28001
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Jul 31 17:24:56 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jul 31 17:24:56 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ca8c29ee

librc: fix Docker auto detection

The original auto detection of Docker containers assumed the presence of
a container environment variable. However, Docker-1.12 does not
implement this, and I'm not sure which versions of docker implemented
it.

The new test is for the presence of a file named .dockerenv in the
root directory.

 src/librc/librc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 3e1f0d8..fdde3d5 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -285,6 +285,9 @@ detect_container(const char *systype)
 		return RC_SYS_RKT;
 	else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
 		return RC_SYS_SYSTEMD_NSPAWN;
+	else if (exists("/.dockerenv"))
+		return RC_SYS_DOCKER;
+	/* old test, I'm not sure when this was valid. */
 	else if (file_regex("/proc/1/environ", "container=docker"))
 		return RC_SYS_DOCKER;
 #endif


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2016-12-20  0:29 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2016-12-20  0:29 UTC (permalink / raw
  To: gentoo-commits

commit:     45aa36cc623eeeb15fb6827b57e0c07a37cdef41
Author:     Doug Freed <dwfreed <AT> mtu <DOT> edu>
AuthorDate: Mon Dec 19 00:43:27 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Dec 20 00:24:31 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=45aa36cc

librc: detect loops in stacked runlevels and abort

This fixes #109.
X-Gentoo-Bug: 558700
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=558700

 src/librc/librc.c | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index fdde3d5..3d3277d 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -367,11 +367,12 @@ rc_parse_service_state(RC_SERVICE state)
  * specified runlevel in dependency order, including the
  * specified runlevel. */
 static void
-get_runlevel_chain(const char *runlevel, RC_STRINGLIST *level_list)
+get_runlevel_chain(const char *runlevel, RC_STRINGLIST *level_list, RC_STRINGLIST *ancestor_list)
 {
 	char path[PATH_MAX];
 	RC_STRINGLIST *dirs;
-	RC_STRING *d, *dn;
+	RC_STRING *d, *parent;
+	const char *nextlevel;
 
 	/*
 	 * If we haven't been passed a runlevel or a level list, or
@@ -395,8 +396,27 @@ get_runlevel_chain(const char *runlevel, RC_STRINGLIST *level_list)
 	 */
 	snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel);
 	dirs = ls_dir(path, LS_DIR);
-	TAILQ_FOREACH_SAFE(d, dirs, entries, dn)
-		get_runlevel_chain(d->value, level_list);
+	TAILQ_FOREACH(d, dirs, entries) {
+		nextlevel = d->value;
+
+		/* Check for loop */
+		if (rc_stringlist_find(ancestor_list, nextlevel)) {
+			fprintf(stderr, "Loop detected in stacked runlevels attempting to enter runlevel %s!\n",
+			    nextlevel);
+			fprintf(stderr, "Ancestors:\n");
+			TAILQ_FOREACH(parent, ancestor_list, entries)
+				fprintf(stderr, "\t%s\n", parent->value);
+			exit(1);
+		}
+
+		/* Add new ancestor */
+		rc_stringlist_add(ancestor_list, nextlevel);
+
+		get_runlevel_chain(nextlevel, level_list, ancestor_list);
+
+		rc_stringlist_delete(ancestor_list, nextlevel);
+	}
+	rc_stringlist_free(dirs);
 }
 
 bool
@@ -500,9 +520,12 @@ librc_hidden_def(rc_runlevel_unstack)
 RC_STRINGLIST *
 rc_runlevel_stacks(const char *runlevel)
 {
-	RC_STRINGLIST *stack;
+	RC_STRINGLIST *stack, *ancestor_list;
 	stack = rc_stringlist_new();
-	get_runlevel_chain(runlevel, stack);
+	ancestor_list = rc_stringlist_new();
+	rc_stringlist_add(ancestor_list, runlevel);
+	get_runlevel_chain(runlevel, stack, ancestor_list);
+	rc_stringlist_free(ancestor_list);
 	return stack;
 }
 librc_hidden_def(rc_runlevel_stacks)


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2017-10-24 15:43 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2017-10-24 15:43 UTC (permalink / raw
  To: gentoo-commits

commit:     f5acc66db7d1a0bfad6a40eefc0240b80f52df94
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Oct 24 15:37:01 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Oct 24 15:37:37 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=f5acc66d

rc_find_pids: ignore pids that are not in our pid namespace

X-Gentoo-Bug: 634634
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=634634

 src/librc/librc-daemon.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 56aaa91b..916cc142 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -80,9 +80,12 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 	DIR *procdir;
 	struct dirent *entry;
 	FILE *fp;
+	int rc;
 	bool container_pid = false;
 	bool openvz_host = false;
 	char *line = NULL;
+	char my_ns[30];
+	char proc_ns[30];
 	size_t len = 0;
 	pid_t p;
 	char buffer[PATH_MAX];
@@ -131,6 +134,14 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 		}
 	}
 
+	memset(my_ns, 0, sizeof(my_ns));
+	memset(proc_ns, 0, sizeof(proc_ns));
+	if (exists("/proc/self/ns/pid")) {
+		rc = readlink("/proc/self/ns/pid", my_ns, sizeof(my_ns));
+		if (rc <= 0)
+			my_ns[0] = '\0';
+	}
+
 	while ((entry = readdir(procdir)) != NULL) {
 		if (sscanf(entry->d_name, "%d", &p) != 1)
 			continue;
@@ -138,6 +149,14 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 			continue;
 		if (pid != 0 && pid != p)
 			continue;
+		snprintf(buffer, sizeof(buffer), "/proc/%d/ns/pid", p);
+		if (exists(buffer)) {
+			rc = readlink(buffer, proc_ns, sizeof(proc_ns));
+			if (rc <= 0)
+				proc_ns[0] = '\0';
+		}
+		if (strcmp(my_ns, proc_ns))
+			continue;
 		if (uid) {
 			snprintf(buffer, sizeof(buffer), "/proc/%d", p);
 			if (stat(buffer, &sb) != 0 || sb.st_uid != uid)


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2017-10-26 18:58 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2017-10-26 18:58 UTC (permalink / raw
  To: gentoo-commits

commit:     cf429ee359356d736c818e8b35db8fca887e7332
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 26 17:54:37 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 17:54:37 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=cf429ee3

rc_service_value_set: remove the option if NULL is the value

This allows the equivalent of "unsetting" a value for a service.

 src/librc/librc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 84c76b5a..ee65b00a 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -894,12 +894,15 @@ rc_service_value_set(const char *service, const char *option,
 		return false;
 
 	snprintf(p, sizeof(file) - (p - file), "/%s", option);
-	if (!(fp = fopen(file, "w")))
-		return false;
-	if (value)
+	if (value) {
+		if (!(fp = fopen(file, "w")))
+			return false;
 		fprintf(fp, "%s", value);
-	fclose(fp);
-	return true;
+		fclose(fp);
+	} else {
+		unlink(file);
+	}
+		return true;
 }
 librc_hidden_def(rc_service_value_set)
 


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2017-11-14 19:22 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2017-11-14 19:22 UTC (permalink / raw
  To: gentoo-commits

commit:     971e82784cd1ad8f9a286ee792e6417359972976
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Nov 13 22:54:57 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Nov 13 22:54:57 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=971e8278

rc_find_pids: namespace fix

Ignore namespaces if there are errors reading either the pid namespace
for the current process or the process we aare testing.

This fixes https://github.com/openrc/openrc/issues/180.

 src/librc/librc-daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 916cc142..a40150a6 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -155,7 +155,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 			if (rc <= 0)
 				proc_ns[0] = '\0';
 		}
-		if (strcmp(my_ns, proc_ns))
+		if (strlen(my_ns) && strlen (proc_ns) && strcmp(my_ns, proc_ns))
 			continue;
 		if (uid) {
 			snprintf(buffer, sizeof(buffer), "/proc/%d", p);


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2017-11-30 19:58 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2017-11-30 19:58 UTC (permalink / raw
  To: gentoo-commits

commit:     a7c99506d9de81b9a2a7547bd11715073de1ce95
Author:     Will Miles <wmiles <AT> sgl <DOT> com>
AuthorDate: Thu Aug 24 01:53:16 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov 30 19:56:54 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a7c99506

Fix repeated dependency cache rebuild if clock skewed

rc_deptree_update_needed would return early as soon as it found
any file newer than the existing dependency cache.  Unfortunately,
the first file found may not be the newest one there; so the
clock skew workaround in rc-misc:_rc_deptree_load would be given
a timestamp that was still too old.

This fix forces a full scan of all relevant files, so as to
ensure that we return a timestamp that will allow the clock skew
fix to operate.   The runtime cost is no worse than the case where
the cache is up to date (ie. we must check every possible file).

This fixes #161.

 src/librc/librc-depend.c | 123 +++++++++++++++++++++++++++--------------------
 1 file changed, 71 insertions(+), 52 deletions(-)

diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 1c993998..37f0b60d 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -542,52 +542,41 @@ rc_deptree_order(const RC_DEPTREE *deptree, const char *runlevel, int options)
 }
 librc_hidden_def(rc_deptree_order)
 
+
+/* Given a time, recurse the target path to find out if there are
+   any older (or newer) files.   If false, sets the time to the
+   oldest (or newest) found.
+*/
 static bool
-mtime_check(const char *source, const char *target, bool newer,
+deep_mtime_check(const char *target, bool newer,
 	    time_t *rel, char *file)
 {
 	struct stat buf;
-	time_t mtime;
 	bool retval = true;
 	DIR *dp;
 	struct dirent *d;
 	char path[PATH_MAX];
 	int serrno = errno;
 
-	/* We have to exist */
-	if (stat(source, &buf) != 0)
-		return false;
-	mtime = buf.st_mtime;
-
 	/* If target does not exist, return true to mimic shell test */
 	if (stat(target, &buf) != 0)
 		return true;
 
 	if (newer) {
-		if (mtime < buf.st_mtime) {
-			if (rel == NULL)
-				return false;
+		if (*rel < buf.st_mtime) {
 			retval = false;
-		}
-		if (rel != NULL) {
-			if (*rel < buf.st_mtime) {
-				if (file)
-					strlcpy(file, target, PATH_MAX);
-				*rel = buf.st_mtime;
-			}
+
+			if (file)
+				strlcpy(file, target, PATH_MAX);
+			*rel = buf.st_mtime;
 		}
 	} else {
-		if (mtime > buf.st_mtime) {
-			if (rel == NULL)
-				return false;
+		if (*rel > buf.st_mtime) {
 			retval = false;
-		}
-		if (rel != NULL) {
-			if (*rel > buf.st_mtime) {
-				if (file)
-					strlcpy(file, target, PATH_MAX);
-				*rel = buf.st_mtime;
-			}
+
+			if (file)
+				strlcpy(file, target, PATH_MAX);
+			*rel = buf.st_mtime;
 		}
 	}
 
@@ -602,16 +591,38 @@ mtime_check(const char *source, const char *target, bool newer,
 		if (d->d_name[0] == '.')
 			continue;
 		snprintf(path, sizeof(path), "%s/%s", target, d->d_name);
-		if (!mtime_check(source, path, newer, rel, file)) {
+		if (!deep_mtime_check(path, newer, rel, file)) {
 			retval = false;
-			if (rel == NULL)
-				break;
 		}
 	}
 	closedir(dp);
 	return retval;
 }
 
+/* Recursively check if target is older/newer than source.
+ * If false, return the filename and most different time (if
+ * the return value arguments are non-null).
+ */
+static bool
+mtime_check(const char *source, const char *target, bool newer,
+	    time_t *rel, char *file)
+{
+	struct stat buf;
+	time_t mtime;
+	bool retval = true;
+
+	/* We have to exist */
+	if (stat(source, &buf) != 0)
+		return false;
+	mtime = buf.st_mtime;
+
+    retval = deep_mtime_check(target,newer,&mtime,file);
+    if (rel) {
+        *rel = mtime;
+    }
+    return retval;
+}
+
 bool
 rc_newer_than(const char *source, const char *target,
 	      time_t *newest, char *file)
@@ -670,6 +681,8 @@ rc_deptree_update_needed(time_t *newest, char *file)
 	RC_STRINGLIST *config;
 	RC_STRING *s;
 	int i;
+	struct stat buf;
+	time_t mtime;
 
 	/* Create base directories if needed */
 	for (i = 0; depdirs[i]; i++)
@@ -677,42 +690,48 @@ rc_deptree_update_needed(time_t *newest, char *file)
 			fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror(errno));
 
 	/* Quick test to see if anything we use has changed and we have
-	 * data in our deptree */
-	if (!existss(RC_DEPTREE_CACHE))
-		return true;
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_INITDIR, newest, file))
-		return true;
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_CONFDIR, newest, file))
-		return true;
+	 * data in our deptree. */
+
+	if (stat(RC_DEPTREE_CACHE, &buf) == 0) {
+		mtime = buf.st_mtime;
+	} else {
+		/* No previous cache found.
+		 * We still run the scan, in case of clock skew; we still need to return
+		 * the newest time.
+		 */
+		newer = true;
+		mtime = time(NULL);
+	}
+
+	newer |= !deep_mtime_check(RC_INITDIR,true,&mtime,file);
+	newer |= !deep_mtime_check(RC_CONFDIR,true,&mtime,file);
 #ifdef RC_PKG_INITDIR
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_PKG_INITDIR, newest, file))
-		return true;
+    newer |= !deep_mtime_check(RC_PKG_INITDIR,true,&mtime,file);
 #endif
 #ifdef RC_PKG_CONFDIR
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_PKG_CONFDIR, newest, file))
-		return true;
+    newer |= !deep_mtime_check(RC_PKG_CONFDIR,true,&mtime,file);
 #endif
-#ifdef RC_LOCAL_INITDIR
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_INITDIR, newest, file))
-		return true;
+#ifdef RC_LOCAL_INITDIRs
+    newer |= !deep_mtime_check(RC_LOCAL_INITDIR,true,&mtime,file);
 #endif
 #ifdef RC_LOCAL_CONFDIR
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_LOCAL_CONFDIR, newest, file))
-		return true;
+    newer |= !deep_mtime_check(RC_LOCAL_CONFDIR,true,&mtime,file);
 #endif
-	if (!rc_newer_than(RC_DEPTREE_CACHE, RC_CONF, newest, file))
-		return true;
+    newer |= !deep_mtime_check(RC_CONF,true,&mtime,file);
 
 	/* Some init scripts dependencies change depending on config files
 	 * outside of baselayout, like syslog-ng, so we check those too. */
 	config = rc_config_list(RC_DEPCONFIG);
 	TAILQ_FOREACH(s, config, entries) {
-		if (!rc_newer_than(RC_DEPTREE_CACHE, s->value, newest, file)) {
-			newer = true;
-			break;
-		}
+		newer |= !deep_mtime_check(s->value, true, &mtime, file);
 	}
 	rc_stringlist_free(config);
+
+	/* Return newest file time, if requested */
+	if ((newer) && (newest != NULL)) {
+	    *newest = mtime;
+	}
+
 	return newer;
 }
 librc_hidden_def(rc_deptree_update_needed)


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2018-05-22 22:12 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2018-05-22 22:12 UTC (permalink / raw
  To: gentoo-commits

commit:     4e0eace837287845504c9895429dc9f64872d075
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu May 17 22:42:14 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 22 17:19:22 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4e0eace8

librc: Add crashed state

 src/librc/librc.c | 1 +
 src/librc/rc.h.in | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index ee65b00a..4473a1bb 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -50,6 +50,7 @@ static const rc_service_state_name_t rc_service_state_names[] = {
 	{ RC_SERVICE_HOTPLUGGED,  "hotplugged" },
 	{ RC_SERVICE_FAILED,      "failed" },
 	{ RC_SERVICE_SCHEDULED,   "scheduled"},
+	{ RC_SERVICE_CRASHED,     "crashed"},
 	{ 0, NULL}
 };
 

diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 1f984d52..d2e51dc6 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -188,7 +188,8 @@ typedef enum
 	/* Optional states service could also be in */
 	RC_SERVICE_FAILED      = 0x0200,
 	RC_SERVICE_SCHEDULED   = 0x0400,
-	RC_SERVICE_WASINACTIVE = 0x0800
+	RC_SERVICE_WASINACTIVE = 0x0800,
+	RC_SERVICE_CRASHED     = 0x1000,
 } RC_SERVICE;
 
 /*! Add the service to the runlevel


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2018-05-22 22:12 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2018-05-22 22:12 UTC (permalink / raw
  To: gentoo-commits

commit:     37e29442721af0dc3846e87ef2b85a474af3cf2b
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri May 18 23:28:07 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 22 17:19:41 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=37e29442

librc: Add check for crashed state

In rc_service_state,, call rc_service_daemons_crashed to check for
a crashed daemon if the service is started.

 src/librc/librc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 4473a1bb..01bfac03 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -849,6 +849,10 @@ rc_service_state(const char *service)
 		}
 	}
 
+	if (state & RC_SERVICE_STARTED) {
+		if (rc_service_daemons_crashed(service))
+			state |= RC_SERVICE_CRASHED;
+	}
 	if (state & RC_SERVICE_STOPPED) {
 		dirs = ls_dir(RC_SVCDIR "/scheduled", 0);
 		TAILQ_FOREACH(dir, dirs, entries) {


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2018-06-20 22:45 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2018-06-20 22:45 UTC (permalink / raw
  To: gentoo-commits

commit:     b2f5531194e33c229462e9f52fa1d9388463f7b7
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jun 20 22:45:01 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jun 20 22:45:01 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b2f55311

librc-misc: convert snprintf calls to xasprintf

 src/librc/librc-misc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 9d514bcd..178768c5 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -237,13 +237,9 @@ static void rc_config_set_value(RC_STRINGLIST *config, char *value)
 		if (token[i] == '\n')
 			token[i] = 0;
 
-		i = strlen(entry) + strlen(token) + 2;
-		newline = xmalloc(sizeof(char) * i);
-		snprintf(newline, i, "%s=%s", entry, token);
+		xasprintf(&newline, "%s=%s", entry, token);
 	} else {
-		i = strlen(entry) + 2;
-		newline = xmalloc(sizeof(char) * i);
-		snprintf(newline, i, "%s=", entry);
+		xasprintf(&newline, "%s=", entry);
 	}
 
 	replaced = false;
@@ -300,8 +296,7 @@ static RC_STRINGLIST *rc_config_kcl(RC_STRINGLIST *config)
 
 		if (value != NULL) {
 			len = varlen + strlen(value) + 2;
-			tmp = xmalloc(sizeof(char) * len);
-			snprintf(tmp, len, "%s=%s", override->value, value);
+			xasprintf(&tmp, "%s=%s", override->value, value);
 		}
 
 		/*


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2018-06-22 20:57 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2018-06-22 20:57 UTC (permalink / raw
  To: gentoo-commits

commit:     72df51e17ba0e1a0f94451b4bbfb338288c4625c
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Jun 22 20:41:25 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Jun 22 20:41:25 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=72df51e1

librc-daemon: convert most snprintf calls to xasprintf

 src/librc/librc-daemon.c | 71 ++++++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index a40150a6..173fcb83 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -23,13 +23,13 @@
 static bool
 pid_is_exec(pid_t pid, const char *exec)
 {
-	char buffer[32];
+	char *buffer = NULL;
 	FILE *fp;
 	int c;
 	bool retval = false;
 
 	exec = basename_c(exec);
-	snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid);
+	xasprintf(&buffer, "/proc/%d/stat", pid);
 	if ((fp = fopen(buffer, "r"))) {
 		while ((c = getc(fp)) != EOF && c != '(')
 			;
@@ -41,23 +41,27 @@ pid_is_exec(pid_t pid, const char *exec)
 		}
 		fclose(fp);
 	}
+	free(buffer);
 	return retval;
 }
 
 static bool
 pid_is_argv(pid_t pid, const char *const *argv)
 {
-	char cmdline[32];
+	char *cmdline = NULL;
 	int fd;
 	char buffer[PATH_MAX];
 	char *p;
 	ssize_t bytes;
 
-	snprintf(cmdline, sizeof(cmdline), "/proc/%u/cmdline", pid);
-	if ((fd = open(cmdline, O_RDONLY)) < 0)
+	xasprintf(&cmdline, "/proc/%u/cmdline", pid);
+	if ((fd = open(cmdline, O_RDONLY)) < 0) {
+		free(cmdline);
 		return false;
+	}
 	bytes = read(fd, buffer, sizeof(buffer));
 	close(fd);
+	free(cmdline);
 	if (bytes == -1)
 		return false;
 
@@ -88,7 +92,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 	char proc_ns[30];
 	size_t len = 0;
 	pid_t p;
-	char buffer[PATH_MAX];
+	char *buffer = NULL;
 	struct stat sb;
 	pid_t openrc_pid = 0;
 	char *pp;
@@ -149,18 +153,22 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 			continue;
 		if (pid != 0 && pid != p)
 			continue;
-		snprintf(buffer, sizeof(buffer), "/proc/%d/ns/pid", p);
+		xasprintf(&buffer, "/proc/%d/ns/pid", p);
 		if (exists(buffer)) {
 			rc = readlink(buffer, proc_ns, sizeof(proc_ns));
 			if (rc <= 0)
 				proc_ns[0] = '\0';
 		}
+		free(buffer);
 		if (strlen(my_ns) && strlen (proc_ns) && strcmp(my_ns, proc_ns))
 			continue;
 		if (uid) {
-			snprintf(buffer, sizeof(buffer), "/proc/%d", p);
-			if (stat(buffer, &sb) != 0 || sb.st_uid != uid)
+			xasprintf(&buffer, "/proc/%d", p);
+			if (stat(buffer, &sb) != 0 || sb.st_uid != uid) {
+				free(buffer);
 				continue;
+			}
+			free(buffer);
 		}
 		if (exec && !pid_is_exec(p, exec))
 			continue;
@@ -169,9 +177,10 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
 			continue;
 		/* If this is an OpenVZ host, filter out container processes */
 		if (openvz_host) {
-			snprintf(buffer, sizeof(buffer), "/proc/%d/status", p);
+			xasprintf(&buffer, "/proc/%d/status", p);
 			if (exists(buffer)) {
 				fp = fopen(buffer, "r");
+				free(buffer);
 				if (! fp)
 					continue;
 				while (! feof(fp)) {
@@ -315,12 +324,13 @@ _match_daemon(const char *path, const char *file, RC_STRINGLIST *match)
 {
 	char *line = NULL;
 	size_t len = 0;
-	char ffile[PATH_MAX];
+	char *ffile = NULL;
 	FILE *fp;
 	RC_STRING *m;
 
-	snprintf(ffile, sizeof(ffile), "%s/%s", path, file);
+	xasprintf(&ffile, "%s/%s", path, file);
 	fp = fopen(ffile, "r");
+	free(ffile);
 
 	if (!fp)
 		return false;
@@ -346,29 +356,22 @@ _match_list(const char *exec, const char *const *argv, const char *pidfile)
 {
 	RC_STRINGLIST *match = rc_stringlist_new();
 	int i = 0;
-	size_t l;
 	char *m;
 
 	if (exec) {
-		l = strlen(exec) + 6;
-		m = xmalloc(sizeof(char) * l);
-		snprintf(m, l, "exec=%s", exec);
+		xasprintf(&m, "exec=%s", exec);
 		rc_stringlist_add(match, m);
 		free(m);
 	}
 
 	while (argv && argv[i]) {
-		l = strlen(*argv) + strlen("argv_=") + 16;
-		m = xmalloc(sizeof(char) * l);
-		snprintf(m, l, "argv_0=%s", argv[i++]);
+		xasprintf(&m, "argv_0=%s", argv[i++]);
 		rc_stringlist_add(match, m);
 		free(m);
 	}
 
 	if (pidfile) {
-		l = strlen(pidfile) + 9;
-		m = xmalloc(sizeof(char) * l);
-		snprintf(m, l, "pidfile=%s", pidfile);
+		xasprintf(&m, "pidfile=%s", pidfile);
 		rc_stringlist_add(match, m);
 		free(m);
 	}
@@ -381,8 +384,8 @@ rc_service_daemon_set(const char *service, const char *exec,
     const char *const *argv,
     const char *pidfile, bool started)
 {
-	char dirpath[PATH_MAX];
-	char file[PATH_MAX];
+	char *dirpath = NULL;
+	char *file = NULL;
 	int nfiles = 0;
 	char oldfile[PATH_MAX] = { '\0' };
 	bool retval = false;
@@ -397,8 +400,7 @@ rc_service_daemon_set(const char *service, const char *exec,
 		return false;
 	}
 
-	snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s",
-	    basename_c(service));
+	xasprintf(&dirpath, RC_SVCDIR "/daemons/%s", basename_c(service));
 
 	/* Regardless, erase any existing daemon info */
 	if ((dp = opendir(dirpath))) {
@@ -407,8 +409,7 @@ rc_service_daemon_set(const char *service, const char *exec,
 			if (d->d_name[0] == '.')
 				continue;
 
-			snprintf(file, sizeof(file), "%s/%s",
-			    dirpath, d->d_name);
+			xasprintf(&file, "%s/%s", dirpath, d->d_name);
 			nfiles++;
 
 			if (!*oldfile) {
@@ -429,8 +430,7 @@ rc_service_daemon_set(const char *service, const char *exec,
 	/* Now store our daemon info */
 	if (started) {
 		if (mkdir(dirpath, 0755) == 0 || errno == EEXIST) {
-			snprintf(file, sizeof(file), "%s/%03d",
-			    dirpath, nfiles + 1);
+			xasprintf(&file, "%s/%03d", dirpath, nfiles + 1);
 			if ((fp = fopen(file, "w"))) {
 				fprintf(fp, "exec=");
 				if (exec)
@@ -458,8 +458,8 @@ bool
 rc_service_started_daemon(const char *service,
     const char *exec, const char *const *argv, int indx)
 {
-	char dirpath[PATH_MAX];
-	char file[16];
+	char *dirpath = NULL;
+	char *file = NULL;
 	RC_STRINGLIST *match;
 	bool retval = false;
 	DIR *dp;
@@ -468,13 +468,13 @@ rc_service_started_daemon(const char *service,
 	if (!service || !exec)
 		return false;
 
-	snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s",
-	    basename_c(service));
+	xasprintf(&dirpath, RC_SVCDIR "/daemons/%s", basename_c(service));
 	match = _match_list(exec, argv, NULL);
 
 	if (indx > 0) {
-		snprintf(file, sizeof(file), "%03d", indx);
+		xasprintf(&file, "%03d", indx);
 		retval = _match_daemon(dirpath, file, match);
+		free(file);
 	} else {
 		if ((dp = opendir(dirpath))) {
 			while ((d = readdir(dp))) {
@@ -489,6 +489,7 @@ rc_service_started_daemon(const char *service,
 	}
 
 	rc_stringlist_free(match);
+	free(dirpath);
 	return retval;
 }
 librc_hidden_def(rc_service_started_daemon)


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2018-06-28 18:03 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2018-06-28 18:03 UTC (permalink / raw
  To: gentoo-commits

commit:     3a803b3135837665d51ef4dd7a8b913c78e71ff6
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jun 27 17:06:19 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jun 27 17:06:19 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3a803b31

librc-daemon.c: fix memory leaks

 src/librc/librc-daemon.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
index 173fcb83..6f3b492f 100644
--- a/src/librc/librc-daemon.c
+++ b/src/librc/librc-daemon.c
@@ -422,6 +422,7 @@ rc_service_daemon_set(const char *service, const char *exec,
 				rename(file, oldfile);
 				strlcpy(oldfile, file, sizeof(oldfile));
 			}
+			free(file);
 		}
 		closedir(dp);
 		rc_stringlist_free(match);
@@ -446,10 +447,12 @@ rc_service_daemon_set(const char *service, const char *exec,
 				fclose(fp);
 				retval = true;
 			}
+			free(file);
 		}
 	} else
 		retval = true;
 
+	free(dirpath);
 	return retval;
 }
 librc_hidden_def(rc_service_daemon_set)


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [gentoo-commits] proj/openrc:master commit in: src/librc/
@ 2018-08-06 22:52 William Hubbs
  0 siblings, 0 replies; 48+ messages in thread
From: William Hubbs @ 2018-08-06 22:52 UTC (permalink / raw
  To: gentoo-commits

commit:     84ed570eaefcbb55b99ba425030bf7d1d1d46137
Author:     Zac Medico <zmedico <AT> gmail <DOT> com>
AuthorDate: Mon Aug  6 21:50:41 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Aug  6 22:39:52 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=84ed570e

librc: fix EACCES errno false-positive crash

Use errno != EACCES to fix false-positive for non-root users
with grsecurity kernels.

Fixes: 37e29442721a ("librc: Add check for crashed state")
This fixes #237

 src/librc/librc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librc/librc.c b/src/librc/librc.c
index 01bfac03..c38695cc 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -850,7 +850,7 @@ rc_service_state(const char *service)
 	}
 
 	if (state & RC_SERVICE_STARTED) {
-		if (rc_service_daemons_crashed(service))
+		if (rc_service_daemons_crashed(service) && errno != EACCES)
 			state |= RC_SERVICE_CRASHED;
 	}
 	if (state & RC_SERVICE_STOPPED) {


^ permalink raw reply related	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2018-08-06 22:52 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-22 20:57 [gentoo-commits] proj/openrc:master commit in: src/librc/ William Hubbs
  -- strict thread matches above, loose matches on Subject: below --
2018-08-06 22:52 William Hubbs
2018-06-28 18:03 William Hubbs
2018-06-20 22:45 William Hubbs
2018-05-22 22:12 William Hubbs
2018-05-22 22:12 William Hubbs
2017-11-30 19:58 William Hubbs
2017-11-14 19:22 William Hubbs
2017-10-26 18:58 William Hubbs
2017-10-24 15:43 William Hubbs
2016-12-20  0:29 William Hubbs
2016-08-15 18:48 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-19  6:12 William Hubbs
2015-12-08 18:53 William Hubbs
2015-11-05 18:53 William Hubbs
2015-11-05 18:53 William Hubbs
2015-05-04 15:10 William Hubbs
2015-01-12 16:44 William Hubbs
2014-11-01 22:05 William Hubbs
2014-10-24 15:45 William Hubbs
2014-10-23 19:13 William Hubbs
2014-10-23 17:57 William Hubbs
2014-10-20 20:59 William Hubbs
2014-07-19 18:06 William Hubbs
2014-06-20 21:22 William Hubbs
2013-10-21 19:53 William Hubbs
2013-10-04 19:07 William Hubbs
2013-10-04 19:07 William Hubbs
2013-04-14  3:45 William Hubbs
2012-10-05  3:28 William Hubbs
2012-02-25 21:02 William Hubbs
2012-02-25 16:57 Christian Ruppert
2012-01-30 19:33 William Hubbs
2012-01-24 18:41 Christian Ruppert
2012-01-21  3:41 William Hubbs
2012-01-16 18:16 William Hubbs
2012-01-15  0:05 Christian Ruppert
2011-11-07 15:58 William Hubbs
2011-07-13 19:39 Christian Ruppert
2011-07-09 21:15 Christian Ruppert
2011-06-28 16:47 Christian Ruppert
2011-05-28 16:02 Mike Frysinger
2011-04-28  0:18 William Hubbs
2011-04-28  0:18 William Hubbs
2011-04-09 19:56 William Hubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox