From 7d284aa628dddc1cd2ca1995a851c825568868ae Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 12 Sep 2014 08:34:47 +0000 Subject: [PATCH] SVCNAME -> RC_SVCNAME --- README | 4 ++-- dhcpcd-run-hooks.8.in | 4 ++-- script.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README b/README index 3ee66833..b6d75d85 100644 --- a/README +++ b/README @@ -98,8 +98,8 @@ To add more simply ./configure -with-hook=ntp.conf Some system services expose the name of the service we are in, -by default dhcpcd will pick SVCNAME from the environment. -You can override this in CPPFLAGS+= -DSVCNAME="RC_SVCNAME". +by default dhcpcd will pick RC_SVCNAME from the environment. +You can override this in CPPFLAGS+= -DRC_SVCNAME="YOUR_SVCNAME". This is important because dhcpcd will scrub the environment aside from $PATH before running hooks. This variable could be used to facilitate service re-entry so this chain could diff --git a/dhcpcd-run-hooks.8.in b/dhcpcd-run-hooks.8.in index d280d562..217b3543 100644 --- a/dhcpcd-run-hooks.8.in +++ b/dhcpcd-run-hooks.8.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 9, 2014 +.Dd September 12, 2014 .Dt DHCPCD-RUN-HOOKS 8 .Os .Sh NAME @@ -131,7 +131,7 @@ script to process them. will clear the environment variables aside from .Ev $PATH and -.Ev $SVCNAME . +.Ev $RC_SVCNAME . The following variables will then be set, along with any protocol supplied ones. .Bl -tag -width Xinterface_order diff --git a/script.c b/script.c index 4ff6823d..f0f8d27c 100644 --- a/script.c +++ b/script.c @@ -58,8 +58,8 @@ #endif /* Allow the OS to define another script env var name */ -#ifndef SVCNAME -#define SVCNAME "SVCNAME" +#ifndef RC_SVCNAME +#define RC_SVCNAME "RC_SVCNAME" #endif #define DEFAULT_PATH "PATH=/usr/bin:/usr/sbin:/bin:/sbin" @@ -632,8 +632,8 @@ script_runreason(const struct interface *ifp, const char *reason) syslog(LOG_ERR, "%s: make_env: %m", ifp->name); return -1; } - /* Resize for PATH and SVCNAME */ - svcname = getenv(SVCNAME); + /* Resize for PATH and RC_SVCNAME */ + svcname = getenv(RC_SVCNAME); ep = realloc(env, sizeof(char *) * (elen + 2 + (svcname ? 1 : 0))); if (ep == NULL) { elen = 0; @@ -658,13 +658,13 @@ script_runreason(const struct interface *ifp, const char *reason) } } if (svcname) { - e = strlen(SVCNAME) + strlen(svcname) + 2; + e = strlen(RC_SVCNAME) + strlen(svcname) + 2; env[++elen] = malloc(e); if (env[elen] == NULL) { elen = 0; goto out; } - snprintf(env[elen], e, "%s=%s", SVCNAME, svcname); + snprintf(env[elen], e, "%s=%s", RC_SVCNAME, svcname); } env[++elen] = NULL; -- 2.47.3