diff options
author | Robert Helgesson <robert@rycee.net> | 2019-04-18 01:19:58 +0200 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2019-04-18 01:37:59 +0200 |
commit | 0d246aa43555d8a0bd3805a2e3a355b9eec35020 (patch) | |
tree | 8000b860f32906dd07644a0c9b032a03445fe552 /modules | |
parent | c5f35b7ff942d7f5875c0b772b7551c03b431c91 (diff) |
systemd: escape unit names in systemctl commands
Diffstat (limited to 'modules')
-rw-r--r-- | modules/systemd-activate.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/systemd-activate.rb b/modules/systemd-activate.rb index 517de40df4b..18ec833f765 100644 --- a/modules/systemd-activate.rb +++ b/modules/systemd-activate.rb @@ -1,5 +1,6 @@ require 'set' require 'open3' +require 'shellwords' @dry_run = ENV['DRY_RUN'] @verbose = ENV['VERBOSE'] @@ -143,14 +144,15 @@ end def get_units_by_activity(units, active) return [] if units.empty? units = units.to_a - is_active = `systemctl --user is-active #{units.join(' ')}`.split + is_active = `systemctl --user is-active #{units.shelljoin}`.split units.select.with_index do |_, i| (is_active[i] == 'active') == active end end def get_restricted_units(units) - infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.to_a.join(' ')}` + units = units.to_a + infos = `systemctl --user show -p RefuseManualStart -p RefuseManualStop #{units.shelljoin}` .split("\n\n") no_manual_start = [] no_manual_stop = [] @@ -173,7 +175,7 @@ end def show_failed_services_status(services) puts services.each do |service| - run_cmd("systemctl --user status #{service}") + run_cmd("systemctl --user status #{service.shellescape}") puts end end |