@@ -123,11 +123,11 @@ static ni_bool_t __ni_ipv6_disbled;
123123 NULL }
124124#define __NI_SUSE_SYSCTL_SUFFIX ".conf"
125125#define __NI_SUSE_SYSCTL_BOOT "/boot/sysctl.conf-"
126- #define __NI_SUSE_SYSCTL_DIRS { "/lib/sysctl.d", \
126+ #define __NI_SUSE_SYSCTL_DIRS { "/run/sysctl.d", \
127+ "/etc/sysctl.d", \
128+ "/usr/local/lib/sysctl.d", \
127129 "/usr/lib/sysctl.d", \
128- "/usr/local/lib/sysctl.d", \
129- "/etc/sysctl.d", \
130- "/run/sysctl.d", \
130+ "/lib/sysctl.d", \
131131 NULL }
132132#define __NI_SUSE_SYSCTL_FILE "/etc/sysctl.conf"
133133#define __NI_SUSE_PROC_IPV6_DIR "/proc/sys/net/ipv6"
@@ -323,21 +323,16 @@ __ni_suse_read_default_hostname(const char *root, char **hostname)
323323 return * hostname ;
324324}
325325
326- static int
327- __ni_suse_string_compare (const void * lhs , const void * rhs )
328- {
329- return strcmp (* (const char * * )lhs , * (const char * * )rhs );
330- }
331326
332327static ni_bool_t
333328__ni_suse_read_global_ifsysctl (const char * root , const char * path )
334329{
335330 const char * sysctldirs [] = __NI_SUSE_SYSCTL_DIRS , * * sysctld ;
336331 ni_string_array_t files = NI_STRING_ARRAY_INIT ;
332+ ni_var_array_t sysctl_d_files = NI_VAR_ARRAY_INIT ;
337333 char dirname [PATH_MAX ];
338334 char pathbuf [PATH_MAX ];
339335 const char * name ;
340- char * real = NULL ;
341336 unsigned int i ;
342337 struct utsname u ;
343338
@@ -350,10 +345,8 @@ __ni_suse_read_global_ifsysctl(const char *root, const char *path)
350345 if (uname (& u ) == 0 ) {
351346 snprintf (pathbuf , sizeof (pathbuf ), "%s%s%s" , root ,
352347 __NI_SUSE_SYSCTL_BOOT , u .release );
353- name = ni_realpath (pathbuf , & real );
354- if (name && ni_isreg (name ))
355- ni_string_array_append (& files , name );
356- ni_string_free (& real );
348+ if (ni_file_exists (pathbuf ))
349+ ni_string_array_append (& files , pathbuf );
357350 }
358351
359352 /*
@@ -367,38 +360,30 @@ __ni_suse_read_global_ifsysctl(const char *root, const char *path)
367360 continue ;
368361
369362 if (ni_scandir (dirname , "*" __NI_SUSE_SYSCTL_SUFFIX , & names )) {
370-
371- /*
372- * config files in sysctl.d directories are often prefixed with
373- * numbers determining an order, so we should preserve that order
374- */
375- qsort (names .data , names .count , sizeof (char * ),
376- __ni_suse_string_compare );
377-
378363 for (i = 0 ; i < names .count ; ++ i ) {
379364 char * path = NULL ;
380365 if (!ni_string_printf (& path , "%s/%s" , dirname , names .data [i ]))
381366 continue ;
382- name = ni_realpath (path , & real );
367+ if (!ni_var_array_get (& sysctl_d_files , names .data [i ]))
368+ ni_var_array_append (& sysctl_d_files , names .data [i ], path );
383369 ni_string_free (& path );
384- if (name && ni_isreg (name ))
385- ni_string_array_append (& files , name );
386- ni_string_free (& real );
387370 }
388371 }
389372 ni_string_array_destroy (& names );
390373 }
374+ ni_var_array_sort_by_name (& sysctl_d_files );
375+ for (i = 0 ; i < sysctl_d_files .count ; i ++ )
376+ ni_string_array_append (& files , sysctl_d_files .data [i ].value );
377+ ni_var_array_destroy (& sysctl_d_files );
391378
392379 /*
393380 * then the old /etc/sysctl.conf
394381 */
395382 snprintf (pathbuf , sizeof (pathbuf ), "%s%s" , root , __NI_SUSE_SYSCTL_FILE );
396- name = ni_realpath (pathbuf , & real );
397- if (name && ni_isreg (name )) {
398- if (ni_string_array_index (& files , name ) == -1 )
399- ni_string_array_append (& files , name );
383+ if (ni_file_exists (pathbuf )) {
384+ if (ni_string_array_index (& files , pathbuf ) == -1 )
385+ ni_string_array_append (& files , pathbuf );
400386 }
401- ni_string_free (& real );
402387
403388 /*
404389 * finally ifsysctl if they exist
@@ -410,12 +395,10 @@ __ni_suse_read_global_ifsysctl(const char *root, const char *path)
410395 snprintf (pathbuf , sizeof (pathbuf ), "%s/%s/%s" ,
411396 root , path , __NI_SUSE_IFSYSCTL_FILE );
412397
413- name = ni_realpath (pathbuf , & real );
414- if (name && ni_isreg (name )) {
415- if (ni_string_array_index (& files , name ) == -1 )
416- ni_string_array_append (& files , name );
398+ if (ni_file_exists (pathbuf )) {
399+ if (ni_string_array_index (& files , pathbuf ) == -1 )
400+ ni_string_array_append (& files , pathbuf );
417401 }
418- ni_string_free (& real );
419402
420403 for (i = 0 ; i < files .count ; ++ i ) {
421404 name = files .data [i ];
0 commit comments