summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Lynch <rusty.lynch@intel.com>2013-09-05 16:56:16 -0700
committerRusty Lynch <rusty.lynch@intel.com>2013-09-05 17:03:45 -0700
commit49fb1bd2a4a2078f5f8536c391f38dd61508f15f (patch)
treecdf0e9e82ba37f91983f2a98e313c3cb6287aa53
parentc9fecee74148f2f2dfa82509dc4ed4b886ef41f0 (diff)
downloadcom-core-accepted/tizen/ivi/genivi.tar.gz
com-core-accepted/tizen/ivi/genivi.tar.bz2
com-core-accepted/tizen/ivi/genivi.zip
Change-Id: I306d315b59a56feb2474bd9a460a50c821aaa50e Signed-off-by: Rusty Lynch <rusty.lynch@intel.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--packaging/libcom-core.changes3
-rw-r--r--packaging/libcom-core.spec15
-rw-r--r--src/secure_socket.c60
4 files changed, 48 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4449a0e..06de187 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,7 @@ INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
glib-2.0
dlog
+ libsystemd-daemon
)
FOREACH(flag ${pkgs_CFLAGS})
diff --git a/packaging/libcom-core.changes b/packaging/libcom-core.changes
index 9246a62..2091ddd 100644
--- a/packaging/libcom-core.changes
+++ b/packaging/libcom-core.changes
@@ -1,3 +1,6 @@
+* Thu Sep 05 2013 Rusty Lynch <rusty.lynch@intel.com> accepted/tizen/20130710.221527@99bbffd
+- Add systemd socket activation support for secure sockets
+
* Wed May 29 2013 Xavier Roche <xavrock.os@gmail.com> accepted/tizen/20130520.100914@a1a091c
- Fix x86_64 build-install compliance
diff --git a/packaging/libcom-core.spec b/packaging/libcom-core.spec
index 6e565e9..537203b 100644
--- a/packaging/libcom-core.spec
+++ b/packaging/libcom-core.spec
@@ -2,24 +2,25 @@ Name: libcom-core
Summary: Library for the light-weight IPC
Version: 0.3.14
Release: 1
-Group: HomeTF/Framework
-License: Apache License
+Group: Base/IPC
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Source1001: libcom-core.manifest
BuildRequires: cmake, gettext-tools, coreutils
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(libsystemd-daemon)
%description
-Light-weight IPC supporting library
+Light-weight IPC supporting library for Tizen
%package devel
-Summary: Files for using API for light-weight IPC.
+Summary: Files for using API for light-weight IPC
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
-Light-weight IPC supporting library (dev)
+Light-weight IPC supporting library for Tizen (dev)
%prep
%setup -q
@@ -34,7 +35,9 @@ rm -rf %{buildroot}
%make_install
mkdir -p %{buildroot}/%{_datarootdir}/license
-%post
+%post -n libcom-core -p /sbin/ldconfig
+
+%postun -n libcom-core -p /sbin/ldconfig
%files -n libcom-core
%manifest %{name}.manifest
diff --git a/src/secure_socket.c b/src/secure_socket.c
index a69a7b3..d49f4a3 100644
--- a/src/secure_socket.c
+++ b/src/secure_socket.c
@@ -26,6 +26,7 @@
#include <sys/un.h>
#include <netinet/in.h>
#include <errno.h>
+#include <systemd/sd-daemon.h>
#include <dlog.h>
@@ -100,33 +101,42 @@ EAPI int secure_socket_create_server(const char *peer)
{
int handle;
int state;
+ int num;
struct sockaddr_un addr;
- handle = create_socket(peer, &addr);
- if (handle < 0)
- return handle;
-
- state = bind(handle, &addr, sizeof(addr));
- if (state < 0) {
- state = -errno;
-
- ErrPrint("Failed to bind a socket %s\n", strerror(errno));
- if (close(handle) < 0)
- ErrPrint("Close a handle : %s\n", strerror(errno));
-
- return state;
- }
-
- state = listen(handle, BACKLOG);
- if (state < 0) {
- state = -errno;
- ErrPrint("Failed to listen a socket %s\n", strerror(errno));
-
- if (close(handle) < 0)
- ErrPrint("Close a handle : %s\n", strerror(errno));
-
- return state;
- }
+ num = sd_listen_fds(0);
+ if (num > 1) {
+ ErrPrint("Too many file descriptors recieved on socket activation.\n");
+ return -1;
+ } else if (num == 1) {
+ handle = SD_LISTEN_FDS_START + 0;
+ } else {
+ handle = create_socket(peer, &addr);
+ if (handle < 0)
+ return handle;
+
+ state = bind(handle, &addr, sizeof(addr));
+ if (state < 0) {
+ state = -errno;
+
+ ErrPrint("Failed to bind a socket %s\n", strerror(errno));
+ if (close(handle) < 0)
+ ErrPrint("Close a handle : %s\n", strerror(errno));
+
+ return state;
+ }
+
+ state = listen(handle, BACKLOG);
+ if (state < 0) {
+ state = -errno;
+ ErrPrint("Failed to listen a socket %s\n", strerror(errno));
+
+ if (close(handle) < 0)
+ ErrPrint("Close a handle : %s\n", strerror(errno));
+
+ return state;
+ }
+ }
if (chmod(peer, 0666) < 0)
ErrPrint("Failed to change the permission of a socket (%s)\n",