Skip to content

Commit

Permalink
in_docker: stricter config json name matching (so it does not match s…
Browse files Browse the repository at this point in the history
…warm service name if any)
  • Loading branch information
fopina committed Apr 22, 2022
1 parent 86bc0a2 commit 93823c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions plugins/in_docker/docker.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ static char *get_config_file(char *id)
return path;
}

static char *extract_name(char *line, char *start)
static char *extract_name(char *line, char *start, int skip)
{
int skip = 9;
int len = 0;
char *name;
char buff[256];
Expand Down Expand Up @@ -283,7 +282,7 @@ static char *get_container_name(struct flb_docker *ctx, char *id)
while ((line = read_line(f))) {
char *index = strstr(line, DOCKER_NAME_ARG);
if (index != NULL) {
container_name = extract_name(line, index);
container_name = extract_name(line, index, sizeof(DOCKER_NAME_ARG)-1);
flb_free(line);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/in_docker/docker.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define DOCKER_CPU_USAGE_FILE "cpuacct.usage"
#define DOCKER_LIB_ROOT "/var/lib/docker/containers"
#define DOCKER_CONFIG_JSON "config.v2.json"
#define DOCKER_NAME_ARG "\"Name\""
#define DOCKER_NAME_ARG "\"Name\":\"/"
#define DEFAULT_INTERVAL_SEC "1"
#define DEFAULT_INTERVAL_NSEC "0"

Expand Down

0 comments on commit 93823c3

Please sign in to comment.