2 * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef TEMP_TEST_USER_H
18 #define TEMP_TEST_USER_H
21 #include <sys/types.h>
23 #include <common/gum-user-types.h>
24 #include <sys/types.h>
27 class TemporaryTestUser {
29 TemporaryTestUser(std::string userName, GumUserType userType, bool offline = false) :
35 m_creatorPid(getpid())
37 TemporaryTestUser(const TemporaryTestUser &) = delete;
38 TemporaryTestUser(TemporaryTestUser &&other);
39 TemporaryTestUser& operator=(const TemporaryTestUser &) = delete;
42 uid_t getUid() const {return m_uid;}
43 uid_t getGid() const {return m_gid;}
45 std::string getUidString() const {return std::to_string(static_cast<unsigned int>(m_uid));}
46 const std::string& getUserName() const {return m_userName;}
47 GumUserType getUserType() const {return m_userType;}
54 bool userCreate(std::string userName, GumUserType userType, bool offline,
55 uid_t &uid, gid_t &gid);
56 bool userRemove(uid_t uid, bool offline);
59 enum class opType {USER_CREATE, USER_REMOVE};
63 void get(void *buf, size_t count);
64 void put(const void *buf, size_t count);
65 template<typename T> T get();
66 template<typename T> void put(const T x);
69 static GumdRunner m_runner;
72 std::string m_userName;
73 GumUserType m_userType;