diff --git a/CMakeLists.txt b/CMakeLists.txt index 059005f547a1cbcc728d134d50acbd8722208c59..e542f2edca96f127b965b92ce35a2adf02b524cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,17 +59,16 @@ link_directories ( ${CMAKE_BINARY_DIR}/lib) set(RE2_STATIC_LIBRARIES -L${RE2_LIBRARY_DIR} -l libre2.a ) -# test +# test inventory and update option( PRINT_JSON "Set to ON to print json objects before sending" OFF ) message(STATUS "${PRINT_JSON}: ${${PRINT_JSON}}") -if ( PRINT_JSON ) - add_definitions ( -DPRINT_JSON ) -endif () -# test to update -option( UPDATE_JSON "Set to ON to print json objects before sending" OFF ) +option( UPDATE_JSON "Set to ON to print json objects" OFF ) message(STATUS "${UPDATE_JSON}: ${${UPDATE_JSON}}") -if ( UPDATE_JSON ) + +if ( PRINT_JSON ) + add_definitions ( -DPRINT_JSON ) +elseif (UPDATE_JSON) add_definitions ( -DUPDATE_JSON ) endif () diff --git a/include/agent/datasid-curl.h b/include/agent/datasid-curl.h deleted file mode 100644 index b7321da24115714b7d8acdd57eba2e3f1fc9aa29..0000000000000000000000000000000000000000 --- a/include/agent/datasid-curl.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include <cstring> -#include <iostream> -#include <fstream> -#include <curl/curl.h> -#include "json/json.h" - -class MyCurl{ - private: - CURL *curl; - std::string curlBuffer; - CURLcode success; - long httpCode = 0; - - public: - bool connection (Json::Value*, std::string, std::fstream*); - bool connectionProxy (std::string); - std::string getData () const; - - static int curlWritter(char *data, size_t size, size_t nmemb, std::string *buffer) { - int result = 0; - - if (buffer != NULL) { - buffer->append(data, size * nmemb); - result = size * nmemb; - } - return result; - } -}; \ No newline at end of file diff --git a/include/agent/linux/datasid-curl.h b/include/agent/linux/datasid-curl.h new file mode 100644 index 0000000000000000000000000000000000000000..49bd10315411dd147583631c57006eb8b6bc1815 --- /dev/null +++ b/include/agent/linux/datasid-curl.h @@ -0,0 +1,44 @@ +#pragma once +#include <cstring> +#include <iostream> +#include <fstream> +#include <curl/curl.h> +#include <agent/linux/datasid-agent.h> +#include <agent/linux/datasid-conf.h> +#include "json/json.h" + +class Curl{ + private: + CURL *curl; + std::string curlBuffer; + CURLcode success; + long httpCode = 0; + std::string message; + + public: + bool getAgentVersion (Json::Value*, std::string, std::fstream*); + bool downloadAgent (Json::Value*, std::string, std::fstream*, Agent*); + void setMessage (std::string); + std::string getData () const; + std::string getMessage () const; + + static int callBckVersion(char *data, size_t size, size_t nmemb, std::string *buffer) { + int result = 0; + + if (buffer != NULL) { + buffer->append(data, size * nmemb); + result = size * nmemb; + } + return result; + } + + static size_t callBackDownload(void *ptr, size_t size, size_t nmemb,void* userdata) { + FILE* stream = (FILE*)userdata; + if (!stream) { + return 0; + } + + size_t written = fwrite((FILE*)ptr, size, nmemb, stream); + return written; + } +}; \ No newline at end of file diff --git a/include/agent/linux/datasid-proxy.h b/include/agent/linux/datasid-proxy.h index 70ac9793942c8b92c6e31b4499ea674f1264873f..dd6e75c6f66ab4ad21a375b2891abccafd787786 100644 --- a/include/agent/linux/datasid-proxy.h +++ b/include/agent/linux/datasid-proxy.h @@ -31,17 +31,20 @@ class Proxy{ std::string port; std::string user; std::string password; + bool proxyFile = false; public: void setHost(std::string); void setPort(std::string); void setUser(std::string); void setPassword(std::string); + void setProxyFile(bool); std::string getHost() const; std::string getPort() const; std::string getUser() const; std::string getPassword() const; + bool getProxyFile() const; }; bool datasid_proxy(Conf* conf, Proxy* proxy, Json::Value* data); diff --git a/include/agent/main.h b/include/agent/main.h index 99922fc35785c880070c924bafb5e1a514c620f2..99befb65abe100c0e3bd5fb952b2cf12f312d096 100644 --- a/include/agent/main.h +++ b/include/agent/main.h @@ -6,6 +6,7 @@ #include "linux/datasid-client.h" #include "linux/datasid-common.h" #include "linux/datasid-conf.h" +#include "linux/datasid-curl.h" #include "linux/datasid-proxy.h" bool fileExist(const std::string& file); diff --git a/src/agent/client.cpp b/src/agent/client.cpp index 8a7ac806b3710045f989f488b437f4e1eb5685b7..511a08011958af6cb9ee6537c32873bfc8a7ef57 100644 --- a/src/agent/client.cpp +++ b/src/agent/client.cpp @@ -20,37 +20,67 @@ */ #include <string> #include "agent/client.h" -#include "agent/datasid-curl.h" +#include "agent/linux/datasid-curl.h" /*--------------------------------------------------------------------- - * update Function + * Function: update * Summary: Contact webservice server to verify client version. */ + bool update(Json::Value* data, Agent* agent, Conf* conf, Proxy* proxy, std::fstream* logFile) { - MyCurl myCurl; + Curl curl; std::string version; - if (myCurl.connection(data, conf->getWebService(), logFile)) { - version = myCurl.getData(); + if (curl.getAgentVersion(data, conf->getWebService(), logFile)) { + version = curl.getData(); if (strcmp(version.c_str(), agent->getVersion().c_str())) { - std::string var = __DATE__ + + curl.setMessage(__DATE__ + std::string(" - WARNING: Client version out-of-date.") + - std::string(" Update client."); + std::string(" Update client.")); - *logFile << var << std::endl; - (*data)["data"]["client_version_out_of_date"] = var; + *logFile << curl.getMessage() << std::endl; + (*data)["data"]["client_version"] = curl.getMessage(); return true; + } else { + curl.setMessage(__DATE__ + + std::string(" - WARNING: Client is already updated.")); + + *logFile << curl.getMessage() << std::endl; + (*data)["data"]["client_agent"] = curl.getMessage(); } } return false; } -// NOLINTNEXTLINE(runtime/references) +/*--------------------------------------------------------------------- + * Function: download + * Summary: Verify if agent client was updated. + */ + +bool download(Json::Value* data, std::fstream* logFile, Agent* agent, + Conf* conf) { + Curl curl; + if (curl.downloadAgent(data, conf->getWebService(), logFile, agent)) { + curl.setMessage(__DATE__ + + std::string(" - Update process terminated ") + + std::string("successfully.")); + + *logFile << curl.getMessage() << std::endl; + (*data)["data"]["update_process"] = curl.getMessage(); + return true; + } + + return false; +} + bool client(Json::Value* data, Agent* agent, Conf* conf, Proxy* proxy, std::string opt, std::fstream* logFile) { if (opt == "update") - return update(data, agent, conf, proxy, logFile); + if (update(data, agent, conf, proxy, logFile)) + if (download(data, logFile, agent, conf)) + return true; + return false; } diff --git a/src/agent/datasid-curl.cpp b/src/agent/datasid-curl.cpp deleted file mode 100644 index c3719437af014f0d95ab24b3ed2c6bdaabe2f35f..0000000000000000000000000000000000000000 --- a/src/agent/datasid-curl.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc-agent - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#include <string> -#include "agent/datasid-curl.h" - -/*--------------------------------------------------------------------- - * connection Method - * Summary: Contact webservice server to get client version. - */ - -bool MyCurl::connection(Json::Value* data, std::string url, - std::fstream* logFile) { - curl = curl_easy_init(); - if (!curl) { - *logFile << " - ERROR: Curl did not initialize!" << std::endl; - return false; - } - - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &MyCurl::curlWritter); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &curlBuffer); - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); - curl_easy_perform(curl); - curl_easy_cleanup(curl); - - if (httpCode == 502) { - std::string var = __DATE__ + - std::string(" - PROXY ERROR: The proxy server received an") + - std::string(" invalid response from server."); - - *logFile << var << std::endl; - (*data)["error"]["invalid_response_from_server"] = var; - - return false; - } - - if (!strcmp(getData().c_str(), "")) { - std::string var = __DATE__ + - std::string(" - ERROR: Server returned an empty version string."); - - *logFile << var << std::endl; - (*data)["error"]["empty_string_returned_from_server"] = var; - - return false; - } - - return true; -} - -/*--------------------------------------------------------------------- - * connectionProxy Method - * Summary: Contact webservice server to get client version using Proxy. - */ -bool MyCurl::connectionProxy(std::string url) { - curl = curl_easy_init(); - if (!curl) - return false; - - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &MyCurl::curlWritter); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &curlBuffer); - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_perform(curl); - curl_easy_cleanup(curl); - - return true; -} - -std::string MyCurl::getData() const { - return this->curlBuffer; -} diff --git a/src/agent/linux/datasid-agent.cpp b/src/agent/linux/datasid-agent.cpp index 0d9a7b33ba98af8823dc7c1937672b6ddbcc426c..9c38390dae1e437126667f753f0a09a6280357b4 100644 --- a/src/agent/linux/datasid-agent.cpp +++ b/src/agent/linux/datasid-agent.cpp @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * - * This file is part of datasid + * This file is part of simmc-agent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,7 +21,7 @@ #include <string> #include "agent/main.h" -/* +/*--------------------------------------------------------------------- * set Functions */ @@ -45,7 +45,7 @@ void Agent::setVersion(std::string v) { this->version = v; } -/* +/*--------------------------------------------------------------------- * get Functions */ @@ -69,10 +69,10 @@ std::string Agent::getVersion() const { return this->version; } -/* - * getAbsolutePath Function: - * get the absolute path of the agent - */ + /*--------------------------------------------------------------------- + * Function: getAbsolutePath + * Summary: get the absolute path of the agent. + */ std::string getAbsolutePath(std::string str, int tot) { int i = str.size(), count = 0; @@ -83,9 +83,9 @@ std::string getAbsolutePath(std::string str, int tot) { return str.substr(0, i); } -/* - * prefixIsSet Function - * Check if the absolute path of agent was setted. +/*--------------------------------------------------------------------- + * Function: prefixIsSet + * Summary: Check if the absolute path of agent was setted. */ bool prefixIsSet(std::string prefix) { diff --git a/src/agent/linux/datasid-client.cpp b/src/agent/linux/datasid-client.cpp index cc65dceb0d930a5ec019b63e891b54c491dba1a9..64e5238200060c9b775a2d525b766b40781e7fcc 100644 --- a/src/agent/linux/datasid-client.cpp +++ b/src/agent/linux/datasid-client.cpp @@ -22,7 +22,6 @@ #include "agent/main.h" #include "agent/client.h" -// NOLINTNEXTLINE(runtime/references) bool datasid_client(Json::Value* data, Agent* agent, Conf* conf, Proxy* proxy, std::string opt, std::fstream* logFile) { if (conf->getWebService().size() == 0) { diff --git a/src/agent/linux/datasid-common.cpp b/src/agent/linux/datasid-common.cpp index a55702280fdfd9b4680650cb080d187702a97ac2..a359d7b4b4d50879a676565fc69562858a04e537 100644 --- a/src/agent/linux/datasid-common.cpp +++ b/src/agent/linux/datasid-common.cpp @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * - * This file is part of datasid + * This file is part of simmc-agent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,9 +21,9 @@ #include <string> #include "agent/linux/datasid-common.h" -/* - * fileExist Function - * verify if a file exist +/*--------------------------------------------------------------------- + * Function: fileExist + * Summary: Verify if a file exist. */ bool fileExist(const std::string& file) { @@ -36,20 +36,21 @@ bool fileExist(const std::string& file) { return false; } -/* - * Create "data" and "log" directories if needed - * c_str() - converte c++ string to c string - */ +/*--------------------------------------------------------------------- + * Function: createDirectories + * Summary: Create "data" and "log" directories if needed. + * c_str() - converte c++ string to c string. + */ void createDirectories(Agent* agent, Conf* conf) { mkdir(conf->getLogDir().c_str(), 0700); mkdir(conf->getDataDir().c_str(), 0700); } -/* - * checkVersionFileExist Function - * check if version file exist and set version variable. - * Otherwise, setted 0.0.0 +/*--------------------------------------------------------------------- + * Function: checkVersionFileExist + * Summary: Check if version file exist and set version variable. + * Otherwise, setted 0.0.0. */ bool checkVersionFileExist(Agent* agent) { @@ -80,7 +81,7 @@ bool datasid_common(Json::Value* data, Agent* agent, Conf* conf, if (!fileExist(agent->getDefaultConf())) { std::string var = __DATE__ + - std::string(" - ERROR: Conf file not found."); + std::string(" - ERROR: Config file not found."); (*data)["error"]["config_file_not_found"] = var; return false; diff --git a/src/agent/linux/datasid-conf.cpp b/src/agent/linux/datasid-conf.cpp index 9c4194a04f745c918d4c31da5fdd2e1d4b10ef54..b5f66db9ebd366beac10e410f9539ecfca50a5ac 100644 --- a/src/agent/linux/datasid-conf.cpp +++ b/src/agent/linux/datasid-conf.cpp @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * - * This file is part of datasid + * This file is part of simmc-agent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,7 +26,8 @@ #include <sstream> #include <string> #include "agent/linux/datasid-conf.h" -/* + +/*--------------------------------------------------------------------- * set Functions */ @@ -62,7 +63,7 @@ void Conf::setUpdatTimeOut(int u) { this->updateTimeOut = u; } -/* +/*--------------------------------------------------------------------- * get Functions */ @@ -98,9 +99,9 @@ int Conf::getUpdateTimeOut() const { return this->updateTimeOut; } -/* - * setConf Function - * If variables from config file setted, +/*--------------------------------------------------------------------- + * Function: setConf + * Summary: If variables from config file setted, * then set the conf object */ diff --git a/src/agent/linux/datasid-curl.cpp b/src/agent/linux/datasid-curl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5090a2c68ae3b473a9f6294133cc2792da145a9f --- /dev/null +++ b/src/agent/linux/datasid-curl.cpp @@ -0,0 +1,150 @@ +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc-agent + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ +#include <string> +#include "agent/linux/datasid-curl.h" + +/*--------------------------------------------------------------------- + * set Functions + */ + +void Curl::setMessage(std::string m) { + this->message = m; +} + +/*--------------------------------------------------------------------- + * get Functions + */ + +std::string Curl::getData() const { + return this->curlBuffer; +} + +std::string Curl::getMessage() const { + return this->message; +} + + +/*--------------------------------------------------------------------- + * Method: getAgentVersion + * Summary: Contact webservice server to get client version. + */ + +bool Curl::getAgentVersion(Json::Value* data, std::string url, + std::fstream* logFile) { + curl = curl_easy_init(); + if (!curl) { + message = __DATE__ + std::string(" - ERROR: Curl did not initialize!"); + + *logFile << message << std::endl; + (*data)["error"]["curl_did_not_initialize"] = message; + + return false; + } + + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Curl::callBckVersion); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &curlBuffer); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); + curl_easy_perform(curl); + curl_easy_cleanup(curl); + + if (httpCode == 502) { + message = __DATE__ + + std::string(" - PROXY ERROR: The proxy server received an") + + std::string(" invalid response from server."); + + *logFile << message << std::endl; + (*data)["error"]["proxy_error"] = message; + + return false; + } + + if (!strcmp(getData().c_str(), "")) { + message = __DATE__ + + std::string(" - ERROR: Server returned an empty version string."); + + *logFile << message << std::endl; + (*data)["error"]["empty_string"] = message; + + return false; + } + + return true; +} + +/*--------------------------------------------------------------------- + * Method: downloadAgent + * Summary: Contact webservice server to update the agent + * Without proxy connection. SSL is enable, but is not download file from https server + */ + +bool Curl::downloadAgent(Json::Value* data, std::string url, + std::fstream* logFile, Agent* agent) { + curl = curl_easy_init(); + if (!curl) { + message = __DATE__ + std::string(" - ERROR: Curl did not initialize!"); + + *logFile << message << std::endl; + (*data)["error"]["curl_did_not_initialize"] = message; + + return false; + } + + const char* home_dir = getenv("HOME"); + + std::string zipname = home_dir + std::string("/agent.zip"); + FILE* fp = fopen(zipname.c_str(), "wb"); + + if (!fp) { + message = __DATE__ + std::string(" - ERROR: Failed to ") + + std::string("create file on the disk."); + + *logFile << message << std::endl; + (*data)["error"]["failed_to_create_file_on_the_disk"] = message; + + return false; + } + + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Curl::callBackDownload); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); + success = curl_easy_perform(curl); + curl_easy_cleanup(curl); + + fclose(fp); + + if (success) { + message = __DATE__ + std::string(" - ERROR: Failed ") + + std::string("to download the agent."); + + *logFile << message << std::endl; + (*data)["error"]["failed_to_download_agent"] = message; + + return false; + } + + return true; +} diff --git a/src/agent/linux/datasid-parse.cpp b/src/agent/linux/datasid-parse.cpp index a9dcf339507495b8b9987efee643c69571758dbc..77ccba82dd0af39573e83d7f8445f40863fee871 100644 --- a/src/agent/linux/datasid-parse.cpp +++ b/src/agent/linux/datasid-parse.cpp @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * - * This file is part of datasid + * This file is part of simmc-agent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,9 +23,10 @@ #include <string> #include "agent/linux/datasid-parse.h" -/* - * trim Function - * Erases leading tabs, leading spaces; trailing tabs, trailing spaces. +/*--------------------------------------------------------------------- + * Function: trim + * Summary: Erases leading tabs, leading spaces; trailing tabs, + * trailing spaces, */ void trim(std::string* str) { @@ -47,9 +48,9 @@ void trim(std::string* str) { str->erase(i, j); } -/* - * normalize Function - * Erases tabs and spaces between the variable's name and its value. +/*--------------------------------------------------------------------------- + * Function: normalize + * Summary: Erases tabs and spaces between the variable's name and its value. */ void normalize(std::string* str) { @@ -75,9 +76,9 @@ void normalize(std::string* str) { } } -/* - * spaceOnly Functio - * Check if a line consists only of spaces and tabs +/*--------------------------------------------------------------------- + * Function: spaceOnly + * Summary: Check if a line consists only of spaces and tabs, */ bool spaceOnly(const std::string* line) { @@ -87,10 +88,10 @@ bool spaceOnly(const std::string* line) { return true; } -/* - * isValid Function - * Check if a line is valid - * The line is valide when has "key":"value"; +/*--------------------------------------------------------------------- + * Function: isValid + * Summary: Check if a line is valid, + * The line is valide when has "key":"value"; */ bool isValid(std::string* line) { @@ -148,9 +149,9 @@ bool isValid(std::string* line) { return true; } -/* - * parse Function - * After check if the line is valid, +/*--------------------------------------------------------------------- + * Function: parse + * Summary: After check if the line is valid, * than parse the "key":"value" to a map. */ @@ -172,10 +173,10 @@ void parse(std::string* line, std::map<std::string, std::string>* content) { } } -/* - * readFile Function - * read a file (config or proxy file) - * Than check if the line is valid. +/*--------------------------------------------------------------------- + * Function: readFile + * Summary: read a file (config or proxy file), then + * check if the line is valid. * Case is valid, parse the "key":"value" to a map. * After all, get de value by key and "initialize" * a conf or proxy object. diff --git a/src/agent/linux/datasid-proxy.cpp b/src/agent/linux/datasid-proxy.cpp index d11231bc792dc74f017f41dc22d04166e4b2c8eb..af280cfa90807f9066b25ffefdb261148a01f8b3 100644 --- a/src/agent/linux/datasid-proxy.cpp +++ b/src/agent/linux/datasid-proxy.cpp @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * - * This file is part of datasid + * This file is part of simmc-agent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,7 +23,7 @@ #include <string> #include "agent/linux/datasid-proxy.h" -/* +/*--------------------------------------------------------------------- * set Functions */ @@ -43,7 +43,11 @@ void Proxy::setPassword(std::string p) { this->password = p; } -/* +void Proxy::setProxyFile(bool opt) { + this->proxyFile = opt; +} + +/*--------------------------------------------------------------------- * get Functions */ @@ -63,10 +67,14 @@ std::string Proxy::getPassword() const { return this->password; } -/* - * setProxy Function - * If variables from proxy file setted, - * then set the proxy object +bool Proxy::getProxyFile() const { + return this->proxyFile; +} + +/*--------------------------------------------------------------------- + * Function: setProxy + * Summary: If variables from proxy file setted, + * then set the proxy object. */ bool setProxy(Proxy* proxy, std::map<std::string, std::string>* content) { @@ -97,5 +105,6 @@ bool datasid_proxy(Conf* conf, Proxy* proxy, Json::Value* data) { } } + proxy->setProxyFile(true); return true; } diff --git a/src/agent/main.cpp b/src/agent/main.cpp index 79979433cb920654004fc213b5134e10e97e4b6a..b60142336198b06dfb5dee066a917073463914e3 100644 --- a/src/agent/main.cpp +++ b/src/agent/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2016 Centro de Computacao Cientifica e Software Livre +/* Copyright (C) 2004-2017 Centro de Computacao Cientifica e Software Livre * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR * * This file is part of simmc-agent