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

Side by Side Diff: chrome/test/pyautolib/chromeos/suid_actions.py

Issue 10084005: Mitigate race caused by flimflam restart in CleanFlimflamDirs() (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
« no previous file with comments | « chrome/test/functional/chromeos_onc.py ('k') | 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 """Helper script to perform actions as a super-user on ChromeOS. 6 """Helper script to perform actions as a super-user on ChromeOS.
7 7
8 Needs to be run with superuser privileges, typically using the 8 Needs to be run with superuser privileges, typically using the
9 suid_python binary. 9 suid_python binary.
10 10
(...skipping 26 matching lines...) Expand all
37 self._ParseArgs() 37 self._ParseArgs()
38 assert os.geteuid() == 0, 'Needs superuser privileges.' 38 assert os.geteuid() == 0, 'Needs superuser privileges.'
39 handler = getattr(self, self._options.action) 39 handler = getattr(self, self._options.action)
40 assert handler and callable(handler), \ 40 assert handler and callable(handler), \
41 'No handler for %s' % self._options.action 41 'No handler for %s' % self._options.action
42 handler() 42 handler()
43 return 0 43 return 0
44 44
45 ## Actions ## 45 ## Actions ##
46 def CleanFlimflamDirs(self): 46 def CleanFlimflamDirs(self):
47 """Clean the contents of all flimflam profiles.""" 47 """Clean the contents of all flimflam profiles.
48
49 TODO(stanleyw): crosbug.com/29421 This method restarts flimflam. It should
50 wait until flimflam is fully initialized and accessible via DBus. Otherwise,
51 there is a race conditions and subsequent accesses to flimflam may fail.
52 """
48 flimflam_dirs = ['/home/chronos/user/flimflam', 53 flimflam_dirs = ['/home/chronos/user/flimflam',
49 '/var/cache/flimflam'] 54 '/var/cache/flimflam']
50 os.system('stop flimflam') 55 os.system('stop flimflam')
51 try: 56 try:
52 for flimflam_dir in flimflam_dirs: 57 for flimflam_dir in flimflam_dirs:
53 if not os.path.exists(flimflam_dir): 58 if not os.path.exists(flimflam_dir):
54 continue 59 continue
55 for item in os.listdir(flimflam_dir): 60 for item in os.listdir(flimflam_dir):
56 path = os.path.join(flimflam_dir, item) 61 path = os.path.join(flimflam_dir, item)
57 if os.path.isdir(path): 62 if os.path.isdir(path):
58 shutil.rmtree(path) 63 shutil.rmtree(path)
59 else: 64 else:
60 os.remove(path) 65 os.remove(path)
61 finally: 66 finally:
62 os.system('start flimflam') 67 os.system('start flimflam')
63 68
64 def RemoveAllCryptohomeVaults(self): 69 def RemoveAllCryptohomeVaults(self):
65 """Remove any existing cryptohome vaults.""" 70 """Remove any existing cryptohome vaults."""
66 cryptohome.remove_all_vaults() 71 cryptohome.remove_all_vaults()
67 72
68 73
69 if __name__ == '__main__': 74 if __name__ == '__main__':
70 sys.exit(SuidAction().Run()) 75 sys.exit(SuidAction().Run())
OLDNEW
« no previous file with comments | « chrome/test/functional/chromeos_onc.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698