X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fdbus-manager.c;h=cffa547678296c63dcaab42d5f21094f82dd5546;hp=c1238f006657e73e0f539ed82c165f1fdcbb8c54;hb=ad6ab0af1ed38e342aeeae1c5f7c1503fab11935;hpb=a7f241db3f1ae96ab2708092e1b31d2feb989947 diff --git a/src/dbus-manager.c b/src/dbus-manager.c index c1238f006..cffa54767 100644 --- a/src/dbus-manager.c +++ b/src/dbus-manager.c @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ /*** This file is part of systemd. @@ -33,6 +33,10 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -72,7 +76,7 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -80,7 +84,7 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -92,7 +96,7 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -131,11 +135,14 @@ " \n" \ " \n" \ " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ " \n" #define INTROSPECTION_BEGIN \ @@ -143,6 +150,7 @@ "\n" \ BUS_MANAGER_INTERFACE \ BUS_PROPERTIES_INTERFACE \ + BUS_PEER_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE #define INTROSPECTION_END \ @@ -240,11 +248,14 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, { "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment }, { "org.freedesktop.systemd1.Manager", "ConfirmSpawn", bus_property_append_bool, "b", &m->confirm_spawn }, { "org.freedesktop.systemd1.Manager", "ShowStatus", bus_property_append_bool, "b", &m->show_status }, + { "org.freedesktop.systemd1.Manager", "SysVConsole", bus_property_append_bool, "b", &m->sysv_console }, { "org.freedesktop.systemd1.Manager", "UnitPath", bus_property_append_strv, "as", m->lookup_paths.unit_path }, { "org.freedesktop.systemd1.Manager", "SysVInitPath", bus_property_append_strv, "as", m->lookup_paths.sysvinit_path }, { "org.freedesktop.systemd1.Manager", "SysVRcndPath", bus_property_append_strv, "as", m->lookup_paths.sysvrcnd_path }, { "org.freedesktop.systemd1.Manager", "NotifySocket", bus_property_append_string, "s", m->notify_socket }, { "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_hierarchy }, + { "org.freedesktop.systemd1.Manager", "MountAuto", bus_property_append_bool, "b", &m->mount_auto }, + { "org.freedesktop.systemd1.Manager", "SwapAuto", bus_property_append_bool, "b", &m->swap_auto }, { NULL, NULL, NULL, NULL, NULL } }; @@ -288,7 +299,33 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) goto oom; + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetUnitByPID")) { + Unit *u; + uint32_t pid; + + if (!dbus_message_get_args( + message, + &error, + DBUS_TYPE_UINT32, &pid, + DBUS_TYPE_INVALID)) + return bus_send_error_reply(m, connection, message, &error, -EINVAL); + + if (!(u = cgroup_unit_by_pid(m, (pid_t) pid))) { + dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "No unit for PID %lu is loaded.", (unsigned long) pid); + return bus_send_error_reply(m, connection, message, &error, -ENOENT); + } + if (!(reply = dbus_message_new_method_return(message))) + goto oom; + + if (!(path = unit_dbus_path(u))) + goto oom; + + if (!dbus_message_append_args( + reply, + DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID)) + goto oom; } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "LoadUnit")) { const char *name; Unit *u; @@ -366,14 +403,14 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, if (!(reply = dbus_message_new_method_return(message))) goto oom; - } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ResetMaintenance")) { + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ResetFailed")) { - manager_reset_maintenance(m); + manager_reset_failed(m); if (!(reply = dbus_message_new_method_return(message))) goto oom; - } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ResetMaintenanceUnit")) { + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ResetFailedUnit")) { const char *name; Unit *u; @@ -389,7 +426,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, return bus_send_error_reply(m, connection, message, &error, -ENOENT); } - unit_reset_maintenance(u); + unit_reset_failed(u); if (!(reply = dbus_message_new_method_return(message))) goto oom; @@ -799,8 +836,11 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, job_type = JOB_RELOAD; } - if (job_type == JOB_START && u->meta.only_by_dependency) { - dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Unit may be activated by dependency only."); + if ((job_type == JOB_START && u->meta.refuse_manual_start) || + (job_type == JOB_STOP && u->meta.refuse_manual_stop) || + ((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) && + (u->meta.refuse_manual_start || u->meta.refuse_manual_stop))) { + dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, may be requested by dependency only."); return bus_send_error_reply(m, connection, message, &error, -EPERM); }