Configuration should be redable by everybody

This commit is contained in:
Bartosz Wieczorek 2025-08-08 11:37:59 +02:00
parent f633b7992a
commit a2c3469b8c
3 changed files with 43 additions and 5 deletions

View File

@ -224,6 +224,41 @@ class RublonCheckApplicationException {
ErrorClass errorClass;
};
class RublonRuntimeException {
public:
enum ErrorClass {
CantCreateSocket,
ConnectionFailed,
CantGetSocketName,
CantReadLocalIP
};
constexpr static auto errorClassPrettyName = make_array< std::string_view >( //
"CantCreateSocket",
"ConnectionFailed",
"CantGetSocketName",
"CantReadLocalIP");
constexpr static auto prettyName = "Rublon Runtime Exception";
RublonRuntimeException(ErrorClass e = CantReadLocalIP) : errorClass{e} {}
constexpr const char * what() const {
return errorClassPrettyName[static_cast< int >(errorClass)].data();
}
static std::optional< RublonRuntimeException > fromString(std::string_view name) {
for(std::size_t i{}; i < errorClassPrettyName.size(); i++) {
if(errorClassPrettyName.at(i) == name) {
return std::make_optional(RublonRuntimeException{static_cast< ErrorClass >(i)});
}
}
return std::nullopt;
}
ErrorClass errorClass;
};
class Error {
using Error_t = std::variant< ConfigurationError,
CoreHandlerError,
@ -231,7 +266,8 @@ class Error {
WerificationError,
MethodError,
RublonAuthenticationInterrupt,
RublonCheckApplicationException >;
RublonCheckApplicationException,
RublonRuntimeException >;
Error_t _error;
public:
@ -242,7 +278,8 @@ class Error {
k_WerificationError,
k_MethodError,
k_RublonAuthenticationInterrupt,
k_RublonCheckApplication
k_RublonCheckApplication,
k_RublonRuntimeException
};
Error() = default;
@ -254,6 +291,7 @@ class Error {
Error(WerificationError error) : _error{error} {}
Error(RublonAuthenticationInterrupt error) : _error{error} {}
Error(RublonCheckApplicationException error) : _error{error} {}
Error(RublonRuntimeException error) : _error{error} {}
Error(const Error &) = default;
Error(Error &&) = default;

View File

@ -12,7 +12,7 @@ namespace rublon {
class RublonFactory {
public:
tl::expected< void, Error > initializeSession(Session & session, int flags, int argc, const char ** argv) {
tl::expected< void, Error > initializeSession(Session & session, [[maybe_unused]]int flags, int argc, const char ** argv) {
log(LogLevel::Debug, "Configuration read start");
memory::MonotonicStack_2k_Resource memory_resource;
ConfigurationReader reader{&memory_resource, "/etc/rublon.config", argc, argv};

View File

@ -9,14 +9,14 @@ if [ ! -f $RUBLON_CONFIG ]
then
cp -a /usr/share/rublon/rublon.config.defaults $RUBLON_CONFIG
chown root:root $RUBLON_CONFIG
chmod 640 $RUBLON_CONFIG
chmod 644 $RUBLON_CONFIG
fi
if [ ! -f $RUBLON_SSH_CONFIG ]
then
cp -a /usr/share/rublon/01-rublon-ssh.conf.default $RUBLON_SSH_CONFIG
chown root:root $RUBLON_SSH_CONFIG
chmod 640 $RUBLON_SSH_CONFIG
chmod 644 $RUBLON_SSH_CONFIG
fi
if [ -f /etc/os-release ]