Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
*~
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
apt-transport-s3 (1.1ubuntu1) oneiric; urgency=low

* Make apt-transport-s3 work, when locale is non-english.

-- Jens Braeuer <[email protected]> Mon, 31 Jan 2012 21:01:25 +0100

apt-transport-s3 (1.0ubuntu1) lucid; urgency=low

* Working around stupid amazon s3 behaviour with filenames
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
cp s3 /usr/lib/apt/methods/
76 changes: 45 additions & 31 deletions src/s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#ifndef APT_HTTP_H
#define APT_HTTP_H

#include <apt-pkg/hashes.h>

#define MAXLEN 360


Expand Down