diff options
author | Bryan Ischo <bryan@ischo.com> | 2008-08-07 14:20:31 +0000 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2008-08-07 14:20:31 +0000 |
commit | 035dd9752eeefdcbb885bc234cda04563f68d319 (patch) | |
tree | 1854a13b20f9532cf9b767df55789362bfde76e6 /src | |
parent | 744c19acf5d8dd7c02193bf3fafd2e6a548f43e4 (diff) | |
download | ceph-libs3-035dd9752eeefdcbb885bc234cda04563f68d319.tar.gz |
* Support build on Microsoft Windows via MingW
* Don't verify Amazon S3's SSL certificate, doing so causes problems
* Added error code to properly report the case where the SSL certificate
verification fails
Diffstat (limited to 'src')
-rw-r--r-- | src/general.c | 2 | ||||
-rw-r--r-- | src/mingw_functions.c | 47 | ||||
-rw-r--r-- | src/request.c | 10 | ||||
-rw-r--r-- | src/s3.c | 8 |
4 files changed, 62 insertions, 5 deletions
diff --git a/src/general.c b/src/general.c index fe0501c..7ea458a 100644 --- a/src/general.c +++ b/src/general.c @@ -31,7 +31,6 @@ #ifndef OPENSSL_THREADS #error "Threading support required in OpenSSL library, but not provided" #endif -#include <pthread.h> #include <string.h> #include "request.h" #include "simplexml.h" @@ -234,6 +233,7 @@ const char *S3_get_status_name(S3Status status) handlecase(AclXmlDocumentTooLarge); handlecase(NameLookupError); handlecase(FailedToConnect); + handlecase(ServerFailedVerification); handlecase(ConnectionFailed); handlecase(AbortedByCallback); handlecase(ErrorAccessDenied); diff --git a/src/mingw_functions.c b/src/mingw_functions.c new file mode 100644 index 0000000..6cdd296 --- /dev/null +++ b/src/mingw_functions.c @@ -0,0 +1,47 @@ +/** ************************************************************************** + * mingw_functions.c + * + * Copyright 2008 Bryan Ischo <bryan@ischo.com> + * + * This file is part of libs3. + * + * libs3 is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, version 3 of the License. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of this library and its programs with the + * OpenSSL library, and distribute linked combinations including the two. + * + * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License version 3 + * along with libs3, in a file named COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + ************************************************************************** **/ + +#include <sys/utsname.h> + +int uname(struct utsname *u) +{ + u->sysname = "not implemented"; + u->machine = "not implemented"; + + return 0; +} + +int setenv(const char *a, const char *b, int c) +{ + return 0; +} + +int unsetenv(const char *a) +{ + return 0; +} + + diff --git a/src/request.c b/src/request.c index 6c2f554..90d2505 100644 --- a/src/request.c +++ b/src/request.c @@ -832,6 +832,11 @@ static S3Status setup_curl(Request *request, // Don't use Curl's 'netrc' feature curl_easy_setopt_safe(CURLOPT_NETRC, CURL_NETRC_IGNORED); + // Don't verify S3's certificate, there are known to be issues with + // them sometimes + // xxx todo - support an option for verifying the S3 CA (default false) + curl_easy_setopt_safe(CURLOPT_SSL_VERIFYPEER, 0); + // Follow any redirection directives that S3 sends curl_easy_setopt_safe(CURLOPT_FOLLOWLOCATION, 1); @@ -1081,7 +1086,7 @@ void request_perform(const RequestParams *params, S3RequestContext *context) // These will hold the computed values RequestComputedValues computed; - + // Validate the bucket name if (params->bucketName && ((status = S3_validate_bucket_name @@ -1246,6 +1251,9 @@ S3Status request_curl_code_to_status(CURLcode code) return S3StatusConnectionFailed; case CURLE_PARTIAL_FILE: return S3StatusOK; + case CURLE_PEER_FAILED_VERIFICATION: + case CURLE_SSL_CACERT: + return S3StatusServerFailedVerification; default: return S3StatusInternalError; } @@ -29,8 +29,8 @@ * calls to libs3 functions, and prints the results. **/ +#include <ctype.h> #include <getopt.h> -#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -1206,7 +1206,8 @@ static void list(int argc, char **argv, int optind) else if (!strncmp(param, ALL_DETAILS_PREFIX, ALL_DETAILS_PREFIX_LEN)) { const char *ad = &(param[ALL_DETAILS_PREFIX_LEN]); - if (!strcasecmp(ad, "true") || !strcasecmp(ad, "yes") || + if (!strcmp(ad, "true") || !strcmp(ad, "TRUE") || + !strcmp(ad, "yes") || !strcmp(ad, "YES") || !strcmp(ad, "1")) { allDetails = 1; } @@ -1436,7 +1437,8 @@ static void put_object(int argc, char **argv, int optind) } else if (!strncmp(param, NO_STATUS_PREFIX, NO_STATUS_PREFIX_LEN)) { const char *ns = &(param[NO_STATUS_PREFIX_LEN]); - if (!strcasecmp(ns, "true") || !strcasecmp(ns, "yes") || + if (!strcmp(ns, "true") || !strcmp(ns, "TRUE") || + !strcmp(ns, "yes") || !strcmp(ns, "YES") || !strcmp(ns, "1")) { noStatus = 1; } |