1 |
commit: 33f3494a33b3d0dca118ede0f1f3a459176dde6d |
2 |
Author: Matthew Thode <mthode <AT> mthode <DOT> org> |
3 |
AuthorDate: Mon Jan 20 16:56:57 2014 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 20 22:42:13 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=33f3494a |
7 |
|
8 |
updating python apps for pep8 |
9 |
|
10 |
--- |
11 |
scripts/migrate-pax | 20 +++--- |
12 |
scripts/pypaxctl | 99 +++++++++++++++--------------- |
13 |
scripts/revdep-pax | 171 ++++++++++++++++++++++++++-------------------------- |
14 |
3 files changed, 150 insertions(+), 140 deletions(-) |
15 |
|
16 |
diff --git a/scripts/migrate-pax b/scripts/migrate-pax |
17 |
index 429d45c..8593271 100755 |
18 |
--- a/scripts/migrate-pax |
19 |
+++ b/scripts/migrate-pax |
20 |
@@ -19,7 +19,8 @@ |
21 |
|
22 |
# We use portage's NEEDED.ELF.2 file. The format is in |
23 |
# /usr/lib/portage/bin/misc-functions.sh ~line 520 |
24 |
-# echo "${arch:3};${obj};${soname};${rpath};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2 |
25 |
+# echo "${arch:3};${obj};${soname};${rpath};${needed}" \ |
26 |
+# >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2 |
27 |
|
28 |
import os |
29 |
import re |
30 |
@@ -28,6 +29,7 @@ import sys |
31 |
import pax |
32 |
import portage |
33 |
|
34 |
+ |
35 |
def get_objects(): |
36 |
|
37 |
vardb = portage.db[portage.root]["vartree"].dbapi |
38 |
@@ -36,11 +38,11 @@ def get_objects(): |
39 |
|
40 |
for pkg in vardb.cpv_all(): |
41 |
needed = vardb.aux_get(pkg, ['NEEDED.ELF.2'])[0].strip() |
42 |
- if not needed: # Some packages have no NEEDED.ELF.2 |
43 |
+ if not needed: # Some packages have no NEEDED.ELF.2 |
44 |
continue |
45 |
for line in re.split('\n', needed): |
46 |
link = re.split(';', line) |
47 |
- objects.append(link[1]) # link[1] is the ELF object |
48 |
+ objects.append(link[1]) # link[1] is the ELF object |
49 |
|
50 |
return objects |
51 |
|
52 |
@@ -69,7 +71,7 @@ def main(): |
53 |
try: |
54 |
opts, args = getopt.getopt(sys.argv[1:], 'vmdh') |
55 |
except getopt.GetoptError as err: |
56 |
- print(str(err)) # will print something like 'option -a not recognized' |
57 |
+ print(str(err)) # will print something like 'option -a not recognized' |
58 |
run_usage() |
59 |
sys.exit(1) |
60 |
|
61 |
@@ -102,7 +104,7 @@ def main(): |
62 |
run_usage() |
63 |
sys.exit(0) |
64 |
|
65 |
- if opt_count == 0 or opt_count > 2 or ( do_migration and do_deleteall): |
66 |
+ if opt_count == 0 or opt_count > 2 or (do_migration and do_deleteall): |
67 |
run_usage() |
68 |
sys.exit(1) |
69 |
|
70 |
@@ -111,7 +113,8 @@ def main(): |
71 |
try: |
72 |
from pax import deletextpax |
73 |
except ImportError: |
74 |
- print('ERROR: Python module pax.so was compiled without XATTR_PAX support, cannot migrate or delete XATTR_PAX') |
75 |
+ print('ERROR: Python module pax.so was compiled without XATTR_PAX support, ' |
76 |
+ 'cannot migrate or delete XATTR_PAX') |
77 |
sys.exit(1) |
78 |
|
79 |
objects = get_objects() |
80 |
@@ -131,8 +134,9 @@ def main(): |
81 |
print("NONE: %s" % elf) |
82 |
|
83 |
if do_migration: |
84 |
- flags = re.sub('-','',flags) |
85 |
- if flags == 'e': continue # Don't create XATTR_PAX for default |
86 |
+ flags = re.sub('-', '', flags) |
87 |
+ if flags == 'e': |
88 |
+ continue # Don't create XATTR_PAX for default |
89 |
pax.setstrflags(elf, flags) |
90 |
|
91 |
if do_deleteall: |
92 |
|
93 |
diff --git a/scripts/pypaxctl b/scripts/pypaxctl |
94 |
index cca3d2c..cfae4d3 100755 |
95 |
--- a/scripts/pypaxctl |
96 |
+++ b/scripts/pypaxctl |
97 |
@@ -24,62 +24,65 @@ import pax |
98 |
|
99 |
xattr_available = True |
100 |
try: |
101 |
- from pax import deletextpax |
102 |
+ from pax import deletextpax |
103 |
except ImportError: |
104 |
- xattr_available = False |
105 |
+ deletextpax = '' |
106 |
+ xattr_available = False |
107 |
+ |
108 |
|
109 |
def run_usage(): |
110 |
- print('Package Name : elfix') |
111 |
- print('Bug Reports : http://bugs.gentoo.org/') |
112 |
- print('Program Name : pypaxctl') |
113 |
- if xattr_available: |
114 |
- print('Description : Get/set/delete PT_PAX or XATTR_PAX flags on an ELF object') |
115 |
- print('') |
116 |
- print('Usage : pypaxctl -g ELF get XATTR_PAX flags first, else get PT_PAX flags') |
117 |
- print(' : pypaxctl -s [-PpEeMmRrSs] ELF set PT_PAX and XATTR_PAX flags whenever possible') |
118 |
- print(' : pypaxctl -d ELF delete the XATTR_PAX field') |
119 |
- else: |
120 |
- print('Description : Get/set PT_PAX flags on an ELF object') |
121 |
- print('') |
122 |
- print('Usage : pypaxctl -g ELF get PT_PAX flags') |
123 |
- print(' : pypaxctl -s [-PpEeMmRrSs] ELF set PT_PAX flags whenever possible') |
124 |
- print('') |
125 |
- print('Note : Python module pax.so was compiled without XATTR_PAX support') |
126 |
- print('') |
127 |
+ print('Package Name : elfix') |
128 |
+ print('Bug Reports : http://bugs.gentoo.org/') |
129 |
+ print('Program Name : pypaxctl') |
130 |
+ xattr_message = '''Description : Get/set/delete PT_PAX or XATTR_PAX flags on an ELF object |
131 |
+ |
132 |
+Usage : pypaxctl -g ELF get XATTR_PAX flags first, else get PT_PAX flags |
133 |
+ : pypaxctl -s [-PpEeMmRrSs] ELF set PT_PAX and XATTR_PAX flags whenever possible |
134 |
+ : pypaxctl -d ELF delete the XATTR_PAX field''' |
135 |
+ if xattr_available: |
136 |
+ print(xattr_message) |
137 |
+ else: |
138 |
+ print('Description : Get/set PT_PAX flags on an ELF object') |
139 |
+ print('') |
140 |
+ print('Usage : pypaxctl -g ELF get PT_PAX flags') |
141 |
+ print(' : pypaxctl -s [-PpEeMmRrSs] ELF set PT_PAX flags whenever possible') |
142 |
+ print('') |
143 |
+ print('Note : Python module pax.so was compiled without XATTR_PAX support') |
144 |
+ print('') |
145 |
|
146 |
|
147 |
def main(): |
148 |
- try: |
149 |
- if xattr_available: |
150 |
- opts, args = getopt.getopt(sys.argv[1:], 'gs:d') |
151 |
- else: |
152 |
- opts, args = getopt.getopt(sys.argv[1:], 'gs:') |
153 |
- except getopt.GetoptError as err: |
154 |
- print(err) |
155 |
- sys.exit(1) |
156 |
+ try: |
157 |
+ if xattr_available: |
158 |
+ opts, args = getopt.getopt(sys.argv[1:], 'gs:d') |
159 |
+ else: |
160 |
+ opts, args = getopt.getopt(sys.argv[1:], 'gs:') |
161 |
+ except getopt.GetoptError as err: |
162 |
+ print(err) |
163 |
+ sys.exit(1) |
164 |
|
165 |
- if( len(opts) != 1 or len(args) < 1 ): |
166 |
- run_usage() |
167 |
- sys.exit(1) |
168 |
+ if (len(opts) != 1) or (len(args) < 1): |
169 |
+ run_usage() |
170 |
+ sys.exit(1) |
171 |
|
172 |
- for o, a in opts: |
173 |
- if o == '-g': |
174 |
- for elf in args: |
175 |
- ( str_flags, bin_flags ) = pax.getflags(elf) |
176 |
- print('%s' % str_flags) |
177 |
- elif o == '-s': |
178 |
- for elf in args: |
179 |
- pax.setstrflags(elf, a) |
180 |
+ for o, a in opts: |
181 |
+ if o == '-g': |
182 |
+ for elf in args: |
183 |
+ (str_flags, bin_flags) = pax.getflags(elf) |
184 |
+ print('%s' % str_flags) |
185 |
+ elif o == '-s': |
186 |
+ for elf in args: |
187 |
+ pax.setstrflags(elf, a) |
188 |
|
189 |
- # Don't worry if xattr_available = False |
190 |
- # because we can't get here if it is. |
191 |
- else: |
192 |
- for elf in args: |
193 |
- try: |
194 |
- pax.deletextpax(elf) |
195 |
- except pax.PaxError: |
196 |
- print('pax_deletextpax: XATTR_PAX not supported') |
197 |
- sys.exit(1) |
198 |
+ # Don't worry if xattr_available = False |
199 |
+ # because we can't get here if it is. |
200 |
+ else: |
201 |
+ for elf in args: |
202 |
+ try: |
203 |
+ pax.deletextpax(elf) |
204 |
+ except pax.PaxError: |
205 |
+ print('pax_deletextpax: XATTR_PAX not supported') |
206 |
+ sys.exit(1) |
207 |
|
208 |
if __name__ == '__main__': |
209 |
- main() |
210 |
+ main() |
211 |
|
212 |
diff --git a/scripts/revdep-pax b/scripts/revdep-pax |
213 |
index b919dbf..ebdea9c 100755 |
214 |
--- a/scripts/revdep-pax |
215 |
+++ b/scripts/revdep-pax |
216 |
@@ -23,14 +23,14 @@ |
217 |
# information we need generated by scanelf during emerge. |
218 |
# |
219 |
# See /usr/lib/portage/bin/misc-functions.sh ~line 520 |
220 |
-# echo "${arch:3};${obj};${soname};${rpath};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2 |
221 |
+# echo "${arch:3};${obj};${soname};${rpath};${needed}" >> \ |
222 |
+# "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2 |
223 |
# |
224 |
|
225 |
import getopt |
226 |
import os |
227 |
import sys |
228 |
import pax |
229 |
- |
230 |
import re |
231 |
import portage |
232 |
|
233 |
@@ -66,11 +66,10 @@ class LinkMap: |
234 |
|
235 |
for pkg in vardb.cpv_all(): |
236 |
needed = vardb.aux_get(pkg, ['NEEDED.ELF.2'])[0].strip() |
237 |
- if needed: # Some packages have no NEEDED.ELF.2 |
238 |
+ if needed: # Some packages have no NEEDED.ELF.2 |
239 |
self.pkgs.append(pkg) |
240 |
for line in re.split('\n', needed): |
241 |
- self.pkgs_needed.setdefault(pkg,[]).append(re.split(';', line)) |
242 |
- |
243 |
+ self.pkgs_needed.setdefault(pkg, []).append(re.split(';', line)) |
244 |
|
245 |
def get_object_needed(self): |
246 |
""" Return object_needed dictionary which has structure |
247 |
@@ -91,11 +90,10 @@ class LinkMap: |
248 |
abi = link[0] |
249 |
elf = link[1] |
250 |
sonames = re.split(',', link[4]) |
251 |
- object_needed.setdefault(abi,{}).update({elf:sonames}) |
252 |
+ object_needed.setdefault(abi, {}).update({elf: sonames}) |
253 |
|
254 |
return object_needed |
255 |
|
256 |
- |
257 |
def get_libraries(self): |
258 |
""" Return library2soname dictionary which has structure |
259 |
|
260 |
@@ -113,14 +111,13 @@ class LinkMap: |
261 |
abi = link[0] |
262 |
elf = link[1] |
263 |
soname = link[2] |
264 |
- if soname: #no soname => executable |
265 |
- library2soname[elf] = (soname,abi) |
266 |
- soname2library[(soname,abi)] = elf |
267 |
- |
268 |
- return ( library2soname, soname2library ) |
269 |
+ if soname: # no soname => executable |
270 |
+ library2soname[elf] = (soname, abi) |
271 |
+ soname2library[(soname, abi)] = elf |
272 |
|
273 |
+ return library2soname, soname2library |
274 |
|
275 |
- def get_soname_needed(self, object_needed, library2soname ): |
276 |
+ def get_soname_needed(self, object_needed, library2soname): |
277 |
""" Return soname_needed dictionary which has structure: |
278 |
|
279 |
{ |
280 |
@@ -137,14 +134,14 @@ class LinkMap: |
281 |
for elf in object_needed[abi]: |
282 |
try: |
283 |
(soname, abi_check) = library2soname[elf] |
284 |
- assert abi == abi_check # We should get the same abi associated with the soname |
285 |
- soname_needed.setdefault(abi,{}).update({soname:object_needed[abi][elf]}) |
286 |
+ # We should get the same abi associated with the soname |
287 |
+ assert abi == abi_check |
288 |
+ soname_needed.setdefault(abi, {}).update({soname: object_needed[abi][elf]}) |
289 |
except KeyError: |
290 |
continue # no soname, its probably an executable |
291 |
|
292 |
return soname_needed |
293 |
|
294 |
- |
295 |
def expand_linkings(self, object_needed, soname2library): |
296 |
""" Expands the object_needed dictionary which has structure |
297 |
|
298 |
@@ -162,27 +159,32 @@ class LinkMap: |
299 |
for elf in object_needed[abi]: |
300 |
while True: |
301 |
found_new_soname = False |
302 |
- for so in object_needed[abi][elf]: # For all the first links ... |
303 |
+ # For all the first links ... |
304 |
+ for so in object_needed[abi][elf]: |
305 |
try: |
306 |
- for sn in object_needed[abi][soname2library[(so,abi)]]: # go to the next links ... |
307 |
- if sn in object_needed[abi][elf]: # skip if already included ... |
308 |
+ # go to the next links ... |
309 |
+ for sn in object_needed[abi][soname2library[(so, abi)]]: |
310 |
+ # skip if already included ... |
311 |
+ if sn in object_needed[abi][elf]: |
312 |
continue |
313 |
- if not (sn,abi) in soname2library: # skip if vdso ... |
314 |
+ # skip if vdso ... |
315 |
+ if not (sn, abi) in soname2library: |
316 |
continue |
317 |
|
318 |
- # This appends to the object_needed and soname_needed lists. No copy was |
319 |
- # done so its the same lists in memory for both, and its modified for both. |
320 |
+ # This appends to the object_needed and soname_needed lists. No copy was |
321 |
+ # done so its the same lists in memory for both, and its modified for both. |
322 |
|
323 |
- object_needed[abi][elf].append(sn) # otherwise collapse it back into |
324 |
- found_new_soname = True # first links of the chain. |
325 |
+ # otherwise collapse it back into |
326 |
+ object_needed[abi][elf].append(sn) |
327 |
+ # first links of the chain. |
328 |
+ found_new_soname = True |
329 |
|
330 |
- except KeyError: # Not all nodes in the chain have a next node |
331 |
+ except KeyError: # Not all nodes in the chain have a next node |
332 |
continue |
333 |
|
334 |
if not found_new_soname: # We're done, that last iteration found |
335 |
break # no new nodes |
336 |
|
337 |
- |
338 |
def get_object_reverse_linkings(self, object_linkings): |
339 |
""" Return object_reverse_linkings dictionary which has structure |
340 |
|
341 |
@@ -197,11 +199,10 @@ class LinkMap: |
342 |
for abi in object_linkings: |
343 |
for elf in object_linkings[abi]: |
344 |
for soname in object_linkings[abi][elf]: |
345 |
- object_reverse_linkings.setdefault(abi,{}).setdefault(soname,[]).append(elf) |
346 |
+ object_reverse_linkings.setdefault(abi, {}).setdefault(soname, []).append(elf) |
347 |
|
348 |
return object_reverse_linkings |
349 |
|
350 |
- |
351 |
def get_maps(self): |
352 |
""" Generate the full forward and reverse links using the above functions """ |
353 |
|
354 |
@@ -209,18 +210,16 @@ class LinkMap: |
355 |
# soname_linkings are only one step into the entire link chain. |
356 |
|
357 |
object_linkings = self.get_object_needed() |
358 |
- ( library2soname, soname2library ) = self.get_libraries() |
359 |
- soname_linkings = self.get_soname_needed( object_linkings, library2soname ) |
360 |
+ (library2soname, soname2library) = self.get_libraries() |
361 |
+ soname_linkings = self.get_soname_needed(object_linkings, library2soname) |
362 |
|
363 |
# After the appending in expand_linkings(), forward_linkings and soname_linkings |
364 |
# have been extended through the entire chain of linking. expand_linkings() is |
365 |
# a "side-effect" function, so we note it here. |
366 |
- self.expand_linkings( soname_linkings, soname2library ) |
367 |
- object_reverse_linkings = self.get_object_reverse_linkings( object_linkings ) |
368 |
- |
369 |
- return ( object_linkings, object_reverse_linkings, library2soname, soname2library ) |
370 |
- |
371 |
+ self.expand_linkings(soname_linkings, soname2library) |
372 |
+ object_reverse_linkings = self.get_object_reverse_linkings(object_linkings) |
373 |
|
374 |
+ return object_linkings, object_reverse_linkings, library2soname, soname2library |
375 |
|
376 |
|
377 |
def print_problems(sonames_missing_library): |
378 |
@@ -231,7 +230,8 @@ def print_problems(sonames_missing_library): |
379 |
|
380 |
|
381 |
def run_forward(verbose): |
382 |
- (object_linkings, object_reverse_linkings, library2soname, soname2library) = LinkMap().get_maps() |
383 |
+ (object_linkings, object_reverse_linkings, |
384 |
+ library2soname, soname2library) = LinkMap().get_maps() |
385 |
|
386 |
sonames_missing_library = [] |
387 |
|
388 |
@@ -257,7 +257,7 @@ def run_forward(verbose): |
389 |
sv = '%s\n\t%s\t%s ( %s )' % (sv, soname, library, library_str_flags) |
390 |
if elf_str_flags != library_str_flags: |
391 |
s = '%s\n\t%s\t%s ( %s )' % (s, soname, library, library_str_flags) |
392 |
- count = count + 1 |
393 |
+ count += 1 |
394 |
except KeyError: |
395 |
sonames_missing_library.append(soname) |
396 |
|
397 |
@@ -276,9 +276,10 @@ def run_forward(verbose): |
398 |
|
399 |
|
400 |
def run_reverse(verbose, executable_only): |
401 |
- (object_linkings, object_reverse_linkings, library2soname, soname2library) = LinkMap().get_maps() |
402 |
+ (object_linkings, object_reverse_linkings, |
403 |
+ library2soname, soname2library) = LinkMap().get_maps() |
404 |
|
405 |
- shell_path = path = os.getenv('PATH').split(':') |
406 |
+ shell_path = os.getenv('PATH').split(':') |
407 |
|
408 |
sonames_missing_library = [] |
409 |
|
410 |
@@ -306,12 +307,12 @@ def run_reverse(verbose, executable_only): |
411 |
sv = '%s\n\t%s ( %s )' % (sv, elf, elf_str_flags) |
412 |
if library_str_flags != elf_str_flags: |
413 |
s = '%s\n\t%s ( %s )' % (s, elf, elf_str_flags) |
414 |
- count = count + 1 |
415 |
+ count += 1 |
416 |
else: |
417 |
sv = '%s\n\t%s ( %s )' % (sv, elf, elf_str_flags) |
418 |
if library_str_flags != elf_str_flags: |
419 |
s = '%s\n\t%s ( %s )' % (s, elf, elf_str_flags) |
420 |
- count = count + 1 |
421 |
+ count += 1 |
422 |
|
423 |
if verbose: |
424 |
print('%s\n' % sv) |
425 |
@@ -345,12 +346,12 @@ def migrate_flags(importer, exporter_str_flags, exporter_bin_flags): |
426 |
|
427 |
#See /usr/include/elf.h for these values |
428 |
pf_flags = { |
429 |
- 'P':1<<4, 'p':1<<5, |
430 |
- 'S':1<<6, 's':1<<7, |
431 |
- 'M':1<<8, 'm':1<<9, |
432 |
- 'X':1<<10, 'x':1<<11, |
433 |
- 'E':1<<12, 'e':1<<13, |
434 |
- 'R':1<<14, 'r':1<<15 |
435 |
+ 'P': 1 << 4, 'p': 1 << 5, |
436 |
+ 'S': 1 << 6, 's': 1 << 7, |
437 |
+ 'M': 1 << 8, 'm': 1 << 9, |
438 |
+ 'X': 1 << 10, 'x': 1 << 11, |
439 |
+ 'E': 1 << 12, 'e': 1 << 13, |
440 |
+ 'R': 1 << 14, 'r': 1 << 15 |
441 |
} |
442 |
|
443 |
try: |
444 |
@@ -373,10 +374,10 @@ def migrate_flags(importer, exporter_str_flags, exporter_bin_flags): |
445 |
result_bin_flags = result_bin_flags ^ pf_flags[exporter_str_flags[i]] |
446 |
result_bin_flags = result_bin_flags | pf_flags[importer_str_flags[i]] |
447 |
print('\t\tWarning: %s has %s, refusing to set to %s' % ( |
448 |
- importer, importer_str_flags[i], exporter_str_flags[i] )), |
449 |
+ importer, importer_str_flags[i], exporter_str_flags[i])), |
450 |
|
451 |
# The exporter's flags is off, so use the importer's flag |
452 |
- if (exporter_str_flags[i] == '-' and importer_str_flags[i] != '-'): |
453 |
+ if (exporter_str_flags[i] == '-') and (importer_str_flags[i] != '-'): |
454 |
result_bin_flags = result_bin_flags | pf_flags[importer_str_flags[i]] |
455 |
|
456 |
pax.setbinflags(importer, result_bin_flags) |
457 |
@@ -394,16 +395,17 @@ def run_elf(elf, verbose, mark, allyes): |
458 |
print('%s: No PAX flags found\n' % elf) |
459 |
return |
460 |
|
461 |
- (object_linkings, object_reverse_linkings, library2soname, soname2library) = LinkMap().get_maps() |
462 |
+ (object_linkings, object_reverse_linkings, |
463 |
+ library2soname, soname2library) = LinkMap().get_maps() |
464 |
|
465 |
mismatched_libraries = [] |
466 |
|
467 |
for abi in object_linkings: |
468 |
- if not elf in object_linkings[abi]: # There may be no elf for that abi |
469 |
+ if not elf in object_linkings[abi]: # There may be no elf for that abi |
470 |
continue |
471 |
for soname in object_linkings[abi][elf]: |
472 |
try: |
473 |
- library = soname2library[(soname,abi)] |
474 |
+ library = soname2library[(soname, abi)] |
475 |
try: |
476 |
(library_str_flags, library_bin_flags) = pax.getflags(library) |
477 |
except pax.PaxError: |
478 |
@@ -444,7 +446,7 @@ def run_elf(elf, verbose, mark, allyes): |
479 |
try: |
480 |
migrate_flags(library, elf_str_flags, elf_bin_flags) |
481 |
except pax.PaxError: |
482 |
- print('\n\tCould not set PAX flags on %s, text maybe busy' % (library, abi)) |
483 |
+ print('\n\tCould not set PAX flags on %s, text maybe busy' % library) |
484 |
|
485 |
try: |
486 |
(library_str_flags, library_bin_flags) = pax.getflags(library) |
487 |
@@ -454,9 +456,10 @@ def run_elf(elf, verbose, mark, allyes): |
488 |
|
489 |
|
490 |
def run_soname(name, verbose, use_soname, mark, allyes, executable_only): |
491 |
- shell_path = path = os.getenv('PATH').split(':') |
492 |
+ shell_path = os.getenv('PATH').split(':') |
493 |
|
494 |
- (object_linkings, object_reverse_linkings, library2soname, soname2library) = LinkMap().get_maps() |
495 |
+ (object_linkings, object_reverse_linkings, |
496 |
+ library2soname, soname2library) = LinkMap().get_maps() |
497 |
|
498 |
if use_soname: |
499 |
soname = name |
500 |
@@ -476,7 +479,6 @@ def run_soname(name, verbose, use_soname, mark, allyes, executable_only): |
501 |
print('%s\tNo such LIBRARY' % name) |
502 |
return |
503 |
|
504 |
- |
505 |
mismatched_elfs = [] |
506 |
|
507 |
for abi in abi_list: |
508 |
@@ -487,15 +489,15 @@ def run_soname(name, verbose, use_soname, mark, allyes, executable_only): |
509 |
library = soname2library[(soname, abi)] |
510 |
|
511 |
try: |
512 |
- (library_str_flags, library_bin_flags) = pax.getflags(library) |
513 |
- print('%s\t%s :%s (%s)\n' % (soname, library, abi, library_str_flags)) |
514 |
+ (library_str_flags, library_bin_flags) = pax.getflags(library) |
515 |
+ print('%s\t%s :%s (%s)\n' % (soname, library, abi, library_str_flags)) |
516 |
except pax.PaxError: |
517 |
- print('%s :%s : No PAX flags found\n' % (library, abi)) |
518 |
- continue |
519 |
+ print('%s :%s : No PAX flags found\n' % (library, abi)) |
520 |
+ continue |
521 |
|
522 |
for elf in object_reverse_linkings[abi][soname]: |
523 |
try: |
524 |
- (elf_str_flags, elf_bin_flags ) = pax.getflags(elf) |
525 |
+ (elf_str_flags, elf_bin_flags) = pax.getflags(elf) |
526 |
except pax.PaxError: |
527 |
elf_str_flags = '****' |
528 |
if verbose: |
529 |
@@ -551,22 +553,23 @@ def run_soname(name, verbose, use_soname, mark, allyes, executable_only): |
530 |
|
531 |
|
532 |
def run_usage(): |
533 |
- print('Package Name : elfix') |
534 |
- print('Bug Reports : http://bugs.gentoo.org/') |
535 |
- print('Program Name : revdep-pax') |
536 |
- print('Description : Get or set pax flags on an ELF object') |
537 |
- print('') |
538 |
- print('Usage : revdep-pax -f [-v] print out all forward mappings for all system ELF objects') |
539 |
- print(' : revdep-pax -r [-ve] print out all reverse mappings for all system sonames') |
540 |
- print(' : revdep-pax -b OBJECT [-myv] print all forward mappings only for OBJECT') |
541 |
- print(' : revdep-pax -s SONAME [-myve] print all reverse mappings only for SONAME') |
542 |
- print(' : revdep-pax -l LIBRARY [-myve] print all reverse mappings only for LIBRARY file') |
543 |
- print(' : revdep-pax [-h] print out this help') |
544 |
- print(' : -v verbose, otherwise just print mismatching objects') |
545 |
- print(' : -e only print out executables in shell $PATH') |
546 |
- print(' : -m don\'t just report, but mark the mismatching objects') |
547 |
- print(' : -y assume "yes" to all prompts for marking (USE CAREFULLY!)') |
548 |
- print('') |
549 |
+ usage = '''Package Name : elfix |
550 |
+Bug Reports : http://bugs.gentoo.org/ |
551 |
+Program Name : revdep-pax |
552 |
+Description : Get or set pax flags on an ELF object |
553 |
+ |
554 |
+Usage : revdep-pax -f [-v] print all forward mappings for all system ELF objects |
555 |
+ : revdep-pax -r [-ve] print all reverse mappings for all system sonames |
556 |
+ : revdep-pax -b OBJECT [-myv] print all forward mappings only for OBJECT |
557 |
+ : revdep-pax -s SONAME [-myve] print all reverse mappings only for SONAME |
558 |
+ : revdep-pax -l LIBRARY [-myve] print all reverse mappings only for LIBRARY file |
559 |
+ : revdep-pax [-h] print this help |
560 |
+ : -v verbose, otherwise just print mismatching objects |
561 |
+ : -e only print executables in shell $PATH |
562 |
+ : -m don\'t just report, but mark the mismatching objects |
563 |
+ : -y assume "yes" to all prompts for marking (BE CAREFULL) |
564 |
+''' |
565 |
+ print(usage) |
566 |
|
567 |
|
568 |
def main(): |
569 |
@@ -579,7 +582,7 @@ def main(): |
570 |
try: |
571 |
opts, args = getopt.getopt(sys.argv[1:], 'hfrb:s:l:vemy') |
572 |
except getopt.GetoptError as err: |
573 |
- print(str(err)) # will print something like 'option -a not recognized' |
574 |
+ print(str(err)) # will print something like 'option -a not recognized' |
575 |
run_usage() |
576 |
sys.exit(1) |
577 |
|
578 |
@@ -587,12 +590,12 @@ def main(): |
579 |
run_usage() |
580 |
sys.exit(1) |
581 |
|
582 |
- do_usage = False |
583 |
+ do_usage = False |
584 |
do_forward = False |
585 |
do_reverse = False |
586 |
|
587 |
- elf = None |
588 |
- soname = None |
589 |
+ elf = None |
590 |
+ soname = None |
591 |
library = None |
592 |
|
593 |
verbose = False |
594 |
@@ -641,11 +644,11 @@ def main(): |
595 |
run_forward(verbose) |
596 |
elif do_reverse: |
597 |
run_reverse(verbose, executable_only) |
598 |
- elif elf != None: |
599 |
+ elif elf is not None: |
600 |
run_elf(elf, verbose, mark, allyes) |
601 |
- elif soname != None: |
602 |
+ elif soname is not None: |
603 |
run_soname(soname, verbose, True, mark, allyes, executable_only) |
604 |
- elif library != None: |
605 |
+ elif library is not None: |
606 |
library = os.path.realpath(library) |
607 |
run_soname(library, verbose, False, mark, allyes, executable_only) |