RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
Classes | Functions
PosixSystem.hpp File Reference
#include <functional>
#include <Optional.hpp>
#include <Error.hpp>

Go to the source code of this file.

Classes

struct  rstudio::launcher_plugins::system::posix::IpAddress
 Represents an IP address. More...
 

Functions

Error rstudio::launcher_plugins::system::posix::enableCoreDumps ()
 Enables core dumps for this process. More...
 
std::string rstudio::launcher_plugins::system::posix::getEnvironmentVariable (const std::string &in_name)
 Gets an environment variable from the system. More...
 
launcher_plugins::Error rstudio::launcher_plugins::system::posix::getIpAddresses (std::vector< IpAddress > &out_addresses, bool in_includeIPv6=false)
 Gets the IP addresses of the machine running this process. More...
 
Error rstudio::launcher_plugins::system::posix::ignoreSignal (int in_signal)
 Ignores a particular signal for this process. More...
 
template<typename T >
rstudio::launcher_plugins::system::posix::posixCall (const std::function< T()> &in_posixFunction)
 Makes a posix call and handles EINTR retries. More...
 
template<typename T >
Error rstudio::launcher_plugins::system::posix::posixCall (const std::function< T()> &in_posixFunction, const ErrorLocation &in_errorLocation, T *out_result=nullptr)
 Makes a posix call and handles EINTR retries. More...
 
bool rstudio::launcher_plugins::system::posix::realUserIsRoot ()
 Checks whether the real user (not the effective user) running this process is root. More...
 
Error rstudio::launcher_plugins::system::posix::restoreRoot ()
 Restores root privileges. More...
 
Error rstudio::launcher_plugins::system::posix::restorePrivileges ()
 Restores privileges of the previous user, whose privileges were dropped by calling temporarilyDropPrivileges. More...
 
Error rstudio::launcher_plugins::system::posix::temporarilyDropPrivileges (const User &in_user, const Optional< GidType > &in_group)
 Temporarily drops privileges from root to the requested user and group. More...
 

Detailed Description

Posix System Utilities.

Function Documentation

◆ enableCoreDumps()

Error rstudio::launcher_plugins::system::posix::enableCoreDumps ( )

Enables core dumps for this process.

Returns
Success if core dumps could be enabled; Error otherwise.

◆ getEnvironmentVariable()

std::string rstudio::launcher_plugins::system::posix::getEnvironmentVariable ( const std::string &  in_name)

Gets an environment variable from the system.

Parameters
in_nameThe name of the environment variable.
Returns
The value of the environment variable, if it exists; empty string otherwise.

◆ getIpAddresses()

launcher_plugins::Error rstudio::launcher_plugins::system::posix::getIpAddresses ( std::vector< IpAddress > &  out_addresses,
bool  in_includeIPv6 = false 
)

Gets the IP addresses of the machine running this process.

Parameters
out_addressesThe IP addresses of the machine running this process.
in_includeIPv6Whether or not to include IPv6 addresses. Default: false.
Returns
Success if the IP addresses could be retrieved; Error otherwise.

◆ ignoreSignal()

Error rstudio::launcher_plugins::system::posix::ignoreSignal ( int  in_signal)

Ignores a particular signal for this process.

Parameters
in_signalThe signal to ignore.
Returns
Success if the specified signal could be ignored; Error otherwise.

◆ posixCall() [1/2]

template<typename T >
T rstudio::launcher_plugins::system::posix::posixCall ( const std::function< T()> &  in_posixFunction)

Makes a posix call and handles EINTR retries.

Only for use with functions that return -1 on error and set errno.

Template Parameters
TThe return type of the function to be called.
Parameters
in_posixFunctionThe function to call.
Returns
The return value of the provided function.

◆ posixCall() [2/2]

template<typename T >
Error rstudio::launcher_plugins::system::posix::posixCall ( const std::function< T()> &  in_posixFunction,
const ErrorLocation in_errorLocation,
T *  out_result = nullptr 
)

Makes a posix call and handles EINTR retries.

Only for use with functions that return -1 on error and set errno.

Template Parameters
TThe return type of the function to be called.
Parameters
in_posixFunctionThe function to call.
in_errorLocationThe location at which this function was invoked.
out_resultOptional output parameter on which the result of in_posixFUnction will be set.
Returns
Success if the posix function was invoked and ran successfully; Error otherwise.

◆ realUserIsRoot()

bool rstudio::launcher_plugins::system::posix::realUserIsRoot ( )

Checks whether the real user (not the effective user) running this process is root.

Returns
True if the real user is root; false otherwise.

◆ restorePrivileges()

Error rstudio::launcher_plugins::system::posix::restorePrivileges ( )

Restores privileges of the previous user, whose privileges were dropped by calling temporarilyDropPrivileges.

Returns
Success if privileges could be restored; Error otherwise.

◆ restoreRoot()

Error rstudio::launcher_plugins::system::posix::restoreRoot ( )

Restores root privileges.

Returns
Success if root privileges could be restored; Error otherwise.

◆ temporarilyDropPrivileges()

Error rstudio::launcher_plugins::system::posix::temporarilyDropPrivileges ( const User in_user,
const Optional< GidType > &  in_group 
)

Temporarily drops privileges from root to the requested user and group.

Parameters
in_userThe user to which to drop privileges.
in_groupThe group to which to drop privileges.
Returns
Success if privileges could be dropped to the requested user and group; Error otherwise.