You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
def set_env(env_file):
while True:
source_file = '/tmp/regr.source.%d'%random.randint(0, (2*32)-1)
if not os.path.isfile(source_file): break
with open(source_file, 'w') as src_file:
src_file.write('#!/bin/bash\n')
src_file.write('source %s\n'%env_file)
src_file.write('env\n')
os.chmod(source_file, 0755)
p = subprocess.Popen(source_file, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.communicate()
setting = re.compile('^(?P[^=])=')
value = re.compile('=(?P.*$)')
env_dict = {}
for line in out.splitlines():
if setting.search(line) and value.search(line):
env_dict[setting.search(line).group('setting')] = value.search(line).group('value')
for k, v in env_dict.items():
os.environ[k] = v
for k, v in env_dict.items():
try:
assert(os.getenv(k) == v)
except AssertionError:
raise Exception('Unable to modify environment')
set_env("/etc/default/storm")
The text was updated successfully, but these errors were encountered:
Possible solution in Storm Script:
def set_env(env_file):
while True:
source_file = '/tmp/regr.source.%d'%random.randint(0, (2*32)-1)
if not os.path.isfile(source_file): break
with open(source_file, 'w') as src_file:
src_file.write('#!/bin/bash\n')
src_file.write('source %s\n'%env_file)
src_file.write('env\n')
os.chmod(source_file, 0755)
p = subprocess.Popen(source_file, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.communicate()
setting = re.compile('^(?P[^=])=')
value = re.compile('=(?P.*$)')
env_dict = {}
for line in out.splitlines():
if setting.search(line) and value.search(line):
env_dict[setting.search(line).group('setting')] = value.search(line).group('value')
for k, v in env_dict.items():
os.environ[k] = v
for k, v in env_dict.items():
try:
assert(os.getenv(k) == v)
except AssertionError:
raise Exception('Unable to modify environment')
set_env("/etc/default/storm")
The text was updated successfully, but these errors were encountered: