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

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

Issue 587463002: checkperms: Recognize "#! /path" as a file that has a shabang. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « third_party/libxslt/xslt-config.in ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | 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 executable 8 Some developers have broken SCM configurations that flip the 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return bool(permission & os.stat(full_path).st_mode) 263 return bool(permission & os.stat(full_path).st_mode)
264 264
265 265
266 def has_shebang_or_is_elf(full_path): 266 def has_shebang_or_is_elf(full_path):
267 """Returns if the file starts with #!/ or is an ELF binary. 267 """Returns if the file starts with #!/ or is an ELF binary.
268 268
269 full_path is the absolute path to the file. 269 full_path is the absolute path to the file.
270 """ 270 """
271 with open(full_path, 'rb') as f: 271 with open(full_path, 'rb') as f:
272 data = f.read(4) 272 data = f.read(4)
273 return (data[:3] == '#!/', data == '\x7fELF') 273 return (data[:3] == '#!/' or data == '#! /', data == '\x7fELF')
274 274
275 275
276 def check_file(root_path, rel_path): 276 def check_file(root_path, rel_path):
277 """Checks the permissions of the file whose path is root_path + rel_path and 277 """Checks the permissions of the file whose path is root_path + rel_path and
278 returns an error if it is inconsistent. Returns None on success. 278 returns an error if it is inconsistent. Returns None on success.
279 279
280 It is assumed that the file is not ignored by is_ignored(). 280 It is assumed that the file is not ignored by is_ignored().
281 281
282 If the file name is matched with must_be_executable() or 282 If the file name is matched with must_be_executable() or
283 must_not_be_executable(), only its executable bit is checked. 283 must_not_be_executable(), only its executable bit is checked.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 print '\nFAILED\n' 471 print '\nFAILED\n'
472 print '\n'.join('%s: %s' % (e['full_path'], e['error']) for e in errors) 472 print '\n'.join('%s: %s' % (e['full_path'], e['error']) for e in errors)
473 return 1 473 return 1
474 if not options.bare: 474 if not options.bare:
475 print '\nSUCCESS\n' 475 print '\nSUCCESS\n'
476 return 0 476 return 0
477 477
478 478
479 if '__main__' == __name__: 479 if '__main__' == __name__:
480 sys.exit(main()) 480 sys.exit(main())
OLDNEW
« no previous file with comments | « third_party/libxslt/xslt-config.in ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698