ADD_DEFINITIONS("-DSYSTEMD_ENV_FILE=\"${SYSTEMD_ENV_FILE}\"")
ADD_DEFINITIONS("-DUPGRADE_DATA_DIR=\"${UPGRADE_DATA_DIR}\"")
+IF (DEFINED WATCHDOG_ENABLED)
+ MESSAGE("WATCHDOG ENABELD!")
+ ADD_DEFINITIONS("-DWATCHDOG_ENABLED")
+ ADD_DEFINITIONS("-DWATCHDOG_TIMEOUT_SEC=${WATCHDOG_TIMEOUT_SEC}")
+ ADD_DEFINITIONS("-DWATCHDOG_NOTIFY_SEC=${WATCHDOG_NOTIFY_SEC}")
+ SET(WATCHDOG_DECLARE "NotifyAccess=main")
+ENDIF (DEFINED WATCHDOG_ENABLED)
+
IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DTIZEN_DEBUG_ENABLE")
ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
+%global watchdog_enabled 1
+%global watchdog_timeout_sec 60
+%global watchdog_notify_sec 20
+
Name: key-manager
Summary: Central Key Manager and utilities
Version: 0.1.23
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(pkgmgr)
+%if 0%{?watchdog_enabled}
+BuildRequires: pkgconfig(argos_watchdog)
+%endif
BuildRequires: boost-devel
BuildRequires: ca-certificates-devel
#Requires(pre): tizen-platform-config-tools
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
%endif
-
export LDFLAGS+="-Wl,--rpath=%{_libdir},-Bsymbolic-functions "
%cmake . -DVERSION=%{version} \
-DINITIAL_VALUES_DIR=%{initial_values_dir} \
-DDB_TEST_DIR=%{db_test_dir} \
-DCA_CERTS_DIR=%{ca_certs_dir} \
- -DUPGRADE_SCRIPT_DIR=%{upgrade_script_dir} \
- -DUPGRADE_DATA_DIR=%{upgrade_data_dir}
+%if 0%{?watchdog_enabled}
+ -DWATCHDOG_ENABLED=%{watchdog_enabled} \
+ -DWATCHDOG_TIMEOUT_SEC=%{watchdog_timeout_sec} \
+ -DWATCHDOG_NOTIFY_SEC=%{watchdog_notify_sec} \
+%endif
+ -DUPGRADE_DATA_DIR=%{upgrade_data_dir} \
+ -DUPGRADE_SCRIPT_DIR=%{upgrade_script_dir}
make %{?jobs:-j%jobs}
+IF (DEFINED WATCHDOG_ENABLED)
+SET(EXTRA_KM_DEPS argos_watchdog)
+ELSE (DEFINED WATCHDOG_ENABLED)
+SET(EXTRA_KM_DEPS)
+ENDIF (DEFINED WATCHDOG_ENABLED)
+
PKG_CHECK_MODULES(KEY_MANAGER_DEP
REQUIRED
dlog
cynara-client-async
cynara-creds-socket
pkgmgr
+ ${EXTRA_KM_DEPS}
)
FIND_PACKAGE(Threads REQUIRED)
#include <dpl/log/log.h>
#include <glib-logic.h>
+#ifdef WATCHDOG_ENABLED
+#include <argos.h>
+#endif
+
namespace {
struct PkgmgrEvent {
PkgmgrEvent(uid_t _uid, const char *_pkgid)
return;
}
+#ifdef WATCHDOG_ENABLED
+ int ret = aw_register(WATCHDOG_TIMEOUT_SEC);
+ if (ret != 0) {
+ LogError("Failed to aw_register. ret(errno): " << ret);
+ } else {
+ LogInfo("aw_register success! watchdog registered.");
+ if (g_timeout_add_seconds(WATCHDOG_NOTIFY_SEC, watchdogMsgSender, nullptr) <= 0) {
+ LogError("Failed to add source for watchdog notify timer. "
+ "let's disable registered watchdog.");
+
+ ret = aw_control(AW_OP_DISABLE, nullptr);
+ if (ret != 0)
+ LogError("Failed to disable registerd watchdog...");
+ }
+ }
+#endif
+
LogDebug("Starting g_main_loop");
g_main_loop_run(m_gMainLoop);
LogDebug("...g_main_loop ended");
}
+#ifdef WATCHDOG_ENABLED
+gboolean GLIBLogic::watchdogMsgSender(gpointer /*data*/)
+{
+ int ret = aw_notify();
+ if (ret != 0)
+ LogError("Failed to aw_notify. ret(errno): " << ret);
+ else
+ LogInfo("aw_notify success!");
+
+ return TRUE;
+}
+#endif
+
void GLIBLogic::LoopStop()
{
LogDebug("Closing g_main_loop");
const void *pmsg,
void *data);
+#ifdef WATCHDOG_ENABLED
+ static gboolean watchdogMsgSender(gpointer data);
+#endif
+
int packageEventCallback(
uid_t uid,
int reqid,
Sockets=central-key-manager-api-encryption.socket
EnvironmentFile=-@SYSTEMD_ENV_FILE@
RuntimeDirectory=@SERVICE_NAME@
+@WATCHDOG_DECLARE@
[Install]
WantedBy=multi-user.target