1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

module/cgroups: Fix exclude pattern quoting

Use shlex.quote() rather than "manual" quoting.
This commit is contained in:
Douglas Raillard 2021-08-16 18:27:10 +01:00 committed by Marc Bonnici
parent 8b92f5530a
commit 301d43d140

View File

@ -16,6 +16,7 @@
import logging import logging
import re import re
from collections import namedtuple from collections import namedtuple
from shlex import quote
from devlib.module import Module from devlib.module import Module
from devlib.exception import TargetStableError from devlib.exception import TargetStableError
@ -129,9 +130,13 @@ class Controller(object):
dstg = self.cgroup(dest) dstg = self.cgroup(dest)
self.target._execute_util( # pylint: disable=protected-access self.target._execute_util( # pylint: disable=protected-access
'cgroups_tasks_move {} {} \'{}\''.format( 'cgroups_tasks_move {src} {dst} {exclude}'.format(
srcg.directory, dstg.directory, exclude), src=quote(srcg.directory),
as_root=True) dst=quote(dstg.directory),
exclude=' '.join(map(quote, exclude))
),
as_root=True,
)
def move_all_tasks_to(self, dest, exclude=None): def move_all_tasks_to(self, dest, exclude=None):
""" """
@ -160,9 +165,10 @@ class Controller(object):
self.logger.debug('Moving all tasks into %s', dest) self.logger.debug('Moving all tasks into %s', dest)
# Build list of tasks to exclude # Build list of tasks to exclude
grep_filters = '' grep_filters = ' '.join(
for comm in exclude: '-e {}'.format(comm)
grep_filters += '-e {} '.format(comm) for comm in exclude
)
self.logger.debug(' using grep filter: %s', grep_filters) self.logger.debug(' using grep filter: %s', grep_filters)
if grep_filters != '': if grep_filters != '':
self.logger.debug(' excluding tasks which name matches:') self.logger.debug(' excluding tasks which name matches:')