summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional/enterprise_helper_linux.py
blob: a2e5782ad22604e1e6690b0a4ab6394f29820373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Helper script to copy policy files into
# the correct managed policy location in the machine

import os
import sys
import shutil


def main():
  assert os.geteuid() == 0, 'Need superuser privileges'
  if sys.argv[1] == 'copy':
    shutil.copy(sys.argv[2], sys.argv[3])
    dirList = os.listdir(sys.argv[3])
    for fname in dirList:
      filename = os.path.join(sys.argv[3], fname)
      os.chmod(filename, 0755)
  elif sys.argv[1] == 'setup_dir':
    os.system('mkdir -p %s' % sys.argv[2])
    os.system('chmod -R 755 /etc/opt/chrome/')
  elif sys.argv[1] == 'remove_dir':
    os.system('rm -rf %s' % sys.argv[2])
  else:
    print >>sys.stderr, 'Invalid syntax. Possible values are [copy], \
                         [setup_dir], [remove_dir]'


if __name__ == '__main__':
  main()