ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+IF (BUILD_WITH_SYSTEMD_DAEMON)
+ ADD_DEFINITIONS("-DBUILD_WITH_SYSTEMD_DAEMON")
+ENDIF (BUILD_WITH_SYSTEMD_DAEMON)
+
SET(TARGET_ASKUSER "askuser")
SET(TARGET_ASKUSER_COMMON "askuser-common")
SET(TARGET_PLUGIN_SERVICE "askuser-plugin-service")
SET(TARGET_TESTS "askuser-tests")
ADD_SUBDIRECTORY(src)
+IF (BUILD_WITH_SYSTEMD_DAEMON)
ADD_SUBDIRECTORY(systemd)
+ENDIF (BUILD_WITH_SYSTEMD_DAEMON)
ADD_SUBDIRECTORY(test)
+%if !%{defined with_systemd_daemon}
+%define with_systemd_daemon 0
+%endif
+
Name: askuser
Summary: Agent service for Cynara 'ask user' policy
Version: 0.1.4
BuildRequires: pkgconfig(cynara-creds-socket)
BuildRequires: pkgconfig(cynara-plugin)
BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(libsystemd-daemon)
-BuildRequires: pkgconfig(libsystemd-journal)
+BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(security-manager)
BuildRequires: pkgconfig(security-privilege-manager)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: coregl
-%{?systemd_requires}
%if !%{defined build_type}
%define build_type RELEASE
%cmake . \
-DCMAKE_BUILD_TYPE=%{?build_type} \
+ -DBUILD_WITH_SYSTEMD_DAEMON=%{?with_systemd_daemon} \
-DCMAKE_VERBOSE_MAKEFILE=ON
make %{?jobs:-j%jobs}
%find_lang %{name}
%post
+%if %{with_systemd_daemon}
# todo properly use systemd --user
ln -s /lib/systemd/user/askuser-notification.service \
/usr/lib/systemd/user/default.target.wants/askuser-notification.service
fi
systemctl restart askuser.service
+%endif
+
systemctl restart cynara.service
%preun
+%if %{with_systemd_daemon}
if [ $1 = 0 ]; then
systemctl stop askuser.service
fi
+%endif
%postun
+%if %{with_systemd_daemon}
if [ $1 = 0 ]; then
systemctl daemon-reload
fi
+%endif
systemctl restart cynara.service
%manifest %{name}.manifest
%license LICENSE
%attr(755, root, root) /usr/bin/askuser
+%if %{with_systemd_daemon}
/usr/lib/systemd/system/askuser.service
+%endif
%files -n askuser-notification
%manifest askuser-notification.manifest
%license LICENSE
%attr(755,root,root) /usr/bin/askuser-notification
+%if %{with_systemd_daemon}
/usr/lib/systemd/user/askuser-notification.service
+%endif
/usr/share/locale/en/LC_MESSAGES/askuser.mo
/usr/share/locale/pl/LC_MESSAGES/askuser.mo
#include <cstdlib>
#include <cstring>
#include <exception>
-#include <systemd/sd-journal.h>
-#include <systemd/sd-daemon.h>
-
#include <attributes/attributes.h>
-
#include <log/alog.h>
+#ifdef BUILD_WITH_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
+
#include "Agent.h"
// Handle kill message from systemd
try {
AskUser::Agent::Agent agent;
+#ifdef BUILD_WITH_SYSTEMD_DAEMON
int ret = sd_notify(0, "READY=1");
if (ret == 0) {
ALOGW("Agent was not configured to notify its status");
} else if (ret < 0) {
ALOGE("sd_notify failed: [" << ret << "]");
}
-
+#endif
agent.run();
} catch (const std::exception &e) {
ALOGC("Agent stopped because of unhandled exception: <" << e.what() << ">");
#include <csignal>
#include <cstdlib>
#include <string>
-#include <systemd/sd-daemon.h>
#include <thread>
#include <unistd.h>
+#ifdef BUILD_WITH_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
+
#include <exception/Exception.h>
#include <log/alog.h>
GuiRunner gui;
AskUserTalker askUserTalker(&gui);
+#ifdef BUILD_WITH_SYSTEMD_DAEMON
int ret = sd_notify(0, "READY=1");
if (ret == 0) {
ALOGW("Agent was not configured to notify its status");
} else if (ret < 0) {
ALOGE("sd_notify failed: [" << ret << "]");
}
+#endif
askUserTalker.run();