Skip to content

Commit

Permalink
Add a new parameter to have an option to choose TCP socket creation
Browse files Browse the repository at this point in the history
  • Loading branch information
deepikas20 committed Mar 18, 2024
1 parent f2a9c1e commit 8df2d94
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
56 changes: 40 additions & 16 deletions app/dockerdwrapperwithcompose.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@ start_dockerd(void)
char *use_sd_card_value = get_parameter_value("SDCardSupport");
char *use_tls_value = get_parameter_value("UseTLS");
char *use_ipc_socket_value = get_parameter_value("IPCSocket");
char *use_tcp_socket_value = get_parameter_value("TCPSocket");
if (use_sd_card_value == NULL || use_tls_value == NULL ||
use_ipc_socket_value == NULL) {
use_ipc_socket_value == NULL || use_tcp_socket_value == NULL) {
goto end;
}
bool use_sdcard = strcmp(use_sd_card_value, "yes") == 0;
bool use_tls = strcmp(use_tls_value, "yes") == 0;
bool use_ipc_socket = strcmp(use_ipc_socket_value, "yes") == 0;
bool use_tcp_socket = strcmp(use_tcp_socket_value, "yes") == 0;

if (use_sdcard) {
// Confirm that the SD card is usable
Expand Down Expand Up @@ -326,27 +328,48 @@ start_dockerd(void)
goto end;
}

args_offset += g_snprintf(args + args_offset,
args_len - args_offset,
" %s %s %s %s %s %s %s %s",
"-H tcp://0.0.0.0:2376",
"--tlsverify",
"--tlscacert",
ca_path,
"--tlscert",
cert_path,
"--tlskey",
key_path);

g_strlcat(msg, " in TLS mode", msg_len);
} else {
if (use_tcp_socket) {
args_offset += g_snprintf(args + args_offset,
args_len - args_offset,
" %s %s %s %s %s %s %s %s",
"-H tcp://0.0.0.0:2376",
"--tlsverify",
"--tlscacert",
ca_path,
"--tlscert",
cert_path,
"--tlskey",
key_path);

g_strlcat(msg, " in TLS mode with TCP socket", msg_len);
} else {
args_offset += g_snprintf(args + args_offset,
args_len - args_offset,
" %s %s %s %s %s %s %s",
"--tlsverify",
"--tlscacert",
ca_path,
"--tlscert",
cert_path,
"--tlskey",
key_path);

g_strlcat(msg, " in TLS mode without TCP socket", msg_len);
}
} else if (!use_tls && use_tcp_socket) {
args_offset += g_snprintf(args + args_offset,
args_len - args_offset,
" %s %s",
"-H tcp://0.0.0.0:2375",
"--tls=false");

g_strlcat(msg, " in unsecured mode", msg_len);
g_strlcat(msg, " in unsecured mode with TCP socket", msg_len);
} else {
// Without TLS and without TCP socket
args_offset += g_snprintf(
args + args_offset, args_len - args_offset, " %s", "--tls=false");

g_strlcat(msg, " in unsecured mode without TCP socket", msg_len);
}

if (use_sdcard) {
Expand Down Expand Up @@ -409,6 +432,7 @@ start_dockerd(void)
free(use_sd_card_value);
free(use_tls_value);
free(use_ipc_socket_value);
free(use_tcp_socket_value);
g_clear_error(&error);

return return_value;
Expand Down
7 changes: 6 additions & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@
},
{
"name": "UseTLS",
"default": "yes",
"default": "no",
"type": "enum:no|No, yes|Yes"
},
{
"name": "IPCSocket",
"default": "yes",
"type": "enum:no|No, yes|Yes"
},
{
"name": "TCPSocket",
"default": "no",
"type": "enum:no|No, yes|Yes"
}
]
}
Expand Down

0 comments on commit 8df2d94

Please sign in to comment.