Merge "Ensure /run_command is readable by all users"

This commit is contained in:
Zuul 2019-01-17 10:43:33 +00:00 committed by Gerrit Code Review
commit 51cf061f38
1 changed files with 7 additions and 1 deletions

View File

@ -310,8 +310,14 @@ def copy_config(config):
LOG.info('Writing out command to execute')
LOG.debug("Command is: %s", config['command'])
# The value from the 'command' key will be written to '/run_command'
with open('/run_command', 'w+') as f:
cmd = '/run_command'
with open(cmd, 'w+') as f:
f.write(config['command'])
# Make sure the generated file is readable by all users
try:
os.chmod(cmd, 0o644)
except OSError:
LOG.exception('Failed to set permission of %s to 0o644', cmd)
def user_group(owner):