2222
2323#define GENDEP RC_LIBEXECDIR "/sh/gendepends.sh"
2424
25- #define RC_DEPCONFIG RC_SVCDIR "/depconfig"
25+ #define RC_DEPCONFIG "/depconfig"
26+
27+ static char *
28+ depconfigpath_get () {
29+ char * path = xmalloc (sizeof (char ) * PATH_MAX );
30+ snprintf (path , PATH_MAX , "%s/%s" , rc_svcdir_get (), RC_DEPCONFIG );
31+ return path ;
32+ }
2633
2734static const char * bootlevel = NULL ;
2835
@@ -655,19 +662,19 @@ static const DEPPAIR deppairs[] = {
655662
656663static const char * const depdirs [] =
657664{
658- RC_SVCDIR ,
659- RC_SVCDIR "/ starting" ,
660- RC_SVCDIR "/ started" ,
661- RC_SVCDIR "/ stopping" ,
662- RC_SVCDIR "/ inactive" ,
663- RC_SVCDIR "/ wasinactive" ,
664- RC_SVCDIR "/ failed" ,
665- RC_SVCDIR "/ hotplugged" ,
666- RC_SVCDIR "/ daemons" ,
667- RC_SVCDIR "/ options" ,
668- RC_SVCDIR "/ exclusive" ,
669- RC_SVCDIR "/ scheduled" ,
670- RC_SVCDIR "/ tmp" ,
665+ "" ,
666+ " starting" ,
667+ " started" ,
668+ " stopping" ,
669+ " inactive" ,
670+ " wasinactive" ,
671+ " failed" ,
672+ " hotplugged" ,
673+ " daemons" ,
674+ " options" ,
675+ " exclusive" ,
676+ " scheduled" ,
677+ " tmp" ,
671678 NULL
672679};
673680
@@ -682,9 +689,13 @@ rc_deptree_update_needed(time_t *newest, char *file)
682689 time_t mtime ;
683690
684691 /* Create base directories if needed */
685- for (i = 0 ; depdirs [i ]; i ++ )
686- if (mkdir (depdirs [i ], 0755 ) != 0 && errno != EEXIST )
687- fprintf (stderr , "mkdir `%s': %s\n" , depdirs [i ], strerror (errno ));
692+ char * depdir = xmalloc (sizeof (char ) * PATH_MAX );
693+ for (i = 0 ; depdirs [i ]; i ++ ) {
694+ snprintf (depdir , PATH_MAX , "%s/%s" , rc_svcdir_get (), depdirs [i ]);
695+ if (mkdir (depdir , 0755 ) != 0 && errno != EEXIST )
696+ fprintf (stderr , "mkdir `%s': %s\n" , depdir , strerror (errno ));
697+ }
698+ free (depdir );
688699
689700 /* Quick test to see if anything we use has changed and we have
690701 * data in our deptree. */
@@ -700,8 +711,8 @@ rc_deptree_update_needed(time_t *newest, char *file)
700711 mtime = time (NULL );
701712 }
702713
703- newer |= !deep_mtime_check (RC_INITDIR ,true,& mtime ,file );
704- newer |= !deep_mtime_check (RC_CONFDIR ,true,& mtime ,file );
714+ newer |= !deep_mtime_check (rc_initdir_get () ,true,& mtime ,file );
715+ newer |= !deep_mtime_check (rc_confdir_get () ,true,& mtime ,file );
705716#ifdef RC_PKG_INITDIR
706717 newer |= !deep_mtime_check (RC_PKG_INITDIR ,true,& mtime ,file );
707718#endif
@@ -718,7 +729,9 @@ rc_deptree_update_needed(time_t *newest, char *file)
718729
719730 /* Some init scripts dependencies change depending on config files
720731 * outside of baselayout, like syslog-ng, so we check those too. */
721- config = rc_config_list (RC_DEPCONFIG );
732+ char * depconf = depconfigpath_get ();
733+ config = rc_config_list (depconf );
734+ free (depconf );
722735 TAILQ_FOREACH (s , config , entries ) {
723736 newer |= !deep_mtime_check (s -> value , true, & mtime , file );
724737 }
@@ -1059,19 +1072,21 @@ rc_deptree_update(void)
10591072 }
10601073
10611074 /* Save our external config files to disk */
1075+ char * depconf = depconfigpath_get ();
10621076 if (TAILQ_FIRST (config )) {
1063- if ((fp = fopen (RC_DEPCONFIG , "w" ))) {
1077+ if ((fp = fopen (depconf , "w" ))) {
10641078 TAILQ_FOREACH (s , config , entries )
10651079 fprintf (fp , "%s\n" , s -> value );
10661080 fclose (fp );
10671081 } else {
10681082 fprintf (stderr , "fopen `%s': %s\n" ,
1069- RC_DEPCONFIG , strerror (errno ));
1083+ depconf , strerror (errno ));
10701084 retval = false;
10711085 }
10721086 } else {
1073- unlink (RC_DEPCONFIG );
1087+ unlink (depconf );
10741088 }
1089+ free (depconf );
10751090
10761091 rc_stringlist_free (config );
10771092 free (deptree );
0 commit comments