Skip to content

Commit

Permalink
Merge pull request #6033 from BOINC/dpa_docker5
Browse files Browse the repository at this point in the history
client and docker_wrapper: lower-case image and container names
  • Loading branch information
AenBleidd authored Jan 28, 2025
2 parents aef22e5 + 327d514 commit 97b7fde
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/app_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "filesys.h"
#include "miofile.h"
#include "parse.h"
#include "str_replace.h"
#include "str_util.h"
#include "url.h"
#include "util.h"
Expand Down
2 changes: 2 additions & 0 deletions lib/str_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <vector>
#include <string.h>

#include "str_replace.h"

#define safe_strcpy(x, y) strlcpy(x, y, sizeof(x))
#define safe_strcat(x, y) strlcat(x, y, sizeof(x))

Expand Down
4 changes: 3 additions & 1 deletion lib/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ void escape_url(string& url) {
url = buf;
}

// Escape a URL for the project directory, cutting off the "http://",
// Escape a project URL, cutting off the "http://",
// converting everthing other than alphanumbers, ., - and _ to "_".
// This is used as the project directory name.
// Note: does not convert to lowercase.
//
void escape_url_readable(char *in, char* out) {
int x, y;
Expand Down
25 changes: 20 additions & 5 deletions lib/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#if defined(_WIN32)
#include "boinc_win.h"
#include "str_replace.h"
#include "str_util.h"
#include "win_util.h"
#endif
Expand Down Expand Up @@ -798,16 +797,32 @@ int DOCKER_CONN::parse_container_name(string line, string &name) {
string docker_image_name(
const char* proj_url_esc, const char* wu_name
) {
char buf[1024];
sprintf(buf, "boinc__%s__%s", proj_url_esc, wu_name);
char buf[1024], url_buf[1024], wu_buf[1024];;

// Docker image names can't have upper case chars
//
safe_strcpy(url_buf, proj_url_esc);
downcase_string(url_buf);
safe_strcpy(wu_buf, wu_name);
downcase_string(wu_buf);

sprintf(buf, "boinc__%s__%s", url_buf, wu_buf);
return string(buf);
}

string docker_container_name(
const char* proj_url_esc, const char* result_name
){
char buf[1024];
sprintf(buf, "boinc__%s__%s", proj_url_esc, result_name);
char buf[1024], url_buf[1024], result_buf[1024];;

// Docker image names can't have upper case chars
//
safe_strcpy(url_buf, proj_url_esc);
downcase_string(url_buf);
safe_strcpy(result_buf, result_name);
downcase_string(result_buf);

sprintf(buf, "boinc__%s__%s", url_buf, result_buf);
return string(buf);
}

Expand Down

0 comments on commit 97b7fde

Please sign in to comment.