[systemd-commits] 2 commits - configure.ac Makefile.am src/exit-status.c src/exit-status.h src/gnome-ask-password-agent.vala src/mount.c src/remount-api-vfs.c src/service.c src/socket.c src/swap.c src/systemadm.vala src/systemctl.c src/systemd-interfaces.vala src/util.c src/util.h
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Jan 20 09:24:42 PST 2011
Makefile.am | 9 -
configure.ac | 10 -
src/exit-status.c | 29 ++++
src/exit-status.h | 5
src/gnome-ask-password-agent.vala | 48 +++----
src/mount.c | 1
src/remount-api-vfs.c | 1
src/service.c | 1
src/socket.c | 1
src/swap.c | 1
src/systemadm.vala | 259 ++++++++++++++++++++------------------
src/systemctl.c | 23 +++
src/systemd-interfaces.vala | 90 ++++++-------
src/util.c | 27 ---
src/util.h | 3
15 files changed, 276 insertions(+), 232 deletions(-)
New commits:
commit 26742b3fd8776c6c64e3c1035adc2599ddeb76d1
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jan 20 18:24:26 2011 +0100
vala: convert from dbus-glib to gdbus
diff --git a/Makefile.am b/Makefile.am
index 351f1ce..47d3ac0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -933,7 +933,6 @@ systemadm_SOURCES = \
systemadm_CFLAGS = \
$(AM_CFLAGS) \
- $(DBUSGLIB_CFLAGS) \
$(GTK_CFLAGS) \
-Wno-unused-variable \
-Wno-unused-function \
@@ -941,13 +940,11 @@ systemadm_CFLAGS = \
-Wno-format-nonliteral
systemadm_VALAFLAGS = \
- --pkg=dbus-glib-1 \
--pkg=posix \
--pkg=gtk+-2.0 \
-g
systemadm_LDADD = \
- $(DBUSGLIB_LIBS) \
$(GTK_LIBS)
systemd_gnome_ask_password_agent_SOURCES = \
@@ -955,7 +952,6 @@ systemd_gnome_ask_password_agent_SOURCES = \
systemd_gnome_ask_password_agent_CFLAGS = \
$(AM_CFLAGS) \
- $(DBUSGLIB_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
$(GTK_CFLAGS) \
-Wno-unused-variable \
@@ -964,7 +960,6 @@ systemd_gnome_ask_password_agent_CFLAGS = \
-Wno-format-nonliteral
systemd_gnome_ask_password_agent_VALAFLAGS = \
- --pkg=dbus-glib-1 \
--pkg=posix \
--pkg=gtk+-2.0 \
--pkg=linux \
@@ -978,7 +973,6 @@ systemd_gnome_ask_password_agent_VALAFLAGS += \
-g
systemd_gnome_ask_password_agent_LDADD = \
- $(DBUSGLIB_LIBS) \
$(LIBNOTIFY_LIBS) \
$(GTK_LIBS)
diff --git a/configure.ac b/configure.ac
index e4520e7..1eb931d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -244,21 +244,17 @@ AM_CONDITIONAL(HAVE_LIBCRYPTSETUP, [test "$have_libcryptsetup" = "yes"])
have_gtk=no
AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
if test "x$enable_gtk" != "xno"; then
- PKG_CHECK_MODULES(GTK, [ gtk+-2.0 gio-unix-2.0 ],
+ PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0 > 2.26 gio-unix-2.0 ],
[AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
if test "x$have_gtk" = xno -a "x$enable_gtk" = xyes; then
- AC_MSG_ERROR([*** gtk support requested but libraries not found])
+ AC_MSG_ERROR([*** gtk support requested but libraries not found])
fi
fi
AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
if test "$have_gtk" = "yes"; then
- PKG_CHECK_MODULES(DBUSGLIB, [ dbus-glib-1 ])
- AC_SUBST(DBUSGLIB_CFLAGS)
- AC_SUBST(DBUSGLIB_LIBS)
-
PKG_CHECK_MODULES(LIBNOTIFY, [ libnotify ])
PKG_CHECK_EXISTS([ libnotify >= 0.7.0 ], [ libnotify07=yes ])
@@ -267,7 +263,7 @@ if test "$have_gtk" = "yes"; then
fi
AM_CONDITIONAL(LIBNOTIFY07, [ test "$libnotify07" = "yes" ])
-AM_PROG_VALAC([0.10])
+AM_PROG_VALAC([0.11])
AC_SUBST(VAPIDIR)
AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
diff --git a/src/gnome-ask-password-agent.vala b/src/gnome-ask-password-agent.vala
index 61bbba0..84f2549 100644
--- a/src/gnome-ask-password-agent.vala
+++ b/src/gnome-ask-password-agent.vala
@@ -19,7 +19,6 @@
using Gtk;
using GLib;
-using DBus;
using Linux;
using Posix;
using Notify;
@@ -102,14 +101,19 @@ public class MyStatusIcon : StatusIcon {
activate.connect(status_icon_activate);
}
- void file_monitor_changed(GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) throws GLib.Error {
+ void file_monitor_changed(GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) {
if (!file.get_basename().has_prefix("ask."))
return;
if (event_type == FileMonitorEvent.CREATED ||
- event_type == FileMonitorEvent.DELETED)
- look_for_password();
+ event_type == FileMonitorEvent.DELETED) {
+ try {
+ look_for_password();
+ } catch (Error e) {
+ show_error(e.message);
+ }
+ }
}
void look_for_password() throws GLib.Error {
@@ -198,7 +202,7 @@ public class MyStatusIcon : StatusIcon {
return true;
}
- void status_icon_activate() throws GLib.Error {
+ void status_icon_activate() {
if (current == null)
return;
@@ -222,24 +226,28 @@ public class MyStatusIcon : StatusIcon {
int to_process;
- Process.spawn_async_with_pipes(
- null,
- { "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket },
- null,
- 0,
- null,
- null,
- out to_process,
- null,
- null);
-
- OutputStream stream = new UnixOutputStream(to_process, true);
+ try {
+ Process.spawn_async_with_pipes(
+ null,
+ { "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket },
+ null,
+ 0,
+ null,
+ null,
+ out to_process,
+ null,
+ null);
+
+ OutputStream stream = new UnixOutputStream(to_process, true);
#if LIBNOTIFY07
- stream.write(password.data, null);
+ stream.write(password.data, null);
#else
- stream.write(password, password.length, null);
+ stream.write(password, password.length, null);
#endif
+ } catch (Error e) {
+ show_error(e.message);
+ }
}
}
@@ -261,8 +269,6 @@ int main(string[] args) {
MyStatusIcon i = new MyStatusIcon();
Gtk.main();
- } catch (DBus.Error e) {
- show_error(e.message);
} catch (GLib.Error e) {
show_error(e.message);
}
diff --git a/src/systemadm.vala b/src/systemadm.vala
index 3a01efd..33777b6 100644
--- a/src/systemadm.vala
+++ b/src/systemadm.vala
@@ -19,7 +19,6 @@
using Gtk;
using GLib;
-using DBus;
using Pango;
static bool user = false;
@@ -79,7 +78,6 @@ public class MainWindow : Window {
private Button server_snapshot_button;
private Button server_reload_button;
- private Connection bus;
private Manager manager;
private RightLabel unit_id_label;
@@ -102,9 +100,9 @@ public class MainWindow : Window {
private ComboBox unit_type_combo_box;
- public MainWindow() throws DBus.Error {
+ public MainWindow() throws IOError {
title = user ? "systemd User Service Manager" : "systemd System Manager";
- position = WindowPosition.CENTER;
+ set_position(WindowPosition.CENTER);
set_default_size(1000, 700);
set_border_width(12);
destroy.connect(Gtk.main_quit);
@@ -297,12 +295,10 @@ public class MainWindow : Window {
bbox.pack_start(cancel_button, false, true, 0);
- bus = DBus.Bus.get(user ? DBus.BusType.SESSION : DBus.BusType.SYSTEM);
-
- manager = bus.get_object(
+ manager = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager") as Manager;
+ "/org/freedesktop/systemd1");
manager.unit_new.connect(on_unit_new);
manager.job_new.connect(on_job_new);
@@ -317,7 +313,7 @@ public class MainWindow : Window {
populate_job_model();
}
- public void populate_unit_model() throws DBus.Error {
+ public void populate_unit_model() throws IOError {
unit_model.clear();
var list = manager.list_units();
@@ -325,18 +321,17 @@ public class MainWindow : Window {
foreach (var i in list) {
TreeIter iter;
- Properties p = bus.get_object(
+ Properties p = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- i.unit_path,
- "org.freedesktop.DBus.Properties") as Properties;
-
+ i.unit_path);
p.properties_changed.connect(on_unit_changed);
- Unit u = bus.get_object(
+ Unit u = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- i.unit_path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ i.unit_path);
unit_model.append(out iter);
unit_model.set(iter,
@@ -350,7 +345,7 @@ public class MainWindow : Window {
}
}
- public void populate_job_model() throws DBus.Error {
+ public void populate_job_model() throws IOError {
job_model.clear();
var list = manager.list_jobs();
@@ -358,17 +353,17 @@ public class MainWindow : Window {
foreach (var i in list) {
TreeIter iter;
- Properties p = bus.get_object(
+ Properties p = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- i.job_path,
- "org.freedesktop.DBus.Properties") as Properties;
+ i.job_path);
p.properties_changed.connect(on_job_changed);
- Job j = bus.get_object(
+ Job j = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- i.job_path,
- "org.freedesktop.systemd1.Job") as Job;
+ i.job_path);
job_model.append(out iter);
job_model.set(iter,
@@ -601,7 +596,7 @@ public class MainWindow : Window {
try {
u.start("replace");
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -614,7 +609,7 @@ public class MainWindow : Window {
try {
u.stop("replace");
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -627,7 +622,7 @@ public class MainWindow : Window {
try {
u.reload("replace");
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -640,7 +635,7 @@ public class MainWindow : Window {
try {
u.restart("replace");
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -653,52 +648,61 @@ public class MainWindow : Window {
try {
j.cancel();
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
public void update_unit_iter(TreeIter iter, string id, Unit u) {
- string t = "";
- Unit.JobLink jl = u.job;
+ try {
+ string t = "";
+ Unit.JobLink jl = u.job;
- if (jl.id != 0) {
- Job j = bus.get_object(
- "org.freedesktop.systemd1",
- jl.path,
- "org.freedesktop.systemd1.Job") as Job;
+ if (jl.id != 0) {
+ Job j = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ "org.freedesktop.systemd1",
+ jl.path);
- t = j.job_type;
- }
+ t = j.job_type;
+ }
- unit_model.set(iter,
- 0, id,
- 1, u.description,
- 2, u.load_state,
- 3, u.active_state,
- 4, u.sub_state,
- 5, t != "" ? "â %s".printf(t) : "",
- 6, u);
+ unit_model.set(iter,
+ 0, id,
+ 1, u.description,
+ 2, u.load_state,
+ 3, u.active_state,
+ 4, u.sub_state,
+ 5, t != "" ? "â %s".printf(t) : "",
+ 6, u);
+ } catch (IOError e) {
+ show_error(e.message);
+ }
}
public void on_unit_new(string id, ObjectPath path) {
- Properties p = bus.get_object(
- "org.freedesktop.systemd1",
- path,
- "org.freedesktop.DBus.Properties") as Properties;
+ try {
- p.properties_changed.connect(on_unit_changed);
+ Properties p = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ "org.freedesktop.systemd1",
+ path);
- TreeIter iter;
- unit_model.append(out iter);
+ p.properties_changed.connect(on_unit_changed);
- Unit u = bus.get_object(
- "org.freedesktop.systemd1",
- path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ TreeIter iter;
+ unit_model.append(out iter);
+
+ Unit u = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ "org.freedesktop.systemd1",
+ path);
- update_unit_iter(iter, id, u);
+ update_unit_iter(iter, id, u);
+ } catch (IOError e) {
+ show_error(e.message);
+ }
}
public void update_job_iter(TreeIter iter, uint32 id, Job j) {
@@ -713,22 +717,28 @@ public class MainWindow : Window {
public void on_job_new(uint32 id, ObjectPath path) {
- Properties p = bus.get_object(
- "org.freedesktop.systemd1",
- path,
- "org.freedesktop.DBus.Properties") as Properties;
+ try {
- p.properties_changed.connect(on_job_changed);
+ Properties p = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ "org.freedesktop.systemd1",
+ path);
- TreeIter iter;
- job_model.append(out iter);
+ p.properties_changed.connect(on_job_changed);
- Job j = bus.get_object(
- "org.freedesktop.systemd1",
- path,
- "org.freedesktop.systemd1.Job") as Job;
+ TreeIter iter;
+ job_model.append(out iter);
+
+ Job j = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ "org.freedesktop.systemd1",
+ path);
+
+ update_job_iter(iter, id, j);
- update_job_iter(iter, id, j);
+ } catch (IOError e) {
+ show_error(e.message);
+ }
}
public void on_unit_removed(string id, ObjectPath path) {
@@ -775,65 +785,76 @@ public class MainWindow : Window {
}
public void on_unit_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
- TreeIter iter;
- string id;
- Unit u = bus.get_object(
- p.get_bus_name(),
- p.get_path(),
- "org.freedesktop.systemd1.Unit") as Unit;
+ try {
+ TreeIter iter;
+ string id;
- if (!(unit_model.get_iter_first(out iter)))
- return;
+ Unit u = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ p.get_name(),
+ p.get_object_path());
- id = u.id;
+ if (!(unit_model.get_iter_first(out iter)))
+ return;
- do {
- string name;
+ id = u.id;
- unit_model.get(iter, 0, out name);
+ do {
+ string name;
- if (id == name) {
- update_unit_iter(iter, id, u);
+ unit_model.get(iter, 0, out name);
- if (current_unit_id == id)
- show_unit(u);
+ if (id == name) {
+ update_unit_iter(iter, id, u);
- break;
- }
+ if (current_unit_id == id)
+ show_unit(u);
- } while (unit_model.iter_next(ref iter));
+ break;
+ }
+
+ } while (unit_model.iter_next(ref iter));
+
+ } catch (IOError e) {
+ show_error(e.message);
+ }
}
public void on_job_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
- TreeIter iter;
- uint32 id;
+ try {
+ TreeIter iter;
+ uint32 id;
- Job j = bus.get_object(
- p.get_bus_name(),
- p.get_path(),
- "org.freedesktop.systemd1.Job") as Job;
+ Job j = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
+ p.get_name(),
+ p.get_object_path());
- if (!(job_model.get_iter_first(out iter)))
- return;
+ if (!(job_model.get_iter_first(out iter)))
+ return;
- id = j.id;
+ id = j.id;
- do {
- uint32 k;
+ do {
+ uint32 k;
- job_model.get(iter, 5, out k);
+ job_model.get(iter, 5, out k);
- if (id == k) {
- update_job_iter(iter, id, j);
+ if (id == k) {
+ update_job_iter(iter, id, j);
- if (current_job_id == id)
- show_job(j);
+ if (current_job_id == id)
+ show_job(j);
- break;
- }
+ break;
+ }
- } while (job_model.iter_next(ref iter));
+ } while (job_model.iter_next(ref iter));
+
+ } catch (IOError e) {
+ show_error(e.message);
+ }
}
public bool unit_filter(TreeModel model, TreeIter iter) {
@@ -886,7 +907,7 @@ public class MainWindow : Window {
public void on_server_reload() {
try {
manager.reload();
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -898,7 +919,7 @@ public class MainWindow : Window {
if (unit_type_combo_box.get_active() != 0)
unit_type_combo_box.set_active(8);
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -912,10 +933,10 @@ public class MainWindow : Window {
try {
var path = manager.load_unit(t);
- Unit u = bus.get_object(
+ Unit u = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ path);
var m = new MessageDialog(this,
DialogFlags.DESTROY_WITH_PARENT,
@@ -927,7 +948,7 @@ public class MainWindow : Window {
m.destroy();
show_unit(u);
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
}
@@ -941,13 +962,13 @@ public class MainWindow : Window {
try {
string path = manager.get_unit(uri);
- Unit u = bus.get_object(
+ Unit u = Bus.get_proxy_sync(
+ user ? BusType.SESSION : BusType.SYSTEM,
"org.freedesktop.systemd1",
- path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ path);
show_unit(u);
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
}
@@ -987,7 +1008,7 @@ int main(string[] args) {
window.show_all();
Gtk.main();
- } catch (DBus.Error e) {
+ } catch (IOError e) {
show_error(e.message);
} catch (GLib.Error e) {
show_error(e.message);
diff --git a/src/systemd-interfaces.vala b/src/systemd-interfaces.vala
index 1d202e0..e3b7941 100644
--- a/src/systemd-interfaces.vala
+++ b/src/systemd-interfaces.vala
@@ -17,10 +17,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-using DBus;
-
[DBus (name = "org.freedesktop.systemd1.Manager")]
-public interface Manager : DBus.Object {
+public interface Manager : DBusProxy {
public struct UnitInfo {
string id;
@@ -46,43 +44,43 @@ public interface Manager : DBus.Object {
public abstract string[] environment { owned get; }
- public abstract UnitInfo[] list_units() throws DBus.Error;
- public abstract JobInfo[] list_jobs() throws DBus.Error;
+ public abstract UnitInfo[] list_units() throws IOError;
+ public abstract JobInfo[] list_jobs() throws IOError;
- public abstract ObjectPath get_unit(string name) throws DBus.Error;
- public abstract ObjectPath get_unit_by_pid(uint32 pid) throws DBus.Error;
- public abstract ObjectPath load_unit(string name) throws DBus.Error;
- public abstract ObjectPath get_job(uint32 id) throws DBus.Error;
+ public abstract ObjectPath get_unit(string name) throws IOError;
+ public abstract ObjectPath get_unit_by_pid(uint32 pid) throws IOError;
+ public abstract ObjectPath load_unit(string name) throws IOError;
+ public abstract ObjectPath get_job(uint32 id) throws IOError;
- public abstract ObjectPath start_unit(string name, string mode = "replace") throws DBus.Error;
- public abstract ObjectPath stop_unit(string name, string mode = "replace") throws DBus.Error;
- public abstract ObjectPath reload_unit(string name, string mode = "replace") throws DBus.Error;
- public abstract ObjectPath restart_unit(string name, string mode = "replace") throws DBus.Error;
- public abstract ObjectPath try_restart_unit(string name, string mode = "replace") throws DBus.Error;
- public abstract ObjectPath reload_or_restart_unit(string name, string mode = "replace") throws DBus.Error;
- public abstract ObjectPath reload_or_try_restart_unit(string name, string mode = "replace") throws DBus.Error;
+ public abstract ObjectPath start_unit(string name, string mode = "replace") throws IOError;
+ public abstract ObjectPath stop_unit(string name, string mode = "replace") throws IOError;
+ public abstract ObjectPath reload_unit(string name, string mode = "replace") throws IOError;
+ public abstract ObjectPath restart_unit(string name, string mode = "replace") throws IOError;
+ public abstract ObjectPath try_restart_unit(string name, string mode = "replace") throws IOError;
+ public abstract ObjectPath reload_or_restart_unit(string name, string mode = "replace") throws IOError;
+ public abstract ObjectPath reload_or_try_restart_unit(string name, string mode = "replace") throws IOError;
- public abstract void reset_failed_unit(string name = "") throws DBus.Error;
+ public abstract void reset_failed_unit(string name = "") throws IOError;
- public abstract void clear_jobs() throws DBus.Error;
+ public abstract void clear_jobs() throws IOError;
- public abstract void subscribe() throws DBus.Error;
- public abstract void unsubscribe() throws DBus.Error;
+ public abstract void subscribe() throws IOError;
+ public abstract void unsubscribe() throws IOError;
- public abstract string dump() throws DBus.Error;
+ public abstract string dump() throws IOError;
- public abstract void reload() throws DBus.Error;
- public abstract void reexecute() throws DBus.Error;
- public abstract void exit() throws DBus.Error;
- public abstract void halt() throws DBus.Error;
- public abstract void power_off() throws DBus.Error;
- public abstract void reboot() throws DBus.Error;
- public abstract void kexec() throws DBus.Error;
+ public abstract void reload() throws IOError;
+ public abstract void reexecute() throws IOError;
+ public abstract void exit() throws IOError;
+ public abstract void halt() throws IOError;
+ public abstract void power_off() throws IOError;
+ public abstract void reboot() throws IOError;
+ public abstract void kexec() throws IOError;
- public abstract ObjectPath create_snapshot(string name = "", bool cleanup = false) throws DBus.Error;
+ public abstract ObjectPath create_snapshot(string name = "", bool cleanup = false) throws IOError;
- public abstract void set_environment(string[] names) throws DBus.Error;
- public abstract void unset_environment(string[] names) throws DBus.Error;
+ public abstract void set_environment(string[] names) throws IOError;
+ public abstract void unset_environment(string[] names) throws IOError;
public abstract signal void unit_new(string id, ObjectPath path);
public abstract signal void unit_removed(string id, ObjectPath path);
@@ -91,7 +89,7 @@ public interface Manager : DBus.Object {
}
[DBus (name = "org.freedesktop.systemd1.Unit")]
-public interface Unit : DBus.Object {
+public interface Unit : DBusProxy {
public struct JobLink {
uint32 id;
ObjectPath path;
@@ -136,19 +134,19 @@ public interface Unit : DBus.Object {
public abstract bool need_daemon_reload { owned get; }
public abstract uint64 job_timeout_usec { owned get; }
- public abstract ObjectPath start(string mode = "replace") throws DBus.Error;
- public abstract ObjectPath stop(string mode = "replace") throws DBus.Error;
- public abstract ObjectPath reload(string mode = "replace") throws DBus.Error;
- public abstract ObjectPath restart(string mode = "replace") throws DBus.Error;
- public abstract ObjectPath try_restart(string mode = "replace") throws DBus.Error;
- public abstract ObjectPath reload_or_restart(string mode = "replace") throws DBus.Error;
- public abstract ObjectPath reload_or_try_restart(string mode = "replace") throws DBus.Error;
+ public abstract ObjectPath start(string mode = "replace") throws IOError;
+ public abstract ObjectPath stop(string mode = "replace") throws IOError;
+ public abstract ObjectPath reload(string mode = "replace") throws IOError;
+ public abstract ObjectPath restart(string mode = "replace") throws IOError;
+ public abstract ObjectPath try_restart(string mode = "replace") throws IOError;
+ public abstract ObjectPath reload_or_restart(string mode = "replace") throws IOError;
+ public abstract ObjectPath reload_or_try_restart(string mode = "replace") throws IOError;
- public abstract void reset_failed() throws DBus.Error;
+ public abstract void reset_failed() throws IOError;
}
[DBus (name = "org.freedesktop.systemd1.Job")]
-public interface Job : DBus.Object {
+public interface Job : DBusProxy {
public struct UnitLink {
string id;
ObjectPath path;
@@ -159,11 +157,11 @@ public interface Job : DBus.Object {
public abstract string job_type { owned get; }
public abstract UnitLink unit { owned get; }
- public abstract void cancel() throws DBus.Error;
+ public abstract void cancel() throws IOError;
}
-[DBus (name = "org.freedesktop.DBus.Properties")]
-public interface Properties : DBus.Object {
- public abstract Value? get(string iface, string property) throws DBus.Error;
- public abstract signal void properties_changed(string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties);
+[DBus (name = "org.freedesktop.Properties")]
+public interface Properties : DBusProxy {
+ public abstract Variant? get(string iface, string property) throws IOError;
+ public abstract signal void properties_changed(string iface, HashTable<string, Variant?> changed_properties, string[] invalidated_properties);
}
commit 9a57c62944258c750d80bca4fe56de4dbab46d67
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jan 20 18:22:03 2011 +0100
systemctl: highlight failed processes in systemctl status
diff --git a/Makefile.am b/Makefile.am
index b594b65..351f1ce 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -820,7 +820,8 @@ systemd_vconsole_setup_LDADD = \
systemd_remount_api_vfs_SOURCES = \
src/remount-api-vfs.c \
- src/mount-setup.c
+ src/mount-setup.c \
+ src/exit-status.c
systemd_remount_api_vfs_CFLAGS = \
$(AM_CFLAGS)
diff --git a/src/exit-status.c b/src/exit-status.c
index 4fed3c7..9b7c027 100644
--- a/src/exit-status.c
+++ b/src/exit-status.c
@@ -20,6 +20,7 @@
***/
#include <stdlib.h>
+#include <sys/wait.h>
#include "exit-status.h"
@@ -143,3 +144,31 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) {
return NULL;
}
+
+
+bool is_clean_exit(int code, int status) {
+
+ if (code == CLD_EXITED)
+ return status == 0;
+
+ /* If a daemon does not implement handlers for some of the
+ * signals that's not considered an unclean shutdown */
+ if (code == CLD_KILLED)
+ return
+ status == SIGHUP ||
+ status == SIGINT ||
+ status == SIGTERM ||
+ status == SIGPIPE;
+
+ return false;
+}
+
+bool is_clean_exit_lsb(int code, int status) {
+
+ if (is_clean_exit(code, status))
+ return true;
+
+ return
+ code == CLD_EXITED &&
+ (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED);
+}
diff --git a/src/exit-status.h b/src/exit-status.h
index 178bdf6..28f03a5 100644
--- a/src/exit-status.h
+++ b/src/exit-status.h
@@ -22,6 +22,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <stdbool.h>
+
typedef enum ExitStatus {
/* EXIT_SUCCESS defined by libc */
/* EXIT_FAILURE defined by libc */
@@ -75,4 +77,7 @@ typedef enum ExitStatusLevel {
const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level);
+bool is_clean_exit(int code, int status);
+bool is_clean_exit_lsb(int code, int status);
+
#endif
diff --git a/src/mount.c b/src/mount.c
index 08e9914..f978a54 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -36,6 +36,7 @@
#include "dbus-mount.h"
#include "special.h"
#include "bus-errors.h"
+#include "exit-status.h"
static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
[MOUNT_DEAD] = UNIT_INACTIVE,
diff --git a/src/remount-api-vfs.c b/src/remount-api-vfs.c
index 8cdf7e8..5b18728 100644
--- a/src/remount-api-vfs.c
+++ b/src/remount-api-vfs.c
@@ -31,6 +31,7 @@
#include "util.h"
#include "set.h"
#include "mount-setup.h"
+#include "exit-status.h"
/* Goes through /etc/fstab and remounts all API file systems, applying
* options that are in /etc/fstab that systemd might not have
diff --git a/src/service.c b/src/service.c
index 431bccc..4115e52 100644
--- a/src/service.c
+++ b/src/service.c
@@ -34,6 +34,7 @@
#include "dbus-service.h"
#include "special.h"
#include "bus-errors.h"
+#include "exit-status.h"
#define COMMENTS "#;\n"
#define NEWLINES "\n\r"
diff --git a/src/socket.c b/src/socket.c
index 7dc205a..3bb8862 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -41,6 +41,7 @@
#include "special.h"
#include "bus-errors.h"
#include "label.h"
+#include "exit-status.h"
static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
[SOCKET_DEAD] = UNIT_INACTIVE,
diff --git a/src/swap.c b/src/swap.c
index 6ab99d5..23a98dd 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -36,6 +36,7 @@
#include "dbus-swap.h"
#include "special.h"
#include "bus-errors.h"
+#include "exit-status.h"
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
[SWAP_DEAD] = UNIT_INACTIVE,
diff --git a/src/systemctl.c b/src/systemctl.c
index f93f2aa..fb34300 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -1847,15 +1847,31 @@ static void print_status_info(UnitStatusInfo *i) {
LIST_FOREACH(exec, p, i->exec) {
char *t;
+ bool good;
/* Only show exited processes here */
if (p->code == 0)
continue;
t = strv_join(p->argv, " ");
- printf("\t Process: %u %s=%s (code=%s, ", p->pid, p->name, strna(t), sigchld_code_to_string(p->code));
+ printf("\t Process: %u %s=%s ", p->pid, p->name, strna(t));
free(t);
+#ifdef HAVE_SYSV_COMPAT
+ if (i->is_sysv)
+ good = is_clean_exit_lsb(p->code, p->status);
+ else
+#endif
+ good = is_clean_exit(p->code, p->status);
+
+ if (!good) {
+ on = ansi_highlight(true);
+ off = ansi_highlight(false);
+ } else
+ on = off = "";
+
+ printf("%s(code=%s, ", on, sigchld_code_to_string(p->code));
+
if (p->code == CLD_EXITED) {
const char *c;
@@ -1870,7 +1886,10 @@ static void print_status_info(UnitStatusInfo *i) {
} else
printf("signal=%s", signal_to_string(p->status));
- printf(")\n");
+
+ printf(")%s\n", off);
+
+ on = off = NULL;
if (i->main_pid == p->pid &&
i->start_timestamp == p->start_timestamp &&
diff --git a/src/util.c b/src/util.c
index 30a3b05..d3876de 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2617,33 +2617,6 @@ int make_null_stdio(void) {
return make_stdio(null_fd);
}
-bool is_clean_exit(int code, int status) {
-
- if (code == CLD_EXITED)
- return status == 0;
-
- /* If a daemon does not implement handlers for some of the
- * signals that's not considered an unclean shutdown */
- if (code == CLD_KILLED)
- return
- status == SIGHUP ||
- status == SIGINT ||
- status == SIGTERM ||
- status == SIGPIPE;
-
- return false;
-}
-
-bool is_clean_exit_lsb(int code, int status) {
-
- if (is_clean_exit(code, status))
- return true;
-
- return
- code == CLD_EXITED &&
- (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED);
-}
-
bool is_device_path(const char *path) {
/* Returns true on paths that refer to a device, either in
diff --git a/src/util.h b/src/util.h
index e9ad881..c8cae70 100644
--- a/src/util.h
+++ b/src/util.h
@@ -267,9 +267,6 @@ char *format_timespan(char *buf, size_t l, usec_t t);
int make_stdio(int fd);
int make_null_stdio(void);
-bool is_clean_exit(int code, int status);
-bool is_clean_exit_lsb(int code, int status);
-
unsigned long long random_ull(void);
#define DEFINE_STRING_TABLE_LOOKUP(name,type) \
More information about the systemd-commits
mailing list