Skip to content

Commit

Permalink
Fix plugins menu integration
Browse files Browse the repository at this point in the history
Fixes #3655
  • Loading branch information
emanuele-f committed Mar 27, 2020
1 parent dc4431f commit ead1dc0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
5 changes: 2 additions & 3 deletions include/HTTPserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern bool enable_users_login;
class HTTPserver {
private:
bool use_http, can_accept_requests;
char *docs_dir, *scripts_dir, *runtime_dir;
char *docs_dir, *scripts_dir;
struct mg_context *httpd_v4;
bool ssl_enabled, gui_access_restricted;
char *captive_redirect_addr;
Expand All @@ -51,7 +51,7 @@ class HTTPserver {
#endif

public:
HTTPserver(const char *_docs_dir, const char *_scripts_dir, const char *_data_dir);
HTTPserver(const char *_docs_dir, const char *_scripts_dir);
~HTTPserver();

bool valid_user_pwd(char *user, char *pass);
Expand All @@ -60,7 +60,6 @@ class HTTPserver {

inline char* get_docs_dir() { return(docs_dir); };
inline char* get_scripts_dir() { return(scripts_dir); };
inline char* get_runtime_dir() { return(runtime_dir); };
inline bool is_ssl_enabled() { return(ssl_enabled); };
inline bool is_gui_access_restricted() { return(gui_access_restricted); };
inline void start_accepting_requests() { can_accept_requests = true; };
Expand Down
8 changes: 0 additions & 8 deletions include/Ntop.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,6 @@ class Ntop {
inline char* get_install_dir() { return(install_dir); };
inline void set_install_dir(char *id) { snprintf(install_dir, MAX_PATH, "%s", id); };

/**
* @brief Get the runtime directory, which contains executable lua scripts generated at runtime.
* @note Currently an alias for the working directory
*
* @return The path of runtime directory.
*/
inline char* get_runtime_dir() { return(working_dir); };

inline char* get_plugins_dir() { return(plugins_dir); };
inline char* get_shadow_plugins_dir() { return(shadow_plugins_dir); };
inline void swap_plugins_dir() { cur_plugins_dir = !cur_plugins_dir; refreshPluginsDir(); };
Expand Down
9 changes: 4 additions & 5 deletions src/HTTPserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,8 @@ static int handle_lua_request(struct mg_connection *conn) {
snprintf(path, sizeof(path), "%s/lua/metrics.lua",
httpserver->get_scripts_dir());
else if(strncmp(request_info->uri, "/plugins/", 9) == 0)
snprintf(path, sizeof(path), "%s/plugins/scripts/%s",
httpserver->get_runtime_dir(), request_info->uri + 9);
snprintf(path, sizeof(path), "%s/scripts/%s",
ntop->get_plugins_dir(), request_info->uri + 9);
else
snprintf(path, sizeof(path), "%s%s%s",
httpserver->get_scripts_dir(),
Expand Down Expand Up @@ -1179,7 +1179,7 @@ int init_client_x509_auth(void *ctx) {

/* ****************************************** */

HTTPserver::HTTPserver(const char *_docs_dir, const char *_scripts_dir, const char *_runtime_dir) {
HTTPserver::HTTPserver(const char *_docs_dir, const char *_scripts_dir) {
bool good_ssl_cert = false;
struct timeval tv;

Expand Down Expand Up @@ -1217,7 +1217,6 @@ HTTPserver::HTTPserver(const char *_docs_dir, const char *_scripts_dir, const ch
gui_access_restricted = true;

docs_dir = strdup(_docs_dir), scripts_dir = strdup(_scripts_dir);
runtime_dir = strdup(_runtime_dir);
ssl_enabled = false;
httpserver = this;
#ifdef HAVE_NEDGE
Expand Down Expand Up @@ -1354,7 +1353,7 @@ HTTPserver::~HTTPserver() {

if(wispr_captive_data) free(wispr_captive_data);
if(captive_redirect_addr) free(captive_redirect_addr);
free(docs_dir), free(scripts_dir), free(runtime_dir);
free(docs_dir), free(scripts_dir);
ntop->getTrace()->traceEvent(TRACE_NORMAL, "HTTP server terminated");
};

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ int main(int argc, char *argv[])

/* Register the HTTP server before dropping the privileges. This is required
* in order to possibly bind the HTTP server to privileged ports (< 1024) */
ntop->registerHTTPserver(new HTTPserver(prefs->get_docs_dir(), prefs->get_scripts_dir(), ntop->get_runtime_dir()));
ntop->registerHTTPserver(new HTTPserver(prefs->get_docs_dir(), prefs->get_scripts_dir()));

/* Drop the privileges before initializing the network interfaces. This
* is necessary as the initialization may create files/directories, which
Expand Down

0 comments on commit ead1dc0

Please sign in to comment.