diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..506b1b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +src/*.o +src/s3 +debian/compat +debian/files +debian/apt-transport-s3 +debian/apt-transport-s3.substvars +debian/apt-transport-s3.debhelper.log +*~ \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 43d8e7f..cd00edb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +apt-transport-s3 (1.1ubuntu1) oneiric; urgency=low + + * Make apt-transport-s3 work, when locale is non-english. + + -- Jens Braeuer Mon, 31 Jan 2012 21:01:25 +0100 + apt-transport-s3 (1.0ubuntu1) lucid; urgency=low * Working around stupid amazon s3 behaviour with filenames diff --git a/src/Makefile b/src/Makefile index 161bc02..d57765b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,13 +2,13 @@ default: s3 clean: - rm *.o s3 + rm -f *.o s3 s3: s3_main.o s3.o connect.o - g++ -lapt-pkg -lapt-inst -lssl -lcrypto -o s3 s3.o s3_main.o connect.o + g++ -o s3 s3.o s3_main.o connect.o -lapt-pkg -lapt-inst -lssl -lcrypto %.o: %.cc gcc -I /usr/include -I./ -g -c $< install: s3 - cp s3 /usr/lib/apt/methods/ \ No newline at end of file + cp s3 /usr/lib/apt/methods/ diff --git a/src/s3.cc b/src/s3.cc index 1ac463d..a23bd4a 100644 --- a/src/s3.cc +++ b/src/s3.cc @@ -740,37 +740,51 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) Req += string("Proxy-Authorization: Basic ") + Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n"; - /* S3 Specific */ - time_t rawtime; - struct tm * timeinfo; - char buffer [80]; - - time( &rawtime); - timeinfo = gmtime( &rawtime); - - strftime(buffer, 80, "%a, %d %b %Y %H:%M:%S +0000", timeinfo); - string dateString((const char*)buffer); - Req += "Date: " + dateString + "\r\n"; - - string extractedPassword; - if (Uri.Password.empty() && NULL == getenv("AWS_SECRET_ACCESS_KEY")) { - cerr << "E: No AWS_SECRET_ACCESS_KEY set" << endl; - exit(1); - } else if(Uri.Password.empty()) { - extractedPassword = getenv("AWS_SECRET_ACCESS_KEY"); - } else { - if(Uri.Password.at(0) == '['){ - extractedPassword = Uri.Password.substr(1,Uri.Password.size()-2); - }else{ - extractedPassword = Uri.Password; - } - } - - char headertext[SLEN], signature[SLEN]; - sprintf(headertext,"GET\n\n\n%s\n%s", dateString.c_str(), normalized_path.c_str()); - doEncrypt(headertext, signature, extractedPassword.c_str()); - - string signatureString(signature); + /* S3 Specific */ + time_t rawtime = 0; + struct tm * timeinfo = NULL; + char buffer [80] = { 0 }; + char* wday = NULL; + + time( &rawtime); + timeinfo = gmtime( &rawtime); + + // strftime does not seem to honour set_locale(LC_ALL, "") or + // set_locale(LC_TIME, ""). So convert day of week by hand. + switch (timeinfo->tm_wday) { + case 0: wday = (char*)"Sun"; break; + case 1: wday = (char*)"Mon"; break; + case 2: wday = (char*)"Tue"; break; + case 3: wday = (char*)"Wed"; break; + case 4: wday = (char*)"Thu"; break; + case 5: wday = (char*)"Fri"; break; + case 6: wday = (char*)"Sat"; break; + } + + strcat(buffer, wday); + strftime(buffer+3, 80, ", %d %b %Y %T %z", timeinfo); + string dateString((const char*)buffer); + Req += "Date: " + dateString + "\r\n"; + + string extractedPassword; + if (Uri.Password.empty() && NULL == getenv("AWS_SECRET_ACCESS_KEY")) { + cerr << "E: No AWS_SECRET_ACCESS_KEY set" << endl; + exit(1); + } else if(Uri.Password.empty()) { + extractedPassword = getenv("AWS_SECRET_ACCESS_KEY"); + } else { + if(Uri.Password.at(0) == '['){ + extractedPassword = Uri.Password.substr(1,Uri.Password.size()-2); + }else{ + extractedPassword = Uri.Password; + } + } + + char headertext[SLEN], signature[SLEN]; + sprintf(headertext,"GET\n\n\n%s\n%s", dateString.c_str(), normalized_path.c_str()); + doEncrypt(headertext, signature, extractedPassword.c_str()); + + string signatureString(signature); string user; if (Uri.User.empty() && NULL == getenv("AWS_ACCESS_KEY_ID")) { cerr << "E: No AWS_ACCESS_KEY_ID set" << endl; diff --git a/src/s3.h b/src/s3.h index dec5cd8..3257c22 100644 --- a/src/s3.h +++ b/src/s3.h @@ -11,6 +11,8 @@ #ifndef APT_HTTP_H #define APT_HTTP_H +#include + #define MAXLEN 360