iceoryx_hoofs 2.0.3
posix_access_rights.hpp
1// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
3//
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
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
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.
15//
16// SPDX-License-Identifier: Apache-2.0
17#ifndef IOX_HOOFS_POSIX_WRAPPER_POSIX_ACCESS_RIGHTS_HPP
18#define IOX_HOOFS_POSIX_WRAPPER_POSIX_ACCESS_RIGHTS_HPP
19
20#include "iceoryx_hoofs/cxx/optional.hpp"
21#include "iceoryx_hoofs/cxx/string.hpp"
22#include "iceoryx_hoofs/cxx/vector.hpp"
23#include "iceoryx_hoofs/platform/types.hpp"
24
25#include <string>
26
27namespace iox
28{
29namespace posix
30{
31static constexpr int MaxNumberOfGroups = 888;
32
34{
35 PosixRights(bool f_read, bool f_write, bool f_execute) noexcept;
36 bool m_read;
37 bool m_write;
38 bool m_execute;
39};
40
42{
43 public:
45 explicit PosixGroup(const gid_t f_id) noexcept;
46 explicit PosixGroup(const string_t& f_name) noexcept;
47
48 bool operator==(const PosixGroup& other) const noexcept;
49
50 string_t getName() const noexcept;
51 gid_t getID() const noexcept;
52
53 bool doesExist() const noexcept;
54
55 static PosixGroup getGroupOfCurrentProcess() noexcept;
56
57 static cxx::optional<uid_t> getGroupID(const string_t& f_name) noexcept;
58 static cxx::optional<string_t> getGroupName(gid_t f_id) noexcept;
59
60 private:
61 gid_t m_id;
62 bool m_doesExist{false};
63};
64
66{
67 public:
70
71 explicit PosixUser(const uid_t f_id) noexcept;
72 explicit PosixUser(const string_t& f_name) noexcept;
73
74 groupVector_t getGroups() const noexcept;
75 string_t getName() const noexcept;
76 uid_t getID() const noexcept;
77
78 bool doesExist() const noexcept;
79
80 static PosixUser getUserOfCurrentProcess() noexcept;
81
82 static cxx::optional<uid_t> getUserID(const string_t& f_name) noexcept;
83 static cxx::optional<string_t> getUserName(uid_t f_id) noexcept;
84
85 private:
86 uid_t m_id;
87 bool m_doesExist{false};
88};
89
90} // namespace posix
91} // namespace iox
92
93#endif // IOX_HOOFS_POSIX_WRAPPER_POSIX_ACCESS_RIGHTS_HPP
Optional implementation from the C++17 standard with C++11. The interface is analog to the C++17 stan...
Definition: optional.hpp:69
string implementation with some adjustments in the API, because we are not allowed to throw exception...
Definition: string.hpp:90
C++11 compatible vector implementation. We needed to do some adjustments in the API since we do not u...
Definition: vector.hpp:39
Definition: posix_access_rights.hpp:42
Definition: posix_access_rights.hpp:66
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29
Definition: posix_access_rights.hpp:34