Chromium Code Reviews| Index: gerrit_util.py |
| diff --git a/gerrit_util.py b/gerrit_util.py |
| index 3a4cc07660b4cc8315a140d74b3dc2ecf236b607..b349dcec56f57e81297a32100d3bd3b3ad2ed0ab 100755 |
| --- a/gerrit_util.py |
| +++ b/gerrit_util.py |
| @@ -15,14 +15,32 @@ import logging |
| import netrc |
| import os |
| import re |
| +import stat |
| +import sys |
| import time |
| import urllib |
| from cStringIO import StringIO |
| +_netrc_file = '_netrc' if sys.platform.startswith('win') else '.netrc' |
| +_netrc_file = os.path.join(os.environ['HOME'], _netrc_file) |
|
Michael Moss
2014/05/22 23:57:03
You mean the netrc module doesn't know how to do t
szager1
2014/05/23 08:52:18
I actually looked through the netrc.py code, on bo
|
| try: |
| - NETRC = netrc.netrc() |
| -except (IOError, netrc.NetrcParseError): |
| + NETRC = netrc.netrc(_netrc_file) |
| +except IOError: |
| + print >> sys.stderr, 'WARNING: Could not read netrc file %s' % _netrc_file |
| NETRC = netrc.netrc(os.devnull) |
| +except netrc.NetrcParseError: |
| + _netrc_stat = os.stat(_netrc_file) |
|
Michael Moss
2014/05/22 23:57:03
FWIW, NetrcParseError.filename
szager1
2014/05/23 08:52:18
Done.
|
| + if _netrc_stat.st_mode & (stat.S_IRWXG | stat.S_IRWXO): |
| + print >> sys.stderr, ( |
| + 'WARNING: netrc file %s cannot be used because its file permissions ' |
| + 'are insecure. netrc file permissions should be 600.' % _netrc_file) |
| + else: |
| + print >> sys.stderr, ('WARNING: Cannot use netrc file %s due to a parsing ' |
| + 'error.' % _netrc_file) |
|
Michael Moss
2014/05/22 23:57:03
If you print the exception, it will give a bit mor
szager1
2014/05/23 08:52:18
Actually, I think the right thing to do is to re-r
|
| + del _netrc_stat |
| + NETRC = netrc.netrc(os.devnull) |
| +del _netrc_file |
| + |
| LOGGER = logging.getLogger() |
| TRY_LIMIT = 5 |