diff options
author | Bryan Ischo <bryan@ischo.com> | 2011-09-28 01:12:32 -0700 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2011-09-28 01:12:32 -0700 |
commit | 5465b5523a323f239cfc0f724afc1f900e24fcc4 (patch) | |
tree | ca57bbcefa3d26dc1e5ff9912d531b1a08707170 | |
parent | 73366b8e549386c6183c64e3b47b913849bcddcf (diff) | |
download | ceph-libs3-5465b5523a323f239cfc0f724afc1f900e24fcc4.tar.gz |
Incorporated change from Yehuda Sadeh which allows runtime
customization of the S3 server to talk to, with additional small
improvements, enhanced by me to support multiple S3 hosts in the same
runtime.
-rw-r--r-- | GNUmakefile | 3 | ||||
-rw-r--r-- | GNUmakefile.mingw | 3 | ||||
-rw-r--r-- | GNUmakefile.osx | 3 | ||||
-rw-r--r-- | inc/libs3.h | 49 | ||||
-rw-r--r-- | inc/request.h | 3 | ||||
-rw-r--r-- | inc/util.h | 10 | ||||
-rw-r--r-- | src/acl.c | 15 | ||||
-rw-r--r-- | src/bucket.c | 22 | ||||
-rw-r--r-- | src/general.c | 14 | ||||
-rw-r--r-- | src/object.c | 15 | ||||
-rw-r--r-- | src/request.c | 23 | ||||
-rw-r--r-- | src/s3.c | 24 | ||||
-rw-r--r-- | src/service.c | 5 | ||||
-rw-r--r-- | src/service_access_logging.c | 17 |
14 files changed, 144 insertions, 62 deletions
diff --git a/GNUmakefile b/GNUmakefile index 1b4611e..0050266 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -37,6 +37,9 @@ # -------------------------------------------------------------------------- # Set libs3 version number, unless it is already set. +# This is trunk0.trunk0 on the libs3 git master branch; release branches +# are created with this set to specific version numbers when releases are +# made. LIBS3_VER_MAJOR ?= trunk0 LIBS3_VER_MINOR ?= trunk0 diff --git a/GNUmakefile.mingw b/GNUmakefile.mingw index 49d30b1..175d1e9 100644 --- a/GNUmakefile.mingw +++ b/GNUmakefile.mingw @@ -37,6 +37,9 @@ # -------------------------------------------------------------------------- # Set libs3 version number, unless it is already set. +# This is trunk0.trunk0 on the libs3 git master branch; release branches +# are created with this set to specific version numbers when releases are +# made. LIBS3_VER_MAJOR ?= trunk0 LIBS3_VER_MINOR ?= trunk0 diff --git a/GNUmakefile.osx b/GNUmakefile.osx index c270add..d4de562 100644 --- a/GNUmakefile.osx +++ b/GNUmakefile.osx @@ -37,6 +37,9 @@ # -------------------------------------------------------------------------- # Set libs3 version number, unless it is already set. +# This is trunk0.trunk0 on the libs3 git master branch; release branches +# are created with this set to specific version numbers when releases are +# made. LIBS3_VER_MAJOR ?= trunk0 LIBS3_VER_MINOR ?= trunk0 diff --git a/inc/libs3.h b/inc/libs3.h index 8f06e31..baa200c 100644 --- a/inc/libs3.h +++ b/inc/libs3.h @@ -116,11 +116,14 @@ extern "C" { ************************************************************************** **/ /** - * This is the hostname that all S3 requests will go through; virtual-host - * style requests will prepend the bucket name to this host name, and - * path-style requests will use this hostname directly + * S3_MAX_HOSTNAME_SIZE is the maximum size we allow for a host name **/ -#define S3_HOSTNAME "s3.amazonaws.com" +#define S3_MAX_HOSTNAME_SIZE 255 + +/** + * This is the default hostname that is being used for the S3 requests + **/ +#define S3_DEFAULT_HOSTNAME "s3.amazonaws.com" /** @@ -194,7 +197,7 @@ extern "C" { * query string **/ #define S3_MAX_AUTHENTICATED_QUERY_STRING_SIZE \ - (sizeof("https://" S3_HOSTNAME "/") + (S3_MAX_KEY_SIZE * 3) + \ + (sizeof("https:///") + S3_MAX_HOSTNAME_SIZE + (S3_MAX_KEY_SIZE * 3) + \ sizeof("?AWSAccessKeyId=") + 32 + sizeof("&Expires=") + 32 + \ sizeof("&Signature=") + 28 + 1) @@ -636,6 +639,12 @@ typedef struct S3AclGrant typedef struct S3BucketContext { /** + * The name of the host to connect to when making S3 requests. If set to + * NULL, the default S3 hostname passed in to S3_initialize will be used. + **/ + const char *hostName; + + /** * The name of the bucket to use in the bucket context **/ const char *bucketName; @@ -1145,13 +1154,20 @@ typedef struct S3GetObjectHandler * all necessary initialization; however, be warned that things may * break if your application re-initializes the dependent libraries * later. + * @param defaultS3Hostname is a string the specifies the default S3 server + * hostname to use when making S3 requests; this value is used + * whenever the hostName of an S3BucketContext is NULL. If NULL is + * passed here then the default of S3_DEFAULT_HOSTNAME will be used. * @return One of: * S3StatusOK on success + * S3StatusUriTooLong if the defaultS3HostName is longer than + * S3_MAX_HOSTNAME_SIZE * S3StatusInternalError if dependent libraries could not be * initialized * S3StatusOutOfMemory on failure due to out of memory **/ -S3Status S3_initialize(const char *userAgentInfo, int flags); +S3Status S3_initialize(const char *userAgentInfo, int flags, + const char *defaultS3HostName); /** @@ -1428,6 +1444,8 @@ S3Status S3_generate_authenticated_query_string * buckets * @param secretAccessKey gives the Amazon Secret Access Key for which to list * owned buckets + * @param hostName is the S3 host name to use; if NULL is passed in, the + * default S3 host as provided to S3_initialize() will be used. * @param requestContext if non-NULL, gives the S3RequestContext to add this * request to, and does not perform the request immediately. If NULL, * performs the request immediately and synchronously. @@ -1437,7 +1455,7 @@ S3Status S3_generate_authenticated_query_string * all callbacks for this request **/ void S3_list_service(S3Protocol protocol, const char *accessKeyId, - const char *secretAccessKey, + const char *secretAccessKey, const char *hostName, S3RequestContext *requestContext, const S3ListServiceHandler *handler, void *callbackData); @@ -1457,6 +1475,8 @@ void S3_list_service(S3Protocol protocol, const char *accessKeyId, * buckets * @param secretAccessKey gives the Amazon Secret Access Key for which to list * owned buckets + * @param hostName is the S3 host name to use; if NULL is passed in, the + * default S3 host as provided to S3_initialize() will be used. * @param bucketName is the bucket name to test * @param locationConstraintReturnSize gives the number of bytes in the * locationConstraintReturn parameter @@ -1477,7 +1497,8 @@ void S3_list_service(S3Protocol protocol, const char *accessKeyId, **/ void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle, const char *accessKeyId, const char *secretAccessKey, - const char *bucketName, int locationConstraintReturnSize, + const char *hostName, const char *bucketName, + int locationConstraintReturnSize, char *locationConstraintReturn, S3RequestContext *requestContext, const S3ResponseHandler *handler, void *callbackData); @@ -1491,6 +1512,8 @@ void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle, * buckets * @param secretAccessKey gives the Amazon Secret Access Key for which to list * owned buckets + * @param hostName is the S3 host name to use; if NULL is passed in, the + * default S3 host as provided to S3_initialize() will be used. * @param bucketName is the name of the bucket to be created * @param cannedAcl gives the "REST canned ACL" to use for the created bucket * @param locationConstraint if non-NULL, gives the geographic location for @@ -1504,8 +1527,9 @@ void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle, * all callbacks for this request **/ void S3_create_bucket(S3Protocol protocol, const char *accessKeyId, - const char *secretAccessKey, const char *bucketName, - S3CannedAcl cannedAcl, const char *locationConstraint, + const char *secretAccessKey, const char *hostName, + const char *bucketName, S3CannedAcl cannedAcl, + const char *locationConstraint, S3RequestContext *requestContext, const S3ResponseHandler *handler, void *callbackData); @@ -1520,6 +1544,8 @@ void S3_create_bucket(S3Protocol protocol, const char *accessKeyId, * buckets * @param secretAccessKey gives the Amazon Secret Access Key for which to list * owned buckets + * @param hostName is the S3 host name to use; if NULL is passed in, the + * default S3 host as provided to S3_initialize() will be used. * @param bucketName is the name of the bucket to be deleted * @param requestContext if non-NULL, gives the S3RequestContext to add this * request to, and does not perform the request immediately. If NULL, @@ -1531,7 +1557,8 @@ void S3_create_bucket(S3Protocol protocol, const char *accessKeyId, **/ void S3_delete_bucket(S3Protocol protocol, S3UriStyle uriStyle, const char *accessKeyId, const char *secretAccessKey, - const char *bucketName, S3RequestContext *requestContext, + const char *hostName, const char *bucketName, + S3RequestContext *requestContext, const S3ResponseHandler *handler, void *callbackData); diff --git a/inc/request.h b/inc/request.h index afb4929..9e3a477 100644 --- a/inc/request.h +++ b/inc/request.h @@ -165,7 +165,8 @@ typedef struct Request // ---------------------------------------------------------------------------- // Initialize the API -S3Status request_api_initialize(const char *userAgentInfo, int flags); +S3Status request_api_initialize(const char *userAgentInfo, int flags, + const char *hostName); // Deinitialize the API void request_api_deinitialize(); @@ -32,6 +32,14 @@ #include <stdint.h> #include "libs3.h" +// acl groups +#define ACS_URL "http://acs.amazonaws.com/groups/" + +#define ACS_GROUP_ALL_USERS ACS_URL "global/AllUsers" +#define ACS_GROUP_AWS_USERS ACS_URL "global/AuthenticatedUsers" +#define ACS_GROUP_LOG_DELIVERY ACS_URL "s3/LogDelivery" + + // Derived from S3 documentation @@ -49,7 +57,7 @@ // https://s3.amazonaws.com/${BUCKET}/${KEY}?acl // 255 is the maximum bucket length #define MAX_URI_SIZE \ - ((sizeof("https://" S3_HOSTNAME "/") - 1) + 255 + 1 + \ + ((sizeof("https:///") - 1) + S3_MAX_HOSTNAME_SIZE + 255 + 1 + \ MAX_URLENCODED_KEY_SIZE + (sizeof("?torrent" - 1)) + 1) // Maximum size of a canonicalized resource @@ -122,7 +122,8 @@ void S3_get_acl(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypeGET, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId @@ -195,16 +196,13 @@ static S3Status generateAclXmlDocument(const char *ownerId, const char *grantee; switch (grant->granteeType) { case S3GranteeTypeAllAwsUsers: - grantee = "http://acs.amazonaws.com/groups/global/" - "AuthenticatedUsers"; + grantee = ACS_GROUP_AWS_USERS; break; case S3GranteeTypeAllUsers: - grantee = "http://acs.amazonaws.com/groups/global/" - "AllUsers"; + grantee = ACS_GROUP_ALL_USERS; break; default: - grantee = "http://acs.amazonaws.com/groups/s3/" - "LogDelivery"; + grantee = ACS_GROUP_LOG_DELIVERY; break; } append("Group\"><URI>%s</URI>", grantee); @@ -322,7 +320,8 @@ void S3_set_acl(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypePUT, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId diff --git a/src/bucket.c b/src/bucket.c index 9bac3ca..f4f1987 100644 --- a/src/bucket.c +++ b/src/bucket.c @@ -107,7 +107,8 @@ static void testBucketCompleteCallback(S3Status requestStatus, void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle, const char *accessKeyId, const char *secretAccessKey, - const char *bucketName, int locationConstraintReturnSize, + const char *hostName, const char *bucketName, + int locationConstraintReturnSize, char *locationConstraintReturn, S3RequestContext *requestContext, const S3ResponseHandler *handler, void *callbackData) @@ -134,7 +135,8 @@ void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle, RequestParams params = { HttpRequestTypeGET, // httpRequestType - { bucketName, // bucketName + { hostName, // hostName + bucketName, // bucketName protocol, // protocol uriStyle, // uriStyle accessKeyId, // accessKeyId @@ -223,8 +225,9 @@ static void createBucketCompleteCallback(S3Status requestStatus, void S3_create_bucket(S3Protocol protocol, const char *accessKeyId, - const char *secretAccessKey, const char *bucketName, - S3CannedAcl cannedAcl, const char *locationConstraint, + const char *secretAccessKey, const char *hostName, + const char *bucketName, S3CannedAcl cannedAcl, + const char *locationConstraint, S3RequestContext *requestContext, const S3ResponseHandler *handler, void *callbackData) { @@ -270,7 +273,8 @@ void S3_create_bucket(S3Protocol protocol, const char *accessKeyId, RequestParams params = { HttpRequestTypePUT, // httpRequestType - { bucketName, // bucketName + { hostName, // hostName + bucketName, // bucketName protocol, // protocol S3UriStylePath, // uriStyle accessKeyId, // accessKeyId @@ -332,7 +336,7 @@ static void deleteBucketCompleteCallback(S3Status requestStatus, void S3_delete_bucket(S3Protocol protocol, S3UriStyle uriStyle, const char *accessKeyId, const char *secretAccessKey, - const char *bucketName, + const char *hostName, const char *bucketName, S3RequestContext *requestContext, const S3ResponseHandler *handler, void *callbackData) { @@ -352,7 +356,8 @@ void S3_delete_bucket(S3Protocol protocol, S3UriStyle uriStyle, RequestParams params = { HttpRequestTypeDELETE, // httpRequestType - { bucketName, // bucketName + { hostName, // hostName + bucketName, // bucketName protocol, // protocol uriStyle, // uriStyle accessKeyId, // accessKeyId @@ -710,7 +715,8 @@ void S3_list_bucket(const S3BucketContext *bucketContext, const char *prefix, RequestParams params = { HttpRequestTypeGET, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId diff --git a/src/general.c b/src/general.c index 861c289..fb30c37 100644 --- a/src/general.c +++ b/src/general.c @@ -32,13 +32,14 @@ static int initializeCountG = 0; -S3Status S3_initialize(const char *userAgentInfo, int flags) +S3Status S3_initialize(const char *userAgentInfo, int flags, + const char *defaultS3HostName) { if (initializeCountG++) { return S3StatusOK; } - return request_api_initialize(userAgentInfo, flags); + return request_api_initialize(userAgentInfo, flags, defaultS3HostName); } @@ -372,18 +373,15 @@ static S3Status convertAclXmlCallback(const char *elementPath, } else if (caData->groupUri[0]) { if (!strcmp(caData->groupUri, - "http://acs.amazonaws.com/groups/global/" - "AuthenticatedUsers")) { + ACS_GROUP_AWS_USERS)) { grant->granteeType = S3GranteeTypeAllAwsUsers; } else if (!strcmp(caData->groupUri, - "http://acs.amazonaws.com/groups/global/" - "AllUsers")) { + ACS_GROUP_ALL_USERS)) { grant->granteeType = S3GranteeTypeAllUsers; } else if (!strcmp(caData->groupUri, - "http://acs.amazonaws.com/groups/s3/" - "LogDelivery")) { + ACS_GROUP_LOG_DELIVERY)) { grant->granteeType = S3GranteeTypeLogDelivery; } else { diff --git a/src/object.c b/src/object.c index 9f1d33b..d7c7f80 100644 --- a/src/object.c +++ b/src/object.c @@ -42,7 +42,8 @@ void S3_put_object(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypePUT, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId @@ -199,7 +200,8 @@ void S3_copy_object(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypeCOPY, // httpRequestType - { destinationBucket ? destinationBucket : + { bucketContext->hostName, // hostName + destinationBucket ? destinationBucket : bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle @@ -239,7 +241,8 @@ void S3_get_object(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypeGET, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId @@ -276,7 +279,8 @@ void S3_head_object(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypeHEAD, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId @@ -313,7 +317,8 @@ void S3_delete_object(const S3BucketContext *bucketContext, const char *key, RequestParams params = { HttpRequestTypeDELETE, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId diff --git a/src/request.c b/src/request.c index 646c26c..b267a5e 100644 --- a/src/request.c +++ b/src/request.c @@ -46,6 +46,8 @@ static Request *requestStackG[REQUEST_STACK_SIZE]; static int requestStackCountG; +char defaultHostNameG[S3_MAX_HOSTNAME_SIZE]; + typedef struct RequestComputedValues { @@ -755,17 +757,20 @@ static S3Status compose_uri(char *buffer, int bufferSize, uri_append("http%s://", (bucketContext->protocol == S3ProtocolHTTP) ? "" : "s"); + const char *hostName = + bucketContext->hostName ? bucketContext->hostName : defaultHostNameG; + if (bucketContext->bucketName && bucketContext->bucketName[0]) { if (bucketContext->uriStyle == S3UriStyleVirtualHost) { - uri_append("%s.s3.amazonaws.com", bucketContext->bucketName); + uri_append("%s.%s", bucketContext->bucketName, hostName); } else { - uri_append("s3.amazonaws.com/%s", bucketContext->bucketName); + uri_append("%s/%s", hostName, bucketContext->bucketName); } } else { - uri_append("%s", "s3.amazonaws.com"); + uri_append("%s", hostName); } uri_append("%s", "/"); @@ -1058,7 +1063,8 @@ static void request_release(Request *request) } -S3Status request_api_initialize(const char *userAgentInfo, int flags) +S3Status request_api_initialize(const char *userAgentInfo, int flags, + const char *defaultHostName) { if (curl_global_init(CURL_GLOBAL_ALL & ~((flags & S3_INIT_WINSOCK) ? 0 : CURL_GLOBAL_WIN32)) @@ -1066,6 +1072,15 @@ S3Status request_api_initialize(const char *userAgentInfo, int flags) return S3StatusInternalError; } + if (!defaultHostName) { + defaultHostName = S3_DEFAULT_HOSTNAME; + } + + if (snprintf(defaultHostNameG, S3_MAX_HOSTNAME_SIZE, + "%s", defaultHostName) >= S3_MAX_HOSTNAME_SIZE) { + return S3StatusUriTooLong; + } + pthread_mutex_init(&requestStackMutexG, 0); requestStackCountG = 0; @@ -144,7 +144,9 @@ static char putenvBufG[256]; static void S3_init() { S3Status status; - if ((status = S3_initialize("s3", S3_INIT_ALL)) + const char *hostname = getenv("S3_HOSTNAME"); + + if ((status = S3_initialize("s3", S3_INIT_ALL, hostname)) != S3StatusOK) { fprintf(stderr, "Failed to initialize libs3: %s\n", S3_get_status_name(status)); @@ -184,6 +186,7 @@ static void usageExit(FILE *out) "\n" " S3_ACCESS_KEY_ID : S3 access key ID (required)\n" " S3_SECRET_ACCESS_KEY : S3 secret access key (required)\n" +" S3_HOSTNAME : specify alternative S3 host (optional)\n" "\n" " Commands (with <required parameters> and [optional parameters]) :\n" "\n" @@ -862,7 +865,7 @@ static void list_service(int allDetails) }; do { - S3_list_service(protocolG, accessKeyIdG, secretAccessKeyG, 0, + S3_list_service(protocolG, accessKeyIdG, secretAccessKeyG, 0, 0, &listServiceHandler, &data); } while (S3_status_is_retryable(statusG) && should_retry()); @@ -906,7 +909,7 @@ static void test_bucket(int argc, char **argv, int optindex) char locationConstraint[64]; do { S3_test_bucket(protocolG, uriStyleG, accessKeyIdG, secretAccessKeyG, - bucketName, sizeof(locationConstraint), + 0, bucketName, sizeof(locationConstraint), locationConstraint, 0, &responseHandler, 0); } while (S3_status_is_retryable(statusG) && should_retry()); @@ -1005,7 +1008,7 @@ static void create_bucket(int argc, char **argv, int optindex) do { S3_create_bucket(protocolG, accessKeyIdG, secretAccessKeyG, - bucketName, cannedAcl, locationConstraint, 0, + 0, bucketName, cannedAcl, locationConstraint, 0, &responseHandler, 0); } while (S3_status_is_retryable(statusG) && should_retry()); @@ -1045,7 +1048,7 @@ static void delete_bucket(int argc, char **argv, int optindex) do { S3_delete_bucket(protocolG, uriStyleG, accessKeyIdG, secretAccessKeyG, - bucketName, 0, &responseHandler, 0); + 0, bucketName, 0, &responseHandler, 0); } while (S3_status_is_retryable(statusG) && should_retry()); if (statusG != S3StatusOK) { @@ -1196,6 +1199,7 @@ static void list_bucket(const char *bucketName, const char *prefix, S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -1315,6 +1319,7 @@ static void delete_object(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -1575,6 +1580,7 @@ static void put_object(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -1761,6 +1767,7 @@ static void copy_object(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, sourceBucketName, protocolG, uriStyleG, @@ -1940,6 +1947,7 @@ static void get_object(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -2013,6 +2021,7 @@ static void head_object(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -2091,6 +2100,7 @@ static void generate_query_string(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -2192,6 +2202,7 @@ void get_acl(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -2354,6 +2365,7 @@ void set_acl(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -2445,6 +2457,7 @@ void get_logging(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, @@ -2610,6 +2623,7 @@ void set_logging(int argc, char **argv, int optindex) S3BucketContext bucketContext = { + 0, bucketName, protocolG, uriStyleG, diff --git a/src/service.c b/src/service.c index 68b3ff8..2d1e038 100644 --- a/src/service.c +++ b/src/service.c @@ -131,7 +131,7 @@ static void completeCallback(S3Status requestStatus, void S3_list_service(S3Protocol protocol, const char *accessKeyId, - const char *secretAccessKey, + const char *secretAccessKey, const char *hostName, S3RequestContext *requestContext, const S3ListServiceHandler *handler, void *callbackData) { @@ -161,7 +161,8 @@ void S3_list_service(S3Protocol protocol, const char *accessKeyId, RequestParams params = { HttpRequestTypeGET, // httpRequestType - { 0, // bucketName + { hostName, // hostName + 0, // bucketName protocol, // protocol S3UriStylePath, // uriStyle accessKeyId, // accessKeyId diff --git a/src/service_access_logging.c b/src/service_access_logging.c index cbed2c1..22c6e40 100644 --- a/src/service_access_logging.c +++ b/src/service_access_logging.c @@ -147,13 +147,11 @@ static S3Status convertBlsXmlCallback(const char *elementPath, } else if (caData->groupUri[0]) { if (!strcmp(caData->groupUri, - "http://acs.amazonaws.com/groups/global/" - "AuthenticatedUsers")) { + ACS_GROUP_AWS_USERS)) { grant->granteeType = S3GranteeTypeAllAwsUsers; } else if (!strcmp(caData->groupUri, - "http://acs.amazonaws.com/groups/global/" - "AllUsers")) { + ACS_GROUP_ALL_USERS)) { grant->granteeType = S3GranteeTypeAllUsers; } else { @@ -325,7 +323,8 @@ void S3_get_server_access_logging(const S3BucketContext *bucketContext, RequestParams params = { HttpRequestTypeGET, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId @@ -405,10 +404,9 @@ static S3Status generateSalXmlDocument(const char *targetBucket, grant->grantee.canonicalUser.displayName); break; default: // case S3GranteeTypeAllAwsUsers/S3GranteeTypeAllUsers: - append("Group\"><URI>http://acs.amazonaws.com/groups/" - "global/%s</URI>", + append("Group\"><URI>%s</URI>", (grant->granteeType == S3GranteeTypeAllAwsUsers) ? - "AuthenticatedUsers" : "AllUsers"); + ACS_GROUP_AWS_USERS : ACS_GROUP_ALL_USERS); break; } append("</Grantee><Permission>%s</Permission></Grant>", @@ -529,7 +527,8 @@ void S3_set_server_access_logging(const S3BucketContext *bucketContext, RequestParams params = { HttpRequestTypePUT, // httpRequestType - { bucketContext->bucketName, // bucketName + { bucketContext->hostName, // hostName + bucketContext->bucketName, // bucketName bucketContext->protocol, // protocol bucketContext->uriStyle, // uriStyle bucketContext->accessKeyId, // accessKeyId |