Skip to content

Commit

Permalink
fix: avoid systemctl migration of rootful modules (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile authored Mar 25, 2024
1 parent 71a9b4f commit ce56eb8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/imageroot/usr/local/agent/actions/transfer-state/10sendpayload
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ username, password = request['credentials']
# Prepare a copy of the source module environment that can be transfered
agent.run_helper('cp', '-v', 'environment', 'environment.clone-module').check_returncode()

# Dump the Systemd enabled services list
with open('default-target.clone-module', 'w') as fpout:
agent.run_helper(*'systemctl --user show default.target -p Wants --value'.split(), stdout=fpout).check_returncode()

with open('timers-target.clone-module', 'w') as fpout:
proc = subprocess.run('systemctl --user show timers.target -p Wants --value'.split(), text=True, capture_output=True)
if proc.returncode != 0:
sysm.exit(3)
tlist = re.sub(r"\bbackup[0-9]+\.timer\b", '', proc.stdout) # remove backup timers
fpout.write(tlist)
if os.geteuid() != 0:
# Dump the Systemd enabled services list
with open('default-target.clone-module', 'w') as fpout:
agent.run_helper(*'systemctl --user show default.target -p Wants --value'.split(), stdout=fpout).check_returncode()

with open('timers-target.clone-module', 'w') as fpout:
proc = subprocess.run('systemctl --user show timers.target -p Wants --value'.split(), text=True, capture_output=True)
if proc.returncode != 0:
sysm.exit(3)
tlist = re.sub(r"\bbackup[0-9]+\.timer\b", '', proc.stdout) # remove backup timers
fpout.write(tlist)

errors = 0
os.environ['RSYNC_PASSWORD'] = password
Expand Down

0 comments on commit ce56eb8

Please sign in to comment.