Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
MountOwnerDetails.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2022 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 /*
20  * File: MountOwnerDetails.h
21  *
22  */
23 #ifndef MOUNTOWNERDETAILS_H
24 #define MOUNTOWNERDETAILS_H
25 
26 #include "MountProperties.h"
27 
28 #include <RdkPluginBase.h>
29 
30 #include <sys/types.h>
31 #include <string>
32 #include <memory>
33 
34 
35 // -----------------------------------------------------------------------------
44 {
45 public:
46  MountOwnerDetails() = delete;
50 
51 private:
52  friend class Storage;
53 
54 public:
55  MountOwnerDetails(const std::string& rootfsPath,
56  const MountOwnerProperties& mountOwnerProperties,
57  const uid_t& defaultUserId,
58  const gid_t& defaultGroupId,
59  const std::shared_ptr<DobbyRdkPluginUtils> &utils);
60 
61 public:
62  bool onCreateRuntime() const;
63 
64 private:
65  bool getOwnerIds(uid_t& userId, gid_t& groupId) const;
66  bool processOwners() const;
67  bool changeOwnerRecursive(const std::string& path, uid_t userId, gid_t groupId) const;
68  bool changeOwner(const std::string& path, uid_t userId, gid_t groupId) const;
69 
70  const std::string mRootfsPath;
71  MountOwnerProperties mMountOwnerProperties;
72  uid_t mDefaultUserId;
73  gid_t mDefaultGroupId;
74  const std::shared_ptr<DobbyRdkPluginUtils> mUtils;
75 };
76 
77 #endif // !defined(MOUNTOWNERDETAILS_H)
Class that represents mount ownership and whether to apply recursively.
Definition: MountOwnerDetails.h:44
bool getOwnerIds(uid_t &userId, gid_t &groupId) const
Get user and group IDs based on their configured.
Definition: MountOwnerDetails.cpp:102
bool changeOwnerRecursive(const std::string &path, uid_t userId, gid_t groupId) const
Change ownership recursively from the given path.
Definition: MountOwnerDetails.cpp:194
bool onCreateRuntime() const
Changes ownership of mount source according to MountOwnerProperties during the createRuntime hook.
Definition: MountOwnerDetails.cpp:73
bool changeOwner(const std::string &path, uid_t userId, gid_t groupId) const
Change ownership of mount according to properties structure.
Definition: MountOwnerDetails.cpp:231
bool processOwners() const
Process individual mount owner and change ownership either singularly or recursively.
Definition: MountOwnerDetails.cpp:154
Dobby RDK Storage Plugin.
Definition: Storage.h:45
MountOwnerProperties struct used for Storage plugin.
Definition: MountProperties.h:63