Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OpenCDMPlugin Class Reference

Dobby plugin for creating the necessary OCDM buffers. More...

#include <OpenCDMPlugin.h>

Inheritance diagram for OpenCDMPlugin:
Inheritance graph
[legend]
Collaboration diagram for OpenCDMPlugin:
Collaboration graph
[legend]

Public Member Functions

 OpenCDMPlugin (const std::shared_ptr< IDobbyEnv > &env, const std::shared_ptr< IDobbyUtils > &utils)
 
std::string name () const final
 Boilerplate that just returns the name of the hook. More...
 
unsigned hookHints () const final
 Indicates which hook points we want and whether to run the asynchronously or synchronously with the other hooks. More...
 
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 in the host filesystem and then mounted into the container. More...
 
- Public Member Functions inherited from PluginBase
virtual bool preStart (const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called after the container is setup, but before the init process is executed. More...
 
virtual bool postStart (const ContainerId &id, pid_t pid, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called after the container is started and the init process is now running. More...
 
virtual bool postStop (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called after the container has stopped. More...
 
virtual bool preDestruction (const ContainerId &id, const std::string &rootfsPath, const Json::Value &jsonData) override
 Hook function called just before the rootfs is deleted, this is called even if there was an error starting the container. More...
 

Private Member Functions

std::string ocdmBufferPath (unsigned bufferNum) const
 Returns the file path of the OCDMBuffer corresponding to the specified buffer number. More...
 
std::string ocdmBufferAdminPath (unsigned bufferNum) const
 Returns the file path of the OCDM admin Buffer corresponding to the specified buffer number. More...
 
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 exist. More...
 
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) writeable. More...
 

Private Attributes

const std::string mName
 
const std::shared_ptr< IDobbyUtilsmUtilities
 
const gid_t mAppsGroupId
 

Additional Inherited Members

- Public Types inherited from IDobbyPlugin
enum  HintFlags : unsigned {
  PostConstructionSync = (1 << 0) , PreStartSync = (1 << 1) , PostStartSync = (1 << 2) , PostStopSync = (1 << 3) ,
  PreDestructionSync = (1 << 4) , PostConstructionAsync = (1 << 16) , PreStartAsync = (1 << 17) , PostStartAsync = (1 << 18) ,
  PostStopAsync = (1 << 19) , PreDestructionAsync = (1 << 20)
}
 Bit flags that should be returned by hookHints. More...
 

Detailed Description

Dobby plugin for creating the necessary OCDM buffers.

To launch the WPE runtime, various OpenCDM temporary files and sockets are needed inside the /tmp directory to allow decryption of DRM content to take place using the OCDMi plugin.

RunC cannot mount files that don't exist, so we need to create the files before we can launch the container

Member Function Documentation

◆ enableTmpOCDMDir()

bool OpenCDMPlugin::enableTmpOCDMDir ( const std::shared_ptr< IDobbyStartState > &  startupState) const
private

Ensures the /tmp/OCDM directory exists and has permissions so accessible by apps but not (directory) writeable.

This is added because on newer OCDM builds they've switched the directories around.

◆ hookHints()

unsigned OpenCDMPlugin::hookHints ( ) const
finalvirtual

Indicates which hook points we want and whether to run the asynchronously or synchronously with the other hooks.

For Netflix, the mounts should be created preStart

Implements IDobbyPlugin.

◆ name()

std::string OpenCDMPlugin::name ( ) const
finalvirtual

Boilerplate that just returns the name of the hook.

This string needs to match the name specified in the container spec json.

Implements IDobbyPlugin.

◆ ocdmBufferAdminPath()

std::string OpenCDMPlugin::ocdmBufferAdminPath ( unsigned  bufferNum) const
private

Returns the file path of the OCDM admin Buffer corresponding to the specified buffer number.

Parameters
[in]bufferNumNumber of buffer to create

◆ ocdmBufferPath()

std::string OpenCDMPlugin::ocdmBufferPath ( unsigned  bufferNum) const
private

Returns the file path of the OCDMBuffer corresponding to the specified buffer number.

Parameters
[in]bufferNumNumber of buffer to create

◆ postConstruction()

bool OpenCDMPlugin::postConstruction ( const ContainerId id,
const std::shared_ptr< IDobbyStartState > &  startupState,
const std::string &  rootfsPath,
const Json::Value &  jsonData 
)
finalvirtual

Creates the required temp files for WPE browser to launch and decrypt content. The files are created in the host filesystem and then mounted into the container.

For now, the files to create are hard coded, but could be passed in via JSON in the future - FIXME

The JSON for the plugin should be formatted like so:

 {
     "name": "OpenCDM",
 }
Parameters
[in]idThe id of the container.
[in]startupStateThe mutable start-up state of the container.
[in]rootfsPathThe absolute path to the rootfs of the container.
[in]jsonDataThe parsed json data from the container spec file.

Reimplemented from PluginBase.

◆ writeFileIfNotExists()

bool OpenCDMPlugin::writeFileIfNotExists ( const std::string &  filePath) const
private

Checks if the specified file exists then creates a blank file with permissions 0760 it if it doesn't exist.

Parameters
[in]filePathThe file to create

The documentation for this class was generated from the following files: