Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: tools/checkperms/checkperms.py

Issue 10083003: Make checkperms.py look for shebang. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Makes sure files have the right permissions. 6 """Makes sure files have the right permissions.
7 7
8 Some developers have broken SCM configurations that flip the svn:executable 8 Some developers have broken SCM configurations that flip the svn:executable
9 permission on for no good reason. Unix developers who run ls --color will then 9 permission on for no good reason. Unix developers who run ls --color will then
10 see .cc files in green and get confused. 10 see .cc files in green and get confused.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 # Not whitelisted, stat the file and check permissions. 170 # Not whitelisted, stat the file and check permissions.
171 try: 171 try:
172 st_mode = os.stat(file_path).st_mode 172 st_mode = os.stat(file_path).st_mode
173 except IOError, e: 173 except IOError, e:
174 return 'Failed to stat file: %s' % e 174 return 'Failed to stat file: %s' % e
175 except OSError, e: 175 except OSError, e:
176 return 'Failed to stat file: %s' % e 176 return 'Failed to stat file: %s' % e
177 177
178 if EXECUTABLE_PERMISSION & st_mode: 178 if EXECUTABLE_PERMISSION & st_mode:
179 # Look if the file starts with #!/
180 with open(file_path, 'rb') as f:
181 if f.read(3).startswith('#!/'):
Lei Zhang 2012/04/13 19:09:49 startswith -> ==
182 # That's fine.
183 return None
184 # TODO(maruel): Check that non-executable file do not start with a shebang.
179 error = 'Contains executable permission' 185 error = 'Contains executable permission'
180 if VERBOSE: 186 if VERBOSE:
181 return '%s: %06o' % (error, st_mode) 187 return '%s: %06o' % (error, st_mode)
182 return error 188 return error
183 return None 189 return None
184 190
185 191
186 def ShouldCheckDirectory(dir_path): 192 def ShouldCheckDirectory(dir_path):
187 """Determine if we should check the content of dir_path.""" 193 """Determine if we should check the content of dir_path."""
188 if not IS_SVN: 194 if not IS_SVN:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 success = CheckDirectory(start_dir) 339 success = CheckDirectory(start_dir)
334 if not success: 340 if not success:
335 print '\nFAILED\n' 341 print '\nFAILED\n'
336 return 1 342 return 1
337 print '\nSUCCESS\n' 343 print '\nSUCCESS\n'
338 return 0 344 return 0
339 345
340 346
341 if '__main__' == __name__: 347 if '__main__' == __name__:
342 sys.exit(main(sys.argv)) 348 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698