--- /dev/null
+/*
+ * Copyright (c) 2015 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 passwd_access.cpp
+ * @author Aleksander Zdyb <a.zdyb@samsung.com>
+ * @version 1.0
+ * @brief Provides access to UID and GID
+ */
+
+#include <cerrno>
+#include <grp.h>
+#include <pwd.h>
+
+#include <dpl/test/test_runner.h>
+
+#include "passwd_access.h"
+
+namespace PasswdAccess {
+ uid_t uid(const std::string &username) {
+ struct passwd *passwd = nullptr;
+ do {
+ errno = 0;
+ passwd = getpwnam(username.c_str());
+ } while (passwd == nullptr && errno == EINTR);
+ RUNNER_ASSERT_ERRNO_MSG(passwd != nullptr, "Error in getpwnam(). Username: " << username);
+ return passwd->pw_uid;
+ }
+
+ gid_t gid(const std::string &groupname) {
+ struct group *group = nullptr;
+ do {
+ errno = 0;
+ group = getgrnam(groupname.c_str());
+ } while (group == nullptr && errno == EINTR);
+ RUNNER_ASSERT_ERRNO_MSG(group != nullptr, "Error in getgrnam(). Groupname: " << groupname);
+ return group->gr_gid;
+ }
+} // namespace PasswdAccess
--- /dev/null
+/*
+ * Copyright (c) 2015 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 passwd_access.h
+ * @author Aleksander Zdyb <a.zdyb@samsung.com>
+ * @version 1.0
+ * @brief Provides access to UID and GID
+ */
+
+#ifndef TESTS_COMMON_PASSWD_ACCESS_H_
+#define TESTS_COMMON_PASSWD_ACCESS_H_
+
+#include <string>
+#include <sys/types.h>
+
+namespace PasswdAccess {
+ uid_t uid(const std::string &username);
+ gid_t gid(const std::string &groupname);
+} // namespace PasswdAccess
+
+#endif // TESTS_COMMON_PASSWD_ACCESS_H_