Common library visibility to hidden 34/62134/3 accepted/tizen/common/20160315.221655 accepted/tizen/ivi/20160315.123126 accepted/tizen/mobile/20160315.123016 accepted/tizen/tv/20160315.123040 accepted/tizen/wearable/20160315.123106 submit/tizen/20160315.072709
authorKyungwook Tak <k.tak@samsung.com>
Mon, 14 Mar 2016 12:45:34 +0000 (21:45 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Tue, 15 Mar 2016 00:10:57 +0000 (09:10 +0900)
Change-Id: I731f3d59c15cc85f1b42f01a0567c279836733fd
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
25 files changed:
src/client/CMakeLists.txt
src/common/CMakeLists.txt
src/common/error-description.cpp
src/common/include/connection-info.h
src/common/include/message-buffer.h
src/common/include/policy.h
src/common/include/protocols.h
src/common/include/smack-check.h [deleted file]
src/common/include/symbol-visibility.h [new file with mode: 0644]
src/common/include/user-check.h [deleted file]
src/common/smack-check.cpp [deleted file]
src/common/user-check.cpp [deleted file]
src/dpl/core/include/dpl/binary_queue.h
src/dpl/core/include/dpl/exception.h
src/dpl/core/include/dpl/noncopyable.h
src/dpl/core/src/assert.cpp
src/dpl/core/src/exception.cpp
src/dpl/core/src/noncopyable.cpp [deleted file]
src/dpl/core/src/singleton.cpp
src/dpl/log/include/dpl/log/log.h
src/server/CMakeLists.txt
src/server/main/include/smack-check.h [new file with mode: 0644]
src/server/main/include/user-check.h [new file with mode: 0644]
src/server/main/smack-check.cpp [new file with mode: 0644]
src/server/main/user-check.cpp [new file with mode: 0644]

index 31a4bf9045b5c618549816b1572d432c4c686d78..1bf39ac2f3ac8a20634729df3819e0d47849701a 100644 (file)
@@ -1,6 +1,3 @@
-SET(AUTH_CLIENT_VERSION_MAJOR 1)
-SET(AUTH_CLIENT_VERSION ${AUTH_CLIENT_VERSION_MAJOR}.0.1)
-
 INCLUDE_DIRECTORIES(
     ${INCLUDE_PATH}
     ${COMMON_PATH}/include
@@ -10,8 +7,8 @@ INCLUDE_DIRECTORIES(
     )
 
 SET(CLIENT_SOURCES
-    ${CLIENT_PATH}/client-common.cpp
-    ${CLIENT_PATH}/client-password.cpp
+    client-common.cpp
+    client-password.cpp
     )
 
 ADD_LIBRARY(${TARGET_CLIENT} SHARED ${CLIENT_SOURCES})
@@ -19,14 +16,12 @@ ADD_LIBRARY(${TARGET_CLIENT} SHARED ${CLIENT_SOURCES})
 SET_TARGET_PROPERTIES(
     ${TARGET_CLIENT}
     PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden" 
-        SOVERSION ${AUTH_CLIENT_VERSION_MAJOR}
-        VERSION ${AUTH_CLIENT_VERSION}
+        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden"
+        SOVERSION ${API_VERSION}
+        VERSION ${VERSION}
     )
 
-TARGET_LINK_LIBRARIES(${TARGET_CLIENT}
-    ${TARGET_COMMON}
-    )
+TARGET_LINK_LIBRARIES(${TARGET_CLIENT} ${TARGET_COMMON})
 
 INSTALL(TARGETS ${TARGET_CLIENT} DESTINATION ${LIB_INSTALL_DIR})
 
@@ -41,8 +36,8 @@ INCLUDE_DIRECTORIES(
     )
 
 SET(CLIENT_ADMIN_SOURCES
-    ${CLIENT_PATH}/client-common.cpp
-    ${CLIENT_PATH}/client-password-admin.cpp
+    client-common.cpp
+    client-password-admin.cpp
     )
 
 ADD_LIBRARY(${TARGET_CLIENT_ADMIN} SHARED ${CLIENT_ADMIN_SOURCES})
@@ -50,13 +45,11 @@ ADD_LIBRARY(${TARGET_CLIENT_ADMIN} SHARED ${CLIENT_ADMIN_SOURCES})
 SET_TARGET_PROPERTIES(
     ${TARGET_CLIENT_ADMIN}
     PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden" 
-        SOVERSION ${AUTH_CLIENT_VERSION_MAJOR}
-        VERSION ${AUTH_CLIENT_VERSION}
+        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden"
+        SOVERSION ${API_VERSION}
+        VERSION ${VERSION}
     )
 
-TARGET_LINK_LIBRARIES(${TARGET_CLIENT_ADMIN}
-    ${TARGET_COMMON}
-    )
+TARGET_LINK_LIBRARIES(${TARGET_CLIENT_ADMIN} ${TARGET_COMMON})
 
 INSTALL(TARGETS ${TARGET_CLIENT_ADMIN} DESTINATION ${LIB_INSTALL_DIR})
index ae76ae718c951626c1539dc4b23ce4ff3cff7bf4..9fb03510c214746d60d2fe5d5c4a1910b39366d3 100644 (file)
@@ -1,40 +1,28 @@
 PKG_CHECK_MODULES(COMMON_DEP
     REQUIRED
     dlog
-    libsmack
     )
 
 SET(COMMON_SOURCES
-    ${COMMON_PATH}/error-description.cpp
-    ${COMMON_PATH}/protocols.cpp
-    ${COMMON_PATH}/policy.cpp
-    ${COMMON_PATH}/message-buffer.cpp
-    ${COMMON_PATH}/smack-check.cpp
-    ${COMMON_PATH}/user-check.cpp
-    ${DPL_PATH}/log/src/abstract_log_provider.cpp
-    ${DPL_PATH}/log/src/dlog_log_provider.cpp
-    ${DPL_PATH}/log/src/log.cpp
-    ${DPL_PATH}/log/src/old_style_log_provider.cpp
+    error-description.cpp
+    message-buffer.cpp
+    policy.cpp
+    protocols.cpp
     ${DPL_PATH}/core/src/assert.cpp
     ${DPL_PATH}/core/src/binary_queue.cpp
     ${DPL_PATH}/core/src/colors.cpp
     ${DPL_PATH}/core/src/exception.cpp
-    ${DPL_PATH}/core/src/noncopyable.cpp
     ${DPL_PATH}/core/src/serialization.cpp
     ${DPL_PATH}/core/src/singleton.cpp
-    )
-
-SET_SOURCE_FILES_PROPERTIES(
-    ${COMMON_SOURCES}
-    PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=default" #TODO: visibility hidden
-    )
-
-INCLUDE_DIRECTORIES(SYSTEM
-    ${COMMON_DEP_INCLUDE_DIRS}
+    ${DPL_PATH}/log/src/abstract_log_provider.cpp
+    ${DPL_PATH}/log/src/dlog_log_provider.cpp
+    ${DPL_PATH}/log/src/log.cpp
+    ${DPL_PATH}/log/src/old_style_log_provider.cpp
     )
 
 INCLUDE_DIRECTORIES(
+    SYSTEM
+    ${COMMON_DEP_INCLUDE_DIRS}
     ${INCLUDE_PATH}
     ${COMMON_PATH}/include
     ${PLUGIN_PATH}/include
@@ -44,15 +32,13 @@ INCLUDE_DIRECTORIES(
 
 ADD_LIBRARY(${TARGET_COMMON} SHARED ${COMMON_SOURCES})
 
-SET_TARGET_PROPERTIES(
-    ${TARGET_COMMON}
+SET_TARGET_PROPERTIES(${TARGET_COMMON}
     PROPERTIES
-        SOVERSION 1.0.0 #TODO: version tracking by rpm spec version specification
-        VERSION 1.0.0
+        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=hidden"
+        SOVERSION ${API_VERSION}
+        VERSION ${VERSION}
     )
 
-TARGET_LINK_LIBRARIES(${TARGET_COMMON}
-    ${COMMON_DEP_LIBRARIES}
-    )
+TARGET_LINK_LIBRARIES(${TARGET_COMMON} ${COMMON_DEP_LIBRARIES})
 
 INSTALL(TARGETS ${TARGET_COMMON} DESTINATION ${LIB_INSTALL_DIR})
index 62f7e5532ffc82c8fbbfb61c10f6f443c27ca736..38d27a642960fd6d21688f98cc663696e7346048 100644 (file)
  * @version     1.0
  * @brief       Implementatin of errorToString function.
  */
-#include <string.h>
+#include "error-description.h"
 
-#include <error-description.h>
+#include <string.h>
+#include <symbol-visibility.h>
 
 #define MAX_BUF 256
 
 namespace AuthPasswd {
 
+COMMON_API
 std::string errnoToString(int err) {
     char buffer[MAX_BUF] = {};
 
index 2d88ae11e651210867c8aaa66df36653e22f1566..ab58a2471680f4af6871da4449c12add06ee697e 100644 (file)
 #include <generic-socket-manager.h>
 #include <message-buffer.h>
 
-namespace AuthPasswd
-{
-    struct ConnectionInfo {
-        InterfaceID interfaceID;
-        MessageBuffer buffer;
-    };
+namespace AuthPasswd {
+
+struct ConnectionInfo {
+    InterfaceID interfaceID;
+    MessageBuffer buffer;
+};
+
+typedef std::map<int, ConnectionInfo> ConnectionInfoMap;
 
-    typedef std::map<int, ConnectionInfo> ConnectionInfoMap;
 } //namespace AuthPasswd
 
 #endif //_CONNECTION_INFO_H_
index 0707017ba3a074052baf6c5bba90587cb1b2b93b..56b707f9849b915a7c62ce379493b85f540171d7 100644 (file)
@@ -16,7 +16,7 @@
  *  limitations under the License
  */
 /*
- * @file        secket-buffer.h
+ * @file        message-buffer.h
  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
  * @version     1.0
  * @brief       Implementatin of MessageBuffer.
 #include <dpl/binary_queue.h>
 #include <dpl/exception.h>
 #include <dpl/serialization.h>
+#include <symbol-visibility.h>
 
 namespace AuthPasswd {
 
 typedef std::vector<unsigned char> RawBuffer;
 
-class MessageBuffer : public AuthPasswd::IStream {
+class COMMON_API MessageBuffer : public AuthPasswd::IStream {
 public:
-    class Exception
-    {
+    class Exception {
     public:
         DECLARE_EXCEPTION_TYPE(AuthPasswd::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OutOfData)
@@ -71,7 +71,7 @@ protected:
     }
 
     size_t m_bytesLeft;
-    AuthPasswd::BinaryQueue m_buffer;
+    BinaryQueue m_buffer;
 };
 
 } // namespace AuthPasswd
index 10e24fc6b7fcfb70b3516f84ea97a40eb757ea61..cf06537922c9d5af9569d4ccfc1bf44efed17aad 100644 (file)
 #include <string>
 #include <auth-passwd-policy-types.h>
 #include <dpl/serialization.h>
+#include <symbol-visibility.h>
 
 namespace AuthPasswd {
 
+COMMON_API
 extern const size_t MAX_PASSWORD_LEN;
+
+COMMON_API
 extern const unsigned int MAX_PASSWORD_HISTORY;
+
+COMMON_API
 extern const unsigned int MAX_PASSWORD_ATTEMPTS;
+
+COMMON_API
 extern const unsigned int PASSWORD_INFINITE_EXPIRATION_DAYS;
+
+COMMON_API
 extern const unsigned int PASSWORD_INFINITE_ATTEMPT_COUNT;
+
+COMMON_API
 extern const unsigned int PASSWORD_API_NO_EXPIRATION;
 
+COMMON_API
 extern const char* NO_PASSWORD;
+
+COMMON_API
 extern const char* NO_PATTERN;
+
+COMMON_API
 extern const char* NO_FORBIDDEND_PASSWORD;
 
+
+COMMON_API
 extern const std::string REGEX_QUALITY_UNSPECIFIED;
+
+COMMON_API
 extern const std::string REGEX_QUALITY_SOMETHING;
+
+COMMON_API
 extern const std::string REGEX_QUALITY_NUMERIC;
+
+COMMON_API
 extern const std::string REGEX_QUALITY_ALPHABETIC;
+
+COMMON_API
 extern const std::string REGEX_QUALITY_ALPHANUMERIC;
 
-struct Policy {
+struct COMMON_API Policy {
     Policy();
     ~Policy();
 
@@ -96,7 +123,7 @@ struct Policy {
     std::set<std::string> forbiddenPasswds;
 };
 
-struct PolicySerializable : public Policy, ISerializable {
+struct COMMON_API PolicySerializable : public Policy, ISerializable {
     explicit PolicySerializable(const Policy &);
     explicit PolicySerializable(IStream &);
     void Serialize(IStream &) const;
index 4ec5776fc3d975bf01ca362a02e30be3b498871d..e851371aab7665bc6128cdbf75a4d423c867bf93 100644 (file)
 #include <time.h>
 #include <sys/types.h>
 
+#include <symbol-visibility.h>
+
 namespace AuthPasswd {
 
+COMMON_API
 extern char const * const SERVICE_SOCKET_PASSWD_CHECK;
+
+COMMON_API
 extern char const * const SERVICE_SOCKET_PASSWD_SET;
+
+COMMON_API
 extern char const * const SERVICE_SOCKET_PASSWD_RESET;
+
+COMMON_API
 extern char const * const SERVICE_SOCKET_PASSWD_POLICY;
 
-enum class PasswordHdrs
-{
+enum class PasswordHdrs {
     HDR_CHK_PASSWD,
     HDR_CHK_PASSWD_STATE,
     HDR_CHK_PASSWD_REUSED,
diff --git a/src/common/include/smack-check.h b/src/common/include/smack-check.h
deleted file mode 100644 (file)
index 43fc4a6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  Authentication password
- *
- *  Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Jooseong Lee <jooseong.lee@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
- */
-
-#ifndef _SMACK_CHECK_H_
-#define _SMACK_CHECK_H_
-
-namespace AuthPasswd {
-
-/*
- * A very simple runtime check for SMACK on the platform
- * Returns 1 if SMACK is present, 0 otherwise
- */
-
-int smack_runtime_check(void);
-
-/*
- * A very simple runtime check for SMACK on the platform
- * Returns 1 if SMACK is present, 0 otherwise. If SMACK_ENABLED is not defined
- * It returns 0.
- */
-int smack_check(void);
-
-} // namespace AuthPasswd
-
-#endif // _SMACK_CHECK_H_
diff --git a/src/common/include/symbol-visibility.h b/src/common/include/symbol-visibility.h
new file mode 100644 (file)
index 0000000..0a20d1c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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        symbol-visibility.h
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       define symbol visiblity for common library.
+ */
+
+#define COMMON_API __attribute__((visibility("default")))
diff --git a/src/common/include/user-check.h b/src/common/include/user-check.h
deleted file mode 100644 (file)
index a16a7b8..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  Authentication password
- *
- *  Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Jooseong Lee  <jooseong.lee@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
- */
-
-#include <sys/socket.h>
-#include <sys/un.h>
-
-namespace AuthPasswd {
-
-int socket_get_user(int sockfd, unsigned int &user);
-
-} // namespace AuthPasswd
-
diff --git a/src/common/smack-check.cpp b/src/common/smack-check.cpp
deleted file mode 100644 (file)
index 8b1e414..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <smack-check.h>
-
-#include <stdlib.h>
-#include <sys/smack.h>
-
-#include <dpl/log/log.h>
-
-namespace AuthPasswd {
-
-int smack_runtime_check(void)
-{
-    static int smack_present = -1;
-    if (-1 == smack_present) {
-        if (NULL == smack_smackfs_path()) {
-            LogDebug("no smack found on device");
-            smack_present = 0;
-        } else {
-            LogDebug("found smack on device");
-            smack_present = 1;
-        }
-    }
-    return smack_present;
-}
-
-int smack_check(void)
-{
-#ifndef SMACK_ENABLED
-    return 0;
-#else
-    return smack_runtime_check();
-#endif
-}
-
-} // namespace AuthPasswd
diff --git a/src/common/user-check.cpp b/src/common/user-check.cpp
deleted file mode 100644 (file)
index 0776b7c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <user-check.h>
-#include <dpl/log/log.h>
-
-namespace AuthPasswd {
-
-int socket_get_user(int sockfd, unsigned int &user)
-{
-    struct ucred cr;
-    socklen_t len = sizeof(struct ucred);
-    if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cr, &len))
-    {
-        LogError("getsockopt() failed");
-        return 1;
-    }
-    user = cr.uid;
-    return 0;
-}
-
-} // namespace AuthPasswd
index 9f29570768588a6c26d0b23bc3af2e13c73aee10..f2c1382ffde40c43f1165c7f54c3ae5971c6709b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
 #ifndef AUTH_PASSWD_BINARY_QUEUE_H
 #define AUTH_PASSWD_BINARY_QUEUE_H
 
-//#include <dpl/abstract_input_output.h>
 #include <dpl/exception.h>
 #include <dpl/noncopyable.h>
 #include <memory>
 #include <list>
 
+#include <symbol-visibility.h>
+
 namespace AuthPasswd {
 /**
  * Binary queue auto pointer
@@ -40,13 +41,10 @@ typedef std::auto_ptr<BinaryQueue> BinaryQueueAutoPtr;
  *
  * @todo Add optimized implementation for FlattenConsume
  */
-class BinaryQueue
-//  : public AbstractInputOutput
-{
-  public:
-    class Exception
-    {
-      public:
+class COMMON_API BinaryQueue {
+public:
+    class Exception {
+    public:
         DECLARE_EXCEPTION_TYPE(AuthPasswd::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OutOfData)
     };
@@ -57,9 +55,8 @@ class BinaryQueue
                                   size_t bufferSize,
                                   void *userParam);
 
-    class BucketVisitor
-    {
-      public:
+    class BucketVisitor {
+    public:
         /**
          * Destructor
          */
@@ -75,10 +72,8 @@ class BinaryQueue
         virtual void OnVisitBucket(const void *buffer, size_t bufferSize) = 0;
     };
 
-  private:
-    struct Bucket :
-        private Noncopyable
-    {
+private:
+    struct Bucket : private Noncopyable {
         const void *buffer;
         const void *ptr;
         size_t size;
@@ -100,19 +95,18 @@ class BinaryQueue
 
     static void DeleteBucket(Bucket *bucket);
 
-    class BucketVisitorCall
-    {
-      private:
+    class BucketVisitorCall {
+    private:
         BucketVisitor *m_visitor;
 
-      public:
+    public:
         BucketVisitorCall(BucketVisitor *visitor);
         virtual ~BucketVisitorCall();
 
         void operator()(Bucket *bucket) const;
     };
 
-  public:
+public:
     /**
      * Construct empty binary queue
      */
index 2d66d6287fd6e319e9cfcd465a39056ab22d1f1f..6d886595276e9302ac0f25afc1dfbb294ff89334 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@
 #include <cstdlib>
 #include <sstream>
 
+#include <symbol-visibility.h>
+
 namespace AuthPasswd {
 void LogUnhandledException(const std::string &str);
 void LogUnhandledException(const std::string &str,
@@ -38,9 +40,8 @@ void LogUnhandledException(const std::string &str,
 }
 
 namespace AuthPasswd {
-class Exception
-{
-  private:
+class COMMON_API Exception {
+private:
     static unsigned int m_exceptionCount;
     static Exception* m_lastException;
     static void (*m_terminateHandler)();
@@ -85,11 +86,11 @@ class Exception
     std::string m_function;
     int m_line;
 
-  protected:
+protected:
     std::string m_message;
     std::string m_className;
 
-  public:
+public:
     static std::string KnownExceptionToString(const Exception &e)
     {
         std::ostringstream message;
@@ -287,6 +288,7 @@ class Exception
         return m_className;
     }
 };
+
 } // namespace AuthPasswd
 
 #define Try try
index 873f386af2a81d4aa5fb73faa48020fd04232fb8..e2abee71c6d7812ff1d922f1332549a21413d884 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  *    limitations under the License.
  */
 /*
- * @file        noncopyable
+ * @file        noncopyable.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @brief       This file is the implementation file of noncopyable
 #define AUTHPASSWD_NONCOPYABLE_H
 
 namespace AuthPasswd {
-class Noncopyable
-{
-  private:
+class Noncopyable {
+public:
+    Noncopyable() {}
+    virtual ~Noncopyable() {}
+
+private:
     Noncopyable(const Noncopyable &);
     const Noncopyable &operator=(const Noncopyable &);
-
-  public:
-    Noncopyable();
-    virtual ~Noncopyable();
 };
 } // namespace AuthPasswd
 
index 10b9ccb4a5a8778065bc06c9d00aff72a9de5bb2..2be23090ff53c9c4972638bf047f6201f1c24a55 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
 #include <dpl/colors.h>
 #include <dpl/log/log.h>
 #include <dpl/exception.h>
+#include <symbol-visibility.h>
 #include <cstdlib>
 
 namespace AuthPasswd {
+COMMON_API
 void AssertProc(const char *condition,
                 const char *file,
                 int line,
index 26f7385567960ee9f7fbdc73243408736fd20c52..78f7ecd56d7dd6ec6068a500cbaca3271c101272 100644 (file)
@@ -29,6 +29,7 @@ Exception* Exception::m_lastException = NULL;
 unsigned int Exception::m_exceptionCount = 0;
 void (*Exception::m_terminateHandler)() = NULL;
 
+COMMON_API
 void LogUnhandledException(const std::string &str)
 {
     // Logging to console
@@ -38,6 +39,7 @@ void LogUnhandledException(const std::string &str)
     LogPedantic(str);
 }
 
+COMMON_API
 void LogUnhandledException(const std::string &str,
                            const char *filename,
                            int line,
diff --git a/src/dpl/core/src/noncopyable.cpp b/src/dpl/core/src/noncopyable.cpp
deleted file mode 100644 (file)
index 06c8772..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    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        noncopyable.cpp
- * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version     1.0
- * @brief       This file is the implementation file of noncopyable
- */
-#include <stddef.h>
-#include <dpl/noncopyable.h>
-
-namespace AuthPasswd {
-Noncopyable::Noncopyable()
-{}
-
-Noncopyable::~Noncopyable()
-{}
-} // namespace AuthPasswd
index a76e8ac3ff3e2027519db1c6163f970a3be95561..54abd526cf43a272988e651bc245b3eb4e947c44 100644 (file)
@@ -14,7 +14,7 @@
  *    limitations under the License.
  */
 /*
- * @file        generic_event.cpp
+ * @file        singleton.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @brief       This file is the implementation file of singleton
index 3af6a81556e388e2d825fece6d9b3d0ef7119fe1..5b1a897b555bfa1030f46ff73a13a00a16a34d84 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <dpl/singleton.h>
 #include <dpl/noncopyable.h>
 #include <dpl/log/abstract_log_provider.h>
+#include <symbol-visibility.h>
 #include <sstream>
 #include <list>
 
@@ -36,16 +37,14 @@ namespace Log {
  * To switch logs into old style, export
  * DPL_USE_OLD_STYLE_LOGS before application start
  */
-class LogSystem :
-    private Noncopyable
-{
-  private:
+class COMMON_API LogSystem : private Noncopyable {
+private:
     typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
     AbstractLogProviderPtrList m_providers;
 
     bool m_isLoggingEnabled;
 
-  public:
+public:
     bool IsLoggingEnabled() const;
     LogSystem();
     virtual ~LogSystem();
@@ -143,9 +142,8 @@ class LogSystem :
 /*
  * Replacement low overhead null logging class
  */
-class NullStream
-{
-  public:
+class COMMON_API NullStream {
+public:
     NullStream() {}
 
     template <typename T>
index ef870b2724b8d08078d62c8f2b641c618a3bca1b..e8b800559e40fda9ca57a6ba8f89b949159a02c0 100644 (file)
@@ -1,18 +1,15 @@
 PKG_CHECK_MODULES(SERVER_DEP
     REQUIRED
-    dlog
-    openssl
     libsmack
     libsystemd-daemon
-    libtzplatform-config
+    openssl
     )
-FIND_PACKAGE(Threads REQUIRED)
 
-INCLUDE_DIRECTORIES(SYSTEM
-    ${SERVER_DEP_INCLUDE_DIRS}
-    )
+FIND_PACKAGE(Threads REQUIRED)
 
 INCLUDE_DIRECTORIES(
+    SYSTEM
+    ${SERVER_DEP_INCLUDE_DIRS}
     ${INCLUDE_PATH}
     ${COMMON_PATH}/include
     ${SERVER_PATH}/main/include
@@ -22,28 +19,32 @@ INCLUDE_DIRECTORIES(
     )
 
 SET(SERVER_SOURCES
-    ${SERVER_PATH}/main/generic-socket-manager.cpp
-    ${SERVER_PATH}/main/socket-manager.cpp
-    ${SERVER_PATH}/main/server-main.cpp
-    ${SERVER_PATH}/service/password.cpp
-    ${SERVER_PATH}/service/password-file.cpp
-    ${SERVER_PATH}/service/password-manager.cpp
-    ${SERVER_PATH}/service/password-file-buffer.cpp
-    ${SERVER_PATH}/service/policy-manager.cpp
-    ${SERVER_PATH}/service/policy-file.cpp
+    main/generic-socket-manager.cpp
+    main/server-main.cpp
+    main/smack-check.cpp
+    main/socket-manager.cpp
+    main/user-check.cpp
+    service/password.cpp
+    service/password-file-buffer.cpp
+    service/password-file.cpp
+    service/password-manager.cpp
+    service/policy-file.cpp
+    service/policy-manager.cpp
     )
 
-SET_SOURCE_FILES_PROPERTIES(
-    ${SERVER_SOURCES}
+SET_SOURCE_FILES_PROPERTIES(${SERVER_SOURCES}
     PROPERTIES
-        COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -fPIE")
+        COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden -fPIE"
+    )
 
 ADD_EXECUTABLE(${TARGET_SERVER} ${SERVER_SOURCES})
 
 TARGET_LINK_LIBRARIES(${TARGET_SERVER}
     ${TARGET_COMMON}
     ${CMAKE_THREAD_LIBS_INIT}
-    ${SERVER_DEP_LIBRARIES} -pie -ldl
+    ${SERVER_DEP_LIBRARIES}
+    -pie
+    -ldl
     )
 
 INSTALL(TARGETS ${TARGET_SERVER}
diff --git a/src/server/main/include/smack-check.h b/src/server/main/include/smack-check.h
new file mode 100644 (file)
index 0000000..b2c9812
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  Authentication password
+ *
+ *  Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Contact: Jooseong Lee <jooseong.lee@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
+ */
+
+#ifndef _SMACK_CHECK_H_
+#define _SMACK_CHECK_H_
+
+namespace AuthPasswd {
+
+/*
+ * A very simple runtime check for SMACK on the platform
+ * Returns 1 if SMACK is present, 0 otherwise. If SMACK_ENABLED is not defined
+ * It returns 0.
+ */
+int smack_check(void);
+
+} // namespace AuthPasswd
+
+#endif // _SMACK_CHECK_H_
diff --git a/src/server/main/include/user-check.h b/src/server/main/include/user-check.h
new file mode 100644 (file)
index 0000000..54cb646
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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        user-check.h
+ * @author      Jooseong Lee (jooseong.lee@samsung.com)
+ * @version     1.0
+ * @brief       Get user id from socket file descriptor of client.
+ */
+#pragma once
+
+namespace AuthPasswd {
+
+int socket_get_user(int sockfd, unsigned int &user);
+
+} // namespace AuthPasswd
+
diff --git a/src/server/main/smack-check.cpp b/src/server/main/smack-check.cpp
new file mode 100644 (file)
index 0000000..5edf69a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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        smack-check.cpp
+ * @author      Jooseong Lee (jooseong.lee@samsung.com)
+ * @version     1.0
+ * @brief       Check smck is enabled on device.
+ */
+#include "smack-check.h"
+
+#include <stdlib.h>
+#include <sys/smack.h>
+
+#include <dpl/log/log.h>
+
+namespace AuthPasswd {
+
+int smack_runtime_check(void)
+{
+    static int smack_present = -1;
+    if (-1 == smack_present) {
+        if (NULL == smack_smackfs_path()) {
+            LogDebug("no smack found on device");
+            smack_present = 0;
+        } else {
+            LogDebug("found smack on device");
+            smack_present = 1;
+        }
+    }
+    return smack_present;
+}
+
+int smack_check(void)
+{
+#ifndef SMACK_ENABLED
+    return 0;
+#else
+    return smack_runtime_check();
+#endif
+}
+
+} // namespace AuthPasswd
diff --git a/src/server/main/user-check.cpp b/src/server/main/user-check.cpp
new file mode 100644 (file)
index 0000000..583e11a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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        user-check.cpp
+ * @author      Jooseong Lee (jooseong.lee@samsung.com)
+ * @version     1.0
+ * @brief       Get user id from socket file descriptor of client.
+ */
+#include "user-check.h"
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <dpl/log/log.h>
+
+namespace AuthPasswd {
+
+int socket_get_user(int sockfd, unsigned int &user)
+{
+    struct ucred cr;
+    socklen_t len = sizeof(struct ucred);
+    if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cr, &len)) {
+        LogError("getsockopt() failed");
+        return 1;
+    }
+    user = cr.uid;
+    return 0;
+}
+
+} // namespace AuthPasswd