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

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

Issue 9960074: Add a test for the "ephemeral_users_enabled" device policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Meh. Copy & paste error in license header. 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_ephemeral.py ('k') | chrome/test/pyautolib/pyauto.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 """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
11 Usage: 11 Usage:
12 sudo python suid_actions.py --action=CleanFlimflamDirs 12 sudo python suid_actions.py --action=CleanFlimflamDirs
13 """ 13 """
14 14
15 import logging
15 import optparse 16 import optparse
16 import os 17 import os
17 import shutil 18 import shutil
18 import sys 19 import sys
19 20
20
21 sys.path.append('/usr/local') # to import autotest libs. 21 sys.path.append('/usr/local') # to import autotest libs.
22 from autotest.cros import cryptohome 22 from autotest.cros import cryptohome
23 23
24 # TODO(bartfab): Remove when crosbug.com/20709 is fixed.
25 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
26 from pyauto import AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE
27
24 28
25 class SuidAction(object): 29 class SuidAction(object):
26 """Helper to perform some super-user actions on ChromeOS.""" 30 """Helper to perform some super-user actions on ChromeOS."""
27 31
28 def _ParseArgs(self): 32 def _ParseArgs(self):
29 parser = optparse.OptionParser() 33 parser = optparse.OptionParser()
30 parser.add_option( 34 parser.add_option(
31 '-a', '--action', help='Action to perform.') 35 '-a', '--action', help='Action to perform.')
32 self._options = parser.parse_args()[0] 36 self._options = parser.parse_args()[0]
33 if not self._options.action: 37 if not self._options.action:
(...skipping 24 matching lines...) Expand all
58 shutil.rmtree(path) 62 shutil.rmtree(path)
59 else: 63 else:
60 os.remove(path) 64 os.remove(path)
61 finally: 65 finally:
62 os.system('start flimflam') 66 os.system('start flimflam')
63 67
64 def RemoveAllCryptohomeVaults(self): 68 def RemoveAllCryptohomeVaults(self):
65 """Remove any existing cryptohome vaults.""" 69 """Remove any existing cryptohome vaults."""
66 cryptohome.remove_all_vaults() 70 cryptohome.remove_all_vaults()
67 71
72 def TryToDisableLocalStateAutoClearing(self):
73 """Try to disable clearing of the local state on session manager startup.
74
75 This will fail if rootfs verification is on.
76 TODO(bartfab): Remove this method when crosbug.com/20709 is fixed.
77 """
78 os.system('mount -o remount,rw /')
79 os.remove(AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE)
80 os.system('mount -o remount,ro /')
81 if os.path.exists(AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE):
82 logging.debug('Failed to remove %s. Session manager will clear local '
83 'state on startup.' % AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE)
84 else:
85 logging.debug('Removed %s. Session manager will not clear local state on '
86 'startup.' % AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE)
87
88 def TryToEnableLocalStateAutoClearing(self):
89 """Try to enable clearing of the local state on session manager startup.
90
91 This will fail if rootfs verification is on.
92 TODO(bartfab): Remove this method when crosbug.com/20709 is fixed.
93 """
94 os.system('mount -o remount,rw /')
95 open(AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE, 'w').close()
96 os.system('mount -o remount,ro /')
97 if os.path.exists(AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE):
98 logging.debug('Created %s. Session manager will clear local state on '
99 'startup.' % AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE)
100 else:
101 logging.debug('Failed to create %s. Session manager will not clear local '
102 'state on startup.' % AUTO_CLEAR_LOCAL_STATE_MAGIC_FILE)
103
68 104
69 if __name__ == '__main__': 105 if __name__ == '__main__':
70 sys.exit(SuidAction().Run()) 106 sys.exit(SuidAction().Run())
OLDNEW
« no previous file with comments | « chrome/test/functional/chromeos_ephemeral.py ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698