From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QnXXC-0005gi-3M for garchives@archives.gentoo.org; Sun, 31 Jul 2011 15:02:30 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 741C621C307; Sun, 31 Jul 2011 15:02:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 33ED721C305 for ; Sun, 31 Jul 2011 15:02:16 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9C9641BC007 for ; Sun, 31 Jul 2011 15:02:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 103843C004 for ; Sun, 31 Jul 2011 15:02:15 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <0c8bea21524c22856fdb8528298b43d6fb20451d.WilliamH@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: man/, sh/, src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: man/runscript.8 sh/runscript.sh.in src/rc/runscript.c X-VCS-Directories: man/ sh/ src/rc/ X-VCS-Committer: WilliamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 0c8bea21524c22856fdb8528298b43d6fb20451d Date: Sun, 31 Jul 2011 15:02:15 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 2de3d06342b473e4df815a425edf38df commit: 0c8bea21524c22856fdb8528298b43d6fb20451d Author: William Hubbs gentoo org> AuthorDate: Wed Jul 27 16:02:23 2011 +0000 Commit: William Hubbs gentoo org> CommitDate: Sun Jul 31 15:00:48 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D0c8bea21 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 /conf.d should be t= ried 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=3D350910 --- 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() =20 .Ed .Sh BUGS -Because of the way we load our configuration files and the need to handl= e -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 cor= rectly. 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 } =20 +loadconfig() +{ + # If we're net.eth0 or openvpn.work then load net or openvpn config + _c=3D${RC_SVCNAME%%.*} + if [ -n "$_c" -a "$_c" !=3D "$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() =20 yesno $RC_DEBUG && set -x =20 -_conf_d=3D${RC_SERVICE%/*}/../conf.d -# If we're net.eth0 or openvpn.work then load net or openvpn config -_c=3D${RC_SVCNAME%%.*} -if [ -n "$_c" -a "$_c" !=3D "$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 =20 # 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 =3D false; int retval, opt, depoptions =3D RC_DEP_TRACE; RC_STRING *svc; - char path[PATH_MAX], lnk[PATH_MAX]; - char *dir, *save =3D NULL, *saveLnk =3D NULL; + char *save =3D NULL; char pidstr[10]; size_t l =3D 0, ll; const char *file; @@ -1121,40 +1120,7 @@ runscript(int argc, char **argv) =20 atexit(cleanup); =20 - /* 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 =3D dirname(path); - if (strchr(lnk, '/')) { - save =3D xstrdup(dir); - saveLnk =3D xstrdup(lnk); - dir =3D dirname(saveLnk); - if (strcmp(dir, save) =3D=3D 0) - file =3D basename_c(argv[1]); - else - file =3D basename_c(lnk); - dir =3D save; - } else - file =3D basename_c(argv[1]); - ll =3D strlen(dir) + strlen(file) + 2; - service =3D xmalloc(ll); - snprintf(service, ll, "%s/%s", dir, file); - if (stat(service, &stbuf) !=3D 0) { - free(service); - service =3D xstrdup(lnk); - } - free(save); - free(saveLnk); - } - if (!service) - service =3D xstrdup(path); + service =3D xstrdup(argv[1]); applet =3D basename_c(service); =20 if (argc < 3)