-SET(AUTH_CLIENT_VERSION_MAJOR 1)
-SET(AUTH_CLIENT_VERSION ${AUTH_CLIENT_VERSION_MAJOR}.0.1)
-
INCLUDE_DIRECTORIES(
${INCLUDE_PATH}
${COMMON_PATH}/include
)
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})
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})
)
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})
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})
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
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})
* @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] = {};
#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_
* 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)
}
size_t m_bytesLeft;
- AuthPasswd::BinaryQueue m_buffer;
+ BinaryQueue m_buffer;
};
} // namespace AuthPasswd
#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();
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;
#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,
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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")))
+++ /dev/null
-/*
- * 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
-
+++ /dev/null
-#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
+++ /dev/null
-#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
/*
- * 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
*
* @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)
};
size_t bufferSize,
void *userParam);
- class BucketVisitor
- {
- public:
+ class BucketVisitor {
+ public:
/**
* Destructor
*/
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;
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
*/
/*
- * 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 <cstdlib>
#include <sstream>
+#include <symbol-visibility.h>
+
namespace AuthPasswd {
void LogUnhandledException(const std::string &str);
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)();
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;
return m_className;
}
};
+
} // namespace AuthPasswd
#define Try try
/*
- * 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.
* 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
/*
- * 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,
unsigned int Exception::m_exceptionCount = 0;
void (*Exception::m_terminateHandler)() = NULL;
+COMMON_API
void LogUnhandledException(const std::string &str)
{
// Logging to console
LogPedantic(str);
}
+COMMON_API
void LogUnhandledException(const std::string &str,
const char *filename,
int line,
+++ /dev/null
-/*
- * 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
* 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
/*
- * 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/singleton.h>
#include <dpl/noncopyable.h>
#include <dpl/log/abstract_log_provider.h>
+#include <symbol-visibility.h>
#include <sstream>
#include <list>
* 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();
/*
* Replacement low overhead null logging class
*/
-class NullStream
-{
- public:
+class COMMON_API NullStream {
+public:
NullStream() {}
template <typename T>
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
)
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}
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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
+
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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