From 1ad9576d727df9949a881bf411e7c36eedfc284a Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 16:48:28 +0200 Subject: [PATCH 01/16] Remove all references to authZ via Argus --- README.md | 2 - etc/storm-frontend-server.conf.template.in | 4 - src/frontend/Authorization.cpp | 633 --------------------- src/frontend/Authorization.hpp | 35 -- src/frontend/FrontendConfiguration.cpp | 38 +- src/frontend/FrontendConfiguration.hpp | 8 - src/frontend/Makefile.am | 11 - src/frontend/asynch.cpp | 157 ----- src/frontend/asynch_status.cpp | 127 ----- src/frontend/srm_server.h | 2 - src/frontend/srmv2_GetRequestSummary.cpp | 13 - src/frontend/srmv2_GetRequestTokens.cpp | 14 - src/frontend/storm-frontend.cpp | 34 -- src/frontend/storm_exception.hpp | 13 - src/frontend/synch.cpp | 29 - src/frontend/xacml_utils.hpp | 108 ---- 16 files changed, 1 insertion(+), 1227 deletions(-) delete mode 100644 src/frontend/Authorization.cpp delete mode 100644 src/frontend/Authorization.hpp delete mode 100644 src/frontend/xacml_utils.hpp diff --git a/README.md b/README.md index 66177a9..024b129 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,6 @@ Install the following required packages: * globus-gsi-credential-devel * CGSI-gSOAP-devel * storm-xmlrpc-c-devel -* argus-pep-api-c -* argus-pep-api-c-devel * libuuid-devel * boost-devel diff --git a/etc/storm-frontend-server.conf.template.in b/etc/storm-frontend-server.conf.template.in index 03d3fba..7b1231f 100644 --- a/etc/storm-frontend-server.conf.template.in +++ b/etc/storm-frontend-server.conf.template.in @@ -23,10 +23,6 @@ db.host = localhost db.user = storm db.passwd = password -# Argus Blacklisting -#check.user.blacklisting = false # default is false -#argus-pepd-endpoint = - #monitoring.enabled = true # default is true #monitoring.timeInterval = 60 # default is 60 (seconds) #monitoring.detailed = false # default is false diff --git a/src/frontend/Authorization.cpp b/src/frontend/Authorization.cpp deleted file mode 100644 index 4d72e86..0000000 --- a/src/frontend/Authorization.cpp +++ /dev/null @@ -1,633 +0,0 @@ -/* Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "gssapi_openssl.h" -#include "cgsi_plugin_int.h" - -#include "Authorization.hpp" -#include "srmlogit.h" -#include "FrontendConfiguration.hpp" -#include "storm_exception.hpp" -#include "srmv2H.h" -#include "xacml_utils.hpp" -#include "srm_server.h" - -using namespace storm::authz; - -#define authz_failure(msg) log_failure_and_throw_authz_error( __func__ , msg ) - -static std::string const DEFAULT_AUTHORIZATION_RESOURCE = "StoRM"; -static std::string const DEFAULT_AUTHORIZATION_ACTION = "access"; -static std::string const DEFAULT_AUTHORIZATION_PROFILE = - "http://glite.org/xacml/profile/grid-wn/1.0"; - -static boost::thread_specific_ptr pep_handle(pep_destroy); - -static void log_failure_and_throw_authz_error(const char* func, - const std::string& msg) { - srmlogit(STORM_LOG_ERROR, func, "%s\n", msg.c_str()); - throw storm::authorization_error(msg); -} - -static void log_failure_and_throw_authz_error(const char* func, - boost::format& fmt) { - log_failure_and_throw_authz_error(func, boost::str(fmt)); -} - -static std::string decision_tostring(xacml_decision_t decision) { - - switch (decision) { - case XACML_DECISION_DENY: - return "Deny"; - break; - case XACML_DECISION_PERMIT: - return "Permit"; - break; - case XACML_DECISION_INDETERMINATE: - return "Indeterminate"; - break; - case XACML_DECISION_NOT_APPLICABLE: - return "Not Applicable"; - break; - - default: - authz_failure("Unsupported xacml_decision_t received."); - return std::string(); // to silence "control reaches end of non-void function" - } -} - -static std::string fulfillon_tostring(xacml_fulfillon_t fulfillon) { - switch (fulfillon) { - case XACML_FULFILLON_DENY: - return "Deny"; - break; - case XACML_FULFILLON_PERMIT: - return "Permit"; - break; - - default: - authz_failure("Unsupported xacml_fulfillon_t received."); - return std::string(); // to silence "control reaches end of non-void function" - } -} - -static -void printXACMLObligation(xacml_obligation_t * obligation) { - - srmlogit(STORM_LOG_DEBUG, __func__, "----Obligation BEGIN----\n"); - srmlogit(STORM_LOG_DEBUG, __func__, "Obligation id: %s\n", - xacml_obligation_getid(obligation)); - srmlogit(STORM_LOG_DEBUG, __func__, "Obligation fulfillOn: %s\n", - fulfillon_tostring( - xacml_obligation_getfulfillon(obligation) - ).c_str()); - - int attrsLength = xacml_obligation_attributeassignments_length( - obligation); - - srmlogit(STORM_LOG_DEBUG, __func__, "Obligation attributes length: %d\n", - attrsLength); - - for (int i = 0; i < attrsLength; i++) { - srmlogit(STORM_LOG_DEBUG, __func__, "++Attribute BEGIN++\n"); - xacml_attributeassignment_t * attr = - xacml_obligation_getattributeassignment(obligation, i); - srmlogit(STORM_LOG_DEBUG, __func__, "Attribute Id: %s\n", - xacml_attributeassignment_getid(attr)); - srmlogit(STORM_LOG_DEBUG, __func__, "Attribute datatype: %s\n", - xacml_attributeassignment_getdatatype(attr)); - srmlogit(STORM_LOG_DEBUG, __func__, "Attribute value: %s\n", - xacml_attributeassignment_getvalue(attr)); - srmlogit(STORM_LOG_DEBUG, __func__, "++Attribute END++\n"); - } - - srmlogit(STORM_LOG_DEBUG, __func__, "----Obligation END----\n"); -} - -static void printXACMLResult(xacml_result_t * result) { - - srmlogit(STORM_LOG_DEBUG, __func__, "----Result BEGIN----\n"); - - srmlogit(STORM_LOG_DEBUG, __func__, "Resource Id: %s\n", - xacml_result_getresourceid(result)); - - srmlogit(STORM_LOG_DEBUG, __func__, "Result decision: %s\n", - decision_tostring(xacml_result_getdecision(result)).c_str()); - - srmlogit(STORM_LOG_DEBUG, __func__, "Status message is: %s\n", - xacml_status_getmessage(xacml_result_getstatus(result))); - - srmlogit(STORM_LOG_DEBUG, __func__, "Status code: %s\n", - xacml_statuscode_getvalue( - xacml_status_getcode(xacml_result_getstatus(result)))); - - if (xacml_statuscode_getsubcode( - xacml_status_getcode(xacml_result_getstatus(result))) != NULL) { - srmlogit(STORM_LOG_DEBUG, __func__, "Status subcode: %s\n", - xacml_statuscode_getvalue( - xacml_statuscode_getsubcode( - xacml_status_getcode( - xacml_result_getstatus(result))))); - } - - int obligationsLength = xacml_result_obligations_length(result); - srmlogit(STORM_LOG_DEBUG, __func__, "Status obligations:\n"); - for (int i = 0; i < obligationsLength; i++) { - //we do not manage obligations - srmlogit(STORM_LOG_DEBUG, __func__, - "Printing the content of an Obligation received. " - "It will not be considered\n"); - printXACMLObligation(xacml_result_getobligation(result, i)); - } - srmlogit(STORM_LOG_DEBUG, __func__, "----Result END----\n"); -} - -static SubjectPtr -create_xacml_subject(std::string const& subjectid) { - - assert(!subjectid.empty()); - - SubjectPtr subject = make_subject(); - - if (!subject) { - authz_failure("Error creating XACML subject."); - } - - AttributePtr subject_attr_id = make_attribute(XACML_SUBJECT_KEY_INFO); - - if (!subject_attr_id) { - authz_failure(boost::format("Error creating XACML subject attribute: %s") - % XACML_SUBJECT_KEY_INFO); - } - - if (xacml_attribute_setdatatype(subject_attr_id.get(), - XACML_DATATYPE_STRING) != PEP_XACML_OK) { - authz_failure(boost::format("Error setting XACML subject data type: %s") - % XACML_DATATYPE_STRING); - } - - if (xacml_attribute_addvalue( - subject_attr_id.get(), - subjectid.c_str() - ) != PEP_XACML_OK) { - authz_failure( - boost::format("Error setting XACML subject attribute value: %s") - % subjectid); - } - - if (xacml_subject_addattribute( - subject.get(), - release_raw_pointer(subject_attr_id) - ) != PEP_XACML_OK) { - authz_failure("Error setting XACML subject attribute"); - } - - return subject; -} - -static ResourcePtr -create_xacml_resource(std::string const& resourceid) { - - assert(!resourceid.empty()); - - ResourcePtr resource = make_resource(); - - if (!resource) { - authz_failure("Error creating XACML resource."); - } - - AttributePtr resource_attr_id = make_attribute(XACML_RESOURCE_ID); - - if (!resource_attr_id) { - authz_failure( - boost::format("Error creating XACML resource attribute: %s") - % XACML_RESOURCE_ID); - } - - if (xacml_attribute_addvalue( - resource_attr_id.get(), - resourceid.c_str() - ) != PEP_XACML_OK) { - authz_failure( - boost::format("Error setting XACML resource attribute value: %s") - % resourceid - ); - } - - if (xacml_resource_addattribute( - resource.get(), - release_raw_pointer(resource_attr_id) - ) != PEP_XACML_OK) { - authz_failure("Error adding XACML resource attribute."); - } - - return resource; -} - -static ActionPtr -create_xacml_action(std::string const& actionid) { - - assert(!actionid.empty()); - - ActionPtr action = make_action(); - - if (!action) { - authz_failure("Error creating XAMCL action."); - } - - AttributePtr action_attr_id = make_attribute(XACML_ACTION_ID); - - if (!action_attr_id) { - authz_failure( - boost::format("Error creating XACML action attribute: %s") - % XACML_ACTION_ID); - } - - if (xacml_attribute_addvalue( - action_attr_id.get(), - actionid.c_str() - ) != PEP_XACML_OK) { - authz_failure( - boost::format("Error setting XACML action attribute value: %s") - % actionid); - } - - if (xacml_action_addattribute( - action.get(), - release_raw_pointer(action_attr_id) - ) != PEP_XACML_OK) { - authz_failure("Error adding XACML action attribute"); - } - - return action; -} - -static EnvironmentPtr -create_xacml_environment_profile(std::string const& profileid) { - - assert(!profileid.empty()); - - EnvironmentPtr environment = make_environment(); - - if (!environment) { - authz_failure("Cannot create XACML Environment."); - } - AttributePtr profile_attr_id = - make_attribute(XACML_GRIDWN_ATTRIBUTE_PROFILE_ID); - - if (!profile_attr_id) { - authz_failure("Cannot create XACML Profile."); - } - - if (xacml_attribute_addvalue( - profile_attr_id.get(), - profileid.c_str() - ) != PEP_XACML_OK) { - authz_failure(boost::format("Error creating XACML profile object. %s") % - profileid); - } - - if (xacml_environment_addattribute( - environment.get(), - release_raw_pointer(profile_attr_id) - ) != PEP_XACML_OK) { - authz_failure("Error setting XACML profile attribute."); - } - - return environment; -} - -static RequestPtr -assemble_xacml_request(SubjectPtr subject, ResourcePtr resource, - ActionPtr action, EnvironmentPtr environment) { - - assert(subject && resource && action && environment); - - RequestPtr request = make_request(); - - if (!request) { - authz_failure("Error creating XACML request."); - } - - if (xacml_request_addsubject( - request.get(), - release_raw_pointer(subject) - ) != PEP_XACML_OK) { - authz_failure("Error adding XACML request subject."); - } - - if (xacml_request_addresource( - request.get(), - release_raw_pointer(resource) - ) != PEP_XACML_OK) { - authz_failure("Error adding XACML request resource."); - } - - if (xacml_request_setaction( - request.get(), - release_raw_pointer(action) - ) != PEP_XACML_OK) { - authz_failure("Error adding XACML request action."); - } - - if (xacml_request_setenvironment( - request.get(), - release_raw_pointer(environment) - ) != PEP_XACML_OK) { - authz_failure("Error adding XACML request environment."); - } - - return request; -} - -static -RequestPtr -create_xacml_request( - std::string const& subject_value, - std::string const& resourceid, - std::string const& actionid -) { - - SubjectPtr subject = create_xacml_subject(subject_value); - ResourcePtr resource = create_xacml_resource(resourceid); - ActionPtr action = create_xacml_action(actionid); - EnvironmentPtr environment = - create_xacml_environment_profile(DEFAULT_AUTHORIZATION_PROFILE); - - return assemble_xacml_request(subject, resource, action, environment); -} - -static xacml_decision_t process_xacml_response(ResponsePtr response) { - - if (!response) { - authz_failure("Cannot process a NULL xacml response."); - } - - xacml_decision_t decision; - int results_length = xacml_response_results_length(response.get()); - srmlogit(STORM_LOG_DEBUG, __func__, "Response: %d results\n", - static_cast(results_length)); - - if (results_length == 0) { - authz_failure("Response contained no results."); - } - - if (results_length > 1) { - srmlogit(STORM_LOG_WARNING, __func__, - "Received an unexpected number of results: %d.\n", - results_length); - } - - for (int i = 0; i < results_length; i++) { - - xacml_result_t * result = 0; - - result = xacml_response_getresult(response.get(), i); - - if (i == 0) { - decision = xacml_result_getdecision(result); - srmlogit(STORM_LOG_DEBUG, __func__, - "The decision for resource %s is: %s\n", - xacml_result_getresourceid(result), - decision_tostring(decision).c_str()); - - printXACMLResult(result); - - } else { - srmlogit(STORM_LOG_DEBUG, __func__, - "Printing the content of a further response. " - "It will not be considered\n"); - - printXACMLResult(result); - } - } - - return decision; -} - -static -globus_gsi_cred_handle_t -get_gsi_credential_from_soap(soap* soap){ - - static const char* CGSI_PLUGIN_ID = "CGSI_PLUGIN_SERVER_1.0"; - - struct cgsi_plugin_data *data = - (struct cgsi_plugin_data*) soap_lookup_plugin(soap, CGSI_PLUGIN_ID); - - if (! data ){ - srmlogit(STORM_LOG_ERROR, __func__,"CGSI plugin not found!\n"); - throw storm::authorization_error("CGSI plugin not found!"); - } - - gss_ctx_id_t gss_context = data->context_handle; - if (! gss_context ){ - srmlogit(STORM_LOG_ERROR, __func__, - "Error extracting context from CGSI plugin: null context!\n"); - throw storm::authorization_error( - "Error extracting context from CGSI plugin: null context!\n"); - } - - gss_cred_id_t gss_cred = (gss_cred_id_t) gss_context->peer_cred_handle; - - if ( gss_cred == GSS_C_NO_CREDENTIAL ) { - throw storm::authorization_error("No GSS credential found!"); - } - - return gss_cred->cred_handle; -} - -static void -release_chain(STACK_OF(X509) *chain){ - sk_X509_pop_free(chain,X509_free); -} - -static -std::string -get_pem_from_cred_handle(const globus_gsi_cred_handle_t cred){ - - STACK_OF(X509) *chain_ptr = 0; - - if (globus_gsi_cred_get_cert_chain(cred, &chain_ptr)) { - throw storm::authorization_error("globus_gsi_cred_get_cert_chain failed!"); - } - - boost::shared_ptr chain(chain_ptr,release_chain); - - X509 *cert_ptr = 0; - - if (globus_gsi_cred_get_cert(cred, &cert_ptr)) { - throw storm::authorization_error("globus_gsi_cred_get_cert failed!"); - } - - boost::shared_ptr cert(cert_ptr,X509_free); - - boost::shared_ptr bio(BIO_new(BIO_s_mem()), BIO_free); - - if (!bio) { - throw storm::authorization_error("BIO_new() failed!"); - } - - if (!PEM_write_bio_X509(bio.get(),cert.get())) { - throw storm::authorization_error("PEM_write_bio_X509() failed!"); - } - - const int chain_size = sk_X509_num(chain.get()); - - for (int i=0; i < chain_size; i++){ - X509 *chain_ele = sk_X509_value(chain.get(),i); - - if (!chain_ele) break; - - if (!PEM_write_bio_X509(bio.get(), chain_ele)){ - throw storm::authorization_error("PEM_write_bio_X509() failed!"); - } - } - - char* pem_chain_buf = 0; - long pem_chain_buf_len = BIO_get_mem_data(bio.get(),&pem_chain_buf); - - if (pem_chain_buf_len <= 0){ - throw storm::authorization_error("BIO_get_mem_data() failed!"); - } - - return std::string(pem_chain_buf, pem_chain_buf_len); -} - -static -std::string -get_pem_from_soap(soap *soap){ - return get_pem_from_cred_handle(get_gsi_credential_from_soap(soap)); -} - -static bool argus_check_enabled(){ - return FrontendConfiguration::getInstance()->getUserCheckBlacklist(); -} - -static void -set_pep_option(storm::authz::PepPtr pep_handle, pep_option opt, std::string const& value){ - pep_error_t pep_rc = pep_setoption(pep_handle.get(), opt, value.c_str()); - if (pep_rc != PEP_OK){ - authz_failure(boost::format("Error setting pep option: %s") - % pep_strerror(pep_rc)); - } -} - -namespace storm{ -namespace authz{ - -PepPtr make_pep() -{ - PepPtr pep_handle(pep_initialize(), pep_destroy); - - if (pep_handle){ - authz_failure("Error building PEP client"); - } - - std::string pepd_endpoint = - FrontendConfiguration::getInstance()->getArgusPepdEndpoint(); - - if (pepd_endpoint.empty()) { - authz_failure("No ARGUS PEPD endpoint configured."); - } - - set_pep_option(pep_handle, PEP_OPTION_ENDPOINT_URL, pepd_endpoint); - - std::string key = - FrontendConfiguration::getInstance()->getHostKeyFile(); - - if (key.empty()) { - authz_failure("Empty private key."); - } - - set_pep_option(pep_handle, PEP_OPTION_ENDPOINT_CLIENT_KEY, key); - - std::string cert = - FrontendConfiguration::getInstance()->getHostCertFile(); - - if (cert.empty()) { - authz_failure("certificate is misconfigured."); - } - - set_pep_option(pep_handle, PEP_OPTION_ENDPOINT_CLIENT_CERT, cert); - - std::string ca_path = - FrontendConfiguration::getInstance()->getCaCertificatesFolder(); - - if (ca_path.empty()){ - authz_failure("ca path is misconfigured."); - } - - set_pep_option(pep_handle, PEP_OPTION_ENDPOINT_SERVER_CAPATH, ca_path); - - return pep_handle; -} - -bool is_blacklisted(soap* soap){ - - if (!argus_check_enabled()) return false; - - std::string pem_chain = get_pem_from_soap(soap); - - std::string resource_id = - FrontendConfiguration::getInstance()->getArgusResourceId(); - - if (resource_id.empty()){ - resource_id = DEFAULT_AUTHORIZATION_RESOURCE; - } - - PEP* pep_handle = static_cast(soap->user)->pep_handle; - assert(pep_handle); - - RequestPtr request_tmp = - create_xacml_request(pem_chain, resource_id, DEFAULT_AUTHORIZATION_ACTION); - - xacml_response_t* response_ptr = 0; - - xacml_request_t* request_ptr = release_raw_pointer(request_tmp); - - pep_error_t pep_rc = - pep_authorize(pep_handle, &request_ptr, &response_ptr); - - RequestPtr request(request_ptr, xacml_request_delete); - ResponsePtr response(response_ptr, xacml_response_delete); - - if (pep_rc != PEP_OK){ - authz_failure(boost::format("Failed to authorize XACML request: %s.") - % pep_strerror(pep_rc)); - } - - xacml_decision_t decision = process_xacml_response(response); - - return (decision != XACML_DECISION_PERMIT); - -} -} -} diff --git a/src/frontend/Authorization.hpp b/src/frontend/Authorization.hpp deleted file mode 100644 index e049641..0000000 --- a/src/frontend/Authorization.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AUTHORIZATION_HPP_ -#define AUTHORIZATION_HPP_ - -#include -#include -class soap; - -namespace storm { - - namespace authz { - - typedef boost::shared_ptr PepPtr; - PepPtr make_pep(); - bool is_blacklisted(soap* soap); - - } - -} - -#endif /*AUTHORIZATION_HPP_*/ diff --git a/src/frontend/FrontendConfiguration.cpp b/src/frontend/FrontendConfiguration.cpp index 9bdef34..3a512c2 100644 --- a/src/frontend/FrontendConfiguration.cpp +++ b/src/frontend/FrontendConfiguration.cpp @@ -56,9 +56,7 @@ const bool DEFAULT_MONITORING_ENABLED = true; const int DEFAULT_MONITORING_TIME_INTERVAL = 60; const bool DEFAULT_MONITORING_DETAILED = false; const bool DEFAULT_XMLRPC_CHECK_ASCII = true; -const bool DEFAULT_USER_CHECK_BLACKLIST = false; const string DEFAULT_CA_CERTIFICATES_FOLDER = string("/etc/grid-security/certificates"); -const string DEFAULT_ARGUS_RESOURCE_ID = "storm"; const char* EMPTY_DESCRIPTION = ""; @@ -149,16 +147,6 @@ const char* OPT_DB_USER_PASSWORD_DESCRIPTION = "Database user password"; const string OPTL_XMLRPC_CHECK_ASCII = string("be.xmlrpc.check.ascii"); const char* OPT_XMLRPC_CHECK_ASCII_DESCRIPTION = "Flag to check or not strings to be sent via xmlrpc to the BE"; -const string OPTL_USER_CHECK_BLACKLIST = string("check.user.blacklisting"); -const char* OPT_USER_CHECK_BLACKLIST_DESCRIPTION = "Flag to check or not strings if a user is blacklisted in Argus"; - -const string OPTL_ARGUS_PEPD_ENDPOINT = string("argus-pepd-endpoint"); -const char* OPT_ARGUS_PEPD_ENDPOINT_DESCRIPTION = "Full SERVICE ENDPOINT of the Argus PEP Daemon"; - -const string OPTL_ARGUS_RESOURCE_ID = string("argus.resource-id"); -const char* OPT_ARGUS_RESOURCE_ID_DESCRIPTION = "the resource identifier for StoRM service in Argus policies"; - - FrontendConfiguration* FrontendConfiguration::instance = NULL; FrontendConfiguration* FrontendConfiguration::getInstance() { @@ -383,18 +371,6 @@ bool FrontendConfiguration::getXMLRPCCheckAscii() { return xmlrpc_check_ascii; } -bool FrontendConfiguration::getUserCheckBlacklist() { - return user_check_blacklist; -} - -string FrontendConfiguration::getArgusPepdEndpoint() { - return argus_pepd_endpoint; -} - -string FrontendConfiguration::getArgusResourceId() { - return argus_resource_id; -} - string FrontendConfiguration::getCaCertificatesFolder() { return ca_certificates_folder; } @@ -434,10 +410,7 @@ po::options_description FrontendConfiguration::defineConfigFileOptions() { (OPTL_DB_USER.c_str(), po::value(), OPT_DB_USER_DESCRIPTION) (OPTL_DB_USER_PASSWORD.c_str(), po::value(), OPT_DB_USER_PASSWORD_DESCRIPTION) (OPTL_ENABLE_MAPPING.c_str(), po::value()->default_value(false), OPT_ENABLE_MAPPING_DESCRIPTION) - (OPTL_ENABLE_VOMSCHECK.c_str(), po::value()->default_value(true), OPT_ENABLE_VOMSCHECK_DESCRIPTION) - (OPTL_USER_CHECK_BLACKLIST.c_str(), po::value()->default_value(DEFAULT_USER_CHECK_BLACKLIST), OPT_USER_CHECK_BLACKLIST_DESCRIPTION) - (OPTL_ARGUS_PEPD_ENDPOINT.c_str(), po::value(), OPT_ARGUS_PEPD_ENDPOINT_DESCRIPTION) - (OPTL_ARGUS_RESOURCE_ID.c_str(), po::value()->default_value(DEFAULT_ARGUS_RESOURCE_ID), OPT_ARGUS_RESOURCE_ID_DESCRIPTION); + (OPTL_ENABLE_VOMSCHECK.c_str(), po::value()->default_value(true), OPT_ENABLE_VOMSCHECK_DESCRIPTION); return configurationFileOptions; } @@ -520,15 +493,6 @@ void FrontendConfiguration::setConfigurationOptions(po::variables_map& vm) { if (vm.count(OPTL_DB_USER_PASSWORD)) dbUserPassword = vm[OPTL_DB_USER_PASSWORD].as (); - if (vm.count(OPTL_USER_CHECK_BLACKLIST)) - user_check_blacklist = vm[OPTL_USER_CHECK_BLACKLIST].as (); - - if (vm.count(OPTL_ARGUS_PEPD_ENDPOINT)) - argus_pepd_endpoint = vm[OPTL_ARGUS_PEPD_ENDPOINT].as (); - - if (vm.count(OPTL_ARGUS_RESOURCE_ID)) - argus_resource_id = vm[OPTL_ARGUS_RESOURCE_ID].as (); - log_file = vm[OPTL_LOG_FILE_NAME].as (); monitoring_file = vm[OPTL_MONITORING_FILE_NAME].as (); monitoringEnabled = vm[OPTL_MONITORING_ENABLED].as (); diff --git a/src/frontend/FrontendConfiguration.hpp b/src/frontend/FrontendConfiguration.hpp index 1eedd7a..30a00a6 100644 --- a/src/frontend/FrontendConfiguration.hpp +++ b/src/frontend/FrontendConfiguration.hpp @@ -52,8 +52,6 @@ extern const std::string OPTL_RECALLTABLE_PORT; extern const std::string OPTL_WSDL_FILE; extern const std::string OPTL_DB_HOST; extern const std::string OPTL_DB_USER; -extern const std::string OPTL_ARGUS_PEPD_ENDPOINT; -extern const std::string OPTL_ARGUS_RESOURCE_ID; // A helper function to simplify printing options stuff template @@ -112,9 +110,6 @@ class FrontendConfiguration { std::string getHostCertFile(); std::string getHostKeyFile(); bool getXMLRPCCheckAscii(); - bool getUserCheckBlacklist(); - std::string getArgusPepdEndpoint(); - std::string getArgusResourceId(); std::string getCaCertificatesFolder(); private: @@ -171,9 +166,6 @@ class FrontendConfiguration { std::string hostcertfile; std::string hostkeyfile; bool xmlrpc_check_ascii; - bool user_check_blacklist; - std::string argus_pepd_endpoint; - std::string argus_resource_id; std::string ca_certificates_folder; }; diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index a23be1e..e33df7f 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -1,6 +1,3 @@ -# $Id$ - -# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,14 +33,11 @@ storm_frontend_server_LDADD = \ @XMLRPC_LIBS@ \ @LIBCURL_LIBS@ \ @GLOBUS_COMMON_LIBS@ \ - @GLOBUS_GSI_CREDENTIAL_LIBS@ \ - @GLOBUS_GSS_ASSIST_LIBS@ \ @GSOAP_SSL_PP_LIBS@ \ @CGSI_GSOAP_PLUGIN_LIBS@ \ @BOOST_PROGRAM_OPTIONS_LIBS@ \ @BOOST_THREAD_LIBS@ \ @BOOST_REGEX_LIBS@ \ - @LIBARGUS_PEP_LIBS@ \ @UUID_LIBS@ storm_frontend_server_LDFLAGS= \ @@ -106,7 +100,6 @@ stormfrontend_others = storm_exception.hpp \ GetTransferProtocolsRequest.cpp GetTransferProtocolsRequest.hpp \ PingRequest.cpp PingRequest.hpp \ ProtocolChecker.cpp ProtocolChecker.hpp \ - Authorization.cpp Authorization.hpp \ cgsi_plugin_int.h \ gssapi_openssl.h globus_gsi_gss_constants.h \ asynch.cpp asynch_status.cpp \ @@ -141,13 +134,9 @@ AM_CPPFLAGS = \ @LIBCURL_CFLAGS@ \ @XMLRPC_CFLAGS@ \ @UUID_CFLAGS@ \ - @GLOBUS_GRIDMAP_CALLOUT_ERROR_CFLAGS@ \ - @GLOBUS_GSI_CREDENTIAL_CFLAGS@ \ - @GLOBUS_GSS_ASSIST_CFLAGS@ \ @GLOBUS_COMMON_CFLAGS@ \ @GSOAP_SSL_PP_CFLAGS@ \ @MYSQL_CFLAGS@ \ - @LIBARGUS_PEP_CFLAGS@ \ $(MTC_CFLAGS) MAINTAINERCLEANFILES = Makefile.in \ diff --git a/src/frontend/asynch.cpp b/src/frontend/asynch.cpp index 7bb687d..bd9c995 100644 --- a/src/frontend/asynch.cpp +++ b/src/frontend/asynch.cpp @@ -22,7 +22,6 @@ #include "BolRequest.hpp" #include "Credentials.hpp" -#include "Authorization.hpp" #include "MonitoringHelper.hpp" #include "get_socket_info.hpp" @@ -44,58 +43,6 @@ int ns1__srmPrepareToPut(struct soap *soap, struct ns1__srmPrepareToPutRequest * srmLogRequestWithSurls("PTP", get_ip(soap).c_str(), request.getClientDN().c_str(), request.getSurlsList().c_str(), request.getSurlsNumber()); - bool blacklisted = false; - try - { - blacklisted = storm::authz::is_blacklisted(soap); - }catch( storm::authorization_error& e){ - - srmlogit(STORM_LOG_ERROR, funcName, "Unable to check user blacklisting. Error: %s\n" , e.what()); - request.invalidateRequestToken(); - try - { - rep->srmPrepareToPutResponse = request.buildSpecificResponse(SRM_USCOREFAILURE, "Unable to check user blacklisting"); - } catch(storm::storm_error &exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_PREPARE_TO_PUT_MONITOR_NAME); - srmLogResponse("PTP", SRM_USCOREFAILURE); - return soap_sender_fault(soap,e.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_PREPARE_TO_PUT_MONITOR_NAME, - request.getStatus()); - srmLogResponse("PTP", request.getStatus()); - return(SOAP_OK); - } - - if(blacklisted) - { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - request.invalidateRequestToken(); - request.setAuthorizationFailureSurls(); - try - { - rep->srmPrepareToPutResponse = request.buildSpecificResponse(SRM_USCOREAUTHORIZATION_USCOREFAILURE, "User not authorized"); - } catch(storm::storm_error &e) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , e.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_PREPARE_TO_PUT_MONITOR_NAME); - srmLogResponse("PTP", SRM_USCOREFAILURE); - return soap_sender_fault(soap,e.what(),0); - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_PREPARE_TO_PUT_MONITOR_NAME, - request.getStatus()); - srmLogResponse("PTP", request.getStatus()); - return(SOAP_OK); - } - else - { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - } int soap_status = __process_file_request ( soap, request, funcName, req, &rep->srmPrepareToPutResponse); @@ -136,58 +83,6 @@ int ns1__srmPrepareToGet(struct soap *soap, struct ns1__srmPrepareToGetRequest * srmLogRequestWithSurls("PTG", get_ip(soap).c_str(), request.getClientDN().c_str(), request.getSurlsList().c_str(), request.getSurlsNumber()); - bool blacklisted = false; - try - { - blacklisted = storm::authz::is_blacklisted(soap); - }catch( storm::authorization_error& e) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to check user blacklisting. Error: %s\n" , e.what()); - request.invalidateRequestToken(); - try - { - rep->srmPrepareToGetResponse = request.buildSpecificResponse(SRM_USCOREFAILURE, "Unable to check user blacklisting"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_PREPARE_TO_GET_MONITOR_NAME); - srmLogResponse("PTG", SRM_USCOREFAILURE); - return soap_sender_fault(soap,e.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_PREPARE_TO_GET_MONITOR_NAME, - request.getStatus()); - srmLogResponse("PTG", request.getStatus()); - return(SOAP_OK); - } - - if(blacklisted) - { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - request.invalidateRequestToken(); - request.setAuthorizationFailureSurls(); - try - { - rep->srmPrepareToGetResponse = request.buildSpecificResponse(SRM_USCOREAUTHORIZATION_USCOREFAILURE, "User not authorized"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_PREPARE_TO_GET_MONITOR_NAME); - srmLogResponse("PTG", SRM_USCOREFAILURE); - return soap_sender_fault(soap,exc.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_PREPARE_TO_GET_MONITOR_NAME, - request.getStatus()); - srmLogResponse("PTG", request.getStatus()); - return(SOAP_OK); - } - else - { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - } int soap_status = __process_file_request ( soap, request, funcName, req, &rep->srmPrepareToGetResponse); @@ -265,58 +160,6 @@ int ns1__srmBringOnline(struct soap *soap, struct ns1__srmBringOnlineRequest *re srmLogRequestWithSurls("BOL", get_ip(soap).c_str(), request.getClientDN().c_str(), request.getSurlsList().c_str(), request.getSurlsNumber()); - bool blacklisted = false; - try - { - blacklisted = storm::authz::is_blacklisted(soap); - }catch( storm::authorization_error& e) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to check user blacklisting. Error: %s\n" , e.what()); - request.invalidateRequestToken(); - request.setAuthorizationFailureSurls(); - try - { - rep->srmBringOnlineResponse = request.buildSpecificResponse(SRM_USCOREFAILURE, "Unable to check user blacklisting"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_BRING_ONLINE_MONITOR_NAME); - srmLogResponse("BOL", SRM_USCOREFAILURE); - return soap_sender_fault(soap,e.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_BRING_ONLINE_MONITOR_NAME, - request.getStatus()); - srmLogResponse("BOL", request.getStatus()); - return(SOAP_OK); - } - - if(blacklisted) - { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - request.invalidateRequestToken(); - try - { - rep->srmBringOnlineResponse = request.buildSpecificResponse(SRM_USCOREAUTHORIZATION_USCOREFAILURE, "User not authorized"); - } catch(storm::storm_error& exc) - { - srmlogit(STORM_LOG_ERROR, funcName, "Unable to build soap response. %s\n" , exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_BRING_ONLINE_MONITOR_NAME); - srmLogResponse("BOL", SRM_USCOREFAILURE); - return soap_sender_fault(soap,exc.what(),0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_BRING_ONLINE_MONITOR_NAME, - request.getStatus()); - srmLogResponse("BOL", request.getStatus()); - return(SOAP_OK); - } - else - { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - } int soap_status = __process_file_request ( soap, request, funcName, req, &rep->srmBringOnlineResponse); diff --git a/src/frontend/asynch_status.cpp b/src/frontend/asynch_status.cpp index 82edaeb..c41d8c0 100644 --- a/src/frontend/asynch_status.cpp +++ b/src/frontend/asynch_status.cpp @@ -32,7 +32,6 @@ #include #include "MonitoringHelper.hpp" #include "Credentials.hpp" -#include "Authorization.hpp" #include "get_socket_info.hpp" #include "base_request.hpp" @@ -60,32 +59,6 @@ int ns1__srmStatusOfPutRequest(struct soap *soap, request.getRequestToken().c_str()); } - bool const is_blacklisted = storm::authz::is_blacklisted(soap); - - if (is_blacklisted) { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - try { - rep->srmStatusOfPutRequestResponse = request.buildSpecificResponse( - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - "User not authorized"); - } catch (std::runtime_error& exc) { - srmlogit(STORM_LOG_ERROR, funcName, - "Unable to build soap response. logic_error: %s\n", - exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_STATUS_OF_PUT_REQUEST_MONITOR_NAME); - srmLogResponse("PTP status", SRM_USCOREFAILURE); - return soap_sender_fault(soap, exc.what(), 0); - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_STATUS_OF_PUT_REQUEST_MONITOR_NAME, - request.getStatus()); - srmLogResponse("PTP status", request.getStatus()); - return (SOAP_OK); - } - - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - soap_status = processRequestStatus(soap, funcName, request, &rep->srmStatusOfPutRequestResponse); @@ -105,18 +78,6 @@ int ns1__srmStatusOfPutRequest(struct soap *soap, ns1__srmStatusOfPutRequestResponse>(soap, SRM_USCOREINVALID_USCOREREQUEST, e.what()); - } catch (storm::authorization_error const& e) { - - storm::request::register_request_error( - __func__, SRM_USCOREAUTHORIZATION_USCOREFAILURE, start_time, - boost::str(boost::format("%s\n") % e.what())); - - rep->srmStatusOfPutRequestResponse = - storm::build_error_message_response< - ns1__srmStatusOfPutRequestResponse>(soap, - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - e.what()); - } return soap_status; @@ -141,49 +102,6 @@ extern "C" int ns1__srmStatusOfGetRequest(struct soap *soap, request.getRequestToken().c_str()); } - bool is_blacklisted; - - try { - is_blacklisted = storm::authz::is_blacklisted(soap); - - } catch ( storm::authorization_error& e ){ - - storm::request::register_request_error( - __func__, SRM_USCOREAUTHORIZATION_USCOREFAILURE, start_time, - boost::str(boost::format("%s\n") % e.what())); - - rep->srmStatusOfGetRequestResponse = - storm::build_error_message_response< - ns1__srmStatusOfGetRequestResponse>(soap, - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - e.what()); - - return SOAP_OK; - } - - if ( is_blacklisted ){ - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - try { - rep->srmStatusOfGetRequestResponse = request.buildSpecificResponse( - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - "User not authorized"); - } catch (std::runtime_error& exc) { - srmlogit(STORM_LOG_ERROR, funcName, - "Unable to build soap response. logic_error: %s\n", - exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_STATUS_OF_GET_REQUEST_MONITOR_NAME); - srmLogResponse("PTG status", SRM_USCOREFAILURE); - return soap_sender_fault(soap, exc.what(), 0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_STATUS_OF_GET_REQUEST_MONITOR_NAME, - request.getStatus()); - srmLogResponse("PTG status", request.getStatus()); - return (SOAP_OK); - } else { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - } int soap_status = processRequestStatus(soap, funcName, request, @@ -225,51 +143,6 @@ extern "C" int ns1__srmStatusOfBringOnlineRequest(struct soap *soap, request.getCredentials().getDN().c_str(), request.getRequestToken().c_str()); } - - bool is_blacklisted; - - try { - is_blacklisted = storm::authz::is_blacklisted(soap); - - } catch ( storm::authorization_error& e ){ - - storm::request::register_request_error( - __func__, SRM_USCOREAUTHORIZATION_USCOREFAILURE, start_time, - boost::str(boost::format("%s\n") % e.what())); - - rep->srmStatusOfBringOnlineRequestResponse = - storm::build_error_message_response< - ns1__srmStatusOfBringOnlineRequestResponse>(soap, - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - e.what()); - - return SOAP_OK; - } - - if ( is_blacklisted ) { - srmlogit(STORM_LOG_INFO, funcName, "The user is blacklisted\n"); - try { - rep->srmStatusOfBringOnlineRequestResponse = - request.buildSpecificResponse( - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - "User not authorized"); - } catch (std::runtime_error& exc) { - srmlogit(STORM_LOG_ERROR, funcName, - "Unable to build soap response. logic_error: %s\n", - exc.what()); - storm::MonitoringHelper::registerOperationError(start_time, - storm::SRM_STATUS_OF_BRING_ONLINE_REQUEST_MONITOR_NAME); - srmLogResponse("BOL status", SRM_USCOREFAILURE); - return soap_sender_fault(soap, exc.what(), 0);; - } - storm::MonitoringHelper::registerOperation(start_time, - storm::SRM_STATUS_OF_BRING_ONLINE_REQUEST_MONITOR_NAME, - request.getStatus()); - srmLogResponse("BOL status", request.getStatus()); - return (SOAP_OK); - } else { - srmlogit(STORM_LOG_DEBUG, funcName, "The user is not blacklisted\n"); - } int soap_status = processRequestStatus< ns1__srmStatusOfBringOnlineRequestRequest, diff --git a/src/frontend/srm_server.h b/src/frontend/srm_server.h index c2f4849..5bb564c 100644 --- a/src/frontend/srm_server.h +++ b/src/frontend/srm_server.h @@ -18,7 +18,6 @@ #define _SRM_SERVER_H #include -#include extern char *xmlrpc_endpoint; @@ -31,7 +30,6 @@ struct srm_dbfd { struct srm_srv_thread_info { srm_dbfd dbfd; const char* request_id; - PEP* pep_handle; }; #endif /* _SRM_SERVER_H */ diff --git a/src/frontend/srmv2_GetRequestSummary.cpp b/src/frontend/srmv2_GetRequestSummary.cpp index d14485c..7aa00d8 100644 --- a/src/frontend/srmv2_GetRequestSummary.cpp +++ b/src/frontend/srmv2_GetRequestSummary.cpp @@ -25,7 +25,6 @@ #include "mysql_query.hpp" #include "storm_mysql.hpp" -#include "Authorization.hpp" #include "MonitoringHelper.hpp" #include #include "Credentials.hpp" @@ -111,18 +110,6 @@ extern "C" int ns1__srmGetRequestSummary(struct soap *soap, } srmlogit(STORM_LOG_INFO, func, "UserDN=%s\n", credentials.getDN().c_str()); - if(storm::authz::is_blacklisted(soap)) - { - srmlogit(STORM_LOG_INFO, func, "The user is blacklisted\n"); - repp->returnStatus->statusCode = SRM_USCOREAUTHORIZATION_USCOREFAILURE; - repp->returnStatus->explanation = const_cast("User not authorized"); - storm::MonitoringHelper::registerOperationFailure(start_time, storm::SRM_GET_REQUEST_SUMMARY_MONITOR_NAME); - return SOAP_OK; - } - else - { - srmlogit(STORM_LOG_DEBUG, func, "The user is not blacklisted\n"); - } // Check for a valid input if (!validate_array_of_req_tokens(func, req->arrayOfRequestTokens)) { srmlogit(STORM_LOG_ERROR, func, "Invalid 'arrayOfRequestTokens'\n"); diff --git a/src/frontend/srmv2_GetRequestTokens.cpp b/src/frontend/srmv2_GetRequestTokens.cpp index 9f7b85a..beb9fd0 100644 --- a/src/frontend/srmv2_GetRequestTokens.cpp +++ b/src/frontend/srmv2_GetRequestTokens.cpp @@ -24,7 +24,6 @@ #include "mysql_query.hpp" #include "storm_mysql.hpp" -#include "Authorization.hpp" #include "MonitoringHelper.hpp" #include @@ -62,19 +61,6 @@ extern "C" int ns1__srmGetRequestTokens(struct soap *soap, storm::MonitoringHelper::registerOperationError(start_time, storm::SRM_GET_REQUEST_TOKENS_MONITOR_NAME); return SOAP_OK; } - - if(storm::authz::is_blacklisted(soap)) - { - srmlogit(STORM_LOG_INFO, func, "The user is blacklisted\n"); - repp->returnStatus->statusCode = SRM_USCOREAUTHORIZATION_USCOREFAILURE; - repp->returnStatus->explanation = const_cast("User not authorized"); - storm::MonitoringHelper::registerOperationFailure(start_time, storm::SRM_GET_REQUEST_TOKENS_MONITOR_NAME); - return SOAP_OK; - } - else - { - srmlogit(STORM_LOG_DEBUG, func, "The user is not blacklisted\n"); - } // TODO ping db connection? diff --git a/src/frontend/storm-frontend.cpp b/src/frontend/storm-frontend.cpp index 9dea97f..8f7cfb2 100644 --- a/src/frontend/storm-frontend.cpp +++ b/src/frontend/storm-frontend.cpp @@ -51,7 +51,6 @@ namespace dt = boost::posix_time; #include "storm_exception.hpp" #include "request_id.hpp" #include "get_socket_info.hpp" -#include "Authorization.hpp" #include #define NAME "StoRM SRM v2.2" @@ -72,25 +71,6 @@ static int gsoap_recv_timeout = 10; int const SYERR = 2; // system error -static std::vector peps; - -void create_peps(int n) -{ - assert(n >= 0); - assert(peps.empty()); - - peps.reserve(n); - for (int i = 0; i != n; ++i) { - peps.push_back(storm::authz::make_pep()); - } -} - -PEP* get_pep(int thread_num) -{ - assert(thread_num >= 0 && static_cast(thread_num) < peps.size()); - return peps[thread_num].get(); -} - void sigint_handler(int /* sig */) { srmlogit(STORM_LOG_INFO, __func__, "Signal SIGINT received: shutting down...\n"); @@ -142,10 +122,6 @@ process_request(struct soap* tsoap) { // explicitly manage the request id here since threadinfo is not // destroyed for each request but kept in the database connection pool thread_info->request_id = storm::get_request_id(); - thread_info->pep_handle = - FrontendConfiguration::getInstance()->getUserCheckBlacklist() - ? get_pep(storm::ThreadPool::getInstance()->getThreadNumber(boost::this_thread::get_id())) - : 0; tsoap->user = thread_info; @@ -275,12 +251,6 @@ void logConfiguration() { srmlogit(STORM_LOG_NONE, __func__, "%s=%u\n", OPTL_MONITORING_TIME_INTERVAL.c_str(), configuration->getMonitoringTimeInterval()); - srmlogit(STORM_LOG_NONE, __func__, "%s=%s\n", - OPTL_ARGUS_PEPD_ENDPOINT.c_str(), - configuration->getArgusPepdEndpoint().c_str()); - srmlogit(STORM_LOG_NONE, __func__, "%s=%s\n", - OPTL_ARGUS_RESOURCE_ID.c_str(), - configuration->getArgusResourceId().c_str()); srmlogit(STORM_LOG_NONE, __func__, "xmlrpc endpoint=%s\n", configuration->getXMLRPCEndpoint().c_str()); srmlogit(STORM_LOG_NONE, __func__, "%s=%d\n", OPTL_RECALLTABLE_PORT.c_str(), @@ -578,10 +548,6 @@ int main(int argc, char** argv) { if (pid > 0) { return 0; } - } - - if (FrontendConfiguration::getInstance()->getUserCheckBlacklist()) { - create_peps(configuration->getNumThreads()); } curl_global_init(CURL_GLOBAL_ALL); diff --git a/src/frontend/storm_exception.hpp b/src/frontend/storm_exception.hpp index 3672d0a..c8135de 100644 --- a/src/frontend/storm_exception.hpp +++ b/src/frontend/storm_exception.hpp @@ -35,19 +35,6 @@ struct invalid_response: public storm_error { } }; -struct authorization_error: public storm_error { - authorization_error(std::string const& m): - storm_error(m) { - } -}; - -struct argus_error: public storm_error { - argus_error(std::string const& m): - storm_error(m) { - } -}; - - struct token_not_found: public invalid_request { token_not_found(std::string const& m) : invalid_request(m) { diff --git a/src/frontend/synch.cpp b/src/frontend/synch.cpp index 1d7cc60..4cd1981 100644 --- a/src/frontend/synch.cpp +++ b/src/frontend/synch.cpp @@ -22,7 +22,6 @@ #include "srmlogit.h" #include "get_socket_info.hpp" -#include "Authorization.hpp" #include "soap_util.hpp" #include "synch.hpp" #include "storm_exception.hpp" @@ -51,23 +50,6 @@ int handle_request(const char* func_name, struct soap* soap, logger.log_request(func_name, request); - bool const request_is_blacklisted = - storm::authz::is_blacklisted(request.getSoapRequest()); - - if (request_is_blacklisted) { - - *soap_resp = storm::build_error_message_response(soap, - SRM_USCOREAUTHORIZATION_USCOREFAILURE, - "Request authorization error: user is blacklisted."); - - storm::request::register_request_error(func_name, - SRM_USCOREAUTHORIZATION_USCOREFAILURE, start_time, - "Request authorization error: user is blacklisted.\n"); - - return SOAP_OK; - } - - // Request is authorized, handle it int const soap_return_value = request.performXmlRpcCall(response_container); storm::MonitoringHelper::registerOperation( @@ -92,17 +74,6 @@ int handle_request(const char* func_name, struct soap* soap, return SOAP_OK; - } catch (storm::authorization_error& e) { - - *soap_resp = storm::build_error_message_response(soap, - SRM_USCOREFAILURE, e.what()); - - storm::request::register_request_error(func_name, SRM_USCOREFAILURE, - start_time, - str(format("Error authorizing request: %s\n") % e.what())); - - return SOAP_OK; - } } diff --git a/src/frontend/xacml_utils.hpp b/src/frontend/xacml_utils.hpp deleted file mode 100644 index ed1c825..0000000 --- a/src/frontend/xacml_utils.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef XACML_UTILS_HPP -#define XACML_UTILS_HPP - -#include -#include -#include "argus/pep.h" - -namespace storm { -namespace authz { - -template -class XacmlDeleter -{ - bool released_; - typedef void (*DeleteFunction)(T*); - DeleteFunction delete_fun_; - public: - XacmlDeleter(DeleteFunction delete_fun) - : released_(false), delete_fun_(delete_fun) - {} - void release() { released_ = true; } - void operator()(T* p) { - if (!released_) delete_fun_(p); - } - private: -}; - -template -inline XacmlDeleter make_deleter(void d(T*)) -{ - return XacmlDeleter(d); -} - -template -inline T* release_raw_pointer(boost::shared_ptr p) -{ - typedef XacmlDeleter Deleter; - Deleter* deleter = boost::get_deleter(p); - assert(deleter && "the deleter is not a release deleter"); - deleter->release(); - return p.get(); -} - -typedef boost::shared_ptr SubjectPtr; -typedef boost::shared_ptr ActionPtr; -typedef boost::shared_ptr ResourcePtr; -typedef boost::shared_ptr EnvironmentPtr; -typedef boost::shared_ptr AttributePtr; -typedef boost::shared_ptr RequestPtr; -typedef boost::shared_ptr ResponsePtr; - -inline SubjectPtr make_subject() -{ - return SubjectPtr(xacml_subject_create(), make_deleter(xacml_subject_delete)); -} - -inline ActionPtr make_action() -{ - return ActionPtr(xacml_action_create(), make_deleter(xacml_action_delete)); -} - -inline ResourcePtr make_resource() -{ - return - ResourcePtr(xacml_resource_create(), make_deleter(xacml_resource_delete)); -} - -inline EnvironmentPtr make_environment() -{ - return - EnvironmentPtr( - xacml_environment_create(), - make_deleter(xacml_environment_delete) - ); -} - -inline AttributePtr make_attribute(char const* attribute_id) -{ - return - AttributePtr( - xacml_attribute_create(attribute_id), - make_deleter(xacml_attribute_delete) - ); -} - -inline RequestPtr make_request() -{ - return RequestPtr(xacml_request_create(), make_deleter(xacml_request_delete)); -} - -}} - -#endif From c0334f63ead18257802e300aef39c8109fa6cd05 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 14:51:17 +0000 Subject: [PATCH 02/16] Use the recommended boost.bind header --- src/frontend/Monitoring.hpp | 2 +- src/frontend/ThreadPool.hpp | 2 +- src/frontend/storm-frontend.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frontend/Monitoring.hpp b/src/frontend/Monitoring.hpp index 83053d7..fda9b8d 100644 --- a/src/frontend/Monitoring.hpp +++ b/src/frontend/Monitoring.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include diff --git a/src/frontend/ThreadPool.hpp b/src/frontend/ThreadPool.hpp index 72ae874..7871f1b 100644 --- a/src/frontend/ThreadPool.hpp +++ b/src/frontend/ThreadPool.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/frontend/storm-frontend.cpp b/src/frontend/storm-frontend.cpp index 8f7cfb2..fde372f 100644 --- a/src/frontend/storm-frontend.cpp +++ b/src/frontend/storm-frontend.cpp @@ -37,7 +37,7 @@ namespace dt = boost::posix_time; #include "FrontendConfiguration.hpp" #include "ThreadPool.hpp" -#include +#include #include "DBConnectionPool.hpp" #include #include "frontend_version.h" @@ -548,7 +548,7 @@ int main(int argc, char** argv) { if (pid > 0) { return 0; } - } + } curl_global_init(CURL_GLOBAL_ALL); From 2224e3ee13368e69b58b8e3d4a8dbbe28055c32d Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 14:53:07 +0000 Subject: [PATCH 03/16] Update boost.m4 There is a set of boost m4s in the aclocal package distribution, but this one seems more recent. --- m4/boost.m4 | 282 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 212 insertions(+), 70 deletions(-) diff --git a/m4/boost.m4 b/m4/boost.m4 index 96b4b54..6a822af 100644 --- a/m4/boost.m4 +++ b/m4/boost.m4 @@ -22,7 +22,7 @@ # along with this program. If not, see . m4_define([_BOOST_SERIAL], [m4_translit([ -# serial 27 +# serial 39 ], [# ], [])]) @@ -226,7 +226,7 @@ AC_LANG_POP([C++])dnl AC_CACHE_CHECK([for Boost's header version], [boost_cv_lib_version], [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl - _BOOST_SED_CPP([[/^boost-lib-version = /{s///;s/[\" ]//g;p;q;}]], + _BOOST_SED_CPP([[/^.*boost-lib-version = /{s///;s/[\" ]//g;p;q;}]], [#include boost-lib-version = BOOST_LIB_VERSION], [boost_cv_lib_version=`cat conftest.i`])]) @@ -288,14 +288,17 @@ fi # BOOST_FIND_LIBS([COMPONENT-NAME], [CANDIDATE-LIB-NAMES], # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], -# [CXX-PROLOGUE]) +# [CXX-PROLOGUE], [CXX-POST-INCLUDE-PROLOGUE], +# [ERROR_ON_UNUSABLE]) # -------------------------------------------------------------- # Look for the Boost library COMPONENT-NAME (e.g., `thread', for # libboost_thread) under the possible CANDIDATE-LIB-NAMES (e.g., # "thread_win32 thread"). Check that HEADER-NAME works and check that # libboost_LIB-NAME can link with the code CXX-TEST. The optional # argument CXX-PROLOGUE can be used to include some C++ code before -# the `main' function. +# the `main' function. The CXX-POST-INCLUDE-PROLOGUE can be used to +# include some code before the `main' function, but after the +# `#include '. # # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above). # @@ -309,6 +312,9 @@ fi # builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp # ... If you want to make sure you have a specific version of Boost # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro. +# +# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their +# configure to fail AC_DEFUN([BOOST_FIND_LIBS], [AC_REQUIRE([BOOST_REQUIRE])dnl AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl @@ -323,7 +329,8 @@ AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl -BOOST_FIND_HEADER([$4]) +AS_IF([test x"$8" = "xno"], [not_found_header='true']) +BOOST_FIND_HEADER([$4], [$not_found_header]) boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib], @@ -337,7 +344,9 @@ case $Boost_lib in #( AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl ;; (no) _AC_MSG_LOG_CONFTEST - AC_MSG_ERROR([cannot find flags to link with the Boost $1 library (libboost-$1)]) + AS_IF([test x"$8" != "xno"], [ + AC_MSG_ERROR([cannot find flags to link with the Boost $1 library (libboost-$1)]) + ]) ;; esac CPPFLAGS=$boost_save_CPPFLAGS @@ -352,16 +361,20 @@ fi # BOOST_FIND_LIB([LIB-NAME], # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], -# [CXX-PROLOGUE]) +# [CXX-PROLOGUE], [CXX-POST-INCLUDE-PROLOGUE], +# [ERROR_ON_UNUSABLE]) # -------------------------------------------------------------- # Backward compatibility wrapper for BOOST_FIND_LIBS. +# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their +# configure to fail AC_DEFUN([BOOST_FIND_LIB], [BOOST_FIND_LIBS([$1], $@)]) # _BOOST_FIND_LIBS([LIB-NAME], [CANDIDATE-LIB-NAMES], # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], -# [CXX-PROLOGUE]) +# [CXX-PROLOGUE], [CXX-POST-INCLUDE-PROLOGUE], +# [ERROR_ON_UNUSABLE]) # -------------------------------------------------------------- # Real implementation of BOOST_FIND_LIBS: rely on these local macros: # Boost_lib, Boost_lib_LDFLAGS, Boost_lib_LDPATH, Boost_lib_LIBS @@ -373,6 +386,9 @@ AC_DEFUN([BOOST_FIND_LIB], # usually installed. If we can't find the standard variants, we try # to enforce -mt (for instance on MacOSX, libboost_thread.dylib # doesn't exist but there's -obviously- libboost_thread-mt.dylib). +# +# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their +# configure to fail AC_DEFUN([_BOOST_FIND_LIBS], [Boost_lib=no case "$3" in #( @@ -420,7 +436,10 @@ dnl empty because the test file is generated only once above (before we dnl start the for loops). AC_COMPILE_IFELSE([], [ac_objext=do_not_rm_me_plz], - [AC_MSG_ERROR([cannot compile a test that uses Boost $1])]) + [AS_IF([test x"$8" != x"no"], [ + AC_MSG_ERROR([cannot compile a test that uses Boost $1]) + ]) + ]) ac_objext=$boost_save_ac_objext boost_failed_libs= # Don't bother to ident the following nested for loops, only the 2 @@ -578,7 +597,7 @@ BOOST_DEFUN([Assign], [BOOST_FIND_HEADER([boost/assign.hpp])]) -# BOOST_ATOMIC([PREFERRED-RT-OPT]) +# BOOST_ATOMIC([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------- # Look for Boost.Atomic. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. @@ -592,7 +611,7 @@ BOOST_DEFUN([Atomic], #endif #ifdef HAVE_STDINT_H #include -#endif]) +#endif], [$2]) ])# BOOST_ATOMIC @@ -600,7 +619,7 @@ BOOST_DEFUN([Atomic], # ------------ # Look for Boost.Bind. BOOST_DEFUN([Bind], -[BOOST_FIND_HEADER([boost/bind.hpp])]) +[BOOST_FIND_HEADER([boost/bind/bind.hpp])]) # BOOST_CAST() @@ -610,7 +629,7 @@ BOOST_DEFUN([Cast], [BOOST_FIND_HEADER([boost/cast.hpp])]) -# BOOST_CHRONO() +# BOOST_CHRONO([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # -------------- # Look for Boost.Chrono. BOOST_DEFUN([Chrono], @@ -618,7 +637,7 @@ BOOST_DEFUN([Chrono], # added as of 1.35.0. If we have a version <1.35, we must not attempt to # find Boost.System as it didn't exist by then. if test $boost_major_version -ge 135; then - BOOST_SYSTEM([$1]) + BOOST_SYSTEM([$1], [$2]) fi # end of the Boost.System check. boost_filesystem_save_LIBS=$LIBS boost_filesystem_save_LDFLAGS=$LDFLAGS @@ -627,7 +646,7 @@ LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIB([chrono], [$1], [boost/chrono.hpp], - [boost::chrono::thread_clock d;]) + [boost::chrono::thread_clock d;], [], [], [$2]) if test $enable_static_boost = yes && test $boost_major_version -ge 135; then BOOST_CHRONO_LIBS="$BOOST_CHRONO_LIBS $BOOST_SYSTEM_LIBS" fi @@ -636,7 +655,7 @@ LDFLAGS=$boost_filesystem_save_LDFLAGS ])# BOOST_CHRONO -# BOOST_CONTEXT([PREFERRED-RT-OPT]) +# BOOST_CONTEXT([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------- # Look for Boost.Context. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. @@ -644,15 +663,74 @@ LDFLAGS=$boost_filesystem_save_LDFLAGS # * This library was introduced in Boost 1.51.0 # * The signatures of make_fcontext() and jump_fcontext were changed in 1.56.0 # * A dependency on boost_thread appears in 1.57.0 +# * The implementation details were moved to boost::context::detail in 1.61.0 +# * 1.61 also introduces execution_context_v2, which is the "lowest common +# denominator" for boost::context presence since then. +# * boost::context::fiber was introduced in 1.69 and execution_context_v2 was +# removed in 1.72 BOOST_DEFUN([Context], [boost_context_save_LIBS=$LIBS boost_context_save_LDFLAGS=$LDFLAGS if test $boost_major_version -ge 157; then - BOOST_THREAD([$1]) + BOOST_THREAD([$1], [$2]) m4_pattern_allow([^BOOST_THREAD_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_THREAD_LIBS" LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS" fi + +if test $boost_major_version -ge 169; then + +BOOST_FIND_LIB([context], [$1], + [boost/context/fiber.hpp], [[ +namespace ctx=boost::context; +int a; +ctx::fiber source{[&a](ctx::fiber&& sink){ + a=0; + int b=1; + for(;;){ + sink=std::move(sink).resume(); + int next=a+b; + a=b; + b=next; + } + return std::move(sink); +}}; +for (int j=0;j<10;++j) { + source=std::move(source).resume(); +} +return a == 34; +]], [], [], [$2]) + +elif test $boost_major_version -ge 161; then + +BOOST_FIND_LIB([context], [$1], + [boost/context/execution_context_v2.hpp], [[ +namespace ctx=boost::context; +int res=0; +int n=35; +ctx::execution_context source( + [n, &res](ctx::execution_context sink, int) mutable { + int a=0; + int b=1; + while(n-->0){ + auto result=sink(a); + sink=std::move(std::get<0>(result)); + auto next=a+b; + a=b; + b=next; + } + return sink; + }); +for(int i=0;i<10;++i){ + auto result=source(i); + source=std::move(std::get<0>(result)); + res = std::get<1>(result); +} +return res == 34; +]], [], [], [$2]) + +else + BOOST_FIND_LIB([context], [$1], [boost/context/fcontext.hpp],[[ @@ -709,7 +787,10 @@ static void f(intptr_t i) { ctx::jump_fcontext(&fc, fcm, i * 2); } #endif -]) +], [], [], [$2]) + +fi + LIBS=$boost_context_save_LIBS LDFLAGS=$boost_context_save_LDFLAGS ])# BOOST_CONTEXT @@ -724,7 +805,7 @@ BOOST_FIND_HEADER([boost/lexical_cast.hpp]) ])# BOOST_CONVERSION -# BOOST_COROUTINE([PREFERRED-RT-OPT]) +# BOOST_COROUTINE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------- # Look for Boost.Coroutine. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. This library was introduced in Boost @@ -734,10 +815,10 @@ BOOST_DEFUN([Coroutine], boost_coroutine_save_LIBS=$LIBS boost_coroutine_save_LDFLAGS=$LDFLAGS # Link-time dependency from coroutine to context -BOOST_CONTEXT([$1]) +BOOST_CONTEXT([$1], [$2]) # Starting from Boost 1.55 a dependency on Boost.System is added if test $boost_major_version -ge 155; then - BOOST_SYSTEM([$1]) + BOOST_SYSTEM([$1], [$2]) fi m4_pattern_allow([^BOOST_(CONTEXT|SYSTEM)_(LIBS|LDFLAGS)]) LIBS="$LIBS $BOOST_CONTEXT_LIBS $BOOST_SYSTEM_LIBS" @@ -745,7 +826,8 @@ LDFLAGS="$LDFLAGS $BOOST_CONTEXT_LDFLAGS" # in 1.53 coroutine was a header only library if test $boost_major_version -eq 153; then - BOOST_FIND_HEADER([boost/coroutine/coroutine.hpp]) + AS_IF([test x"$2" = "xno"], [not_found_header='true']) + BOOST_FIND_HEADER([boost/coroutine/coroutine.hpp], [$not_found_header]) else BOOST_FIND_LIB([coroutine], [$1], [boost/coroutine/coroutine.hpp], @@ -756,7 +838,7 @@ else #else boost::coroutines::asymmetric_coroutine::pull_type coro; coro.get(); #endif - ]) + ], [], [], [$2]) fi # Link-time dependency from coroutine to context, existed only in 1.53, in 1.54 # coroutine doesn't use context from its headers but from its library. @@ -781,14 +863,14 @@ BOOST_DEFUN([CRC], ])# BOOST_CRC -# BOOST_DATE_TIME([PREFERRED-RT-OPT]) +# BOOST_DATE_TIME([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------- # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Date_Time], [BOOST_FIND_LIB([date_time], [$1], [boost/date_time/posix_time/posix_time.hpp], - [boost::posix_time::ptime t;]) + [boost::posix_time::ptime t;], [], [], [$2]) ])# BOOST_DATE_TIME @@ -799,7 +881,7 @@ BOOST_DEFUN([Exception], [BOOST_FIND_HEADER([boost/exception/all.hpp])]) -# BOOST_FILESYSTEM([PREFERRED-RT-OPT]) +# BOOST_FILESYSTEM([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------------ # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see # the documentation of BOOST_FIND_LIB above. @@ -810,7 +892,7 @@ BOOST_DEFUN([Filesystem], # added as of 1.35.0. If we have a version <1.35, we must not attempt to # find Boost.System as it didn't exist by then. if test $boost_major_version -ge 135; then - BOOST_SYSTEM([$1]) + BOOST_SYSTEM([$1], [$2]) fi # end of the Boost.System check. boost_filesystem_save_LIBS=$LIBS boost_filesystem_save_LDFLAGS=$LDFLAGS @@ -818,7 +900,8 @@ m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIB([filesystem], [$1], - [boost/filesystem/path.hpp], [boost::filesystem::path p;]) + [boost/filesystem/path.hpp], [boost::filesystem::path p;], + [], [], [$2]) if test $enable_static_boost = yes && test $boost_major_version -ge 135; then BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS" fi @@ -878,7 +961,7 @@ BOOST_DEFUN([Geometry], ])# BOOST_GEOMETRY -# BOOST_GRAPH([PREFERRED-RT-OPT]) +# BOOST_GRAPH([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------- # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. @@ -887,13 +970,14 @@ BOOST_DEFUN([Graph], boost_graph_save_LDFLAGS=$LDFLAGS # Link-time dependency from graph to regex was added as of 1.40.0. if test $boost_major_version -ge 140; then - BOOST_REGEX([$1]) + BOOST_REGEX([$1], [$2]) m4_pattern_allow([^BOOST_REGEX_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_REGEX_LIBS" LDFLAGS="$LDFLAGS $BOOST_REGEX_LDFLAGS" fi BOOST_FIND_LIB([graph], [$1], - [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;]) + [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;], + [], [], [$2]) LIBS=$boost_graph_save_LIBS LDFLAGS=$boost_graph_save_LDFLAGS ])# BOOST_GRAPH @@ -906,14 +990,15 @@ BOOST_DEFUN([Hash], [BOOST_FIND_HEADER([boost/functional/hash.hpp])]) -# BOOST_IOSTREAMS([PREFERRED-RT-OPT]) +# BOOST_IOSTREAMS([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------- # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([IOStreams], [BOOST_FIND_LIB([iostreams], [$1], [boost/iostreams/device/file_descriptor.hpp], - [boost::iostreams::file_descriptor fd; fd.close();]) + [boost::iostreams::file_descriptor fd; fd.close();], + [], [], [$2]) ])# BOOST_IOSTREAMS @@ -931,7 +1016,7 @@ BOOST_DEFUN([Lambda], [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])]) -# BOOST_LOCALE() +# BOOST_LOCALE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # -------------- # Look for Boost.Locale BOOST_DEFUN([Locale], @@ -940,40 +1025,40 @@ boost_locale_save_LIBS=$LIBS boost_locale_save_LDFLAGS=$LDFLAGS # require SYSTEM for boost-1.50.0 and up if test $boost_major_version -ge 150; then - BOOST_SYSTEM([$1]) + BOOST_SYSTEM([$1], [$2]) m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" fi # end of the Boost.System check. BOOST_FIND_LIB([locale], [$1], [boost/locale.hpp], - [[boost::locale::generator gen; std::locale::global(gen(""));]]) + [[boost::locale::generator gen; std::locale::global(gen(""));]], [], [], [$2]) LIBS=$boost_locale_save_LIBS LDFLAGS=$boost_locale_save_LDFLAGS ])# BOOST_LOCALE -# BOOST_LOG([PREFERRED-RT-OPT]) +# BOOST_LOG([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------- # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Log], [boost_log_save_LIBS=$LIBS boost_log_save_LDFLAGS=$LDFLAGS -BOOST_SYSTEM([$1]) -BOOST_FILESYSTEM([$1]) -BOOST_DATE_TIME([$1]) +BOOST_SYSTEM([$1], [$2]) +BOOST_FILESYSTEM([$1], [$2]) +BOOST_DATE_TIME([$1], [$2]) m4_pattern_allow([^BOOST_(SYSTEM|FILESYSTEM|DATE_TIME)_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_DATE_TIME_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_DATE_TIME_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIB([log], [$1], [boost/log/core/core.hpp], - [boost::log::attribute a; a.get_value();]) + [boost::log::attribute a; a.get_value();], [], [], [$2]) LIBS=$boost_log_save_LIBS LDFLAGS=$boost_log_save_LDFLAGS ])# BOOST_LOG -# BOOST_LOG_SETUP([PREFERRED-RT-OPT]) +# BOOST_LOG_SETUP([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------- # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. @@ -986,7 +1071,7 @@ LIBS="$LIBS $BOOST_LOG_LIBS" LDFLAGS="$LDFLAGS $BOOST_LOG_LDFLAGS" BOOST_FIND_LIB([log_setup], [$1], [boost/log/utility/setup/from_settings.hpp], - [boost::log::basic_settings bs; bs.empty();]) + [boost::log::basic_settings bs; bs.empty();], [], [], [$2]) LIBS=$boost_log_setup_save_LIBS LDFLAGS=$boost_log_setup_save_LDFLAGS ])# BOOST_LOG_SETUP @@ -1004,7 +1089,7 @@ BOOST_DEFUN([Math], [BOOST_FIND_HEADER([boost/math/special_functions.hpp])]) -# BOOST_MPI([PREFERRED-RT-OPT]) +# BOOST_MPI([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------- # Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is @@ -1021,7 +1106,8 @@ BOOST_FIND_LIB([mpi], [$1], [boost/mpi.hpp], [int argc = 0; char **argv = 0; - boost::mpi::environment env(argc,argv);]) + boost::mpi::environment env(argc,argv);], + [], [], [$2]) CXX=${boost_save_CXX} CXXCPP=${boost_save_CXXCPP} ])# BOOST_MPI @@ -1078,14 +1164,15 @@ BOOST_DEFUN([Preprocessor], [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])]) -# BOOST_PROPERTY_TREE([PREFERRED-RT-OPT]) +# BOOST_PROPERTY_TREE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------------- # Look for Boost.Property_Tree. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Property_Tree], [BOOST_FIND_LIB([property_tree], [$1], [boost/property_tree/ptree.hpp], - [boost::property_tree::ptree pt; boost::property_tree::read_xml d("test", pt);]) + [boost::property_tree::ptree pt; boost::property_tree::read_xml d("test", pt);], + [], [], [$2]) ])# BOOST_PROPERTY_TREE @@ -1116,14 +1203,15 @@ BOOST_DEFUN([Uuid], [BOOST_FIND_HEADER([boost/uuid/uuid.hpp])]) -# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT]) +# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ----------------------------------------- # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Program_Options], [BOOST_FIND_LIB([program_options], [$1], [boost/program_options.hpp], - [boost::program_options::options_description d("test");]) + [boost::program_options::options_description d("test");], + [], [], [$2]) ])# BOOST_PROGRAM_OPTIONS @@ -1139,7 +1227,7 @@ boost_python_save_$1=$$1 $1="$$1 $BOOST_PYTHON_$1"]) -# BOOST_PYTHON([PREFERRED-RT-OPT]) +# BOOST_PYTHON([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # -------------------------------- # Look for Boost.Python. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. @@ -1150,7 +1238,7 @@ _BOOST_PYTHON_CONFIG([LIBS], [libs]) m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl BOOST_FIND_LIBS([python], [python python3], [$1], [boost/python.hpp], - [], [BOOST_PYTHON_MODULE(empty) {}]) + [], [BOOST_PYTHON_MODULE(empty) {}], [], [$2]) CPPFLAGS=$boost_python_save_CPPFLAGS LDFLAGS=$boost_python_save_LDFLAGS LIBS=$boost_python_save_LIBS @@ -1164,18 +1252,26 @@ BOOST_DEFUN([Ref], [BOOST_FIND_HEADER([boost/ref.hpp])]) -# BOOST_REGEX([PREFERRED-RT-OPT]) +# BOOST_REGEX([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------- # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Regex], [BOOST_FIND_LIB([regex], [$1], [boost/regex.hpp], - [boost::regex exp("*"); boost::regex_match("foo", exp);]) + [boost::regex exp("*"); boost::regex_match("foo", exp);], + [], [], [$2]) ])# BOOST_REGEX -# BOOST_SERIALIZATION([PREFERRED-RT-OPT]) +# BOOST_SCOPE_EXIT() +# ------------ +# Look for Boost.ScopeExit. +BOOST_DEFUN([SCOPE_EXIT], +[BOOST_FIND_HEADER([boost/scope_exit.hpp])]) + + +# BOOST_SERIALIZATION([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # --------------------------------------- # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see # the documentation of BOOST_FIND_LIB above. @@ -1183,18 +1279,20 @@ BOOST_DEFUN([Serialization], [BOOST_FIND_LIB([serialization], [$1], [boost/archive/text_oarchive.hpp], [std::ostream* o = 0; // Cheap way to get an ostream... - boost::archive::text_oarchive t(*o);]) + boost::archive::text_oarchive t(*o);], + [], [], [$2]) ])# BOOST_SERIALIZATION -# BOOST_SIGNALS([PREFERRED-RT-OPT]) +# BOOST_SIGNALS([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # --------------------------------- # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Signals], [BOOST_FIND_LIB([signals], [$1], [boost/signal.hpp], - [boost::signal s;]) + [boost::signal s;], + [], [], [$2]) ])# BOOST_SIGNALS @@ -1230,7 +1328,7 @@ BOOST_DEFUN([String_Algo], ]) -# BOOST_SYSTEM([PREFERRED-RT-OPT]) +# BOOST_SYSTEM([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # -------------------------------- # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. This library was introduced in Boost @@ -1238,11 +1336,11 @@ BOOST_DEFUN([String_Algo], BOOST_DEFUN([System], [BOOST_FIND_LIB([system], [$1], [boost/system/error_code.hpp], - [boost::system::error_code e; e.clear();]) + [boost::system::error_code e; e.clear();], [], [], [$2]) ])# BOOST_SYSTEM -# BOOST_TEST([PREFERRED-RT-OPT]) +# BOOST_TEST([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------ # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. @@ -1252,11 +1350,11 @@ BOOST_FIND_LIB([unit_test_framework], [$1], [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);], [using boost::unit_test::test_suite; test_suite* init_unit_test_suite(int argc, char ** argv) - { return NULL; }]) + { return NULL; }], [], [$2]) ])# BOOST_TEST -# BOOST_THREAD([PREFERRED-RT-OPT]) +# BOOST_THREAD([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # --------------------------------- # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. @@ -1270,7 +1368,7 @@ boost_thread_save_LDFLAGS=$LDFLAGS boost_thread_save_CPPFLAGS=$CPPFLAGS # Link-time dependency from thread to system was added as of 1.49.0. if test $boost_major_version -ge 149; then -BOOST_SYSTEM([$1]) +BOOST_SYSTEM([$1], [$2]) fi # end of the Boost.System check. m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" @@ -1289,7 +1387,7 @@ if test $boost_major_version -lt 148; then fi BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext], [$1], - [boost/thread.hpp], [boost::thread t; boost::mutex m;]) + [boost/thread.hpp], [boost::thread t; boost::mutex m;], [], [], [$2]) case $host_os in (*mingw*) boost_thread_w32_socket_link=-lws2_32;; @@ -1365,7 +1463,7 @@ BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp]) ])# BOOST_POINTER_CONTAINER -# BOOST_WAVE([PREFERRED-RT-OPT]) +# BOOST_WAVE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE]) # ------------------------------ # NOTE: If you intend to use Wave/Spirit with thread support, make sure you # call BOOST_THREAD first. @@ -1383,7 +1481,7 @@ LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \ $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS" BOOST_FIND_LIB([wave], [$1], [boost/wave.hpp], - [boost::wave::token_id id; get_token_name(id);]) + [boost::wave::token_id id; get_token_name(id);], [], [], [$2]) LIBS=$boost_wave_save_LIBS LDFLAGS=$boost_wave_save_LDFLAGS ])# BOOST_WAVE @@ -1451,10 +1549,11 @@ AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag], -pthreads -mthreads -lpthread --thread-safe -mt";; esac # Generate the test file. - AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0);])]) + AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include + void *f(void*){ return 0; }], + [pthread_t th; pthread_create(&th,0,f,0); pthread_join(th,0); + pthread_attr_t attr; pthread_attr_init(&attr); pthread_cleanup_push(0, 0); + pthread_cleanup_pop(0);])]) for boost_pthread_flag in '' $boost_pthread_flags; do boost_pthread_ok=false dnl Re-use the test file already generated. @@ -1516,12 +1615,53 @@ if test x$boost_cv_inc_path != xno; then # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines # the same defines as GCC's). for i in \ + "defined __clang__ && __clang_major__ == 14 && __clang_minor__ == 0 @ clang140" \ + "defined __clang__ && __clang_major__ == 13 && __clang_minor__ == 0 @ clang130" \ + "defined __clang__ && __clang_major__ == 12 && __clang_minor__ == 0 @ clang120" \ + "defined __clang__ && __clang_major__ == 11 && __clang_minor__ == 1 @ clang111" \ + "defined __clang__ && __clang_major__ == 11 && __clang_minor__ == 0 @ clang110" \ + "defined __clang__ && __clang_major__ == 10 && __clang_minor__ == 0 @ clang100" \ + "defined __clang__ && __clang_major__ == 9 && __clang_minor__ == 0 @ clang90" \ + "defined __clang__ && __clang_major__ == 8 && __clang_minor__ == 0 @ clang80" \ + "defined __clang__ && __clang_major__ == 7 && __clang_minor__ == 0 @ clang70" \ + "defined __clang__ && __clang_major__ == 6 && __clang_minor__ == 0 @ clang60" \ + "defined __clang__ && __clang_major__ == 5 && __clang_minor__ == 0 @ clang50" \ + "defined __clang__ && __clang_major__ == 4 && __clang_minor__ == 0 @ clang40" \ + "defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 9 @ clang39" \ + "defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 8 @ clang38" \ + "defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 7 @ clang37" \ + _BOOST_mingw_test(11, 2) \ + _BOOST_gcc_test(11, 2) \ + _BOOST_mingw_test(11, 1) \ + _BOOST_gcc_test(11, 1) \ + _BOOST_mingw_test(10, 3) \ + _BOOST_gcc_test(10, 3) \ + _BOOST_mingw_test(10, 2) \ + _BOOST_gcc_test(10, 2) \ + _BOOST_mingw_test(10, 1) \ + _BOOST_gcc_test(10, 1) \ + _BOOST_mingw_test(9, 3) \ + _BOOST_gcc_test(9, 3) \ + _BOOST_mingw_test(9, 2) \ + _BOOST_gcc_test(9, 2) \ + _BOOST_mingw_test(9, 1) \ + _BOOST_gcc_test(9, 1) \ + _BOOST_mingw_test(9, 0) \ + _BOOST_gcc_test(9, 0) \ + _BOOST_mingw_test(8, 5) \ + _BOOST_gcc_test(8, 5) \ + _BOOST_mingw_test(8, 4) \ + _BOOST_gcc_test(8, 4) \ + _BOOST_mingw_test(8, 3) \ + _BOOST_gcc_test(8, 3) \ _BOOST_mingw_test(8, 2) \ _BOOST_gcc_test(8, 2) \ _BOOST_mingw_test(8, 1) \ _BOOST_gcc_test(8, 1) \ _BOOST_mingw_test(8, 0) \ _BOOST_gcc_test(8, 0) \ + _BOOST_mingw_test(7, 4) \ + _BOOST_gcc_test(7, 4) \ _BOOST_mingw_test(7, 3) \ _BOOST_gcc_test(7, 3) \ _BOOST_mingw_test(7, 2) \ @@ -1530,6 +1670,8 @@ if test x$boost_cv_inc_path != xno; then _BOOST_gcc_test(7, 1) \ _BOOST_mingw_test(7, 0) \ _BOOST_gcc_test(7, 0) \ + _BOOST_mingw_test(6, 5) \ + _BOOST_gcc_test(6, 5) \ _BOOST_mingw_test(6, 4) \ _BOOST_gcc_test(6, 4) \ _BOOST_mingw_test(6, 3) \ From 263414ee7469db221ea6ba65ecdd18828e4e9e67 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 16:56:54 +0200 Subject: [PATCH 04/16] Remove references to Argus-related dependencies Don't require a specific Boost version for the moment. Use the MySQL m4 macro coming with the aclocal package distribution. Avoid the use of my_bool, which doesn't exist any more in MySQL. --- configure.ac | 11 +++++------ src/db/storm_mysql_ifce.cpp | 2 +- src/frontend/Makefile.am | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 9c4555b..b40394f 100755 --- a/configure.ac +++ b/configure.ac @@ -34,21 +34,20 @@ AM_PROG_CC_C_O AC_PROG_INSTALL AC_COMPILER -BOOST_REQUIRE([1.41.0]) +BOOST_REQUIRE BOOST_SMART_PTR BOOST_PROGRAM_OPTIONS([mt-]) BOOST_THREADS([mt-]) BOOST_REGEX([mt-]) AC_XMLRPC_C -AC_MYSQL +AX_LIB_MYSQL PKG_CHECK_MODULES([LIBCURL],[libcurl]) -PKG_CHECK_MODULES([LIBARGUS_PEP], [libargus-pep]) PKG_CHECK_MODULES([GLOBUS_COMMON],[globus-common]) -PKG_CHECK_MODULES([GLOBUS_GRIDMAP_CALLOUT_ERROR],[globus-gridmap-callout-error]) -PKG_CHECK_MODULES([GLOBUS_GSI_CREDENTIAL],[globus-gsi-credential]) -PKG_CHECK_MODULES([GLOBUS_GSS_ASSIST],[globus-gss-assist]) +# PKG_CHECK_MODULES([GLOBUS_GRIDMAP_CALLOUT_ERROR],[globus-gridmap-callout-error]) +# PKG_CHECK_MODULES([GLOBUS_GSI_CREDENTIAL],[globus-gsi-credential]) +# PKG_CHECK_MODULES([GLOBUS_GSS_ASSIST],[globus-gss-assist]) PKG_CHECK_MODULES([OPENSSL],[openssl]) PKG_CHECK_MODULES([UUID],[uuid]) diff --git a/src/db/storm_mysql_ifce.cpp b/src/db/storm_mysql_ifce.cpp index 8e4a511..c1090e5 100644 --- a/src/db/storm_mysql_ifce.cpp +++ b/src/db/storm_mysql_ifce.cpp @@ -39,7 +39,7 @@ int storm_opendb(std::string const& server, std::string const& user, std::string dbfd->mysql = mysql_init(NULL); } - my_bool const reconnect = 1; + bool const reconnect = 1; mysql_options(dbfd->mysql, MYSQL_OPT_RECONNECT, &reconnect); unsigned int const connect_timeout = 10; // seconds mysql_options(dbfd->mysql, MYSQL_OPT_CONNECT_TIMEOUT, &connect_timeout); diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index e33df7f..3b3985a 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -29,7 +29,7 @@ storm_frontend_server_CFLAGS = $(INCLUDES) storm_frontend_server_CXXFLAGS = $(INCLUDES) storm_frontend_server_LDADD = \ $(top_builddir)/src/db/libstormdb.la \ - @MYSQL_LIBS@ \ + @MYSQL_LDFLAGS@ \ @XMLRPC_LIBS@ \ @LIBCURL_LIBS@ \ @GLOBUS_COMMON_LIBS@ \ From de4bceb9af5f857baca249c952b12a58953cb362 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 15:15:03 +0000 Subject: [PATCH 05/16] Use the system xmlrpc-c --- m4/xmlrpc-c.m4 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/m4/xmlrpc-c.m4 b/m4/xmlrpc-c.m4 index f13eff7..5ac6a13 100644 --- a/m4/xmlrpc-c.m4 +++ b/m4/xmlrpc-c.m4 @@ -1,4 +1,4 @@ -dnl Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. +dnl Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2024. dnl dnl Licensed under the Apache License, Version 2.0 (the "License"); dnl you may not use this file except in compliance with the License. @@ -14,19 +14,23 @@ dnl limitations under the License. AC_DEFUN([AC_XMLRPC_C], [ - AC_ARG_WITH(xmlrpc_includes, - [ --with-xmlrpc_includes=XMLRPC_INCLUDES Sets a non-standard location for xmlrpc-c includes], + AC_ARG_WITH([xmlrpc_includes], + [AC_HELP_STRING([--with-xmlrpc_includes=XMLRPC_INCLUDES],[Sets a non-standard location for xmlrpc-c includes])], [with_xmlrpc_includes="$withval"], - [with_xmlrpc_includes="/usr/include/storm"]) + []) AC_ARG_WITH(xmlrpc_libs, - [ --with-xmlrpc_libs=XMLRPC_LIBS Sets a non-standard location for xmlrpc-c librarires], + [AC_HELP_STRING([--with-xmlrpc_libs=XMLRPC_LIBS],[Sets a non-standard location for xmlrpc-c libraries])], [with_xmlrpc_libs="$withval"], - [with_xmlrpc_libs="/usr/lib64/storm"]) + []) - - XMLRPC_CFLAGS="-I$with_xmlrpc_includes" - XMLRPC_LIBS="-L$with_xmlrpc_libs -lxmlrpc_client -lxmlrpc_xmlparse -lxmlrpc -lxmlrpc_util -lxmlrpc_xmltok" + if test "x${with_xmlrpc_includes}" != x; then + XMLRPC_CFLAGS="-I$with_xmlrpc_includes" + fi + if test "x${with_xmlrpc_libs}" != x; then + XMLRPC_LIBS="-L$with_xmlrpc_libs" + fi + XMLRPC_LIBS="$XMLRPC_LIBS -lxmlrpc_client -lxmlrpc -lxmlrpc_util" CPPFLAGS_SAVE=$CPPFLAGS CFLAGS_SAVE=$CFLAGS From d17ebf7f67c9eebfd5cf2cdde40a4023717c16e6 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 15:17:52 +0000 Subject: [PATCH 06/16] Improve mysql.4 --- m4/mysql.m4 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/m4/mysql.m4 b/m4/mysql.m4 index 451f4f3..e85bc0f 100644 --- a/m4/mysql.m4 +++ b/m4/mysql.m4 @@ -14,13 +14,14 @@ dnl limitations under the License. AC_DEFUN([AC_MYSQL], [ - AC_ARG_WITH(mysql_config_location, - [ --with-mysql_config_location=LOCATION Location of the mysql_config program.], - [with_mysql_config_location="$withval"], - [with_mysql_config_location="/usr/lib64/mysql/mysql_config"]) + AC_ARG_WITH([mysql_config_location], + [AC_HELP_STRING[--with-mysql_config_location=LOCATION],[Location of the mysql_config program]], + [with_mysql_config_location="$withval"], + [with_mysql_config_location="mysql_config"]) if ! test -e "$with_mysql_config_location"; then - AC_MSG_ERROR("mysql_config not found at $with_mysql_config_location.") + AC_CHECK_PROG([mysql_config_program],[mysql_config],[yes],[no],[], + [AC_MSG_ERROR("mysql_config not found at $with_mysql_config_location.")]) fi MYSQL_CFLAGS=$(${with_mysql_config_location} --cflags) From e8d0b5d0d2b46e2ae0095ca5cc8e1c6090ab80a0 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 5 Jul 2024 17:18:15 +0200 Subject: [PATCH 07/16] Not needed any more --- m4/mysql.m4 | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 m4/mysql.m4 diff --git a/m4/mysql.m4 b/m4/mysql.m4 deleted file mode 100644 index e85bc0f..0000000 --- a/m4/mysql.m4 +++ /dev/null @@ -1,50 +0,0 @@ -dnl Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2013. -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. - -AC_DEFUN([AC_MYSQL], -[ - AC_ARG_WITH([mysql_config_location], - [AC_HELP_STRING[--with-mysql_config_location=LOCATION],[Location of the mysql_config program]], - [with_mysql_config_location="$withval"], - [with_mysql_config_location="mysql_config"]) - - if ! test -e "$with_mysql_config_location"; then - AC_CHECK_PROG([mysql_config_program],[mysql_config],[yes],[no],[], - [AC_MSG_ERROR("mysql_config not found at $with_mysql_config_location.")]) - fi - - MYSQL_CFLAGS=$(${with_mysql_config_location} --cflags) - MYSQL_LIBS=$(${with_mysql_config_location} --libs_r) - - CPPFLAGS_SAVE=$CPPFLAGS - CFLAGS_SAVE=$CFLAGS - CPPFLAGS=$MYSQL_CFLAGS - CFLAGS=$MYSQL_CFLAGS - AC_CHECK_HEADER([mysql/mysql.h],,[AC_MSG_ERROR("Header not found: mysql/mysql.h. Please install the mysql development package.")]) - CPPFLAGS=$CPPFLAGS_SAVE - CFLAGS=$CFLAGS_SAVE - - CPPFLAGS_SAVE=$CPPFLAGS - CFLAGS_SAVE=$CFLAGS - LIBS_SAVE=$LIBS - CFLAGS=$MYSQL_LIBS - CPPFLAGS=$MYSQL_LIBS - AC_CHECK_LIB([mysqlclient_r],[mysql_send_query],,[AC_MSG_ERROR("mysql library check failed. Please install the mysql development package.")]) - LIBS=$LIBS_SAVE - CPPFLAGS=$CPPFLAGS_SAVE - CFLAGS=$CFLAGS_SAVE - - AC_SUBST(MYSQL_CFLAGS) - AC_SUBST(MYSQL_LIBS) -]) From 41fb504de7e86747bf8dbc3e3c05713963a88e08 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Wed, 24 Jul 2024 16:24:29 +0200 Subject: [PATCH 08/16] ltsugar.m4 is generated --- m4/ltsugar.m4 | 123 -------------------------------------------------- 1 file changed, 123 deletions(-) delete mode 100644 m4/ltsugar.m4 diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4 deleted file mode 100644 index 9000a05..0000000 --- a/m4/ltsugar.m4 +++ /dev/null @@ -1,123 +0,0 @@ -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) From f53a6be8d1447f88e4a0ea3d9105fea5541cdea6 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Thu, 25 Jul 2024 12:18:48 +0000 Subject: [PATCH 09/16] print wsdl2h version with -V --- m4/wsdl2h.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m4/wsdl2h.m4 b/m4/wsdl2h.m4 index 17a58ec..cd7e94c 100644 --- a/m4/wsdl2h.m4 +++ b/m4/wsdl2h.m4 @@ -44,7 +44,9 @@ AC_DEFUN([AC_WSDL2H], dnl @<:@ becomes [ dnl @:>@ becomes ] wsdl2h_version=$($WSDL2H -help 2>&1 | grep 'wsdl2h release' | grep -o '@<:@0-9@:>@\.@<:@0-9@:>@\.@<:@0-9@:>@*$' | head -1) - + if test "x$wsdl2h_version" == "x"; then + wsdl2h_version=$($WSDL2H -V 2>&1) + fi normalized_version=$(printf "%02d%02d%02d" $(echo $wsdl2h_version | tr '.' ' ')) WSDL2H_FLAGS="" From dc2f60515c098972f71045e0e4e634f4346b4eb9 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Thu, 25 Jul 2024 12:19:19 +0000 Subject: [PATCH 10/16] Modernize configure.ac - update minimum autoconf version to the one available on EL9 (and 8) - capitalize product name (it will be normalized where needed) - remove Andrea's email as contact for bugs - replace deprecated or removed macros - verify that MySQL libs have been indeed found, else abort - don't constrain gSOAP version --- configure.ac | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) mode change 100755 => 100644 configure.ac diff --git a/configure.ac b/configure.ac old mode 100755 new mode 100644 index b40394f..b6d05c7 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010. +# Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2024. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -AC_PREREQ([2.59]) -AC_INIT([storm frontend server], [1.8.16], andrea.ceccanti@cnaf.infn.it) +AC_PREREQ([2.69]) +AC_INIT([StoRM Frontend Server],[1.8.16]) AC_CONFIG_AUX_DIR([./aux]) AC_CONFIG_MACRO_DIR([m4]) @@ -21,47 +21,48 @@ AC_CONFIG_SRCDIR([src/frontend/storm-frontend.cpp]) AM_INIT_AUTOMAKE -AC_COPYRIGHT([Copyright (c) 2004-2013 Istituto Nazionale di Fisica Nucleare +AC_COPYRIGHT([Copyright (c) 2004-2024 Istituto Nazionale di Fisica Nucleare See LICENSE file for details ]) +LT_INIT AC_PROG_CXX AC_PROG_CC AC_PROG_LN_S AC_PROG_MAKE_SET -AC_PROG_LIBTOOL -AM_PROG_CC_C_O AC_PROG_INSTALL AC_COMPILER BOOST_REQUIRE BOOST_SMART_PTR BOOST_PROGRAM_OPTIONS([mt-]) -BOOST_THREADS([mt-]) +BOOST_THREAD([mt-]) BOOST_REGEX([mt-]) AC_XMLRPC_C AX_LIB_MYSQL +if test "x${MYSQL_VERSION}" = x; then + AC_MSG_ERROR([MySQL is not available]) +else + AC_MSG_NOTICE([using MySQL version ${MYSQL_VERSION}]) +fi PKG_CHECK_MODULES([LIBCURL],[libcurl]) PKG_CHECK_MODULES([GLOBUS_COMMON],[globus-common]) -# PKG_CHECK_MODULES([GLOBUS_GRIDMAP_CALLOUT_ERROR],[globus-gridmap-callout-error]) -# PKG_CHECK_MODULES([GLOBUS_GSI_CREDENTIAL],[globus-gsi-credential]) -# PKG_CHECK_MODULES([GLOBUS_GSS_ASSIST],[globus-gss-assist]) PKG_CHECK_MODULES([OPENSSL],[openssl]) PKG_CHECK_MODULES([UUID],[uuid]) -PKG_CHECK_MODULES([GSOAP],[gsoap >= 2.7]) -PKG_CHECK_MODULES([GSOAP_PP],[gsoap++ >= 2.7]) -PKG_CHECK_MODULES([GSOAP_SSL],[gsoapssl >= 2.7]) -PKG_CHECK_MODULES([GSOAP_SSL_PP],[gsoapssl++ >= 2.7]) +PKG_CHECK_MODULES([GSOAP],[gsoap]) +PKG_CHECK_MODULES([GSOAP_PP],[gsoap++]) +PKG_CHECK_MODULES([GSOAP_SSL],[gsoapssl]) +PKG_CHECK_MODULES([GSOAP_SSL_PP],[gsoapssl++]) AC_CGSI_GSOAP AC_WSDL2H ## Generating output -AM_CONFIG_HEADER([src/autogen/config.h]) +AC_CONFIG_HEADERS([src/autogen/config.h]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([etc/Makefile]) AC_CONFIG_FILES([etc/storm-frontend-server.conf.template]) From 022ad2fcb2e65281bfd25a1c9c5b152f8410544a Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Thu, 25 Jul 2024 12:25:45 +0000 Subject: [PATCH 11/16] Ignore ltsugar.m4 --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ef57432..875b42d 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,6 @@ Makefile.in !/m4/acinclude.m4 !/m4/boost.m4 !/m4/cgsi-gsoap.m4 -!/m4/ltsugar.m4 !/m4/mysql.m4 !/m4/wsdl2h.m4 !/m4/xmlrpc-c.m4 From a3142ce9afe24c0af56eeb5784d7752e45aba690 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Thu, 25 Jul 2024 12:35:20 +0000 Subject: [PATCH 12/16] Fix compilation of get_ip - use a coherent include guard - replace include with forward declaration of the soap struct - remove the unused getip function --- src/frontend/get_socket_info.cpp | 14 +++----------- src/frontend/get_socket_info.hpp | 10 +++++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/frontend/get_socket_info.cpp b/src/frontend/get_socket_info.cpp index 6e537e7..207b4fa 100644 --- a/src/frontend/get_socket_info.cpp +++ b/src/frontend/get_socket_info.cpp @@ -1,5 +1,6 @@ #include "get_socket_info.hpp" #include "srmlogit.h" +#include "srmv2H.h" #include #include #include @@ -90,17 +91,8 @@ std::string get_address(struct soap * soap, sockaddr_storage * peer) * @param soap [IN] the soap struct * @return address as string */ -std::string get_ip(struct soap *soap) +std::string get_ip(soap *soap) { - return get_address(soap,&(soap->peer)); + return get_address(soap,reinterpret_cast(&(soap->peer))); } -extern "C" { - -char *getip(struct soap *soap, char *buffer) -{ - strcpy(buffer, get_ip(soap).c_str()); - return buffer; -} - -} diff --git a/src/frontend/get_socket_info.hpp b/src/frontend/get_socket_info.hpp index 620139f..a9f119f 100644 --- a/src/frontend/get_socket_info.hpp +++ b/src/frontend/get_socket_info.hpp @@ -1,9 +1,9 @@ -#ifndef GSOAP_COMMON_HPP_ -#define GSOAP_COMMON_HPP_ +#ifndef GET_SOCKET_INFO_HPP +#define GET_SOCKET_INFO_HPP -#include "cgsi_plugin.h" +struct soap; #include -std::string get_ip(struct soap * soap); +std::string get_ip(soap * soap); -#endif //GSOAP_COMMON_HPP +#endif From 66e94decc4aaa7a6a62a9a086842ca7c3623d952 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 26 Jul 2024 08:37:55 +0000 Subject: [PATCH 13/16] Link correctly against the gSOAP generated code - Build the generated gSOAP C code as C and not as C++ - Use the C gSOAP library. - Include the generated gSOAP header as `extern "C"`, but include stdsoap2.h before that, to avoid to apply the C linkage also to C++ code (e.g. templates) present in stdsoap2.h --- src/frontend/Makefile.am | 24 ++++++++++++------------ src/frontend/asynch.cpp | 3 +++ src/frontend/asynch_status.cpp | 9 ++++++--- src/frontend/srmv2_GetRequestSummary.cpp | 5 ++++- src/frontend/srmv2_GetRequestTokens.cpp | 6 +++++- src/frontend/synch.cpp | 4 ++++ wsdl/Makefile.am | 11 ++++++++++- 7 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index 3b3985a..83cbe9c 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -33,7 +33,7 @@ storm_frontend_server_LDADD = \ @XMLRPC_LIBS@ \ @LIBCURL_LIBS@ \ @GLOBUS_COMMON_LIBS@ \ - @GSOAP_SSL_PP_LIBS@ \ + @GSOAP_SSL_LIBS@ \ @CGSI_GSOAP_PLUGIN_LIBS@ \ @BOOST_PROGRAM_OPTIONS_LIBS@ \ @BOOST_THREAD_LIBS@ \ @@ -118,8 +118,8 @@ stormfrontend_others = storm_exception.hpp \ token_validator.hpp token_validator.cpp \ xmlrpc_decode.cpp xmlrpc_encode.cpp \ storm_util.cpp storm_utils.hpp \ - srmv2C.cc \ - srmv2Server.cc \ + srmv2Server.c \ + srmv2C.c \ Monitor.hpp InstrumentedMonitor.hpp \ MonitorStub.hpp InstrumentedMonitorBuilder.hpp \ MonitorHelper.hpp \ @@ -135,21 +135,21 @@ AM_CPPFLAGS = \ @XMLRPC_CFLAGS@ \ @UUID_CFLAGS@ \ @GLOBUS_COMMON_CFLAGS@ \ - @GSOAP_SSL_PP_CFLAGS@ \ + @GSOAP_SSL_CFLAGS@ \ @MYSQL_CFLAGS@ \ $(MTC_CFLAGS) MAINTAINERCLEANFILES = Makefile.in \ - srmv2C.cc \ - srmv2Server.cc + srmv2C.c \ + srmv2Server.c -srmv2C.cc: - @echo "Copying file \"srmv2C.cc\" from $(GENERATED_GSOAP_INCLUDES)" - /bin/cp $(GENERATED_GSOAP_INCLUDES)/srmv2C.cc . +srmv2C.c: $(GENERATED_GSOAP_INCLUDES)/srmv2C.c + @echo "Copying file \"srmv2C.c\" from $(GENERATED_GSOAP_INCLUDES)" + /bin/cp $(GENERATED_GSOAP_INCLUDES)/srmv2C.c . -srmv2Server.cc: - @echo "Copying file \"srmv2Server.cc\" from $(GENERATED_GSOAP_INCLUDES)" - /bin/cp $(GENERATED_GSOAP_INCLUDES)/srmv2Server.cc . +srmv2Server.c: $(GENERATED_GSOAP_INCLUDES)/srmv2Server.c + @echo "Copying file \"srmv2Server.c\" from $(GENERATED_GSOAP_INCLUDES)" + /bin/cp $(GENERATED_GSOAP_INCLUDES)/srmv2Server.c . distclean-local: rm -f srmv2C.cc srmv2Server.cc diff --git a/src/frontend/asynch.cpp b/src/frontend/asynch.cpp index bd9c995..94a3556 100644 --- a/src/frontend/asynch.cpp +++ b/src/frontend/asynch.cpp @@ -13,7 +13,10 @@ * limitations under the License. */ +#include "stdsoap2.h" +extern "C" { #include "srmv2H.h" +} #include "srmlogit.h" #include "filerequest_template.hpp" #include "PtpRequest.hpp" diff --git a/src/frontend/asynch_status.cpp b/src/frontend/asynch_status.cpp index c41d8c0..17c6a55 100644 --- a/src/frontend/asynch_status.cpp +++ b/src/frontend/asynch_status.cpp @@ -20,7 +20,10 @@ * Author: alb */ +#include "stdsoap2.h" +extern "C" { #include "srmv2H.h" +} #include "srmlogit.h" #include "StatusTemplate.hpp" #include "PutStatusRequest.hpp" @@ -83,7 +86,7 @@ int ns1__srmStatusOfPutRequest(struct soap *soap, return soap_status; } -extern "C" int ns1__srmStatusOfGetRequest(struct soap *soap, +int ns1__srmStatusOfGetRequest(struct soap *soap, struct ns1__srmStatusOfGetRequestRequest *req, struct ns1__srmStatusOfGetRequestResponse_ *rep) { static const char* funcName = "srmStatusOfGetRequest"; @@ -125,7 +128,7 @@ extern "C" int ns1__srmStatusOfGetRequest(struct soap *soap, } } -extern "C" int ns1__srmStatusOfBringOnlineRequest(struct soap *soap, +int ns1__srmStatusOfBringOnlineRequest(struct soap *soap, struct ns1__srmStatusOfBringOnlineRequestRequest *req, struct ns1__srmStatusOfBringOnlineRequestResponse_ *rep) { static const char* funcName = "srmStatusOfBringOnLineRequest"; @@ -167,7 +170,7 @@ extern "C" int ns1__srmStatusOfBringOnlineRequest(struct soap *soap, } } -extern "C" int ns1__srmStatusOfCopyRequest(struct soap *soap, +int ns1__srmStatusOfCopyRequest(struct soap *soap, struct ns1__srmStatusOfCopyRequestRequest *req, struct ns1__srmStatusOfCopyRequestResponse_ *rep) { static const char* funcName = "srmStatusOfCopyRequest"; diff --git a/src/frontend/srmv2_GetRequestSummary.cpp b/src/frontend/srmv2_GetRequestSummary.cpp index 7aa00d8..dbdcfc4 100644 --- a/src/frontend/srmv2_GetRequestSummary.cpp +++ b/src/frontend/srmv2_GetRequestSummary.cpp @@ -19,7 +19,10 @@ #include #include #include +#include "stdsoap2.h" +extern "C" { #include "srmv2H.h" +} #include "srmlogit.h" #include "soap_util.hpp" #include "mysql_query.hpp" @@ -81,7 +84,7 @@ ns1__TRequestType getRequestType(std::string& r_type) return ns1__TRequestType(PREPARE_USCORETO_USCOREPUT); } -extern "C" int ns1__srmGetRequestSummary(struct soap *soap, +int ns1__srmGetRequestSummary(struct soap *soap, struct ns1__srmGetRequestSummaryRequest *req, struct ns1__srmGetRequestSummaryResponse_ *rep) { diff --git a/src/frontend/srmv2_GetRequestTokens.cpp b/src/frontend/srmv2_GetRequestTokens.cpp index beb9fd0..a880490 100644 --- a/src/frontend/srmv2_GetRequestTokens.cpp +++ b/src/frontend/srmv2_GetRequestTokens.cpp @@ -18,7 +18,11 @@ #include #include #include +#include "stdsoap2.h" +extern "C" { #include "srmv2H.h" +} + #include "srmlogit.h" #include "soap_util.hpp" #include "mysql_query.hpp" @@ -36,7 +40,7 @@ using namespace std; -extern "C" int ns1__srmGetRequestTokens(struct soap *soap, +int ns1__srmGetRequestTokens(struct soap *soap, struct ns1__srmGetRequestTokensRequest *req, struct ns1__srmGetRequestTokensResponse_ *rep) { diff --git a/src/frontend/synch.cpp b/src/frontend/synch.cpp index 4cd1981..67baffd 100644 --- a/src/frontend/synch.cpp +++ b/src/frontend/synch.cpp @@ -13,7 +13,11 @@ * limitations under the License. */ +#include "stdsoap2.h" +extern "C" { #include "srmv2H.h" +} + #include #include "MonitoringHelper.hpp" diff --git a/wsdl/Makefile.am b/wsdl/Makefile.am index 9d8e647..51dcb42 100755 --- a/wsdl/Makefile.am +++ b/wsdl/Makefile.am @@ -31,8 +31,17 @@ skeletons: $(FLAG_FILE) $(FLAG_FILE): touch $(FLAG_FILE) mkdir -p $(top_builddir)/wsdl/gsoap-autogen + # -w always wrap response parameters in a response struct (<=1.1.4 behavior) + # -c generate C source code + # -e don't qualify enum names + # -y generate typedef synonyms for structs and enums + # -tfile use type map file instead of the default file typemap.dat @WSDL2H@ @WSDL2H_FLAGS@ -w -c -e -y -t $(top_srcdir)/wsdl/typemap.dat $(top_srcdir)/wsdl/srm.v2.2.wsdl -o $(top_builddir)/wsdl/gsoap-autogen/srm.v2.2.h - cd $(top_builddir)/wsdl/gsoap-autogen; @SOAPCPP2@ -S -I/usr/include -c -p srmv2 srm.v2.2.h; mv srmv2C.c srmv2C.cc; mv srmv2Server.c srmv2Server.cc; cd .. + # -S generate server-side source code only + # -Ipath use path(s) for #import (paths separated with ':') + # -c generate C source code + # -pname save files with new prefix name instead of 'soap' + cd $(top_builddir)/wsdl/gsoap-autogen; @SOAPCPP2@ -S -I/usr/include -c -p srmv2 srm.v2.2.h clean-local: rm -rf $(top_builddir)/wsdl/gsoap-autogen From 95d4731053c31ddf58a8635fee47b6540e50da46 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 26 Jul 2024 12:34:33 +0000 Subject: [PATCH 14/16] Add devcontainer The support for CentOS 7 is incomplete, but will soon be removed. --- .devcontainer/Dockerfile-centos7 | 26 ++ .devcontainer/Dockerfile-el9 | 8 + .devcontainer/devcontainer.json | 27 ++ .devcontainer/docker-compose.yml | 23 ++ .../library-scripts/add-deps-redhat.sh | 32 ++ .../library-scripts/add-repos-redhat.sh | 14 + .../library-scripts/common-redhat.sh | 355 ++++++++++++++++++ .devcontainer/library-scripts/provide-deps.sh | 50 +++ .devcontainer/library-scripts/provide-user.sh | 59 +++ .devcontainer/library-scripts/scl_enable | 6 + 10 files changed, 600 insertions(+) create mode 100644 .devcontainer/Dockerfile-centos7 create mode 100644 .devcontainer/Dockerfile-el9 create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .devcontainer/library-scripts/add-deps-redhat.sh create mode 100644 .devcontainer/library-scripts/add-repos-redhat.sh create mode 100644 .devcontainer/library-scripts/common-redhat.sh create mode 100755 .devcontainer/library-scripts/provide-deps.sh create mode 100644 .devcontainer/library-scripts/provide-user.sh create mode 100644 .devcontainer/library-scripts/scl_enable diff --git a/.devcontainer/Dockerfile-centos7 b/.devcontainer/Dockerfile-centos7 new file mode 100644 index 0000000..ef0dd62 --- /dev/null +++ b/.devcontainer/Dockerfile-centos7 @@ -0,0 +1,26 @@ +FROM --platform=amd64 centos:7 + +ARG DEVTOOLSET_VERSION=11 +ARG PLATFORM=linux +ARG ARCH=x86_64 + +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=${USER_UID} + +COPY library-scripts/*.sh /tmp/library-scripts/ +COPY library-scripts/scl_enable /opt/app-root/etc/ + +ENV APP_ROOT=/opt/app-root +ENV BASH_ENV=${APP_ROOT}/etc/scl_enable \ + ENV=${APP_ROOT}/etc/scl_enable \ + PROMPT_COMMAND=". ${APP_ROOT}/etc/scl_enable" + +RUN \ + sed -i "s/#DEVTOOLSET_VERSION#/${DEVTOOLSET_VERSION}/g" /opt/app-root/etc/scl_enable && \ + chmod +x /tmp/library-scripts/*.sh && \ + /tmp/library-scripts/provide-deps.sh && \ + /tmp/library-scripts/provide-user.sh ${USERNAME} ${USER_UID} ${USER_GID} && \ + rm -rf /tmp/library-scripts + +USER ${USERNAME} diff --git a/.devcontainer/Dockerfile-el9 b/.devcontainer/Dockerfile-el9 new file mode 100644 index 0000000..8a1c9cd --- /dev/null +++ b/.devcontainer/Dockerfile-el9 @@ -0,0 +1,8 @@ +FROM almalinux:9 + +COPY library-scripts/*.sh /tmp/library-scripts/ +RUN \ + bash /tmp/library-scripts/add-repos-redhat.sh && \ + bash /tmp/library-scripts/common-redhat.sh false automatic automatic automatic true false && \ + bash /tmp/library-scripts/add-deps-redhat.sh && \ + rm -r tmp/library-scripts diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7f24dd5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +{ + "name": "StoRM Frontend Devel", + "build": { + "dockerfile": "Dockerfile-el9" + }, + "init": true, + "capAdd": ["SYS_PTRACE"], + "securityOpt": ["seccomp=unconfined"], + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools-extension-pack", + "eamodio.gitlens", + "maelvalais.autoconf" + ], + "settings": { + "terminal.integrated.profiles.linux": { + "/bin/bash": null + } + } + } + }, + "features": { + "ghcr.io/devcontainers/features/git:1": {} + }, + "remoteUser": "vscode" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..2871796 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,23 @@ + +services: + + container-el9: + + environment: + - TZ=Europe/Rome + + build: + context: . + dockerfile: Dockerfile-el9 + + volumes: + - .:/workspace + + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined + + command: sleep infinity + + init: true diff --git a/.devcontainer/library-scripts/add-deps-redhat.sh b/.devcontainer/library-scripts/add-deps-redhat.sh new file mode 100644 index 0000000..5efc6ad --- /dev/null +++ b/.devcontainer/library-scripts/add-deps-redhat.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# +# Copyright (c) Istituto Nazionale di Fisica Nucleare +# Licensed under the EUPL +# +# Syntax: ./add-deps-redhat.sh + +set -e + +package_list="\ + autoconf \ + autoconf-archive \ + automake \ + bear \ + bison \ + boost-devel \ + diffutils \ + CGSI-gSOAP-devel \ + file \ + gcc-c++ \ + gdb \ + git \ + globus-common-devel \ + gsoap-devel \ + libtool \ + libuuid-devel \ + make \ + mariadb-devel \ + openssl-devel \ + xmlrpc-c-devel" + +dnf install -y ${package_list} diff --git a/.devcontainer/library-scripts/add-repos-redhat.sh b/.devcontainer/library-scripts/add-repos-redhat.sh new file mode 100644 index 0000000..21ee954 --- /dev/null +++ b/.devcontainer/library-scripts/add-repos-redhat.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# Copyright (c) Istituto Nazionale di Fisica Nucleare +# Licensed under the EUPL +# +# Syntax: ./add-repos-redhat.sh + +set -e + +repo_list="epel-release" + +dnf install -y ${repo_list} + +dnf config-manager --set-enabled crb diff --git a/.devcontainer/library-scripts/common-redhat.sh b/.devcontainer/library-scripts/common-redhat.sh new file mode 100644 index 0000000..3f9150d --- /dev/null +++ b/.devcontainer/library-scripts/common-redhat.sh @@ -0,0 +1,355 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# ** This script is community supported ** +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./common-redhat.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] + +set -e + +INSTALL_ZSH=${1:-"true"} +USERNAME=${2:-"automatic"} +USER_UID=${3:-"automatic"} +USER_GID=${4:-"automatic"} +UPGRADE_PACKAGES=${5:-"true"} +INSTALL_OH_MYS=${6:-"true"} +SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" +MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Ensure that login shells get the correct path if the user updated the PATH using ENV. +rm -f /etc/profile.d/00-restore-env.sh +echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh +chmod +x /etc/profile.d/00-restore-env.sh + +# If in automatic mode, determine if a user already exists, if not use vscode +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + if id -u ${CURRENT_USER} > /dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=vscode + fi +elif [ "${USERNAME}" = "none" ]; then + USERNAME=root + USER_UID=0 + USER_GID=0 +fi + +# Load markers to see which steps have already run +if [ -f "${MARKER_FILE}" ]; then + echo "Marker file found:" + cat "${MARKER_FILE}" + source "${MARKER_FILE}" +fi + +# Install common dependencies +if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then + + package_list="\ + openssh-clients \ + gnupg2 \ + iproute \ + procps \ + lsof \ + net-tools \ + psmisc \ + wget \ + ca-certificates \ + rsync \ + unzip \ + zip \ + nano \ + vim-minimal \ + less \ + jq \ + openssl-libs \ + krb5-libs \ + libicu \ + zlib \ + sudo \ + sed \ + grep \ + which \ + man-db \ + strace" + + # Install OpenSSL 1.0 compat if needed + if yum -q list compat-openssl10 >/dev/null 2>&1; then + package_list="${package_list} compat-openssl10" + fi + + yum -y install ${package_list} + + if ! type curl > /dev/null 2>&1; then + yum -y install curl + fi + + PACKAGES_ALREADY_INSTALLED="true" +fi + +# Update to latest versions of packages +if [ "${UPGRADE_PACKAGES}" = "true" ]; then + yum upgrade -y +fi + +# Create or update a non-root user to match UID/GID. +group_name="${USERNAME}" +if id -u ${USERNAME} > /dev/null 2>&1; then + # User exists, update if needed + if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then + group_name="$(id -gn $USERNAME)" + groupmod --gid $USER_GID ${group_name} + usermod --gid $USER_GID $USERNAME + fi + if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then + usermod --uid $USER_UID $USERNAME + fi +else + # Create user + if [ "${USER_GID}" = "automatic" ]; then + groupadd $USERNAME + else + groupadd --gid $USER_GID $USERNAME + fi + if [ "${USER_UID}" = "automatic" ]; then + useradd -s /bin/bash --gid $USERNAME -m $USERNAME + else + useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME + fi +fi + +# Add sudo support for non-root user +if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME + chmod 0440 /etc/sudoers.d/$USERNAME + EXISTING_NON_ROOT_USER="${USERNAME}" +fi + +# ** Shell customization section ** +if [ "${USERNAME}" = "root" ]; then + user_rc_path="/root" +else + user_rc_path="/home/${USERNAME}" +fi + +# .bashrc/.zshrc snippet +rc_snippet="$(cat << 'EOF' + +if [ -z "${USER}" ]; then export USER=$(whoami); fi +if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.local/bin"; fi + +# Display optional first run image specific notice if configured and terminal is interactive +if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then + if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then + cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" + elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then + cat "/workspaces/.codespaces/shared/first-run-notice.txt" + fi + mkdir -p $HOME/.config/vscode-dev-containers + # Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it + ((sleep 10s; touch "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed") &) +fi + +# Set the default git editor if not already set +if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then + if [ "${TERM_PROGRAM}" = "vscode" ]; then + if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then + export GIT_EDITOR="code-insiders --wait" + else + export GIT_EDITOR="code --wait" + fi + fi +fi + +EOF +)" + +# code shim, it fallbacks to code-insiders if code is not available +cat << 'EOF' > /usr/local/bin/code +#!/bin/sh + +get_in_path_except_current() { + which -a "$1" | grep -A1 "$0" | grep -v "$0" +} + +code="$(get_in_path_except_current code)" + +if [ -n "$code" ]; then + exec "$code" "$@" +elif [ "$(command -v code-insiders)" ]; then + exec code-insiders "$@" +else + echo "code or code-insiders is not installed" >&2 + exit 127 +fi +EOF +chmod +x /usr/local/bin/code + +# Codespaces bash and OMZ themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme +codespaces_bash="$(cat \ +<<'EOF' + +# Codespaces bash prompt theme +__bash_prompt() { + local userpart='`export XIT=$? \ + && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ + && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' + local gitbranch='`\ + if [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ + export BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null); \ + if [ "${BRANCH}" != "" ]; then \ + echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \ + && if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ + echo -n " \[\033[1;33m\]✗"; \ + fi \ + && echo -n "\[\033[0;36m\]) "; \ + fi; \ + fi`' + local lightblue='\[\033[1;34m\]' + local removecolor='\[\033[0m\]' + PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ " + unset -f __bash_prompt +} +__bash_prompt + +EOF +)" + +codespaces_zsh="$(cat \ +<<'EOF' +# Codespaces zsh prompt theme +__zsh_prompt() { + local prompt_username + if [ ! -z "${GITHUB_USER}" ]; then + prompt_username="@${GITHUB_USER}" + else + prompt_username="%n" + fi + PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow + PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd + PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status + PROMPT+='%{$fg[white]%}$ %{$reset_color%}' + unset -f __zsh_prompt +} +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})" +__zsh_prompt + +EOF +)" + +# Add RC snippet and custom bash prompt +if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then + echo "${rc_snippet}" >> /etc/bashrc + echo "${codespaces_bash}" >> "${user_rc_path}/.bashrc" + if [ "${USERNAME}" != "root" ]; then + echo "${codespaces_bash}" >> "/root/.bashrc" + fi + chown ${USERNAME}:${group_name} "${user_rc_path}/.bashrc" + RC_SNIPPET_ALREADY_ADDED="true" +fi + +# Optionally install and configure zsh and Oh My Zsh! +if [ "${INSTALL_ZSH}" = "true" ]; then + if ! type zsh > /dev/null 2>&1; then + yum install -y zsh + fi + if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then + echo "${rc_snippet}" >> /etc/zshrc + ZSH_ALREADY_INSTALLED="true" + fi + + # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme. + # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script. + oh_my_install_dir="${user_rc_path}/.oh-my-zsh" + if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then + template_path="${oh_my_install_dir}/templates/zshrc.zsh-template" + user_rc_file="${user_rc_path}/.zshrc" + umask g-w,o-w + mkdir -p ${oh_my_install_dir} + git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + "https://github.com/ohmyzsh/ohmyzsh" "${oh_my_install_dir}" 2>&1 + echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file} + sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file} + mkdir -p ${oh_my_install_dir}/custom/themes + echo "${codespaces_zsh}" > "${oh_my_install_dir}/custom/themes/codespaces.zsh-theme" + # Shrink git while still enabling updates + cd "${oh_my_install_dir}" + git repack -a -d -f --depth=1 --window=1 + # Copy to non-root user if one is specified + if [ "${USERNAME}" != "root" ]; then + cp -rf "${user_rc_file}" "${oh_my_install_dir}" /root + chown -R ${USERNAME}:${group_name} "${user_rc_path}" + fi + fi +fi + +# Persist image metadata info, script if meta.env found in same directory +meta_info_script="$(cat << 'EOF' +#!/bin/sh +. /usr/local/etc/vscode-dev-containers/meta.env + +# Minimal output +if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then + echo "${VERSION}" + exit 0 +elif [ "$1" = "release" ]; then + echo "${GIT_REPOSITORY_RELEASE}" + exit 0 +elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then + echo "${CONTENTS_URL}" + exit 0 +fi + +#Full output +echo +echo "Development container image information" +echo +if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi +if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi +if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi +if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi +if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi +if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi +if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi +echo +EOF +)" +if [ -f "${SCRIPT_DIR}/meta.env" ]; then + mkdir -p /usr/local/etc/vscode-dev-containers/ + cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env + echo "${meta_info_script}" > /usr/local/bin/devcontainer-info + chmod +x /usr/local/bin/devcontainer-info +fi + +# Write marker file +mkdir -p "$(dirname "${MARKER_FILE}")" +echo -e "\ + PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\ + EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\ + RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\ + ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" + +echo "Done!" diff --git a/.devcontainer/library-scripts/provide-deps.sh b/.devcontainer/library-scripts/provide-deps.sh new file mode 100755 index 0000000..8575667 --- /dev/null +++ b/.devcontainer/library-scripts/provide-deps.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Copyright 2023 Istituto Nazionale di Fisica Nucleare +# SPDX-License-Identifier: EUPL-1.2 + +set -ex + +# Add repo for devtools and git 2.x +yum install -y \ + centos-release-scl \ + epel-release \ + https://packages.endpointdev.com/rhel/7/os/${ARCH}/endpoint-repo.${ARCH}.rpm \ + http://repository.egi.eu/sw/production/umd/4/centos7/x86_64/updates/umd-release-4.1.3-1.el7.centos.noarch.rpm + +yum update -y + +yum install -y --setopt=tsflags=nodocs \ + sudo \ + git \ + wget \ + curl \ + zip \ + unzip \ + tar \ + rpm-build \ + devtoolset-"${DEVTOOLSET_VERSION}" \ + devtoolset-"${DEVTOOLSET_VERSION}"-libubsan-devel \ + devtoolset-"${DEVTOOLSET_VERSION}"-libasan-devel \ + autoconf \ + automake \ + make \ + libtool \ + openssl-devel \ + gsoap-devel \ + curl-devel \ + mysql-devel \ + globus-gssapi-gsi-devel \ + globus-gss-assist-devel \ + globus-common-devel \ + globus-gridmap-callout-error-devel \ + globus-gsi-credential-devel \ + CGSI-gSOAP-devel \ + storm-xmlrpc-c-devel \ + argus-pep-api-c \ + argus-pep-api-c-devel \ + libuuid-devel \ + boost-devel + +yum clean all +rm -rf /var/cache/yum \ No newline at end of file diff --git a/.devcontainer/library-scripts/provide-user.sh b/.devcontainer/library-scripts/provide-user.sh new file mode 100644 index 0000000..7c75141 --- /dev/null +++ b/.devcontainer/library-scripts/provide-user.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Copyright 2023 Istituto Nazionale di Fisica Nucleare +# SPDX-License-Identifier: EUPL-1.2 + +USERNAME=${1} +USER_UID=${2} +USER_GID=${3} + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +groupadd --gid $USER_GID $USERNAME +useradd --uid $USER_UID --gid $USER_GID -m $USERNAME + +mkdir -p /etc/sudoers.d/ + +echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME +chmod 0440 /etc/sudoers.d/$USERNAME + +CODESPACES_BASH="$(cat \ +<<'EOF' + +# Codespaces bash prompt theme +__bash_prompt() { + local userpart='`export XIT=$? \ + && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ + && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' + local gitbranch='`\ + export BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null); \ + if [ "${BRANCH}" = "HEAD" ]; then \ + export BRANCH=$(git describe --contains --all HEAD 2>/dev/null); \ + fi; \ + if [ "${BRANCH}" != "" ]; then \ + echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \ + && if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ + echo -n " \[\033[1;33m\]✗"; \ + fi \ + && echo -n "\[\033[0;36m\]) "; \ + fi`' + local lightblue='\[\033[1;34m\]' + local removecolor='\[\033[0m\]' + PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ " + unset -f __bash_prompt +} +__bash_prompt + +EOF +)" + +USER_RC_PATH="/home/${USERNAME}" +echo "${CODESPACES_BASH}" >> "${USER_RC_PATH}/.bashrc" +chown ${USERNAME}:${USER_GID} "${USER_RC_PATH}/.bashrc" + +echo "Done!" diff --git a/.devcontainer/library-scripts/scl_enable b/.devcontainer/library-scripts/scl_enable new file mode 100644 index 0000000..31effef --- /dev/null +++ b/.devcontainer/library-scripts/scl_enable @@ -0,0 +1,6 @@ +# IMPORTANT: Do not add more content to this file unless you know what you are +# doing. This file is sourced everytime the shell session is opened. +# +# This will make scl collection binaries work out of box. +unset BASH_ENV PROMPT_COMMAND ENV +source scl_source enable devtoolset-#DEVTOOLSET_VERSION# From 9b29b13e0d53b16d4c3c6fca1a6c38cf459dd4b9 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 26 Jul 2024 14:45:44 +0200 Subject: [PATCH 15/16] Remove support for devcontainer on CentOS 7 --- .devcontainer/Dockerfile-centos7 | 26 ---------- .devcontainer/library-scripts/provide-deps.sh | 50 ------------------- .devcontainer/library-scripts/scl_enable | 6 --- 3 files changed, 82 deletions(-) delete mode 100644 .devcontainer/Dockerfile-centos7 delete mode 100755 .devcontainer/library-scripts/provide-deps.sh delete mode 100644 .devcontainer/library-scripts/scl_enable diff --git a/.devcontainer/Dockerfile-centos7 b/.devcontainer/Dockerfile-centos7 deleted file mode 100644 index ef0dd62..0000000 --- a/.devcontainer/Dockerfile-centos7 +++ /dev/null @@ -1,26 +0,0 @@ -FROM --platform=amd64 centos:7 - -ARG DEVTOOLSET_VERSION=11 -ARG PLATFORM=linux -ARG ARCH=x86_64 - -ARG USERNAME=vscode -ARG USER_UID=1000 -ARG USER_GID=${USER_UID} - -COPY library-scripts/*.sh /tmp/library-scripts/ -COPY library-scripts/scl_enable /opt/app-root/etc/ - -ENV APP_ROOT=/opt/app-root -ENV BASH_ENV=${APP_ROOT}/etc/scl_enable \ - ENV=${APP_ROOT}/etc/scl_enable \ - PROMPT_COMMAND=". ${APP_ROOT}/etc/scl_enable" - -RUN \ - sed -i "s/#DEVTOOLSET_VERSION#/${DEVTOOLSET_VERSION}/g" /opt/app-root/etc/scl_enable && \ - chmod +x /tmp/library-scripts/*.sh && \ - /tmp/library-scripts/provide-deps.sh && \ - /tmp/library-scripts/provide-user.sh ${USERNAME} ${USER_UID} ${USER_GID} && \ - rm -rf /tmp/library-scripts - -USER ${USERNAME} diff --git a/.devcontainer/library-scripts/provide-deps.sh b/.devcontainer/library-scripts/provide-deps.sh deleted file mode 100755 index 8575667..0000000 --- a/.devcontainer/library-scripts/provide-deps.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2023 Istituto Nazionale di Fisica Nucleare -# SPDX-License-Identifier: EUPL-1.2 - -set -ex - -# Add repo for devtools and git 2.x -yum install -y \ - centos-release-scl \ - epel-release \ - https://packages.endpointdev.com/rhel/7/os/${ARCH}/endpoint-repo.${ARCH}.rpm \ - http://repository.egi.eu/sw/production/umd/4/centos7/x86_64/updates/umd-release-4.1.3-1.el7.centos.noarch.rpm - -yum update -y - -yum install -y --setopt=tsflags=nodocs \ - sudo \ - git \ - wget \ - curl \ - zip \ - unzip \ - tar \ - rpm-build \ - devtoolset-"${DEVTOOLSET_VERSION}" \ - devtoolset-"${DEVTOOLSET_VERSION}"-libubsan-devel \ - devtoolset-"${DEVTOOLSET_VERSION}"-libasan-devel \ - autoconf \ - automake \ - make \ - libtool \ - openssl-devel \ - gsoap-devel \ - curl-devel \ - mysql-devel \ - globus-gssapi-gsi-devel \ - globus-gss-assist-devel \ - globus-common-devel \ - globus-gridmap-callout-error-devel \ - globus-gsi-credential-devel \ - CGSI-gSOAP-devel \ - storm-xmlrpc-c-devel \ - argus-pep-api-c \ - argus-pep-api-c-devel \ - libuuid-devel \ - boost-devel - -yum clean all -rm -rf /var/cache/yum \ No newline at end of file diff --git a/.devcontainer/library-scripts/scl_enable b/.devcontainer/library-scripts/scl_enable deleted file mode 100644 index 31effef..0000000 --- a/.devcontainer/library-scripts/scl_enable +++ /dev/null @@ -1,6 +0,0 @@ -# IMPORTANT: Do not add more content to this file unless you know what you are -# doing. This file is sourced everytime the shell session is opened. -# -# This will make scl collection binaries work out of box. -unset BASH_ENV PROMPT_COMMAND ENV -source scl_source enable devtoolset-#DEVTOOLSET_VERSION# From 98fa4e6af3535b0b92eff3ba99a969a49bbf7d3b Mon Sep 17 00:00:00 2001 From: Francesco Giacomini Date: Fri, 26 Jul 2024 14:46:15 +0200 Subject: [PATCH 16/16] Refine devcontainer support --- .devcontainer/devcontainer.json | 1 + .gitignore | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7f24dd5..396a2fb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,6 +20,7 @@ } } }, + "remoteEnv": {"TZ": "Europe/Rome"}, "features": { "ghcr.io/devcontainers/features/git:1": {} }, diff --git a/.gitignore b/.gitignore index 875b42d..fc702bb 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,3 @@ Makefile.in !/m4/xmlrpc-c.m4 src/autogen .vscode -.devcontainer