#include <fstream>
#include <vector>
+#include <string>
#include <set>
#include <csignal>
#include <cerrno>
#include <sys/stat.h> // S_IRUSR
#include <fcntl.h> // create
-#ifdef DEBUG
- #define NO_DAEMON (1)
-#endif
-
#define START_FILE "/._ST_ART_ED_"
using STG::SettingsImpl;
return 0;
}
//-----------------------------------------------------------------------------
-#ifndef NO_DAEMON
int ForkAndWait(const std::string& confDir)
-#else
-int ForkAndWait(const std::string&)
-#endif
{
-#ifndef NO_DAEMON
const auto pid = fork();
const auto startFile = confDir + START_FILE;
unlink(startFile.c_str());
exit(1);
break;
}
-#endif
return 0;
}
+
//-----------------------------------------------------------------------------
void KillExecuters()
{
++pid;
}
}
+
+void PrintHelp(const std::string& programName)
+{
+ std::cout << "Usage: " << programName << "[-h/--help] [-v/--version] [-f/--foreground] [<conf-dir-path>]\n"
+ << "\t --help, -h - print this help;\n"
+ << "\t --version, -v - print version;\n"
+ << "\t --foreground, -f - do not go into background;\n"
+ << "\t <conf-dir-path> - path to the directory where the configuration file is located.\n";
+}
+
+void PrintVersion(const std::string& programName)
+{
+ std::cout << programName << "\n"
+ << "Stargazer version" << " " << SERVER_VERSION << "\n";
+}
//-----------------------------------------------------------------------------
} // namespace anonymous
//-----------------------------------------------------------------------------
return 1;
}
- SettingsImpl settings(argc == 2 ? argv[1] : "");
+ std::string path;
+ bool noDaemon(false);
+
+ if (argc == 1)
+ path = "";
+ else
+ {
+ for (int i = 1; i < argc; ++i)
+ {
+ const std::string arg(argv[i]);
+ if (arg == "--help" || arg == "-h")
+ {
+ PrintHelp(argv[0]);
+ return 0;
+ }
+ if (arg == "--version" || arg == "-v")
+ {
+ PrintVersion(argv[0]);
+ return 0;
+ }
+ if (arg == "--foreground" || arg == "-f")
+ noDaemon = true;
+ else
+ path = arg;
+ }
+ }
+
+ SettingsImpl settings(path);
if (settings.ReadSettings())
{
return -1;
}
-#ifndef NO_DAEMON
- const auto startFile = settings.GetConfDir() + START_FILE;
-#endif
-
- if (ForkAndWait(settings.GetConfDir()) < 0)
+ if (!noDaemon)
{
- STG::Logger::get()("Fork error!");
- return -1;
+ if (ForkAndWait(settings.GetConfDir()) < 0)
+ {
+ STG::Logger::get()("Fork error!");
+ return -1;
+ }
}
auto& WriteServLog = STG::Logger::get();
WriteServLog("Stg started successfully.");
WriteServLog("+++++++++++++++++++++++++++++++++++++++++++++");
-#ifndef NO_DAEMON
- creat(startFile.c_str(), S_IRUSR);
-#endif
+ if (!noDaemon)
+ {
+ const auto startFile = settings.GetConfDir() + START_FILE;
+ creat(startFile.c_str(), S_IRUSR);
+ }
bool running = true;
while (running)
endif ()
endif ( BUILD_MOD_AO )
+if ( BUILD_MOD_RADIUS )
+ add_library ( mod_radius MODULE other/radius/radius.cpp )
+ target_link_libraries ( mod_radius scriptexecuter logger common )
+ set_target_properties ( mod_radius PROPERTIES PREFIX "" )
+
+ if ( CLANG_TIDY_EXE )
+ set_target_properties ( mod_radius PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}" )
+ endif ()
+ if ( INCLUDE_WHAT_YOU_USE_EXE )
+ set_target_properties ( mod_radius PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "${DO_INCLUDE_WHAT_YOU_USE}" )
+ endif ()
+endif ( BUILD_MOD_RADIUS )
+
if ( BUILD_MOD_IA )
add_library ( mod_auth_ia MODULE authorization/inetaccess/inetaccess.cpp )
target_link_libraries ( mod_auth_ia scriptexecuter crypto logger common )
--- /dev/null
+#pragma once
+
+#include "stg/auth.h"
+#include <string>
+
+namespace STG
+{
+ class RADIUS : public Auth
+ {
+ public:
+ RADIUS();
+
+ int Start() override { return 0; }
+ int Stop() override { return 0; }
+ int Reload(const ModuleSettings & /*ms*/) override { return 0; }
+ bool IsRunning() override { return isRunning; }
+ int ParseSettings() override { return 0; }
+ const std::string & GetStrError() const override { return errorStr; }
+ std::string GetVersion() const override;
+ uint16_t GetStartPosition() const override { return 0; }
+ uint16_t GetStopPosition() const override { return 0; }
+
+ int SendMessage(const Message & msg, uint32_t ip) const override { return 0; }
+
+ private:
+ mutable std::string errorStr;
+ bool isRunning;
+
+ };
+}