10
10
LD_SO_CONF_MAIN = '/etc/ld.so.conf'
11
11
LD_SO_CONF_DEFAULT_INCLUDE = 'ld.so.conf.d/*.conf'
12
12
LD_SO_CONF_COMMENT_PREFIX = '#'
13
- FMT_LIST_SEPARATOR = '\n - '
13
+ LD_LIBRARY_PATH_VAR = 'LD_LIBRARY_PATH'
14
+ FMT_LIST_SEPARATOR_1 = '\n - '
15
+ FMT_LIST_SEPARATOR_2 = '\n - '
14
16
15
17
16
18
def _read_file (file_path ):
@@ -21,10 +23,10 @@ def _read_file(file_path):
21
23
def _report_custom_ld_so_configuration (summary ):
22
24
reporting .create_report ([
23
25
reporting .Title (
24
- 'Third party libraries linked with ld.so.conf are not supported .'
26
+ 'Detected customized configuration for dynamic linker .'
25
27
),
26
28
reporting .Summary (summary ),
27
- reporting .Remediation (hint = ('Remove the custom ld.so configuration and apply the changes '
29
+ reporting .Remediation (hint = ('Remove or revert the custom ld.so configuration and apply the changes '
28
30
'using the ldconfig command.' )),
29
31
reporting .RelatedResource ('file' , '/etc/ld.so.conf' ),
30
32
reporting .RelatedResource ('directory' , '/etc/ld.so.conf.d' ),
@@ -36,13 +38,11 @@ def _report_custom_ld_so_configuration(summary):
36
38
def _is_modified (config_path ):
37
39
""" Decide if the configuration file was modified based on the package it belongs to. """
38
40
result = run (['rpm' , '-Vf' , config_path ], checked = False )
39
- if result ['exit_code' ] == 0 :
41
+ if not result ['exit_code' ]:
40
42
return False
41
- output = result ['stdout' ]
42
- # Note that the condition is relaxed so that files different only
43
- # in the modification timestamp won't be considered as modified.
44
- modification_flags = output .split (' ' , 1 )[0 ]
45
- return modification_flags .strip ('.' ) != 'T'
43
+ modification_flags = result ['stdout' ].split (' ' , 1 )[0 ]
44
+ # The file is considered modified only when the checksum does not match
45
+ return '5' in modification_flags
46
46
47
47
48
48
def _is_included_ld_so_config_custom (config_path ):
@@ -90,34 +90,44 @@ def _parse_main_ld_so_config():
90
90
91
91
def check_ld_so_configuration ():
92
92
included_configs , other_lines = _parse_main_ld_so_config ()
93
- summary = ''
93
+ custom_configurations = ''
94
94
95
95
if other_lines :
96
96
# The main ld.so config file is expected to only include additional configs that are owned by a package
97
- summary += ('The /etc/ld.so.conf file has unexpected contents:'
98
- '{}{}' .format (FMT_LIST_SEPARATOR ,
99
- FMT_LIST_SEPARATOR .join (other_lines ) ))
97
+ custom_configurations += ('{} The /etc/ld.so.conf file has unexpected contents:'
98
+ '{}{}' ) .format (FMT_LIST_SEPARATOR_1 ,
99
+ FMT_LIST_SEPARATOR_2 , FMT_LIST_SEPARATOR_2 .join (other_lines ))
100
100
101
101
is_default_include_present = '/etc/' + LD_SO_CONF_DEFAULT_INCLUDE in included_configs
102
102
if not is_default_include_present :
103
- api .current_logger ().debug ('The default include "' + LD_SO_CONF_DEFAULT_INCLUDE +
104
- '" is not present in the ' + LD_SO_CONF_MAIN + ' file.' )
103
+ api .current_logger ().debug ('The default include "{}" is not present in '
104
+ 'the {} file.' . format ( LD_SO_CONF_DEFAULT_INCLUDE , LD_SO_CONF_MAIN ) )
105
105
106
106
if is_default_include_present and len (included_configs ) != 1 :
107
107
# The additional included configs will most likely be created manually by the user
108
108
# and therefore will get flagged as custom in the next part of this function
109
- api .current_logger ().debug ('The default include "' + LD_SO_CONF_DEFAULT_INCLUDE +
110
- '" is not the only include in the ' + LD_SO_CONF_MAIN + ' file.' )
109
+ api .current_logger ().debug ('The default include "{}" is not the only include in '
110
+ 'the {} file.' . format ( LD_SO_CONF_DEFAULT_INCLUDE , LD_SO_CONF_MAIN ) )
111
111
112
112
# Detect custom ld configs from the includes in the main ld.so.conf
113
113
custom_ld_configs = set ()
114
114
for cfg_glob in included_configs :
115
115
custom_ld_configs .update ({cfg for cfg in glob .glob (cfg_glob ) if _is_included_ld_so_config_custom (cfg )})
116
116
117
117
if custom_ld_configs :
118
- summary += ('\n The following config files were marked as unsupported:'
119
- '{}{}' .format (FMT_LIST_SEPARATOR ,
120
- FMT_LIST_SEPARATOR .join (custom_ld_configs )))
121
-
122
- if summary :
118
+ custom_configurations += ('{}The following drop in config files were marked as custom:'
119
+ '{}{}' ).format (FMT_LIST_SEPARATOR_1 ,
120
+ FMT_LIST_SEPARATOR_2 , FMT_LIST_SEPARATOR_2 .join (custom_ld_configs ))
121
+
122
+ if os .environ .get (LD_LIBRARY_PATH_VAR , None ):
123
+ custom_configurations += ('{}The variable "{}" contains unexpected dynamic linker '
124
+ 'configuration.' ).format (FMT_LIST_SEPARATOR_1 , LD_LIBRARY_PATH_VAR )
125
+
126
+ if custom_configurations :
127
+ summary = ('Custom configurations to the dynamic linker could potentially impact the upgrade in a negative '
128
+ 'way. The custom configuration includes modifications to {}, custom or modified drop in config '
129
+ 'files in the {} directory and additional entries in the {} variable. These modifications '
130
+ 'configure the dynamic linker to use different libraries that might not be provided by Red Hat '
131
+ 'products. The following custom configurations were detected '
132
+ 'by leapp:{}' ).format (LD_SO_CONF_MAIN , LD_SO_CONF_DIR , LD_LIBRARY_PATH_VAR , custom_configurations )
123
133
_report_custom_ld_so_configuration (summary )
0 commit comments