2 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Bumjin Im <bj.im@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @file sever2-main.cpp
20 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
22 * @brief Implementation of security-server2
27 #include <dpl/log/log.h>
28 #include <dpl/log/audit-smack-log.h>
29 #include <dpl/singleton.h>
30 #include <dpl/singleton_safe_impl.h>
32 #include <socket-manager.h>
34 #include <data-share.h>
36 #include <privilege-by-pid.h>
37 #include <app-permissions.h>
40 #include <installer.h>
42 IMPLEMENT_SAFE_SINGLETON(SecurityServer::Log::LogSystem);
44 #define REGISTER_SOCKET_SERVICE(manager, service) \
45 registerSocketService<service>(manager, #service)
48 void registerSocketService(SecurityServer::SocketManager &manager, const std::string& serviceName)
54 manager.RegisterSocketService(service);
56 } catch (const SecurityServer::Exception &exception) {
57 LogError("Error in creating service " << serviceName <<
58 ", details:\n" << exception.DumpToString());
59 } catch (const std::exception& e) {
60 LogError("Error in creating service " << serviceName <<
61 ", details:\n" << e.what());
63 LogError("Error in creating service " << serviceName <<
64 ", unknown exception occured");
72 UNHANDLED_EXCEPTION_HANDLER_BEGIN
74 SecurityServer::Singleton<SecurityServer::Log::LogSystem>::Instance().SetTag("SECURITY_SERVER");
76 // This provider may be used in security-server only.
77 // If we add it inside LogSystem constructor it also
78 // will be used by security-server-client library.
79 SecurityServer::Log::AuditSmackLog *smackLog = new SecurityServer::Log::AuditSmackLog;
83 SecurityServer::Singleton<SecurityServer::Log::LogSystem>::Instance().AddProvider(smackLog);
87 sigaddset(&mask, SIGTERM);
88 sigaddset(&mask, SIGPIPE);
89 if (-1 == pthread_sigmask(SIG_BLOCK, &mask, NULL)) {
90 LogError("Error in pthread_sigmask");
95 SecurityServer::SocketManager manager;
97 REGISTER_SOCKET_SERVICE(manager, SecurityServer::CookieService);
98 REGISTER_SOCKET_SERVICE(manager, SecurityServer::SharedMemoryService);
99 REGISTER_SOCKET_SERVICE(manager, SecurityServer::GetGidService);
100 REGISTER_SOCKET_SERVICE(manager, SecurityServer::PrivilegeByPidService);
101 REGISTER_SOCKET_SERVICE(manager, SecurityServer::AppPermissionsService);
102 REGISTER_SOCKET_SERVICE(manager, SecurityServer::PasswordService);
103 REGISTER_SOCKET_SERVICE(manager, SecurityServer::InstallerService);
107 UNHANDLED_EXCEPTION_HANDLER_END