From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RUNDc-0006KN-AC for garchives@archives.gentoo.org; Sat, 26 Nov 2011 18:43:20 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 63F4B21C098; Sat, 26 Nov 2011 18:43:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 1DF5921C098 for ; Sat, 26 Nov 2011 18:43:08 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 85CC71B4020 for ; Sat, 26 Nov 2011 18:43:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id DFB6180042 for ; Sat, 26 Nov 2011 18:43:06 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: Subject: [gentoo-commits] proj/elfix:master commit in: scripts/, doc/ X-VCS-Repository: proj/elfix X-VCS-Files: doc/revdep-pax.1 doc/revdep-pax.pod scripts/revdep-pax X-VCS-Directories: scripts/ doc/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: f85a9ba0fc729d43fdf240da7d075eaaa09c6b62 Date: Sat, 26 Nov 2011 18:43:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: b1350175-bfb1-41bb-8c46-f11556e37a15 X-Archives-Hash: c79b598124692fb007db5575d542f124 commit: f85a9ba0fc729d43fdf240da7d075eaaa09c6b62 Author: Anthony G. Basile gentoo org> AuthorDate: Sat Nov 26 18:42:59 2011 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sat Nov 26 18:42:59 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/elfix.git;a=3D= commit;h=3Df85a9ba0 scripts/revdep-pax: add -e switch, verbose for ~/bin:/usr/local/bin:/usr/= bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/usr/lib64/subve= rsion/bin:/usr/games/bin only --- doc/revdep-pax.1 | 36 +++++++++++++++------------ doc/revdep-pax.pod | 24 ++++++++++------- scripts/revdep-pax | 68 ++++++++++++++++++++++++++++------------------= ----- 3 files changed, 71 insertions(+), 57 deletions(-) diff --git a/doc/revdep-pax.1 b/doc/revdep-pax.1 index 8e2b008..3933f76 100644 --- a/doc/revdep-pax.1 +++ b/doc/revdep-pax.1 @@ -135,13 +135,13 @@ revdep\-pax \- find mismatching PaX markings betwee= n ELF objects and their libra .IX Header "SYNOPSIS" \&\fBrevdep-pax\fR \-f [\-v] .PP -\&\fBrevdep-pax\fR \-r [\-v] +\&\fBrevdep-pax\fR \-r [\-ve] .PP \&\fBrevdep-pax\fR \-b \s-1OBJECT\s0 [\-mv] .PP -\&\fBrevdep-pax\fR \-s \s-1SONAME\s0 [\-mv] +\&\fBrevdep-pax\fR \-s \s-1SONAME\s0 [\-mve] .PP -\&\fBrevdep-pax\fR \-l \s-1LIBRARY\s0 [\-mv] +\&\fBrevdep-pax\fR \-l \s-1LIBRARY\s0 [\-mve] .PP \&\fBrevdep-pax\fR [\-h] .SH "DESCRIPTION" @@ -165,28 +165,32 @@ and in mark mode (\-m), the user is prompted whethe= r to proceed with the migrati so that the PaX flags of the target inherit the flags of the source. .SH "OPTIONS" .IX Header "OPTIONS" -.IP "\fB\-f\fR Scan the system for all forward mappings" 4 -.IX Item "-f Scan the system for all forward mappings" +.IP "\fB\-f\fR Scan the system for all forward mappings." 4 +.IX Item "-f Scan the system for all forward mappings." .PD 0 .IP "" 4 -.IP "\fB\-r\fR Scan the system for all reverse mappings" 4 -.IX Item "-r Scan the system for all reverse mappings" +.IP "\fB\-r\fR Scan the system for all reverse mappings." 4 +.IX Item "-r Scan the system for all reverse mappings." .IP "" 4 -.IP "\fB\-b\fR \s-1OBJECT\s0 Retrieve only the forward mappings for t= his \s-1ELF\s0 \s-1OBJECT\s0" 4 -.IX Item "-b OBJECT Retrieve only the forward mappings for this ELF O= BJECT" +.IP "\fB\-b\fR \s-1OBJECT\s0 Retrieve only the forward mappings for t= his \s-1ELF\s0 \s-1OBJECT\s0." 4 +.IX Item "-b OBJECT Retrieve only the forward mappings for this ELF O= BJECT." .IP "" 4 -.IP "\fB\-s\fR \s-1SONAME\s0 Retrieve only the reverse mappings for t= his \s-1SONAME\s0" 4 -.IX Item "-s SONAME Retrieve only the reverse mappings for this SONAM= E" +.IP "\fB\-s\fR \s-1SONAME\s0 Retrieve only the reverse mappings for t= his \s-1SONAME\s0." 4 +.IX Item "-s SONAME Retrieve only the reverse mappings for this SONAM= E." .IP "" 4 -.IP "\fB\-l\fR \s-1LIBRARY\s0 Retrieve only the reverse mappings for t= his \s-1LIBRARY\s0" 4 -.IX Item "-l LIBRARY Retrieve only the reverse mappings for this LIBRA= RY" -.IP "" 4 -.IP "\fB\-v\fR Report all mappings, not just the mismatched ones" 4 -.IX Item "-v Report all mappings, not just the mismatched ones" +.IP "\fB\-l\fR \s-1LIBRARY\s0 Retrieve only the reverse mappings for t= his \s-1LIBRARY\s0." 4 +.IX Item "-l LIBRARY Retrieve only the reverse mappings for this LIBRA= RY." .IP "" 4 .IP "\fB\-m\fR Prompt the user to mark the found object with the PaX f= lags of the source" 4 .IX Item "-m Prompt the user to mark the found object with the PaX fla= gs of the source" .IP "" 4 +.IP "\fB\-v\fR Report all mappings, not just the mismatched ones." 4 +.IX Item "-v Report all mappings, not just the mismatched ones." +.IP "" 4 +.ie n .IP "\fB\-e\fR If \-v is chosen, then limit the report to only t= hose executables in the current shell's $PATH. If \-m is chosen, then li= mit the markings to only those executables. This flag only has effect fo= r reverse mappings, i.e., for \-r, \-s or \-l." 4 +.el .IP "\fB\-e\fR If \-v is chosen, then limit the report to only tho= se executables in the current shell's \f(CW$PATH\fR. If \-m is chosen, t= hen limit the markings to only those executables. This flag only has eff= ect for reverse mappings, i.e., for \-r, \-s or \-l." 4 +.IX Item "-e If -v is chosen, then limit the report to only those exec= utables in the current shell's $PATH. If -m is chosen, then limit the ma= rkings to only those executables. This flag only has effect for reverse = mappings, i.e., for -r, -s or -l." +.IP "" 4 .IP "\fB\-h\fR Print out a short help message and exit." 4 .IX Item "-h Print out a short help message and exit." .PD diff --git a/doc/revdep-pax.pod b/doc/revdep-pax.pod index fc46418..a72b0ba 100644 --- a/doc/revdep-pax.pod +++ b/doc/revdep-pax.pod @@ -6,13 +6,13 @@ B - find mismatching PaX markings between E= LF objects and their libr =20 B -f [-v] =20 -B -r [-v] +B -r [-ve] =20 B -b OBJECT [-mv] =20 -B -s SONAME [-mv] +B -s SONAME [-mve] =20 -B -l LIBRARY [-mv] +B -l LIBRARY [-mve] =20 B [-h] =20 @@ -40,31 +40,35 @@ so that the PaX flags of the target inherit the flags= of the source. =20 =3Dover =20 -=3Ditem B<-f> Scan the system for all forward mappings +=3Ditem B<-f> Scan the system for all forward mappings. =20 =3Ditem =20 -=3Ditem B<-r> Scan the system for all reverse mappings +=3Ditem B<-r> Scan the system for all reverse mappings. =20 =3Ditem =20 -=3Ditem B<-b> OBJECT Retrieve only the forward mappings for this ELF = OBJECT +=3Ditem B<-b> OBJECT Retrieve only the forward mappings for this ELF = OBJECT. =20 =3Ditem =20 -=3Ditem B<-s> SONAME Retrieve only the reverse mappings for this SONA= ME +=3Ditem B<-s> SONAME Retrieve only the reverse mappings for this SONA= ME. =20 =3Ditem =20 -=3Ditem B<-l> LIBRARY Retrieve only the reverse mappings for this LIBR= ARY +=3Ditem B<-l> LIBRARY Retrieve only the reverse mappings for this LIBR= ARY. =20 =3Ditem =20 -=3Ditem B<-v> Report all mappings, not just the mismatched ones +=3Ditem B<-m> Prompt the user to mark the found object with the PaX fl= ags of the source. =20 =3Ditem =20 -=3Ditem B<-m> Prompt the user to mark the found object with the PaX fl= ags of the source +=3Ditem B<-v> Report all mappings, not just the mismatched ones. + +=3Ditem + +=3Ditem B<-e> If -v is chosen, then limit the report to only those exe= cutables in the current shell's $PATH. If -m is chosen, then limit the m= arkings to only those executables. This flag only has effect for reverse= mappings, i.e., for -r, -s or -l. =20 =3Ditem =20 diff --git a/scripts/revdep-pax b/scripts/revdep-pax index bfea494..b65a65a 100755 --- a/scripts/revdep-pax +++ b/scripts/revdep-pax @@ -105,13 +105,10 @@ def print_forward_linkings( forward_linkings, so2li= brary_mappings, verbose ): print sv print if count =3D=3D 0: - print print '\tNo mismatches' - print else: - print print '\tMismatches' - print + print else: if count !=3D 0: print s @@ -120,14 +117,12 @@ def print_forward_linkings( forward_linkings, so2li= brary_mappings, verbose ): =20 missing_binaries =3D set(missing_binaries) print - print print '**** Missing binaries ****' for m in missing_binaries: print m =20 missing_links =3D set(missing_links) print - print print '**** Missing forward linkings ****' for m in missing_links: print m @@ -136,7 +131,8 @@ def print_forward_linkings( forward_linkings, so2libr= ary_mappings, verbose ): print =20 =20 -def print_reverse_linkings( reverse_linkings, so2library_mappings, verbo= se ): +def print_reverse_linkings( reverse_linkings, so2library_mappings, verbo= se, executable_only ): + shell_path =3D path =3D os.getenv('PATH').split(':') missing_sonames =3D [] missing_links =3D [] =20 @@ -155,7 +151,11 @@ def print_reverse_linkings( reverse_linkings, so2lib= rary_mappings, verbose ): for binary in reverse_linkings[soname]: try: ( binary_flags, binary_pax_flags ) =3D pax.getflags(binary) - sv =3D '%s\n\t%s ( %s )' % ( sv, binary, binary_flags ) + if executable_only: + if os.path.dirname(binary) in shell_path:=09 + sv =3D '%s\n\t%s ( %s )' % ( sv, binary, binary_flags ) + else: + sv =3D '%s\n\t%s ( %s )' % ( sv, binary, binary_flags ) if library_flags !=3D binary_flags: s =3D '%s\n\t%s ( %s )' % ( s, binary, binary_flags ) count =3D count + 1 @@ -166,13 +166,10 @@ def print_reverse_linkings( reverse_linkings, so2li= brary_mappings, verbose ): print sv print if count =3D=3D 0: - print print '\tNo mismatches' - print else: - print print '\tMismatches' - print + print else: if count !=3D 0: print s @@ -181,17 +178,16 @@ def print_reverse_linkings( reverse_linkings, so2li= brary_mappings, verbose ): =20 missing_sonames =3D set(missing_sonames) print - print print '**** Missing sonames ****' for m in missing_sonames: print m =20 missing_links =3D set(missing_links) print - print print '**** Missing reverse linkings ****' for m in missing_links: print m + print print =20 @@ -202,14 +198,15 @@ def run_usage(): print 'Program Name : revdep-pax' print 'Description : Get or set pax flags on an ELF object' print - print 'Usage : revdep-pax -f [-v] print out all forwar= d mappings for all system binaries' - print ' : revdep-pax -r [-v] print out all revers= e mappints for all system sonames' - print ' : revdep-pax -b OBJECT [-mv] print all forward ma= ppings only for OBJECT' - print ' : revdep-pax -s SONAME [-mv] print all reverse ma= ppings only for SONAME' - print ' : revdep-pax -l LIBRARY [-mv] print all reverse ma= ppings only for LIBRARY file' - print ' : revdep-pax [-h] print out this help' - print ' : -v verbose, otherwise j= ust print mismatching objects' - print ' : -m don\'t just report, = but mark the mismatching objects' + print 'Usage : revdep-pax -f [-v] print out all forwa= rd mappings for all system binaries' + print ' : revdep-pax -r [-ve] print out all rever= se mappings for all system sonames' + print ' : revdep-pax -b OBJECT [-mv] print all forward m= appings only for OBJECT' + print ' : revdep-pax -s SONAME [-mve] print all reverse m= appings only for SONAME' + print ' : revdep-pax -l LIBRARY [-mve] print all reverse m= appings only for LIBRARY file' + print ' : revdep-pax [-h] print out this help= ' + print ' : -v verbose, otherwise = just print mismatching objects' + print ' : -e assuming verbose, o= nly print out executables in shell $PATH' + print ' : -m don\'t just report,= but mark the mismatching objects' print =20 =20 @@ -219,10 +216,10 @@ def run_forward(verbose): print =20 =20 -def run_reverse(verbose): +def run_reverse(verbose, executable_only): ( forward_linkings, so2library_mappings ) =3D get_forward_linkings() reverse_linkings =3D invert_linkings( forward_linkings ) - print_reverse_linkings( reverse_linkings, so2library_mappings, verbose = ) + print_reverse_linkings( reverse_linkings, so2library_mappings, verbose,= executable_only) print =20 =20 @@ -285,7 +282,9 @@ def invert_so2library_mappings( so2library_mappings )= : return library2soname_mappings =20 =20 -def run_soname(name, verbose, use_soname, mark): +def run_soname(name, verbose, use_soname, executable_only, mark): + shell_path =3D path =3D os.getenv('PATH').split(':') + ( forward_linkings, so2library_mappings ) =3D get_forward_linkings() reverse_linkings =3D invert_linkings( forward_linkings ) =20 @@ -299,7 +298,7 @@ def run_soname(name, verbose, use_soname, mark): library =3D so2library_mappings[soname] =20 ( library_flags, library_pax_flags ) =3D pax.getflags(library) - print soname, '\t', library, '(', library_flags, ')' + print '%s\t%s (%s)' % ( soname, library, library_flags ) print =20 mismatched_binaries =3D [] @@ -307,7 +306,11 @@ def run_soname(name, verbose, use_soname, mark): try: ( binary_flags, binary_pax_flags ) =3D pax.getflags(binary) if verbose: - print '\t%s ( %s )' % ( binary, binary_flags ) + if executable_only: + if os.path.dirname(binary) in shell_path:=09 + print '\t%s ( %s )' % ( binary, binary_flags ) + else: + print '\t%s ( %s )' % ( binary, binary_flags ) if library_flags !=3D binary_flags: mismatched_binaries.append(binary) if not verbose: @@ -347,7 +350,7 @@ def run_soname(name, verbose, use_soname, mark): =20 def main(): try: - opts, args =3D getopt.getopt(sys.argv[1:], 'hfrb:s:l:vm') + opts, args =3D getopt.getopt(sys.argv[1:], 'hfrb:s:l:vem') except getopt.GetoptError, err: print str(err) # will print something like 'option -a not recognized' run_usage() @@ -366,6 +369,7 @@ def main(): library =3D None =20 verbose =3D False + executable_only =3D False mark =3D False =20 opt_count =3D 0 @@ -391,6 +395,8 @@ def main(): opt_count +=3D 1 elif o =3D=3D '-v': verbose =3D True + elif o =3D=3D '-e': + executable_only =3D True elif o =3D=3D '-m': mark =3D True else: @@ -404,14 +410,14 @@ def main(): elif do_forward: run_forward(verbose) elif do_reverse: - run_reverse(verbose) + run_reverse(verbose, executable_only) elif binary !=3D None: run_binary(binary, verbose, mark) elif soname !=3D None: - run_soname(soname, verbose, True, mark) + run_soname(soname, verbose, executable_only, True, mark) elif library !=3D None: library =3D os.path.realpath(library) - run_soname(library, verbose, False, mark) + run_soname(library, verbose, executable_only, False, mark) =20 if __name__ =3D=3D '__main__': main()