From 34e0eb48bce45daba20070b87990e4d5bb168b83 Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Mon, 30 Jan 2012 22:15:02 +0100 Subject: [PATCH 1/8] Clean should work on incomplete builds too. --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 161bc02..cf57667 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ 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 @@ -11,4 +11,4 @@ s3: s3_main.o s3.o connect.o 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/ From daa743ea00b881170a4a2ab1148803de17f91d30 Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Mon, 30 Jan 2012 23:12:40 +0100 Subject: [PATCH 2/8] Include Header to avoid Hash-related warning. --- src/s3.h | 2 ++ 1 file changed, 2 insertions(+) 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 From 2af41f61219597e800baad9bb399f59e2e1865c0 Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Mon, 30 Jan 2012 23:15:45 +0100 Subject: [PATCH 3/8] Move link-libs param to end. Otherwise this wont build on my Ubuntu 11.10 amd64. --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index cf57667..d57765b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,7 @@ clean: 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 $< From 3a89e4a6694d6ab5b60008971211e1a85549ed5d Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Mon, 30 Jan 2012 23:17:45 +0100 Subject: [PATCH 4/8] Ignore object, s3-binary and debian-temp-file. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7618a1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +src/*.o +src/s3 +debian/compat +*~ \ No newline at end of file From 6df74a10b0cee893670bff1c776b4c24f072d5d4 Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Tue, 31 Jan 2012 00:01:08 +0100 Subject: [PATCH 5/8] Ignore even more files. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 7618a1d..506b1b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +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 From 22cfad554389039f8a5ea89c8bc63b2f433b9c87 Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Tue, 31 Jan 2012 00:01:32 +0100 Subject: [PATCH 6/8] Convert tabs to spaces. --- src/s3.cc | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/s3.cc b/src/s3.cc index 1ac463d..54f5bda 100644 --- a/src/s3.cc +++ b/src/s3.cc @@ -740,37 +740,37 @@ 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; + 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); string user; if (Uri.User.empty() && NULL == getenv("AWS_ACCESS_KEY_ID")) { cerr << "E: No AWS_ACCESS_KEY_ID set" << endl; From dbcb87659a1d35f325cda8f8c789a57f4d152a7f Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Tue, 31 Jan 2012 01:01:46 +0100 Subject: [PATCH 7/8] Have proper RFC2822 style Date HTTP header field. HTTP header field "Date" would contain the day of week in accoring to the set locale. This breaks RFC2822-style date format. AWS would reply 'AWS authentication requires a valid Date or x-amz-date header'. --- src/s3.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/s3.cc b/src/s3.cc index 54f5bda..a23bd4a 100644 --- a/src/s3.cc +++ b/src/s3.cc @@ -741,14 +741,28 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n"; /* S3 Specific */ - time_t rawtime; - struct tm * timeinfo; - char buffer [80]; + time_t rawtime = 0; + struct tm * timeinfo = NULL; + char buffer [80] = { 0 }; + char* wday = NULL; time( &rawtime); timeinfo = gmtime( &rawtime); - strftime(buffer, 80, "%a, %d %b %Y %H:%M:%S +0000", timeinfo); + // 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"; From 307344ac2936f7db6c4b05d03663340fbf4b7f4e Mon Sep 17 00:00:00 2001 From: Jens Braeuer Date: Tue, 31 Jan 2012 01:11:11 +0100 Subject: [PATCH 8/8] Add changelog. --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) 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