src/listeners/audit.c \
src/listeners/systemd.c \
src/util/log.c \
- src/util/notify_queue.c
+ src/util/notify_queue.c \
+ src/util/systemd_dbus.c
faultd_LDADD = $(LIBSYSTEMD_LIBS) $(AUDIT_LIBS) $(LIBEJDB_LIBS)
#define FAULTD_ACTION_REBOOT_ID "org.tizen.faultd.action.REBOOT"
#define FAULTD_ACTION_RECOVERY_REBOOT_ID "org.tizen.faultd.action.RECOVERY_REBOOT"
+#define FAULTD_DEFAULT_ACTION_IMPL "default"
+
#endif /* FAULTD_ACTION_H */
--- /dev/null
+/*
+ * faultd
+ *
+ * Copyright © 2017 Samsung Electronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <systemd/sd-bus.h>
+
+#include "common.h"
+#include "systemd_dbus.h"
+
+int faultd_dbus_call(char *service, char *obj, char *interface, char *method,
+ sd_bus_error *error, sd_bus_message **out_msg,
+ char *types, ...)
+{
+ _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
+ _cleanup_(sd_bus_error_free) sd_bus_error error_buf = SD_BUS_ERROR_NULL;
+ int ret;
+
+ if (!error)
+ error = &error_buf;
+
+ ret = sd_bus_default_system(&bus);
+ if (ret < 0)
+ return ret;
+
+ ret = sd_bus_message_new_method_call(bus, &m, service,
+ obj, interface, method);
+ if (ret < 0)
+ goto fail;
+
+ if (types) {
+ va_list args;
+
+ va_start(args, types);
+ ret = sd_bus_message_appendv(m, types, args);
+ va_end(args);
+ if (ret < 0)
+ goto fail;
+ }
+
+ return sd_bus_call(bus, m, 0, error, out_msg);
+
+fail:
+ return sd_bus_error_set_errno(error, ret);
+}
--- /dev/null
+/*
+ * faultd
+ *
+ * Copyright © 2017 Samsung Electronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FAULTD_SYSTEMD_DBUS_H
+#define FAULTD_SYSTEMD_DBUS_H
+
+#include <systemd/sd-bus.h>
+
+#define SYSTEMD_SERVICE "org.freedesktop.systemd1"
+
+#define SYSTEMD_OBJ "/org/freedesktop/systemd1"
+
+#define SYSTEMD_MANAGER_INTERFACE "org.freedesktop.systemd1.Manager"
+#define SYSTEMD_UNIT_INTERFACE "org.freedesktop.systemd1.Unit"
+
+int faultd_dbus_call(char *service, char *obj, char *interface, char *method,
+ sd_bus_error *error, sd_bus_message **out_msg,
+ char *args, ...);
+
+#define faultd_dbus_call_simple(SRV, OBJ, INTF, METHOD, ARGS, ...) \
+ faultd_dbus_call(SRV, OBJ, INTF, METHOD, NULL, NULL, ARGS, ##__VA_ARGS__)
+
+#define faultd_dbus_call_systemd_simple(OBJ, INTF, METHOD, ARGS, ...) \
+ faultd_dbus_call_simple(SYSTEMD_SERVICE, OBJ, INTF, METHOD, \
+ ARGS, ##__VA_ARGS__)
+
+#endif /* FAULTD_SYSTEMD_DBUS_H */