Always use absolute path for custom kill-scripts

When rootwrap was used to run custom kill-scripts, it worked fine with
the executable name without full path as path was in the rootwrap's
exec_dirs config option thus rootwrap was able to find it.

But as we migrated to privsep it don't works like that anymore.
It's better to use absolute path of the kill-script always and that
patch changes to do it like that.

Change-Id: I66d70304530935e2add3345aba6aa3c549a0a2df
Closes-Bug: #1923198
(cherry picked from commit e5ccfee6cf)
This commit is contained in:
Slawek Kaplonski 2021-04-09 15:28:41 +02:00
parent d526594950
commit bfaf0ebc11
2 changed files with 5 additions and 3 deletions

View File

@ -128,8 +128,9 @@ class ProcessManager(MonitoredProcess):
def get_kill_cmd(self, sig, pid):
if self.kill_scripts_path:
kill_file = "%s-kill" % self.service
if os.path.isfile(os.path.join(self.kill_scripts_path, kill_file)):
return [kill_file, sig, pid]
kill_file_path = os.path.join(self.kill_scripts_path, kill_file)
if os.path.isfile(kill_file_path):
return [kill_file_path, sig, pid]
return ['kill', '-%s' % (sig), pid]
def get_pid_file_name(self):

View File

@ -271,7 +271,8 @@ class TestProcessManager(base.BaseTestCase):
kill_scripts_path='test-path/'):
cfg.CONF.set_override("kill_scripts_path", kill_scripts_path, "AGENT")
if kill_script_exists:
expected_cmd = ['test-service-kill', '9', 4]
expected_cmd = [
os.path.join(kill_scripts_path, 'test-service-kill'), '9', 4]
else:
expected_cmd = ['kill', '-9', 4]