コード例 #1
0
 def init_volume(self, context):
     """
     Create new dir on host, put a file in it, set $context context
     recursively and check it was set properly.
     :param context: Desired volume context
     :return: path to new directory
     """
     if self.config['use_system_tmp']:
         tmp = '/var/tmp'
     else:
         tmp = self.tmpdir
     volume = tempfile.mkdtemp(prefix=self.__class__.__name__, dir=tmp)
     if docker_daemon.user_namespaces_enabled():
         os.chown(volume,
                  docker_daemon.user_namespaces_uid(),
                  docker_daemon.user_namespaces_gid())
     self.sub_stuff['volumes'].add(volume)
     host_file = os.path.join(volume, "hostfile")
     open(host_file, 'w').write("01")
     set_selinux_context(volume, context, True)
     _context = get_selinux_context(volume)
     self.failif(context not in _context, "Newly set context was not set"
                 " properly (set %s, get %s)" % (context, _context))
     self.check_context_recursive(volume, _context)
     return volume
コード例 #2
0
 def initialize(self):
     super(CpBase, self).initialize()
     set_selinux_context(self.tmpdir)
     dc = self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['di'] = DockerImages(self)
     container_name = dc.get_unique_name()
     self.sub_stuff['container_name'] = container_name
     fqin = DockerImage.full_name_from_defaults(self.config)
     self.sub_stuff['fqin'] = fqin
コード例 #3
0
ファイル: cp.py プロジェクト: edsantiago/autotest-docker
 def initialize(self):
     super(CpBase, self).initialize()
     set_selinux_context(self.tmpdir)
     dc = self.sub_stuff["dc"] = DockerContainers(self)
     self.sub_stuff["di"] = DockerImages(self)
     container_name = dc.get_unique_name()
     self.sub_stuff["container_name"] = container_name
     fqin = DockerImage.full_name_from_defaults(self.config)
     self.sub_stuff["fqin"] = fqin
コード例 #4
0
ファイル: rm.py プロジェクト: lsm5/autotest-docker
 def init_static_data(self):
     volume = self.sub_stuff["volume"] = self.tmpdir
     environment.set_selinux_context(volume, "svirt_sandbox_file_t")
     start_filename = os.path.join(volume, "start")
     self.sub_stuff["start_filename"] = start_filename
     ssfile = open(start_filename, "wb")
     init_time = str(self.parent_subtest.stuff["init_time"])
     ssfile.write(init_time)
     ssfile.close()
コード例 #5
0
 def init_static_data(self):
     volume = self.sub_stuff['volume'] = self.tmpdir
     environment.set_selinux_context(volume, "svirt_sandbox_file_t")
     start_filename = os.path.join(volume, 'start')
     self.sub_stuff['start_filename'] = start_filename
     ssfile = open(start_filename, "w")
     init_time = str(self.parent_subtest.stuff['init_time'])
     ssfile.write(init_time)
     ssfile.close()
コード例 #6
0
ファイル: cp.py プロジェクト: ldoktor/autotest-docker
 def initialize(self):
     super(CpBase, self).initialize()
     set_selinux_context(self.tmpdir)
     dc = self.sub_stuff['dc'] = DockerContainers(self, "cli")
     self.sub_stuff['di'] = DockerImages(self, "cli")
     container_name = dc.get_unique_name()
     self.sub_stuff['container_name'] = container_name
     fqin = DockerImage.full_name_from_defaults(self.config)
     self.sub_stuff['fqin'] = fqin
コード例 #7
0
 def init_volume(self, context):
     """
     Create new dir on host, put a file in it, set $context context
     recursively and check it was set properly.
     :param context: Desired volume context
     :return: path to new directory
     """
     if self.config['use_system_tmp']:
         tmp = '/var/tmp'
     else:
         tmp = self.tmpdir
     volume = tempfile.mkdtemp(prefix=self.__class__.__name__, dir=tmp)
     self.sub_stuff['volumes'].add(volume)
     host_file = os.path.join(volume, "hostfile")
     open(host_file, 'w').write("01")
     set_selinux_context(volume, context, True)
     _context = get_selinux_context(volume)
     self.failif(context not in _context, "Newly set context was not set"
                 " properly (set %s, get %s)" % (context, _context))
     self.check_context_recursive(volume, _context)
     return volume
コード例 #8
0
 def set_selinux_context(subtest, host_path):
     context = subtest.config['selinux_context'].strip()
     if context != '':
         environment.set_selinux_context(host_path, context)
コード例 #9
0
 def set_selinux_context(subtest, host_path):
     context = subtest.config['selinux_context'].strip()
     if context != '':
         environment.set_selinux_context(host_path, context)
コード例 #10
0
def set_selinux_context(pwd, context=None, recursive=True):
    """ Wrapper around environment.set_selinux_context """
    return environment.set_selinux_context(pwd, context, recursive)
コード例 #11
0
def set_selinux_context(pwd, context=None, recursive=True):
    """ Wrapper around environment.set_selinux_context """
    return environment.set_selinux_context(pwd, context, recursive)