NAWA 0.9
Web Application Framework for C++
nawarun Namespace Reference

Classes

struct  Parameters
 

Typedefs

using PrivilegeDowngradeData = std::tuple< uid_t, gid_t, std::vector< gid_t > >
 
using init_t = int(nawa::AppInit &)
 
using handleRequest_t = int(nawa::Connection &)
 

Functions

unsigned int getConcurrency (nawa::Config const &config)
 
std::pair< init_t *, std::shared_ptr< nawa::HandleRequestFunctionWrapper > > loadAppFunctions (nawa::Config const &config)
 
void reload (int signum)
 
std::optional< PrivilegeDowngradeDatapreparePrivilegeDowngrade (nawa::Config const &config)
 
void replaceLogger (nawa::Log const &log)
 
Parameters parseCommandLine (int argc, char **argv)
 
int run (Parameters const &parameters)
 

Class Documentation

◆ nawarun::Parameters

struct nawarun::Parameters

Definition at line 38 of file nawarun.h.

Class Members
typedef pair< string, string > ConfigOptionId
typedef pair< ConfigOptionId, string > ConfigOverride
Class Members
optional< string > configFile
vector< ConfigOverride > configOverrides

Typedef Documentation

◆ PrivilegeDowngradeData

using nawarun::PrivilegeDowngradeData = typedef std::tuple<uid_t, gid_t, std::vector<gid_t> >

Definition at line 36 of file nawarun.h.

◆ init_t

using nawarun::init_t = typedef int(nawa::AppInit&)

Type for the init() function of NAWA apps.

Definition at line 46 of file nawarun.h.

◆ handleRequest_t

Type for the handleRequest(Connection) function of NAWA apps.

Definition at line 47 of file nawarun.h.

Function Documentation

◆ getConcurrency()

unsigned int nawarun::getConcurrency ( nawa::Config const &  config)

Get the number of threads to use from config.

Parameters
configConfig
Returns
Number of threads

Definition at line 184 of file nawarun.cpp.

◆ loadAppFunctions()

pair< init_t *, shared_ptr< HandleRequestFunctionWrapper > > nawarun::loadAppFunctions ( nawa::Config const &  config)

Load the init() and handleRequest() functions of an app. Note: the init function also becomes unavailable when the HandleRequestFunctionWrapper is destructed. Throws a nawa::Exception on failure.

Parameters
configConfig
Returns
Pair of init function and smart pointer to wrapper containing the handleRequest function.

Definition at line 200 of file nawarun.cpp.

◆ reload()

void nawarun::reload ( int  signum)

Reload on signal.

Parameters
signumSignal

Definition at line 229 of file nawarun.cpp.

◆ preparePrivilegeDowngrade()

optional< PrivilegeDowngradeData > nawarun::preparePrivilegeDowngrade ( nawa::Config const &  config)

Prepare privilege downgrade considering the corresponding options in the config and check for errors. Will log warnings and throw a nawa::Exception in case of failure.

Parameters
configConfig
Returns
A tuple with the UID and GID and a list of supplementary groups if privilege downgrade should happen (i.e., nawarun is running as root).

Definition at line 287 of file nawarun.cpp.

◆ replaceLogger()

void nawarun::replaceLogger ( nawa::Log const &  log)

Replace nawarun's logger with the given one for testing purposes.

Parameters
logLogger

Definition at line 329 of file nawarun.cpp.

◆ parseCommandLine()

Parameters nawarun::parseCommandLine ( int  argc,
char **  argv 
)

Parse command line arguments. If –help or -h is encountered as the first argument, printHelpAndExit() is invoked.

Parameters
argcNumber of arguments
argvArguments
Returns
A structure containing the path to the config file (optional, as it can be skipped with –no-config-file), and a list of config option overrides (identifier-value pairs, wherein the identifier is a pair of category and key).

Parse command line arguments. If –help or -h is encountered as the first argument, printHelpAndExit() is invoked.

Parameters
argcNumber of arguments
argvArguments
Returns
A structure containing the path to the config file (optional, as it can be skipped with –no-config-file) and a list of config option overrides (identifier-value pairs, wherein the identifier is a pair of category and key).

Definition at line 340 of file nawarun.cpp.

◆ run()

int nawarun::run ( Parameters const &  parameters)

Run nawarun.

Parameters
parametersParameters
Returns
Return code (0 on success, 1 on failure).

Definition at line 392 of file nawarun.cpp.