Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement directory listing #35

Merged
merged 15 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "vendor/gtest"]
path = vendor/gtest
url = https://github.com/google/googletest.git

[submodule "vendor/tinyxml2"]
path = vendor/tinyxml2
url = https://github.com/leethomason/tinyxml2.git
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ if(NOT APPLE)
SET( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined")
endif()

if( NOT XROOTD_EXTERNAL_TINYXML2 )
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(vendor/tinyxml2)
else()
find_package(tinyxml2::tinyxml2)
endif()

include_directories(${XROOTD_INCLUDES} ${CURL_INCLUDE_DIRS} ${LIBCRYPTO_INCLUDE_DIRS})

add_library(XrdS3 SHARED src/S3File.cc src/S3AccessInfo.cc src/S3FileSystem.cc src/AWSv4-impl.cc src/S3Commands.cc src/HTTPCommands.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)
add_library(XrdS3 SHARED src/S3File.cc src/S3Directory.cc src/S3AccessInfo.cc src/S3FileSystem.cc src/AWSv4-impl.cc src/S3Commands.cc src/HTTPCommands.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)
add_library(XrdHTTPServer SHARED src/HTTPFile.cc src/HTTPFileSystem.cc src/HTTPCommands.cc src/stl_string_utils.cc src/shortfile.cc src/logging.cc)

target_link_libraries(XrdS3 -ldl ${XROOTD_UTILS_LIB} ${XROOTD_SERVER_LIB} ${CURL_LIBRARIES} ${LIBCRYPTO_LIBRARIES})
target_link_libraries(XrdS3 -ldl ${XROOTD_UTILS_LIB} ${XROOTD_SERVER_LIB} ${CURL_LIBRARIES} ${LIBCRYPTO_LIBRARIES} tinyxml2::tinyxml2)
target_link_libraries(XrdHTTPServer -ldl ${XROOTD_UTILS_LIB} ${XROOTD_SERVER_LIB} ${CURL_LIBRARIES} ${LIBCRYPTO_LIBRARIES})

# The CMake documentation strongly advises against using these macros; instead, the pkg_check_modules
Expand Down
4 changes: 3 additions & 1 deletion src/AWSv4-impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ std::string canonicalizeQueryString(
}

// We'll always have a superflous trailing ampersand.
canonicalQueryString.erase(canonicalQueryString.end() - 1);
if (!canonicalQueryString.empty()) {
canonicalQueryString.erase(canonicalQueryString.end() - 1);
}
return canonicalQueryString;
}

Expand Down
18 changes: 2 additions & 16 deletions src/HTTPCommands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ HTTPRequest::~HTTPRequest() {}
if (rv##B != CURLE_OK) { \
this->errorCode = "E_CURL_LIB"; \
this->errorMessage = "curl_easy_setopt( " #B " ) failed."; \
/* dprintf( D_ALWAYS, "curl_easy_setopt( %s ) failed (%d): '%s', \
failing.\n", #B, rv##B, curl_easy_strerror( rv##B ) ); */ \
return false; \
} \
}
Expand Down Expand Up @@ -168,6 +166,8 @@ bool HTTPRequest::sendPreparedRequest(const std::string &protocol,
const std::string &uri,
const std::string &payload) {

m_log.Log(XrdHTTPServer::Debug, "SendRequest", "Sending HTTP request",
uri.c_str());
CURLcode rv = curl_global_init(CURL_GLOBAL_ALL);
if (rv != 0) {
this->errorCode = "E_CURL_LIB";
Expand Down Expand Up @@ -317,20 +317,6 @@ bool HTTPRequest::sendPreparedRequest(const std::string &protocol,
CAFile = x509_ca_file;
}

if (CAPath.empty()) {
char *soap_ssl_ca_dir = getenv("GAHP_SSL_CADIR");
if (soap_ssl_ca_dir != NULL) {
CAPath = soap_ssl_ca_dir;
}
}

if (CAFile.empty()) {
char *soap_ssl_ca_file = getenv("GAHP_SSL_CAFILE");
if (soap_ssl_ca_file != NULL) {
CAFile = soap_ssl_ca_file;
}
}

if (!CAPath.empty()) {
SET_CURL_SECURITY_OPTION(curl.get(), CURLOPT_CAPATH, CAPath.c_str());
}
Expand Down
4 changes: 3 additions & 1 deletion src/HTTPCommands.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class HTTPRequest {
virtual bool SendHTTPRequest(const std::string &payload);

unsigned long getResponseCode() const { return responseCode; }
const std::string & getErrorCode() const {return errorCode;}
const std::string & getErrorMessage() const {return errorMessage;}
const std::string &getResultString() const { return resultString; }

// Currently only used in PUTS, but potentially useful elsewhere
Expand Down Expand Up @@ -74,7 +76,7 @@ class HTTPRequest {
std::string errorCode;

std::string resultString;
unsigned long responseCode;
unsigned long responseCode{0};
unsigned long expectedResponseCode = 200;
bool includeResponseHeader;

Expand Down
6 changes: 6 additions & 0 deletions src/S3AccessInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ const std::string &S3AccessInfo::getS3SecretKeyFile() const {
void S3AccessInfo::setS3SecretKeyFile(const std::string &s3SecretKeyFile) {
s3_secret_key_file = s3SecretKeyFile;
}

const std::string &S3AccessInfo::getS3UrlStyle() const { return s3_url_style; }

void S3AccessInfo::setS3UrlStyle(const std::string &s3UrlStyle) {
s3_url_style = s3UrlStyle;
}
12 changes: 8 additions & 4 deletions src/S3AccessInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Created by Rich Wellner on 2/29/24.
//

#ifndef XROOTD_S3_HTTP_S3ACCESSINFO_HH
#define XROOTD_S3_HTTP_S3ACCESSINFO_HH
#pragma once

#include <string>

Expand Down Expand Up @@ -33,13 +32,18 @@ class S3AccessInfo {

void setS3SecretKeyFile(const std::string &s3SecretKeyFile);

const std::string &getS3UrlStyle() const;

void setS3UrlStyle(const std::string &s3UrlStyle);

const int getS3SignatureVersion() const {return 4;}

private:
std::string s3_bucket_name;
std::string s3_service_name;
std::string s3_region;
std::string s3_service_url;
std::string s3_access_key_file;
std::string s3_secret_key_file;
std::string s3_url_style;
};

#endif // XROOTD_S3_HTTP_S3ACCESSINFO_HH
Loading
Loading