File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -656,12 +656,30 @@ rc_set_user(void)
656656 clear_dirfds ();
657657}
658658
659+ static const char * * env_scriptdirs ;
660+
659661const char * const *
660662rc_scriptdirs (void )
661663{
664+ static bool set = false;
665+ const char * dirs ;
666+
662667 if (rc_dirs .set )
663668 return rc_dirs .scriptdirs ;
664- return scriptdirs ;
669+
670+ if (!set && (dirs = getenv ("RC_SCRIPTDIRS" ))) {
671+ char * tmp = xstrdup (dirs );
672+ unsigned entries = 0 ;
673+
674+ for (const char * entry = dirs ; * entry ; entry ++ )
675+ entries += * entry == ':' ;
676+ env_scriptdirs = calloc (entries + 2 , sizeof (* scriptdirs ));
677+
678+ for (size_t i = 0 ; i < entries + 1 && tmp ; i ++ )
679+ env_scriptdirs [i ] = strsep (& tmp , ":" );
680+ }
681+
682+ return env_scriptdirs ? env_scriptdirs : scriptdirs ;
665683}
666684
667685size_t
Original file line number Diff line number Diff line change @@ -59,6 +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" ,
6263 "LANG" , "LC_MESSAGES" , "TERM" ,
6364 "EINFO_COLOR" , "EINFO_VERBOSE" ,
6465 NULL
You can’t perform that action at this time.
0 commit comments