1 |
commit: 68bea515fdb194cfecf57c3f51fda445bb62f7d0 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 28 20:37:52 2011 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 28 20:37:52 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=68bea515 |
7 |
|
8 |
scripts/revdep-pax: added an allyes option |
9 |
|
10 |
--- |
11 |
doc/revdep-pax.1 | 16 ++++++++++------ |
12 |
doc/revdep-pax.pod | 16 ++++++++++------ |
13 |
scripts/revdep-pax | 44 +++++++++++++++++++++++++++----------------- |
14 |
3 files changed, 47 insertions(+), 29 deletions(-) |
15 |
|
16 |
diff --git a/doc/revdep-pax.1 b/doc/revdep-pax.1 |
17 |
index 3d2974c..698e90c 100644 |
18 |
--- a/doc/revdep-pax.1 |
19 |
+++ b/doc/revdep-pax.1 |
20 |
@@ -137,11 +137,11 @@ revdep\-pax \- find mismatching PaX markings between ELF objects and their libra |
21 |
.PP |
22 |
\&\fBrevdep-pax\fR \-r [\-ve] |
23 |
.PP |
24 |
-\&\fBrevdep-pax\fR \-b \s-1OBJECT\s0 [\-mv] |
25 |
+\&\fBrevdep-pax\fR \-b \s-1OBJECT\s0 [\-myv] |
26 |
.PP |
27 |
-\&\fBrevdep-pax\fR \-s \s-1SONAME\s0 [\-mve] |
28 |
+\&\fBrevdep-pax\fR \-s \s-1SONAME\s0 [\-myve] |
29 |
.PP |
30 |
-\&\fBrevdep-pax\fR \-l \s-1LIBRARY\s0 [\-mve] |
31 |
+\&\fBrevdep-pax\fR \-l \s-1LIBRARY\s0 [\-myve] |
32 |
.PP |
33 |
\&\fBrevdep-pax\fR [\-h] |
34 |
.SH "DESCRIPTION" |
35 |
@@ -181,9 +181,6 @@ so that the PaX flags of the target inherit the flags of the source. |
36 |
.IP "\fB\-l\fR \s-1LIBRARY\s0 Retrieve only the reverse mappings for this \s-1LIBRARY\s0." 4 |
37 |
.IX Item "-l LIBRARY Retrieve only the reverse mappings for this LIBRARY." |
38 |
.IP "" 4 |
39 |
-.IP "\fB\-m\fR Prompt the user to mark the found object with the PaX flags of the source." 4 |
40 |
-.IX Item "-m Prompt the user to mark the found object with the PaX flags of the source." |
41 |
-.IP "" 4 |
42 |
.IP "\fB\-v\fR Report all mappings, not just the mismatched ones." 4 |
43 |
.IX Item "-v Report all mappings, not just the mismatched ones." |
44 |
.IP "" 4 |
45 |
@@ -191,6 +188,13 @@ so that the PaX flags of the target inherit the flags of the source. |
46 |
.el .IP "\fB\-e\fR Limit the markings or report to only those executables in the current shell's \f(CW$PATH\fR." 4 |
47 |
.IX Item "-e Limit the markings or report to only those executables in the current shell's $PATH." |
48 |
.IP "" 4 |
49 |
+.IP "\fB\-m\fR Prompt the user to mark the found object with the PaX flags of the source." 4 |
50 |
+.IX Item "-m Prompt the user to mark the found object with the PaX flags of the source." |
51 |
+.IP "" 4 |
52 |
+.ie n .IP "\fB\-y\fR Assume ""yes"" to all prompts for making (\s-1USE\s0 \s-1CAREFULLY\s0!)" 4 |
53 |
+.el .IP "\fB\-y\fR Assume ``yes'' to all prompts for making (\s-1USE\s0 \s-1CAREFULLY\s0!)" 4 |
54 |
+.IX Item "-y Assume yes to all prompts for making (USE CAREFULLY!)" |
55 |
+.IP "" 4 |
56 |
.IP "\fB\-h\fR Print out a short help message and exit." 4 |
57 |
.IX Item "-h Print out a short help message and exit." |
58 |
.PD |
59 |
|
60 |
diff --git a/doc/revdep-pax.pod b/doc/revdep-pax.pod |
61 |
index 03ff277..19bf750 100644 |
62 |
--- a/doc/revdep-pax.pod |
63 |
+++ b/doc/revdep-pax.pod |
64 |
@@ -8,11 +8,11 @@ B<revdep-pax> -f [-v] |
65 |
|
66 |
B<revdep-pax> -r [-ve] |
67 |
|
68 |
-B<revdep-pax> -b OBJECT [-mv] |
69 |
+B<revdep-pax> -b OBJECT [-myv] |
70 |
|
71 |
-B<revdep-pax> -s SONAME [-mve] |
72 |
+B<revdep-pax> -s SONAME [-myve] |
73 |
|
74 |
-B<revdep-pax> -l LIBRARY [-mve] |
75 |
+B<revdep-pax> -l LIBRARY [-myve] |
76 |
|
77 |
B<revdep-pax> [-h] |
78 |
|
79 |
@@ -60,15 +60,19 @@ so that the PaX flags of the target inherit the flags of the source. |
80 |
|
81 |
=item |
82 |
|
83 |
-=item B<-m> Prompt the user to mark the found object with the PaX flags of the source. |
84 |
+=item B<-v> Report all mappings, not just the mismatched ones. |
85 |
|
86 |
=item |
87 |
|
88 |
-=item B<-v> Report all mappings, not just the mismatched ones. |
89 |
+=item B<-e> Limit the markings or report to only those executables in the current shell's $PATH. |
90 |
|
91 |
=item |
92 |
|
93 |
-=item B<-e> Limit the markings or report to only those executables in the current shell's $PATH. |
94 |
+=item B<-m> Prompt the user to mark the found object with the PaX flags of the source. |
95 |
+ |
96 |
+=item |
97 |
+ |
98 |
+=item B<-y> Assume "yes" to all prompts for making (USE CAREFULLY!) |
99 |
|
100 |
=item |
101 |
|
102 |
|
103 |
diff --git a/scripts/revdep-pax b/scripts/revdep-pax |
104 |
index be6a387..e22d3a7 100755 |
105 |
--- a/scripts/revdep-pax |
106 |
+++ b/scripts/revdep-pax |
107 |
@@ -228,7 +228,7 @@ def migrate_flags(importer, exporter_str_flags, exporter_bin_flags): |
108 |
pax.setflags(importer, result_bin_flags) |
109 |
|
110 |
|
111 |
-def run_binary(binary, verbose, mark): |
112 |
+def run_binary(binary, verbose, mark, allyes): |
113 |
( linkings, mappings ) = get_ldd_linkings(binary) |
114 |
( binary_str_flags, binary_bin_flags ) = pax.getflags(binary) |
115 |
print '%s (%s)\n' % ( binary, binary_str_flags ) |
116 |
@@ -259,7 +259,10 @@ def run_binary(binary, verbose, mark): |
117 |
for library in mismatched_libraries: |
118 |
do_marking = False |
119 |
while True: |
120 |
- ans = raw_input('\tSet flags for %s (y/n): ' % library) |
121 |
+ if allyes: |
122 |
+ ans = 'y' |
123 |
+ else: |
124 |
+ ans = raw_input('\tSet flags for %s (y/n): ' % library) |
125 |
if ans == 'y': |
126 |
do_marking = True |
127 |
break |
128 |
@@ -286,7 +289,7 @@ def invert_so2library_mappings( so2library_mappings ): |
129 |
return library2soname_mappings |
130 |
|
131 |
|
132 |
-def run_soname(name, verbose, use_soname, mark, executable_only): |
133 |
+def run_soname(name, verbose, use_soname, mark, allyes, executable_only): |
134 |
shell_path = path = os.getenv('PATH').split(':') |
135 |
|
136 |
( forward_linkings, so2library_mappings ) = get_forward_linkings() |
137 |
@@ -340,7 +343,10 @@ def run_soname(name, verbose, use_soname, mark, executable_only): |
138 |
continue |
139 |
do_marking = False |
140 |
while True: |
141 |
- ans = raw_input('\tSet flags for %s (y/n): ' % binary) |
142 |
+ if allyes: |
143 |
+ ans = 'y' |
144 |
+ else: |
145 |
+ ans = raw_input('\tSet flags for %s (y/n): ' % binary) |
146 |
if ans == 'y': |
147 |
do_marking = True |
148 |
break |
149 |
@@ -365,21 +371,22 @@ def run_usage(): |
150 |
print 'Program Name : revdep-pax' |
151 |
print 'Description : Get or set pax flags on an ELF object' |
152 |
print |
153 |
- print 'Usage : revdep-pax -f [-v] print out all forward mappings for all system binaries' |
154 |
- print ' : revdep-pax -r [-ve] print out all reverse mappings for all system sonames' |
155 |
- print ' : revdep-pax -b OBJECT [-mv] print all forward mappings only for OBJECT' |
156 |
- print ' : revdep-pax -s SONAME [-mve] print all reverse mappings only for SONAME' |
157 |
- print ' : revdep-pax -l LIBRARY [-mve] print all reverse mappings only for LIBRARY file' |
158 |
- print ' : revdep-pax [-h] print out this help' |
159 |
- print ' : -v verbose, otherwise just print mismatching objects' |
160 |
- print ' : -e only print out executables in shell $PATH' |
161 |
- print ' : -m don\'t just report, but mark the mismatching objects' |
162 |
+ print 'Usage : revdep-pax -f [-v] print out all forward mappings for all system binaries' |
163 |
+ print ' : revdep-pax -r [-ve] print out all reverse mappings for all system sonames' |
164 |
+ print ' : revdep-pax -b OBJECT [-myv] print all forward mappings only for OBJECT' |
165 |
+ print ' : revdep-pax -s SONAME [-myve] print all reverse mappings only for SONAME' |
166 |
+ print ' : revdep-pax -l LIBRARY [-myve] print all reverse mappings only for LIBRARY file' |
167 |
+ print ' : revdep-pax [-h] print out this help' |
168 |
+ print ' : -v verbose, otherwise just print mismatching objects' |
169 |
+ print ' : -e only print out executables in shell $PATH' |
170 |
+ print ' : -m don\'t just report, but mark the mismatching objects' |
171 |
+ print ' : -y assume "yes" to all prompts for making (USE CAREFULLY!)' |
172 |
print |
173 |
|
174 |
|
175 |
def main(): |
176 |
try: |
177 |
- opts, args = getopt.getopt(sys.argv[1:], 'hfrb:s:l:vem') |
178 |
+ opts, args = getopt.getopt(sys.argv[1:], 'hfrb:s:l:vemy') |
179 |
except getopt.GetoptError, err: |
180 |
print str(err) # will print something like 'option -a not recognized' |
181 |
run_usage() |
182 |
@@ -400,6 +407,7 @@ def main(): |
183 |
verbose = False |
184 |
executable_only = False |
185 |
mark = False |
186 |
+ allyes = False |
187 |
|
188 |
opt_count = 0 |
189 |
|
190 |
@@ -428,6 +436,8 @@ def main(): |
191 |
executable_only = True |
192 |
elif o == '-m': |
193 |
mark = True |
194 |
+ elif o == '-y': |
195 |
+ allyes = True |
196 |
else: |
197 |
print 'Option included in getopt but not handled here!' |
198 |
print 'Please file a bug' |
199 |
@@ -442,18 +452,18 @@ def main(): |
200 |
run_reverse(verbose, executable_only) |
201 |
elif binary != None: |
202 |
try: |
203 |
- run_binary(binary, verbose, mark) |
204 |
+ run_binary(binary, verbose, mark, allyes) |
205 |
except: |
206 |
print 'Please check that %s exists!' % binary |
207 |
elif soname != None: |
208 |
try: |
209 |
- run_soname(soname, verbose, True, mark, executable_only) |
210 |
+ run_soname(soname, verbose, True, mark, allyes, executable_only) |
211 |
except: |
212 |
print 'Please check that %s exists!' % soname |
213 |
elif library != None: |
214 |
try: |
215 |
library = os.path.realpath(library) |
216 |
- run_soname(library, verbose, False, mark, executable_only) |
217 |
+ run_soname(library, verbose, False, mark, allyes, executable_only) |
218 |
except: |
219 |
print 'Please check that %s exists!' % library |