diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 23:23:58 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 23:23:58 +0000 |
commit | 87be1009c787e56f738fb7cf9d91d731e3f0af86 (patch) | |
tree | d7c1b17724bfd2d17ef75272fffa718fb1664fc7 /chrome | |
parent | a2487faa6da1445e4b3a192119763d5a8459bff8 (diff) | |
download | chromium_src-87be1009c787e56f738fb7cf9d91d731e3f0af86.zip chromium_src-87be1009c787e56f738fb7cf9d91d731e3f0af86.tar.gz chromium_src-87be1009c787e56f738fb7cf9d91d731e3f0af86.tar.bz2 |
Revert 142616 - Reimplement SetPolicies() on the Mac using the Directory Service command line tool.
Directly writing managed preferences to /Library/Managed Preferences relies on an undocumented detail, and does not guarantee that the preferences system sees those changes.
TBR=nirnimesh@chromium.org
BUG=130094
TEST=policy.py pyautos pass in the mac bots
Review URL: https://chromiumcodereview.appspot.com/10563015
TBR=joaodasilva@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10532187
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 4 | ||||
-rw-r--r-- | chrome/test/pyautolib/policy_base.py | 39 | ||||
-rwxr-xr-x | chrome/test/pyautolib/policy_posix_util.py | 17 |
3 files changed, 24 insertions, 36 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index 5c06b41..6a2db13 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -212,6 +212,10 @@ '-passwords', # crbug.com/97140 '-plugins.PluginsTest.testDisableEnableAllPlugins', + # crbug.com/130094 + '-policy', + '-policy_prefs_ui.PolicyPrefsUITest.testToggleUserPolicyTogglesBanner', + '-policy_prefs_ui.PolicyPrefsUITest.testUserPoliciesShowBanner', # crbug.com/69619 '-search_engines.SearchEnginesTest.testDiscoverSearchEngine', # Keychain popups make sync tests difficult on Mac. crbug.com/49378 diff --git a/chrome/test/pyautolib/policy_base.py b/chrome/test/pyautolib/policy_base.py index 14c4072..89e6d74 100644 --- a/chrome/test/pyautolib/policy_base.py +++ b/chrome/test/pyautolib/policy_base.py @@ -279,32 +279,31 @@ class PolicyTestBase(pyauto.PyUITest): def _SetUserPolicyMac(self, user_policy=None): """Writes the given user policy to the plist policy file read by Chrome.""" assert self.IsMac() + sudo_cmd_file = os.path.join(os.path.dirname(__file__), + 'policy_posix_util.py') if self.GetBrowserInfo()['properties']['branding'] == 'Google Chrome': - bundle = 'com.google.Chrome' + policies_file_base = 'com.google.Chrome.plist' else: - bundle = 'org.chromium.Chromium' - - if user_policy: - mcx = { - bundle: dict( - [ (k, { 'state': 'always', 'value': v }) - for (k,v) in user_policy.iteritems() ]) - } + policies_file_base = 'org.chromium.Chromium.plist' - tmp_file = tempfile.mktemp(dir='/tmp') - plistlib.writePlist(mcx, tmp_file) - else: - tmp_file = '' + policies_location = os.path.join('/Library', 'Managed Preferences', + getpass.getuser()) - user = getpass.getuser() - sudo_cmd_file = os.path.join(os.path.dirname(__file__), - 'policy_posix_util.py') - subprocess.call(['suid-python', sudo_cmd_file, - 'mcximport', user, bundle, tmp_file]) + if os.path.exists(policies_location): + logging.debug('Removing directory %s' % policies_location) + subprocess.call(['suid-python', sudo_cmd_file, + 'remove_dir', policies_location]) - if tmp_file: - os.remove(tmp_file) + if user_policy is not None: + policies_tmp_file = os.path.join('/tmp', policies_file_base) + plistlib.writePlist(user_policy, policies_tmp_file) + subprocess.call(['suid-python', sudo_cmd_file, + 'setup_dir', policies_location]) + # Copy policy file to the managed directory + subprocess.call(['suid-python', sudo_cmd_file, + 'copy', policies_tmp_file, policies_location]) + os.remove(policies_tmp_file) def SetUserPolicy(self, user_policy=None): """Sets the user policy provided as a dict. diff --git a/chrome/test/pyautolib/policy_posix_util.py b/chrome/test/pyautolib/policy_posix_util.py index 682d511..420131b 100755 --- a/chrome/test/pyautolib/policy_posix_util.py +++ b/chrome/test/pyautolib/policy_posix_util.py @@ -7,7 +7,6 @@ import os import shutil -import subprocess import sys @@ -26,24 +25,10 @@ def main(): os.system('chmod -R 755 "%s/../.."' % sys.argv[2]) elif sys.argv[1] == 'remove_dir': os.system('rm -rf "%s"' % sys.argv[2]) - elif sys.argv[1] == 'mcximport': - assert sys.platform == 'darwin' - user = sys.argv[2] - bundle = sys.argv[3] - mcx_file = sys.argv[4] - # Note: os.system() drops the euid priviledges on mac. - # Clear the current preferences. - subprocess.call(['dscl', '.', '-mcxdelete', '/Users/' + user, bundle, '=']) - # Import the new preferences, if a file was specified. - if mcx_file: - subprocess.call(['dscl', '.', '-mcximport', '/Users/' + user, mcx_file]) - # Make sure the cache is refreshed. - subprocess.call(['mcxrefresh', '-n', user]) else: - mac_opt_cmds = ', [mcximport]' if sys.platform == 'darwin' else '' print >>sys.stderr, ( 'Invalid syntax. Possible values are [copy], [setup_dir], ' - '[perm_dir], [remove_dir]%s' % mac_opt_cmds) + '[perm_dir], [remove_dir]') return 1 return 0 |