blocxx
Secure.cpp File Reference
#include "blocxx/BLOCXX_config.h"
#include "blocxx/Array.hpp"
#include "blocxx/Secure.hpp"
#include "blocxx/FileSystem.hpp"
#include "blocxx/String.hpp"
#include "blocxx/Paths.hpp"
#include "blocxx/Format.hpp"
#include "blocxx/LazyGlobal.hpp"
#include <fcntl.h>
#include <grp.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdlib>
#include <cstdio>
#include <cerrno>
#include <vector>
#include <algorithm>

Go to the source code of this file.

Namespaces

namespace  BLOCXX_NAMESPACE
 Taken from RFC 1321.
 
namespace  BLOCXX_NAMESPACE::Secure
 

Macros

#define THRBLOCXX_IF(tst, ExceptionClass, msg)
 
#define THRBLOCXX_ERRNO_IF(tst, ExceptionClass, msg)
 
#define ABORT_IF(tst, msg)
 
#define ABORT_ERRNO_IF(tst, msg)
 

Functions

void BLOCXX_NAMESPACE::Secure::dropPrivilegesPermanently (::uid_t newuid, ::gid_t newgid, EChildGroupAction extendedGroupAction)
 
StringArray BLOCXX_NAMESPACE::Secure::minimalEnvironment ()
 
void BLOCXX_NAMESPACE::Secure::runAs (char const *username, EChildGroupAction extendedGroupAction=E_SOURCE_EXTENDED_GROUPS)
 Look up user ID and group ID for username in password file, chdir to "/", then drop privileges and run with that user ID and group ID.
 

Macro Definition Documentation

◆ ABORT_ERRNO_IF

#define ABORT_ERRNO_IF ( tst,
msg )
Value:
THRBLOCXX_ERRNO_IF((tst), Secure::ProcessAbortException, (msg))
#define THRBLOCXX_ERRNO_IF(tst, ExceptionClass, msg)
Definition Secure.cpp:94

Definition at line 105 of file Secure.cpp.

Referenced by BLOCXX_NAMESPACE::Secure::dropPrivilegesPermanently(), and BLOCXX_NAMESPACE::Secure::runAs().

◆ ABORT_IF

#define ABORT_IF ( tst,
msg )
Value:
THRBLOCXX_IF((tst), Secure::ProcessAbortException, (msg))
#define THRBLOCXX_IF(tst, ExceptionClass, msg)
Definition Secure.cpp:85

Definition at line 103 of file Secure.cpp.

Referenced by BLOCXX_NAMESPACE::Secure::dropPrivilegesPermanently(), and BLOCXX_NAMESPACE::Secure::runAs().

◆ THRBLOCXX_ERRNO_IF

#define THRBLOCXX_ERRNO_IF ( tst,
ExceptionClass,
msg )
Value:
do \
{ \
if (tst) \
{ \
BLOCXX_THROW_ERRNO_MSG(ExceptionClass, (msg)); \
} \
} while (false)

Definition at line 94 of file Secure.cpp.

◆ THRBLOCXX_IF

#define THRBLOCXX_IF ( tst,
ExceptionClass,
msg )
Value:
do \
{ \
if (tst) \
{ \
BLOCXX_THROW(ExceptionClass, (msg)); \
} \
} while (false)

Definition at line 85 of file Secure.cpp.