public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/openrc:master commit in: man/, sh/, src/rc/
@ 2011-07-31 15:02 William Hubbs
  0 siblings, 0 replies; 2+ messages in thread
From: William Hubbs @ 2011-07-31 15:02 UTC (permalink / raw
  To: gentoo-commits

commit:     0c8bea21524c22856fdb8528298b43d6fb20451d
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 16:02:23 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jul 31 15:00:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0c8bea21

Improve processing of service directories and conf.d files

symbolic links should not be followed in an attempt to work out the name
of the service we are running. Also, @sysconfdir <AT> /conf.d should be tried
as a backup directory for configuration files.

I would like to thank Robin Johnson for his input on this change.

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

---
 man/runscript.8    |    6 ------
 sh/runscript.sh.in |   33 +++++++++++++++++++--------------
 src/rc/runscript.c |   38 ++------------------------------------
 3 files changed, 21 insertions(+), 56 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index 253b349..bf06d7b 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -462,12 +462,6 @@ show()
 
 .Ed
 .Sh BUGS
-Because of the way we load our configuration files and the need to handle
-more than one service directory, you can only use symlinks in service
-directories to other services in the same directory.
-You cannot symlink to a service in a different directory even if it is
-another service directory.
-.Pp
 is_older_than should return 0 on success.
 Instead we return 1 to be compliant with Gentoo baselayout.
 Users are encouraged to use the is_newer_than function which returns correctly.

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index df34b5e..fe30a03 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -16,6 +16,23 @@ sourcex()
 	fi
 }
 
+loadconfig()
+{
+	# If we're net.eth0 or openvpn.work then load net or openvpn config
+	_c=${RC_SVCNAME%%.*}
+	if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
+		if ! sourcex -e "$1/$_c.$RC_RUNLEVEL"; then
+			sourcex -e "$1/$_c"
+		fi
+	fi
+	unset _c
+
+	# Overlay with our specific config
+	if ! sourcex -e "$1/$RC_SVCNAME.$RC_RUNLEVEL"; then
+		sourcex -e "$1/$RC_SVCNAME"
+	fi
+}
+
 if [ ! -e ${RC_SVCDIR}/softlevel ]; then
 	eerror "You are attempting to run an openrc service on a"
 	eerror "system which openrc did not boot."
@@ -165,21 +182,9 @@ status()
 
 yesno $RC_DEBUG && set -x
 
-_conf_d=${RC_SERVICE%/*}/../conf.d
-# If we're net.eth0 or openvpn.work then load net or openvpn config
-_c=${RC_SVCNAME%%.*}
-if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
-	if ! sourcex -e "$_conf_d/$_c.$RC_RUNLEVEL"; then
-		sourcex -e "$_conf_d/$_c"
-	fi
-fi
-unset _c
-
-# Overlay with our specific config
-if ! sourcex -e "$_conf_d/$RC_SVCNAME.$RC_RUNLEVEL"; then
-	sourcex -e "$_conf_d/$RC_SVCNAME"
+if ! loadconfig "${RC_SERVICE%/*}/../conf.d"; then
+		loadconfig "@SYSCONFDIR@/conf.d"
 fi
-unset _conf_d
 
 # Load any system overrides
 sourcex -e "@SYSCONFDIR@/rc.conf"

diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 02d9e7e..8278f5b 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1100,8 +1100,7 @@ runscript(int argc, char **argv)
 	bool doneone = false;
 	int retval, opt, depoptions = RC_DEP_TRACE;
 	RC_STRING *svc;
-	char path[PATH_MAX], lnk[PATH_MAX];
-	char *dir, *save = NULL, *saveLnk = NULL;
+	char *save = NULL;
 	char pidstr[10];
 	size_t l = 0, ll;
 	const char *file;
@@ -1121,40 +1120,7 @@ runscript(int argc, char **argv)
 
 	atexit(cleanup);
 
-	/* We need to work out the real full path to our service.
-	 * This works fine, provided that we ONLY allow multiplexed services
-	 * to exist in the same directory as the master link.
-	 * Also, the master link as to be a real file in the init dir. */
-	if (!realpath(argv[1], path)) {
-		fprintf(stderr, "realpath: %s\n", strerror(errno));
-		exit(EXIT_FAILURE);
-	}
-	memset(lnk, 0, sizeof(lnk));
-	if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
-		dir = dirname(path);
-		if (strchr(lnk, '/')) {
-			save = xstrdup(dir);
-			saveLnk = xstrdup(lnk);
-			dir = dirname(saveLnk);
-			if (strcmp(dir, save) == 0)
-				file = basename_c(argv[1]);
-			else
-				file = basename_c(lnk);
-			dir = save;
-		} else
-			file = basename_c(argv[1]);
-		ll = strlen(dir) + strlen(file) + 2;
-		service = xmalloc(ll);
-		snprintf(service, ll, "%s/%s", dir, file);
-		if (stat(service, &stbuf) != 0) {
-			free(service);
-			service = xstrdup(lnk);
-		}
-		free(save);
-		free(saveLnk);
-	}
-	if (!service)
-		service = xstrdup(path);
+	service = xstrdup(argv[1]);
 	applet = basename_c(service);
 
 	if (argc < 3)



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

* [gentoo-commits] proj/openrc:master commit in: man/, sh/, src/rc/
@ 2011-12-11 17:43 William Hubbs
  0 siblings, 0 replies; 2+ messages in thread
From: William Hubbs @ 2011-12-11 17:43 UTC (permalink / raw
  To: gentoo-commits

commit:     5e01051c4eccf1fc52b32b060478a534d34769ed
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 11 07:18:08 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Dec 11 07:18:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=5e01051c

Allow init scripts to be executed with a relative path

This was a regression that was caused by the fix for
http://bugs.gentoo.org/show_bug.cgi?id=350910. I am reverting the commit
that we said fixed that bug and re-opening it.

Reported-By: Nathaniel <nathaniel <AT> paust.us
X-Gentoo-Bug: 392457
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=392457

---
 man/runscript.8    |    6 ++++++
 sh/runscript.sh.in |   33 ++++++++++++++-------------------
 src/rc/runscript.c |   38 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 56 insertions(+), 21 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index 64da26c..2889970 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -465,6 +465,12 @@ show()
 
 .Ed
 .Sh BUGS
+Because of the way we load our configuration files and the need to handle
+more than one service directory, you can only use symlinks in service
+directories to other services in the same directory.
+You cannot symlink to a service in a different directory even if it is
+another service directory.
+.Pp
 is_older_than should return 0 on success.
 Instead we return 1 to be compliant with Gentoo baselayout.
 Users are encouraged to use the is_newer_than function which returns correctly.

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 4032cb8..07f96d8 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -16,23 +16,6 @@ sourcex()
 	fi
 }
 
-loadconfig()
-{
-	# If we're net.eth0 or openvpn.work then load net or openvpn config
-	_c=${RC_SVCNAME%%.*}
-	if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
-		if ! sourcex -e "$1/$_c.$RC_RUNLEVEL"; then
-			sourcex -e "$1/$_c"
-		fi
-	fi
-	unset _c
-
-	# Overlay with our specific config
-	if ! sourcex -e "$1/$RC_SVCNAME.$RC_RUNLEVEL"; then
-		sourcex -e "$1/$RC_SVCNAME"
-	fi
-}
-
 sourcex "@SYSCONFDIR@/init.d/functions.sh"
 sourcex "@LIBEXECDIR@/sh/rc-functions.sh"
 
@@ -195,9 +178,21 @@ status()
 
 yesno $RC_DEBUG && set -x
 
-if ! loadconfig "${RC_SERVICE%/*}/../conf.d"; then
-		loadconfig "@SYSCONFDIR@/conf.d"
+_conf_d=${RC_SERVICE%/*}/../conf.d
+# If we're net.eth0 or openvpn.work then load net or openvpn config
+_c=${RC_SVCNAME%%.*}
+if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
+	if ! sourcex -e "$_conf_d/$_c.$RC_RUNLEVEL"; then
+		sourcex -e "$_conf_d/$_c"
+	fi
+fi
+unset _c
+
+# Overlay with our specific config
+if ! sourcex -e "$_conf_d/$RC_SVCNAME.$RC_RUNLEVEL"; then
+	sourcex -e "$_conf_d/$RC_SVCNAME"
 fi
+unset _conf_d
 
 # Load any system overrides
 sourcex -e "@SYSCONFDIR@/rc.conf"

diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 3306500..b460cc3 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1100,7 +1100,8 @@ runscript(int argc, char **argv)
 	bool doneone = false;
 	int retval, opt, depoptions = RC_DEP_TRACE;
 	RC_STRING *svc;
-	char *save = NULL;
+	char path[PATH_MAX], lnk[PATH_MAX];
+	char *dir, *save = NULL, *saveLnk = NULL;
 	char pidstr[10];
 	size_t l = 0, ll;
 	struct stat stbuf;
@@ -1119,7 +1120,40 @@ runscript(int argc, char **argv)
 
 	atexit(cleanup);
 
-	service = xstrdup(argv[1]);
+	/* We need to work out the real full path to our service.
+	 * This works fine, provided that we ONLY allow multiplexed services
+	 * to exist in the same directory as the master link.
+	 * Also, the master link as to be a real file in the init dir. */
+	if (!realpath(argv[1], path)) {
+		fprintf(stderr, "realpath: %s\n", strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+	memset(lnk, 0, sizeof(lnk));
+	if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
+		dir = dirname(path);
+		if (strchr(lnk, '/')) {
+			save = xstrdup(dir);
+			saveLnk = xstrdup(lnk);
+			dir = dirname(saveLnk);
+			if (strcmp(dir, save) == 0)
+				file = basename_c(argv[1]);
+			else
+				file = basename_c(lnk);
+			dir = save;
+		} else
+			file = basename_c(argv[1]);
+		ll = strlen(dir) + strlen(file) + 2;
+		service = xmalloc(ll);
+		snprintf(service, ll, "%s/%s", dir, file);
+		if (stat(service, &stbuf) != 0) {
+			free(service);
+			service = xstrdup(lnk);
+		}
+		free(save);
+		free(saveLnk);
+	}
+	if (!service)
+		service = xstrdup(path);
 	applet = basename_c(service);
 
 	if (argc < 3)



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

end of thread, other threads:[~2011-12-11 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-11 17:43 [gentoo-commits] proj/openrc:master commit in: man/, sh/, src/rc/ William Hubbs
  -- strict thread matches above, loose matches on Subject: below --
2011-07-31 15:02 William Hubbs

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