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

Side by Side Diff: bin/cros_gsdcurl.py

Issue 3058046: Fix gsdcurl to correctly URL-quote a password passed via GSDCURL_PASSWORD (Closed) Base URL: ssh://gitrw.chromium.org/crosutils.git
Patch Set: eliminate incorrectly added stray file Created 10 years, 4 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 | « 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS 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 6
7 import getpass 7 import getpass
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 import tempfile 12 import tempfile
13 import urllib 13 import urllib
14 14
15 15
16 def Authenticate(): 16 def Authenticate():
17 # Authenticate. 17 # Authenticate.
18 default_username = os.environ.get('LOGNAME', '') 18 default_username = os.environ.get('LOGNAME', '')
19 username = os.environ.get('GSDCURL_USERNAME') 19 username = os.environ.get('GSDCURL_USERNAME')
20 if username is None: 20 if username is None:
21 sys.stderr.write('Username [' + default_username + ']: ') 21 sys.stderr.write('Username [' + default_username + ']: ')
22 username = raw_input() 22 username = raw_input()
23 if username == '': 23 if username == '':
24 username = default_username + '@google.com' 24 username = default_username + '@google.com'
25 elif '@' not in username: 25 elif '@' not in username:
26 username = username + '@google.com' 26 username = username + '@google.com'
27 passwd = os.environ.get('GSDCURL_PASSWORD') 27 passwd = os.environ.get('GSDCURL_PASSWORD')
28 if passwd is None: 28 if passwd is None:
29 sys.stderr.write('Password: ') 29 sys.stderr.write('Password: ')
30 passwd = urllib.quote_plus(getpass.getpass(prompt='')) 30 passwd = getpass.getpass(prompt='')
31 cmd = [ 31 cmd = [
32 'curl', '--silent', 'https://www.google.com/accounts/ClientLogin', 32 'curl', '--silent', 'https://www.google.com/accounts/ClientLogin',
33 '-d', 'Email=' + username, 33 '-d', 'Email=' + username,
34 '-d', 'Passwd=' + passwd, 34 '-d', 'Passwd=' + urllib.quote_plus(passwd),
35 '-d', 'accountType=GOOGLE', 35 '-d', 'accountType=GOOGLE',
36 '-d', 'source=Google-gsdcurl-ver1', 36 '-d', 'source=Google-gsdcurl-ver1',
37 '-d', 'service=cds', 37 '-d', 'service=cds',
38 ] 38 ]
39 p = subprocess.Popen(cmd, stdout=subprocess.PIPE) 39 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
40 (p_stdout, _) = p.communicate() 40 (p_stdout, _) = p.communicate()
41 assert p.returncode == 0 41 assert p.returncode == 0
42 m = re.search('\nAuth=([^\n]+)\n', p_stdout) 42 m = re.search('\nAuth=([^\n]+)\n', p_stdout)
43 if not m: 43 if not m:
44 sys.stderr.write('BAD LOGIN\n') 44 sys.stderr.write('BAD LOGIN\n')
(...skipping 16 matching lines...) Expand all
61 os.remove(cookies) 61 os.remove(cookies)
62 62
63 63
64 def main(argv): 64 def main(argv):
65 auth = Authenticate() 65 auth = Authenticate()
66 return DoCurl(auth, argv) 66 return DoCurl(auth, argv)
67 67
68 68
69 if __name__ == '__main__': 69 if __name__ == '__main__':
70 sys.exit(main(sys.argv)) 70 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