CommandFilter should compare basename from both sides
Otherwise we're comparing basename with fullpath when fullpath is the command argument. Closes-Bug:: #1956606 Change-Id: I76094065de5b37f59a2500fbce7f500ada9915da
This commit is contained in:
parent
25fcff997b
commit
7e1cd98f08
|
@ -74,7 +74,9 @@ class CommandFilter(object):
|
|||
|
||||
def match(self, userargs):
|
||||
"""Only check that the first argument (command) matches exec_path."""
|
||||
return userargs and os.path.basename(self.exec_path) == userargs[0]
|
||||
exec_path = os.path.basename(self.exec_path)
|
||||
user_path = os.path.basename(userargs[0]) if userargs else False
|
||||
return userargs and exec_path == user_path
|
||||
|
||||
def preexec(self):
|
||||
"""Setuid in subprocess right before command is invoked."""
|
||||
|
|
|
@ -77,6 +77,10 @@ later_install_cmd: CommandFilter, %s, root
|
|||
self.assertEqual(expect_out, out)
|
||||
self.assertEqual(expect_err, err)
|
||||
|
||||
def _test_run_with_path(self, expect_byte=True):
|
||||
code, out, err = self.execute(['/bin/echo', 'teststr'])
|
||||
self.assertEqual(0, code)
|
||||
|
||||
def _test_run_with_stdin(self, expect_byte=True):
|
||||
code, out, err = self.execute(['cat'], stdin=b'teststr')
|
||||
self.assertEqual(0, code)
|
||||
|
|
Loading…
Reference in New Issue