SET(AUL-1_PKG_CHECK_MODULES dlog libprivilege-control app-checker rua glib-2.0 vconf pkgmgr-info privacy-manager-client)
pkg_check_modules(pkgs REQUIRED ${AUL-1_PKG_CHECK_MODULES} )
-pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker libtzplatform-config pkgmgr-info)
+pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker libtzplatform-config pkgmgr-info libsystemd-daemon)
PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 gio-2.0 dlog bundle rua)
FIND_LIBRARY(LIB_DL dl)
GPollFD *gpollfd;
GSource *src;
- fd = __create_server_sock(AUL_UTIL_PID);
+ fd = __create_sock_activation();
+ if (fd == -1) {
+ _D("Create server socket without socket activation");
+ fd = __create_server_sock(AUL_UTIL_PID);
+ }
+
src = g_source_new(&funcs, sizeof(GSource));
gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
_static_ int __agent_pre_init(int argc, char **argv)
{
int fd;
- char *socket_path = NULL;
+ char socket_path[PATH_MAX];
/* signal init*/
__signal_init();
- /* get my(agent) command line*/
- agent_cmdline = __proc_get_cmdline_bypid(getpid());
- if (agent_cmdline == NULL) {
- _E("agent cmdline fail to get");
- return -1;
- }
- _D("agent cmdline = %s", agent_cmdline);
+ /* get my(agent) command line*/
+ agent_cmdline = __proc_get_cmdline_bypid(getpid());
+ if (agent_cmdline == NULL) {
+ _E("agent cmdline fail to get");
+ return -1;
+ }
+ _D("agent cmdline = %s", agent_cmdline);
/* create agent socket */
- asprintf(&socket_path,"/run/user/%d/amd_agent",getuid());
- if(socket_path)
+
+ fd = __create_sock_activation();
+ if (fd == -1) {
+ _D("Create server socket without socket activation");
+ snprintf(socket_path, sizeof(socket_path),
+ "/run/user/%d/amd_agent", getuid());
fd = __create_server_sock_by_path(socket_path);
- else
- return -1;
- free(socket_path);
+ }
if (fd < 0) {
_E("server sock error");
return -1;
app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen);
int __create_agent_client_sock(int uid);
int __create_server_sock_by_path(char *path);
+int __create_sock_activation(void);
#endif
--- /dev/null
+[Socket]
+ListenStream=/tmp/alaunch/-2
+DirectoryMode=0777
+
+[Install]
+WantedBy=sockets.target
--- /dev/null
+[Socket]
+ListenStream=/run/user/%U/amd_agent
+
+[Install]
+WantedBy=sockets.target
Group: System/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-Source102: ac.service
+Source101: ac.service
+Source102: ac.socket
Source103: amd_session_agent.service
+Source104: amd_session_agent.socket
Source1001: %{name}.manifest
Requires(post): /sbin/ldconfig
BuildRequires: libattr-devel
BuildRequires: pkgconfig(privacy-manager-client)
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(libsystemd-daemon)
%description
Application utility library
sqlite3 %{buildroot}%{TZ_SYS_DB}/.mida.db < %{buildroot}%{_datadir}/aul/mida_db.sql
rm -rf %{buildroot}%{_datadir}/aul/mida_db.sql
-mkdir -p %{buildroot}%{_unitdir}
-mkdir -p %{buildroot}%{_unitdir_user}
-install -m 0644 %SOURCE102 %{buildroot}%{_unitdir}/ac.service
+mkdir -p %{buildroot}%{_unitdir}/default.target.wants
+mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
+mkdir -p %{buildroot}%{_unitdir_user}/default.target.wants
+mkdir -p %{buildroot}%{_unitdir_user}/sockets.target.wants
+install -m 0644 %SOURCE101 %{buildroot}%{_unitdir}/ac.service
+install -m 0644 %SOURCE102 %{buildroot}%{_unitdir}/ac.socket
install -m 0644 %SOURCE103 %{buildroot}%{_unitdir_user}/amd_session_agent.service
+install -m 0644 %SOURCE104 %{buildroot}%{_unitdir_user}/amd_session_agent.socket
+ln -sf ../ac.service %{buildroot}%{_unitdir}/default.target.wants/ac.service
+ln -sf ../ac.socket %{buildroot}%{_unitdir}/sockets.target.wants/ac.socket
+ln -sf ../amd_session_agent.service %{buildroot}%{_unitdir_user}/default.target.wants/amd_session_agent.service
+ln -sf ../amd_session_agent.socket %{buildroot}%{_unitdir_user}/sockets.target.wants/amd_session_agent.socket
%preun
if [ $1 == 0 ]; then
%post
/sbin/ldconfig
-systemctl enable ac
-systemctl --global enable amd_session_agent
systemctl daemon-reload
if [ $1 == 1 ]; then
systemctl restart ac.service
%{_datadir}/aul/preload_list.txt
%{_datadir}/aul/preexec_list.txt
%{_unitdir}/ac.service
+%{_unitdir}/default.target.wants/ac.service
+%{_unitdir}/ac.socket
+%{_unitdir}/sockets.target.wants/ac.socket
%{_unitdir_user}/amd_session_agent.service
+%{_unitdir_user}/default.target.wants/amd_session_agent.service
+%{_unitdir_user}/amd_session_agent.socket
+%{_unitdir_user}/sockets.target.wants/amd_session_agent.socket
%{_bindir}/amd
%{_bindir}/daemon-manager-release-agent
%{_bindir}/daemon-manager-launch-agent
#include <sys/xattr.h>
#include <errno.h>
#include <fcntl.h>
+#include <systemd/sd-daemon.h>
#include "app_sock.h"
#include "simple_util.h"
return fd;
}
+int __create_sock_activation(void)
+{
+ int fds;
+ fds = sd_listen_fds(0);
+ if (fds == 1)
+ return SD_LISTEN_FDS_START;
+ if (fds > 1)
+ _E("Too many file descriptors received.\n");
+ else
+ _D("There is no socket stream");
-
+ return -1;
+}
int __create_agent_client_sock(int uid)
{