Remove unused service.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 14 Nov 2013 16:25:40 +0000 (17:25 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:13:23 +0000 (17:13 +0100)
[Issue#]    N/A
[Bug]       N/A
[Cause]     Code that was using exec serivice was removed.
[Problem]   Service exec path was not used.
[Solution]  Deprecated code has been removed.

[Verification] Build, run tests.

Change-Id: I33e5ba64486d4b631a8a92a8a1af65e1e2ca096b

src/CMakeLists.txt
src/server2/common/protocols.cpp
src/server2/common/protocols.h
src/server2/main/server2-main.cpp
src/server2/service/exec-path.cpp [deleted file]
src/server2/service/exec-path.h [deleted file]

index 59dc74f..dc38028 100644 (file)
@@ -26,7 +26,6 @@ SET(SECURITY_SERVER_SOURCES
     ${SERVER2_PATH}/service/cookie.cpp
     ${SERVER2_PATH}/service/cookie-jar.cpp
     ${SERVER2_PATH}/service/privilege-by-pid.cpp
-    ${SERVER2_PATH}/service/exec-path.cpp
     ${SERVER2_PATH}/service/get-object-name.cpp
     )
 
index 6978181..87ffd74 100644 (file)
@@ -35,8 +35,6 @@ char const * const SERVICE_SOCKET_GET_GID =
     "/tmp/.security-server-api-get-gid.sock";
 char const * const SERVICE_SOCKET_PRIVILEGE_BY_PID =
     "/tmp/.security-server-api-privilege-by-pid.sock";
-char const * const SERVICE_SOCKET_EXEC_PATH =
-    "/tmp/.security-server-api-exec-path.sock";
 char const * const SERVICE_SOCKET_GET_OBJECT_NAME =
     "/tmp/.security-server-api-get-object-name.sock";
 char const * const SERVICE_SOCKET_APP_PERMISSIONS =
index 29ee384..ec9e4f6 100644 (file)
@@ -33,7 +33,6 @@ extern char const * const SERVICE_SOCKET_SHARED_MEMORY;
 extern char const * const SERVICE_SOCKET_ECHO;
 extern char const * const SERVICE_SOCKET_GET_GID;
 extern char const * const SERVICE_SOCKET_PRIVILEGE_BY_PID;
-extern char const * const SERVICE_SOCKET_EXEC_PATH;
 extern char const * const SERVICE_SOCKET_GET_OBJECT_NAME;
 extern char const * const SERVICE_SOCKET_APP_PERMISSIONS;
 extern char const * const SERVICE_SOCKET_COOKIE_GET;
index e5fa207..b3512b1 100644 (file)
@@ -34,7 +34,6 @@
 #include <data-share.h>
 #include <get-gid.h>
 #include <privilege-by-pid.h>
-#include <exec-path.h>
 #include <get-object-name.h>
 #include <app-permissions.h>
 #include <cookie.h>
@@ -69,10 +68,6 @@ int server2(void) {
         SecurityServer::PrivilegeByPidService *privByPidService = new SecurityServer::PrivilegeByPidService;
         privByPidService->Create();
         manager.RegisterSocketService(privByPidService);
-        
-        SecurityServer::ExecPathService *execService = new SecurityServer::ExecPathService;
-        execService->Create();
-        manager.RegisterSocketService(execService);
 
         SecurityServer::GetObjectNameService *getObjectNameService = new SecurityServer::GetObjectNameService;
         getObjectNameService->Create();
diff --git a/src/server2/service/exec-path.cpp b/src/server2/service/exec-path.cpp
deleted file mode 100644 (file)
index 4cb36b7..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-/*
- * @file        exec-path.cpp
- * @author      Zofia Abramowska (z.abramowska@samsung.com)
- * @version     1.0
- * @brief       Implementation of api-exec-path service.
- */
-
-#include <string>
-
-#include <unistd.h>
-#include <sys/smack.h>
-
-#include <dpl/log/log.h>
-#include <dpl/serialization.h>
-
-#include <protocols.h>
-#include <exec-path.h>
-#include <security-server.h>
-#include <security-server-util.h>
-#include <smack-check.h>
-
-namespace SecurityServer {
-
-GenericSocketService::ServiceDescriptionVector ExecPathService::GetServiceDescription() {
-    return ServiceDescriptionVector
-        {{SERVICE_SOCKET_EXEC_PATH, "security-server" }};
-}
-
-void ExecPathService::accept(const AcceptEvent &event) {
-    LogDebug("Accept event. ConnectionID.sock: " << event.connectionID.sock
-        << " ConnectionID.counter: " << event.connectionID.counter
-        << " ServiceID: " << event.interfaceID);
-}
-
-void ExecPathService::write(const WriteEvent &event) {
-    LogDebug("WriteEvent. ConnectionID: " << event.connectionID.sock <<
-        " Size: " << event.size << " Left: " << event.left);
-    if (event.left == 0)
-        m_serviceManager->Close(event.connectionID);
-}
-
-bool ExecPathService::processOne(const ConnectionID &conn, MessageBuffer &buffer) {
-    LogDebug("Processing message");
-
-    int pid = 0;
-    char *exe;
-
-    if (!buffer.Ready()) {
-        return false;
-    }
-
-    Try {
-        Deserialization::Deserialize(buffer, pid);
-     } Catch (MessageBuffer::Exception::Base) {
-        LogDebug("Broken protocol. Closing socket.");
-        m_serviceManager->Close(conn);
-        return false;
-    }
-
-    MessageBuffer sendBuffer;
-    int retVal;
-
-    // get executable path
-    exe = read_exe_path_from_proc(pid);
-    // quickly getting rid of allocated memory
-    // when read_exe_path_from_proc will rewritten this won't be required
-    std::string exec_path(exe ? exe : "");
-    free(exe);
-
-    if (exec_path.empty())
-    {
-         LogError("Server: Failed to read executable path for pid " << pid);
-         retVal = SECURITY_SERVER_API_ERROR_SERVER_ERROR;
-         Serialization::Serialize(sendBuffer, retVal);
-         m_serviceManager->Write(conn, sendBuffer.Pop());
-         return true;
-    }
-
-    retVal = SECURITY_SERVER_API_SUCCESS;
-    Serialization::Serialize(sendBuffer, retVal);
-    Serialization::Serialize(sendBuffer, exec_path);
-    m_serviceManager->Write(conn, sendBuffer.Pop());
-    return true;
-}
-
-void ExecPathService::process(const ReadEvent &event) {
-    LogDebug("Read event for counter: " << event.connectionID.counter);
-    auto &buffer = m_messageBufferMap[event.connectionID.counter];
-    buffer.Push(event.rawBuffer);
-
-    // We can get several requests in one package.
-    // Extract and process them all
-    while(processOne(event.connectionID, buffer));
-}
-
-void ExecPathService::close(const CloseEvent &event) {
-    LogDebug("CloseEvent. ConnectionID: " << event.connectionID.sock);
-    m_messageBufferMap.erase(event.connectionID.counter);
-}
-
-} // namespace SecurityServer
-
diff --git a/src/server2/service/exec-path.h b/src/server2/service/exec-path.h
deleted file mode 100644 (file)
index 12aa7a6..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-/*
- * @file        exec-path.h
- * @author      Zofia Abramowska (z.abramowska@samsung.com)
- * @version     1.0
- * @brief       Implementation of api-exec-path
- */
-
-#ifndef _SECURITY_SERVER_EXEC_PATH_
-#define _SECURITY_SERVER_EXEC_PATH_
-
-#include <service-thread.h>
-#include <generic-socket-manager.h>
-
-#include <message-buffer.h>
-
-namespace SecurityServer {
-
-class ExecPathService
-  : public SecurityServer::GenericSocketService
-  , public SecurityServer::ServiceThread<ExecPathService>
-{
-public:
-    typedef std::map<int, MessageBuffer> MessageBufferMap;
-
-    ServiceDescriptionVector GetServiceDescription();
-
-    DECLARE_THREAD_EVENT(AcceptEvent, accept)
-    DECLARE_THREAD_EVENT(WriteEvent, write)
-    DECLARE_THREAD_EVENT(ReadEvent, process)
-    DECLARE_THREAD_EVENT(CloseEvent, close)
-
-    void accept(const AcceptEvent &event);
-    void write(const WriteEvent &event);
-    void process(const ReadEvent &event);
-    void close(const CloseEvent &event);
-private:
-    bool processOne(const ConnectionID &conn, MessageBuffer &buffer);
-    MessageBufferMap m_messageBufferMap;
-};
-
-} // namespace SecurityServer
-
-#endif // _SECURITY_SERVER_EXEC_PATH_