Skip to content

Commit a9b519b

Browse files
committed
librc: read RC_SVCDIR from the environment
1 parent f0a4c49 commit a9b519b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/librc/librc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,18 @@ rc_runleveldir(void)
730730
const char *
731731
rc_svcdir(void)
732732
{
733-
return rc_dirs.set ? rc_dirs.svcdir : RC_SVCDIR;
733+
static const char *svcdir;
734+
static bool set = false;
735+
736+
if (rc_dirs.set)
737+
return rc_dirs.svcdir;
738+
739+
if (!set && !rc_dirs.set) {
740+
svcdir = getenv("RC_SVCDIR");
741+
set = true;
742+
}
743+
744+
return svcdir ? svcdir : RC_SVCDIR;
734745
}
735746

736747
static ssize_t

src/shared/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const char *const env_allowlist[] = {
5959
"EERROR_QUIET", "EINFO_QUIET",
6060
"IN_BACKGROUND", "IN_DRYRUN", "IN_HOTPLUG",
6161
"RC_DEBUG", "RC_NODEPS", "RC_USER_SERVICES",
62-
"RC_SCRIPTDIRS",
62+
"RC_SCRIPTDIRS", "RC_SVCDIR",
6363
"LANG", "LC_MESSAGES", "TERM",
6464
"EINFO_COLOR", "EINFO_VERBOSE",
6565
NULL

0 commit comments

Comments
 (0)