Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
OpenCDMPlugin.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 2020 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: OpenCDMPlugin.h
21  *
22  */
23 #ifndef OPENCDMPLUGIN_H
24 #define OPENCDMPLUGIN_H
25 
26 #include <IDobbyPlugin.h>
27 #include <PluginBase.h>
28 
29 #include <sys/types.h>
30 #include <netinet/in.h>
31 
32 #include <unistd.h>
33 #include <string>
34 #include <memory>
35 
36 // -----------------------------------------------------------------------------
49 class OpenCDMPlugin : public PluginBase
50 {
51 public:
52  OpenCDMPlugin(const std::shared_ptr<IDobbyEnv> &env,
53  const std::shared_ptr<IDobbyUtils> &utils);
54  ~OpenCDMPlugin() override;
55 
56 public:
57  std::string name() const final;
58 
59  unsigned hookHints() const final;
60 
61 public:
62  bool postConstruction(const ContainerId& id,
63  const std::shared_ptr<IDobbyStartState>& startupState,
64  const std::string& rootfsPath,
65  const Json::Value& jsonData) final;
66 
67 private:
68  const std::string mName;
69  const std::shared_ptr<IDobbyUtils> mUtilities;
70  const gid_t mAppsGroupId;
71 
72 private:
73  std::string ocdmBufferPath(unsigned bufferNum) const;
74  std::string ocdmBufferAdminPath(unsigned bufferNum) const;
75  bool writeFileIfNotExists(const std::string &filePath) const;
76  bool enableTmpOCDMDir(const std::shared_ptr<IDobbyStartState>& startupState) const;
77 };
78 
79 #endif // !defined(OPENCDMPLUGIN_H)
A wrapper around a std::string, used to add some type definition to to an id and also to sanity check...
Definition: ContainerId.h:41
Dobby plugin for creating the necessary OCDM buffers.
Definition: OpenCDMPlugin.h:50
std::string ocdmBufferAdminPath(unsigned bufferNum) const
Returns the file path of the OCDM admin Buffer corresponding to the specified buffer number.
Definition: OpenCDMPlugin.cpp:228
std::string ocdmBufferPath(unsigned bufferNum) const
Returns the file path of the OCDMBuffer corresponding to the specified buffer number.
Definition: OpenCDMPlugin.cpp:216
bool postConstruction(const ContainerId &id, const std::shared_ptr< IDobbyStartState > &startupState, const std::string &rootfsPath, const Json::Value &jsonData) final
Creates the required temp files for WPE browser to launch and decrypt content. The files are created ...
Definition: OpenCDMPlugin.cpp:116
unsigned hookHints() const final
Indicates which hook points we want and whether to run the asynchronously or synchronously with the o...
Definition: OpenCDMPlugin.cpp:90
bool writeFileIfNotExists(const std::string &filePath) const
Checks if the specified file exists then creates a blank file with permissions 0760 it if it doesn't ...
Definition: OpenCDMPlugin.cpp:241
bool enableTmpOCDMDir(const std::shared_ptr< IDobbyStartState > &startupState) const
Ensures the /tmp/OCDM directory exists and has permissions so accessible by apps but not (directory) ...
Definition: OpenCDMPlugin.cpp:180
std::string name() const final
Boilerplate that just returns the name of the hook.
Definition: OpenCDMPlugin.cpp:78
Basic object that provides the default overrides for a plugin.
Definition: PluginBase.h:38