@@ -4,7 +4,6 @@ use strict;
44use warnings;
55use File::Basename;
66use File::Slurp;
7−use Net::DBus;
87use Sys::Syslog qw(:standard :macros);
98use Cwd 'abs_path';
109
@@ -68,15 +67,17 @@ EOF
6867$SIG{PIPE} = "IGNORE";
6968
7069sub getActiveUnits {
71− my $mgr = Net::DBus->system->get_service("org.freedesktop.systemd1")->get_object("/org/freedesktop/systemd1");
72− my $units = $mgr->ListUnitsByPatterns([], []);
70+ # FIXME: use D-Bus or whatever to query this, since parsing the
71+ # output of list-units is likely to break.
72+ # Use current version of systemctl binary before daemon is reexeced.
73+ my $lines = `LANG= /run/current-system/sw/bin/systemctl list-units --full --no-legend`;
7374 my $res = {};
74− for my $item (@$units) {
75− my ($id, $description, $load_state, $active_state, $sub_state,
76− $following, $unit_path, $job_id, $job_type, $job_path) = @$item;
77− next unless $following eq '';
78− next if $job_id == 0 and $active_state eq 'inactive';
79− $res->{$id} = { load => $load_state, state => $active_state, substate => $sub_state };
75+ foreach my $line (split '\n', $lines) {
76+ chomp $line;
77+ last if $line eq "";
78+ $line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s/ or next;
79+ next if $1 eq "UNIT";
80+ $res->{$1} = { load => $2, state => $3, substate => $4 };
8081 }
8182 return $res;
8283}