GitLab will be unavailable (again) this Thursday 8:00-8:30 to complete a database upgrade: http://cern.ch/go/r8ln

DMC-910: Fix couple of leaks

parent db7d8016
......@@ -170,6 +170,8 @@ GridFTPSession::~GridFTPSession()
globus_gass_copy_handleattr_destroy(&gass_handle_attr);
globus_ftp_client_handleattr_destroy(&attr_handle);
globus_ftp_client_features_destroy(&this->ftp_features);
OM_uint32 minor_status;
gss_release_cred(&minor_status, &this->cred_id);
}
......@@ -262,7 +264,8 @@ void GridFTPSession::set_udt(bool udt)
}
void gfal_globus_set_credentials(gfal2_context_t context, const char *url, globus_ftp_client_operationattr_t* opattr)
void gfal_globus_set_credentials(gfal2_context_t context, const char *url, gss_cred_id_t *cred_id,
globus_ftp_client_operationattr_t* opattr)
{
// X509
gchar* ucert = gfal2_get_opt_string(context, "X509", "CERT", NULL);
......@@ -286,7 +289,7 @@ void gfal_globus_set_credentials(gfal2_context_t context, const char *url, globu
gfal2_log(G_LOG_LEVEL_DEBUG, "FTP using user %s", user);
}
gfal_globus_set_credentials(ucert, ukey, user, passwd, opattr);
gfal_globus_set_credentials(ucert, ukey, user, passwd, cred_id, opattr);
// Release memory
g_free(ucert);
......@@ -298,10 +301,9 @@ void gfal_globus_set_credentials(gfal2_context_t context, const char *url, globu
void gfal_globus_set_credentials(const char* ucert, const char* ukey,
const char *user, const char *passwd,
gss_cred_id_t *cred_id,
globus_ftp_client_operationattr_t* opattr)
{
gss_cred_id_t cred_id = GSS_C_NO_CREDENTIAL;
if (ucert) {
std::stringstream buffer;
std::ifstream cert_stream(ucert);
......@@ -320,13 +322,13 @@ void gfal_globus_set_credentials(const char* ucert, const char* ukey,
buffer << key_stream.rdbuf();
}
OM_uint32 minor_status, major_status;
gss_buffer_desc_struct buffer_desc;
buffer_desc.value = g_strdup(buffer.str().c_str());
buffer_desc.length = buffer.str().size();
OM_uint32 minor_status, major_status;
major_status = gss_import_cred(&minor_status, &cred_id,
major_status = gss_import_cred(&minor_status, cred_id,
GSS_C_NO_OID, 0, // 0 = Pass credentials; 1 = Pass path as X509_USER_PROXY=...
&buffer_desc, 0, NULL);
g_free(buffer_desc.value);
......@@ -353,7 +355,7 @@ void gfal_globus_set_credentials(const char* ucert, const char* ukey,
}
globus_ftp_client_operationattr_set_authorization(
opattr, cred_id, user, passwd, NULL, NULL);
opattr, *cred_id, user, passwd, NULL, NULL);
}
......@@ -605,7 +607,7 @@ GridFTPSession* GridFTPFactory::get_new_handle(const std::string &hostname)
session->set_ipv6(ipv6);
session->set_delayed_pass(delay_passv);
gfal_globus_set_credentials(gfal2_context, hostname.c_str(), &session->operation_attr_ftp);
gfal_globus_set_credentials(gfal2_context, hostname.c_str(), &session->cred_id, &session->operation_attr_ftp);
return session.release();
}
......
......@@ -102,6 +102,7 @@ public:
std::string hostname;
gss_cred_id_t cred_id;
globus_ftp_client_handle_t handle_ftp;
globus_ftp_client_plugin_t debug_ftp_plugin;
globus_ftp_client_handleattr_t attr_handle;
......@@ -215,10 +216,12 @@ int gfal_globus_error_convert(globus_object_t * error, char ** str_error);
// throw Glib::Error if error associated with this result
void gfal_globus_check_result(GQuark scope, globus_result_t res);
void gfal_globus_set_credentials(gfal2_context_t context, const char *url, globus_ftp_client_operationattr_t* opattr);
void gfal_globus_set_credentials(gfal2_context_t context, const char *url,
gss_cred_id_t *cred_id, globus_ftp_client_operationattr_t* opattr);
void gfal_globus_set_credentials(const char* ucert, const char* ukey,
const char *user, const char *passwd,
gss_cred_id_t *cred_id,
globus_ftp_client_operationattr_t* opattr);
#endif /* GRIDFTPWRAPPER_H */
......@@ -70,8 +70,7 @@ int gfal_mds_cache_resolve_endpoint(gfal2_context_t handle, const char* host,
GError** err)
{
// Cache configuration
gchar *cache_file = gfal2_get_opt_string(handle, bdii_config_group,
bdii_cache_file, NULL);
gchar *cache_file = gfal2_get_opt_string(handle, bdii_config_group, bdii_cache_file, NULL);
if (!cache_file)
return 0;
......@@ -81,6 +80,9 @@ int gfal_mds_cache_resolve_endpoint(gfal2_context_t handle, const char* host,
// (A cache may not be present!)
pugi::xml_document cache;
pugi::xml_parse_result loadResult = cache.load_file(cache_file);
g_free(cache_file);
if (loadResult.status != pugi::status_ok) {
gfal2_log(G_LOG_LEVEL_WARNING, "Could not load BDII CACHE_FILE: %s",
loadResult.description());
......
......@@ -242,22 +242,21 @@ int gfal_mds_get_srm_types_endpoint(LDAP *ld, LDAPMessage *result, gfal_mds_endp
**/
int gfal_mds_get_ldapuri(gfal2_context_t context, char *buff, size_t s_buff, GError **err)
{
char *bdii_var = getenv(bdii_env_var);
if (bdii_var == NULL)
char *bdii_var = g_strdup(getenv(bdii_env_var));
if (bdii_var == NULL) {
bdii_var = gfal2_get_opt_string(context, bdii_config_group, bdii_config_var, NULL);
}
if (bdii_var == NULL || bdii_var[0] == '\0') {
g_set_error(err, gfal2_get_core_quark(), EINVAL,
" no valid value for BDII found:"
" please, configure the plugin properly, or try setting in the environment LCG_GFAL_INFOSYS");
g_free(bdii_var);
return -1;
}
gfal2_log(G_LOG_LEVEL_DEBUG, " use LCG_GFAL_INFOSYS : %s", bdii_var);
// Since strtok will modify, use a copy
bdii_var = g_strdup(bdii_var);
char *save_ptr = NULL;
char *token = NULL;
......@@ -275,7 +274,6 @@ int gfal_mds_get_ldapuri(gfal2_context_t context, char *buff, size_t s_buff, GEr
buff[i - 1] = '\0';
g_free(bdii_var);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment