Change user type identification from name to uid.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 5 Jun 2014 15:11:53 +0000 (17:11 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 12 Sep 2014 12:57:08 +0000 (14:57 +0200)
User name is not unique. We need to use kernel understanable value.

Change-Id: I747cb249e430f40104bee6fc694bfe55fe259e81

src/include/ckm/key-manager.h
src/manager/client/client-control.cpp
src/manager/main/generic-socket-manager.h
src/manager/service/ckm-logic.cpp
src/manager/service/ckm-logic.h
src/manager/service/ckm-service.cpp

index de3ef82..aab1f31 100644 (file)
@@ -37,22 +37,22 @@ class Control
 public:
     Control();
     // decrypt user key with password
-    int unlockUserKey(const std::string &user, const std::string &password) const;
+    int unlockUserKey(uid_t user, const std::string &password) const;
 
     // remove user key from memory
-    int lockUserKey(const std::string &user) const;
+    int lockUserKey(uid_t user) const;
 
     // remove user data from Store and erase key used for encryption
-    int removeUserData(const std::string &user) const;
+    int removeUserData(uid_t user) const;
 
     // change password for user
-    int changeUserPassword(const std::string &user, const std::string &oldPassword, const std::string &newPassword) const;
+    int changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) const;
 
-       // This is work around for security-server api - resetPassword that may be called without passing oldPassword.
-       // This api should not be supported on tizen 3.0
-       // User must be already logged in and his DKEK is already loaded into memory in plain text form.
-       // The service will use DKEK in plain text and encrypt it in encrypted form (using new password).
-       int resetUserPassword(const std::string &user, const std::string &newPassword) const;
+    // This is work around for security-server api - resetPassword that may be called without passing oldPassword.
+    // This api should not be supported on tizen 3.0
+    // User must be already logged in and his DKEK is already loaded into memory in plain text form.
+    // The service will use DKEK in plain text and encrypt it in encrypted form (using new password).
+    int resetUserPassword(uid_t user, const std::string &newPassword) const;
 
     virtual ~Control();
 private:
index 6d30c8a..4819369 100644 (file)
@@ -36,11 +36,8 @@ public:
     ControlImpl& operator=(const ControlImpl &) = delete;
     ControlImpl& operator=(ControlImpl &&) = delete;
 
-    static int unlockUserKey(const std::string &user, const std::string &password) {
+    static int unlockUserKey(uid_t user, const std::string &password) {
         return try_catch([&] {
-            if (user.empty())
-                return KEY_MANAGER_API_ERROR_INPUT_PARAM;
-
             MessageBuffer send, recv;
             Serialization::Serialize(send, static_cast<int>(ControlCommand::UNLOCK_USER_KEY));
             Serialization::Serialize(send, user);
@@ -61,11 +58,8 @@ public:
         });
     }
 
-    static int lockUserKey(const std::string &user) {
+    static int lockUserKey(uid_t user) {
         return try_catch([&] {
-            if (user.empty())
-                return KEY_MANAGER_API_ERROR_INPUT_PARAM;
-
             MessageBuffer send, recv;
             Serialization::Serialize(send, static_cast<int>(ControlCommand::LOCK_USER_KEY));
             Serialization::Serialize(send, user);
@@ -85,11 +79,8 @@ public:
         });
     }
 
-    static int removeUserData(const std::string &user) {
+    static int removeUserData(uid_t user) {
         return try_catch([&] {
-            if (user.empty())
-                return KEY_MANAGER_API_ERROR_INPUT_PARAM;
-
             MessageBuffer send, recv;
             Serialization::Serialize(send, static_cast<int>(ControlCommand::REMOVE_USER_DATA));
             Serialization::Serialize(send, user);
@@ -109,11 +100,8 @@ public:
         });
     }
 
-    static int changeUserPassword(const std::string &user, const std::string &oldPassword, const std::string &newPassword) {
+    static int changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) {
         return try_catch([&] {
-            if (user.empty())
-                return KEY_MANAGER_API_ERROR_INPUT_PARAM;
-
             MessageBuffer send, recv;
             Serialization::Serialize(send, static_cast<int>(ControlCommand::CHANGE_USER_PASSWORD));
             Serialization::Serialize(send, user);
@@ -135,11 +123,8 @@ public:
         });
     }
 
-    static int resetUserPassword(const std::string &user, const std::string &newPassword) {
+    static int resetUserPassword(uid_t user, const std::string &newPassword) {
         return try_catch([&] {
-            if (user.empty())
-                return KEY_MANAGER_API_ERROR_INPUT_PARAM;
-
             MessageBuffer send, recv;
             Serialization::Serialize(send, static_cast<int>(ControlCommand::RESET_USER_PASSWORD));
             Serialization::Serialize(send, user);
@@ -169,23 +154,23 @@ Control::Control()
 
 Control::~Control(){}
 
-int Control::unlockUserKey(const std::string &user, const std::string &password) const {
+int Control::unlockUserKey(uid_t user, const std::string &password) const {
     return m_impl->unlockUserKey(user, password);
 }
 
-int Control::lockUserKey(const std::string &user) const {
+int Control::lockUserKey(uid_t user) const {
     return m_impl->lockUserKey(user);
 }
 
-int Control::removeUserData(const std::string &user) const {
+int Control::removeUserData(uid_t user) const {
     return m_impl->removeUserData(user);
 }
 
-int Control::changeUserPassword(const std::string &user, const std::string &oldPassword, const std::string &newPassword) const {
+int Control::changeUserPassword(uid_t user, const std::string &oldPassword, const std::string &newPassword) const {
     return m_impl->changeUserPassword(user, oldPassword, newPassword);
 }
 
-int Control::resetUserPassword(const std::string &user, const std::string &newPassword) const {
+int Control::resetUserPassword(uid_t user, const std::string &newPassword) const {
     return m_impl->resetUserPassword(user, newPassword);
 }
 
index 987e870..c9be9ac 100644 (file)
@@ -29,6 +29,8 @@
 #include <vector>
 #include <string>
 
+#include <sys/types.h>
+
 #include <dpl/exception.h>
 
 #include <generic-event.h>
@@ -42,7 +44,7 @@ namespace CKM {
 typedef int InterfaceID;
 
 struct Credentials {
-    int uid;
+    uid_t uid;
     std::string smackLabel;
 };
 
index 73e2aee..51a7cb1 100644 (file)
@@ -30,7 +30,7 @@ namespace CKM {
 CKMLogic::CKMLogic(){}
 CKMLogic::~CKMLogic(){}
 
-RawBuffer CKMLogic::unlockUserKey(const std::string &user, const std::string &password) {
+RawBuffer CKMLogic::unlockUserKey(uid_t user, const std::string &password) {
     (void)user;
     (void)password;
 
@@ -39,7 +39,7 @@ RawBuffer CKMLogic::unlockUserKey(const std::string &user, const std::string &pa
     return response.Pop();
 }
 
-RawBuffer CKMLogic::lockUserKey(const std::string &user) {
+RawBuffer CKMLogic::lockUserKey(uid_t user) {
     (void)user;
 
     MessageBuffer response;
@@ -47,7 +47,7 @@ RawBuffer CKMLogic::lockUserKey(const std::string &user) {
     return response.Pop();
 }
 
-RawBuffer CKMLogic::removeUserData(const std::string &user) {
+RawBuffer CKMLogic::removeUserData(uid_t user) {
     (void)user;
 
     MessageBuffer response;
@@ -56,7 +56,7 @@ RawBuffer CKMLogic::removeUserData(const std::string &user) {
 }
 
 RawBuffer CKMLogic::changeUserPassword(
-    const std::string &user,
+    uid_t user,
     const std::string &oldPassword,
     const std::string &newPassword)
 {
@@ -70,7 +70,7 @@ RawBuffer CKMLogic::changeUserPassword(
 }
 
 RawBuffer CKMLogic::resetUserPassword(
-    const std::string &user,
+    uid_t user,
     const std::string &newPassword)
 {
     (void)user;
index 53169ec..fcd0a76 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <string>
 #include <vector>
+
 #include <message-buffer.h>
 #include <protocols.h>
 #include <ckm/ckm-type.h>
@@ -39,19 +40,19 @@ public:
     CKMLogic& operator=(CKMLogic &&) = delete;
     virtual ~CKMLogic();
 
-    RawBuffer unlockUserKey(const std::string &user, const std::string &password);
+    RawBuffer unlockUserKey(uid_t user, const std::string &password);
 
-    RawBuffer lockUserKey(const std::string &user);
+    RawBuffer lockUserKey(uid_t user);
 
-    RawBuffer removeUserData(const std::string &user);
+    RawBuffer removeUserData(uid_t user);
 
     RawBuffer changeUserPassword(
-        const std::string &user,
+        uid_t user,
         const std::string &oldPassword,
         const std::string &newPassword);
 
     RawBuffer resetUserPassword(
-        const std::string &user,
+        uid_t user,
         const std::string &newPassword);
 
     RawBuffer saveData(
index b6c1784..2b99f36 100644 (file)
@@ -104,7 +104,7 @@ bool CKMService::processOne(
 
 RawBuffer CKMService::processControl(MessageBuffer &buffer) {
     int command;
-    std::string user;
+    uid_t user;
     ControlCommand cc;
     std::string newPass, oldPass;