Define unix sock path commonly 40/60240/2
authorKyungwook Tak <k.tak@samsung.com>
Wed, 24 Feb 2016 08:33:42 +0000 (17:33 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Thu, 25 Feb 2016 01:41:41 +0000 (10:41 +0900)
Change-Id: Ia965558fb1ec5ea986a923e60283973abd747e5c
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
CMakeLists.txt
packaging/pubkey-pinning.spec
src/common/include/ui/connection.h
src/common/ui/popup-bin/popup.cpp
src/common/ui/popup_runner.cpp
systemd/CMakeLists.txt
systemd/pubkey-pinning-popup.socket.in [moved from systemd/pubkey-pinning-popup.socket with 70% similarity]

index fa2510f..dd225f0 100644 (file)
@@ -43,6 +43,7 @@ ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
 ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
 
 ADD_DEFINITIONS("-DPROJECT_NAME=\"${PROJECT_NAME}\"")
+ADD_DEFINITIONS("-DSOCK_PATH=\"${SOCK_PATH}\"")
 
 # compiler warning flags
 ADD_DEFINITIONS("-Wall")
index e287e00..88a4653 100644 (file)
@@ -61,11 +61,13 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
 export LDFLAGS+="-Wl,--rpath=%_prefix/lib"
 
+%global sock_path /tmp/.%name-popup.sock
 
 %{!?build_type:%define build_type "Release"}
 %cmake . -DCMAKE_INSTALL_PREFIX=%_prefix \
         -DVERSION=%version               \
         -DINCLUDEDIR=%_includedir        \
+        -DSOCK_PATH=%sock_path           \
         -DCMAKE_BUILD_TYPE=%build_type   \
 %if 0%{?pubkey_pinning_test_build}
         -DPUBKEY_PINNING_TEST_BUILD=1    \
index 587d4cd..2b906b3 100644 (file)
@@ -24,8 +24,6 @@
 
 #include "ui/popup_common.h"
 
-#define TPKP_UI_SOCK_ADDR "/tmp/.tpkp-ui-backend.sock"
-
 namespace TPKP {
 namespace UI {
 
index b417aad..574ece0 100644 (file)
@@ -41,8 +41,6 @@
 #endif
 #define LOG_TAG "TPKP_POPUP"
 
-#define TPKP_UI_SOCK_ADDR "/tmp/.tpkp-ui-backend.sock"
-
 using namespace TPKP::UI;
 
 namespace {
@@ -242,7 +240,7 @@ int getSockFromSystemd(void)
        int n = sd_listen_fds(0);
 
        for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; ++fd) {
-               if (sd_is_socket_unix(fd, SOCK_STREAM, 1, TPKP_UI_SOCK_ADDR, 0) > 0) {
+               if (sd_is_socket_unix(fd, SOCK_STREAM, 1, SOCK_PATH, 0) > 0) {
                        SLOGD("Get socket from systemd. fd[%d]", fd);
                        return fd;
                }
index 7816406..0aa9fe1 100644 (file)
@@ -83,7 +83,7 @@ Response runPopup(const std::string &hostname, int timeout) noexcept
                else if (timeout < TIMEOUT_MS_MIN)
                        timeout = TIMEOUT_MS_MIN;
 
-               ServiceConnection connection(TPKP_UI_SOCK_ADDR, timeout);
+               ServiceConnection connection(SOCK_PATH, timeout);
                BinaryStream outStream = connection.processRequest(inStream);
 
                deserialize(pdp, outStream);
index 249b1ee..f18d387 100644 (file)
@@ -1,4 +1,5 @@
 CONFIGURE_FILE(pubkey-pinning-popup.service.in pubkey-pinning-popup.service @ONLY)
+CONFIGURE_FILE(pubkey-pinning-popup.socket.in pubkey-pinning-popup.socket @ONLY)
 
 INSTALL(
        FILES
similarity index 70%
rename from systemd/pubkey-pinning-popup.socket
rename to systemd/pubkey-pinning-popup.socket.in
index 9afc063..4c23237 100644 (file)
@@ -1,5 +1,5 @@
 [Socket]
-ListenStream=/tmp/.tpkp-ui-backend.sock
+ListenStream=@SOCK_PATH@
 SocketMode=0777
 Service=pubkey-pinning-popup.service