dbus-service.c revision 718db96199eb307751264e4163555662c9a389fa
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "strv.h"
#include "path-util.h"
#include "unit.h"
#include "service.h"
#include "dbus-unit.h"
#include "dbus-execute.h"
#include "dbus-kill.h"
#include "dbus-cgroup.h"
#include "dbus-service.h"
#include "bus-util.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_start_limit_action, start_limit_action, StartLimitAction);
const sd_bus_vtable bus_service_vtable[] = {
SD_BUS_PROPERTY("NotifyAccess", "s", property_get_notify_access, offsetof(Service, notify_access), 0),
SD_BUS_PROPERTY("TimeoutStartUSec", "t", bus_property_get_usec, offsetof(Service, timeout_start_usec), 0),
SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Service, timeout_stop_usec), 0),
SD_BUS_PROPERTY("StartLimitInterval", "t", bus_property_get_usec, offsetof(Service, start_limit.interval), 0),
SD_BUS_PROPERTY("StartLimitBurst", "u", bus_property_get_unsigned, offsetof(Service, start_limit.burst), 0),
SD_BUS_PROPERTY("StartLimitAction", "s", property_get_start_limit_action, offsetof(Service, start_limit_action), 0),
SD_BUS_PROPERTY("PermissionsStartOnly", "b", bus_property_get_bool, offsetof(Service, permissions_start_only), 0),
SD_BUS_PROPERTY("RootDirectoryStartOnly", "b", bus_property_get_bool, offsetof(Service, root_directory_start_only), 0),
SD_BUS_PROPERTY("RemainAfterExit", "b", bus_property_get_bool, offsetof(Service, remain_after_exit), 0),
SD_BUS_PROPERTY("MainPID", "u", bus_property_get_pid, offsetof(Service, main_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Service, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("StatusText", "s", NULL, offsetof(Service, status_text), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Service, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
BUS_EXEC_STATUS_VTABLE("ExecMain", offsetof(Service, main_exec_status), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
BUS_EXEC_COMMAND_VTABLE("ExecStartPre", offsetof(Service, exec_command[SERVICE_EXEC_START_PRE]), 0),
BUS_EXEC_COMMAND_VTABLE("ExecStartPost", offsetof(Service, exec_command[SERVICE_EXEC_START_POST]), 0),
BUS_EXEC_COMMAND_VTABLE("ExecStopPost", offsetof(Service, exec_command[SERVICE_EXEC_STOP_POST]), 0),
};
const char* const bus_service_changing_properties[] = {
"ExecMainStartTimestamp",
"ExecMainStartTimestampMonotonic",
"ExecMainExitTimestamp",
"ExecMainExitTimestampMonotonic",
"ExecMainPID",
"ExecMainCode",
"ExecMainStatus",
"MainPID",
"ControlPID",
"StatusText",
"Result",
};
static int bus_service_set_transient_property(
Service *s,
const char *name,
sd_bus_error *error) {
int r;
assert(s);
int b;
if (r < 0)
return r;
if (mode != UNIT_CHECK) {
s->remain_after_exit = b;
}
return 1;
unsigned n = 0;
if (r < 0)
return r;
const char *path;
int b;
if (r < 0)
return r;
if (!path_is_absolute(path))
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (mode != UNIT_CHECK) {
ExecCommand *c;
if (!c)
return -ENOMEM;
if (!c->path) {
free(c);
return -ENOMEM;
}
c->ignore = b;
path_kill_slashes(c->path);
}
n++;
}
if (r < 0)
return r;
if (mode != UNIT_CHECK) {
ExecCommand *c;
if (n == 0) {
}
if (!f)
return -ENOMEM;
fputs("ExecStart=\n", f);
_cleanup_free_ char *a;
a = strv_join_quoted(c->argv);
if (!a)
return -ENOMEM;
fprintf(f, "ExecStart=%s@%s %s\n",
c->path,
a);
}
fflush(f);
}
return 1;
}
return 0;
}
Unit *u,
const char *name,
sd_bus_error *error) {
int r;
assert(s);
if (r != 0)
return r;
/* This is a transient unit, let's load a little more */
if (r != 0)
return r;
if (r != 0)
return r;
}
return 0;
}
int bus_service_commit_properties(Unit *u) {
assert(u);
return 0;
}