feat: add --fastsync-server-path flag to configure remote server binary path
CI / lint (pull_request) Successful in 10s
CI / sanitizers (address) (pull_request) Successful in 14s
CI / sanitizers (undefined) (pull_request) Successful in 16s
CI / fuzz-build (pull_request) Successful in 15s
CI / coverage (pull_request) Successful in 9s
CI / valgrind (pull_request) Successful in 12s
CI / build-and-test (pull_request) Successful in 54s

This commit is contained in:
2026-07-21 18:09:50 +02:00
parent 1929e7d7b3
commit 30239c6f50
7 changed files with 22 additions and 10 deletions
+5
View File
@@ -56,6 +56,8 @@ static void print_usage(void) {
printf(" --key <path> TLS private key file (PEM)\n"); printf(" --key <path> TLS private key file (PEM)\n");
printf(" --ca <path> TLS CA certificate file (PEM)\n"); printf(" --ca <path> TLS CA certificate file (PEM)\n");
printf(" --partial Keep partial files on interrupted transfer\n"); printf(" --partial Keep partial files on interrupted transfer\n");
printf(" --fastsync-server-path <path>\n");
printf(" Path to fastsync-server on remote (default: fastsync-server)\n");
printf(" --help Show this help\n"); printf(" --help Show this help\n");
printf(" -V, --version Show version and exit\n"); printf(" -V, --version Show version and exit\n");
} }
@@ -224,6 +226,9 @@ int main(int argc, char* argv[]) {
config->tls_ca = str_dup(argv[++i]); config->tls_ca = str_dup(argv[++i]);
} else if (strcmp(argv[i], "--partial") == 0) { } else if (strcmp(argv[i], "--partial") == 0) {
config->partial = true; config->partial = true;
} else if (strcmp(argv[i], "--fastsync-server-path") == 0 && i + 1 < argc) {
free(config->fastsync_server_path);
config->fastsync_server_path = str_dup(argv[++i]);
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) { } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
set_log_level(LOG_LEVEL_DEBUG); set_log_level(LOG_LEVEL_DEBUG);
} else if (argv[i][0] == '-') { } else if (argv[i][0] == '-') {
+4 -2
View File
@@ -228,7 +228,8 @@ static int send_chunks_multithreaded(void* pipeline_context) {
fprintf(stderr, "Error: -f/--sendfile is not supported with SSH transport\n"); fprintf(stderr, "Error: -f/--sendfile is not supported with SSH transport\n");
return 1; return 1;
} }
client = client_connect_ssh(context->config->ssh_destination, context->config->ssh_port); client = client_connect_ssh(context->config->ssh_destination, context->config->ssh_port,
context->config->fastsync_server_path);
} else if (context->config->use_tls) { } else if (context->config->use_tls) {
client = client_create(); client = client_create();
if (!client || !client_connect_tls(client, context->config->server_host, if (!client || !client_connect_tls(client, context->config->server_host,
@@ -385,7 +386,8 @@ int send_files(Config* config) {
fprintf(stderr, "Error: -f/--sendfile is not supported with SSH transport\n"); fprintf(stderr, "Error: -f/--sendfile is not supported with SSH transport\n");
return 1; return 1;
} }
client = client_connect_ssh(config->ssh_destination, config->ssh_port); client =
client_connect_ssh(config->ssh_destination, config->ssh_port, config->fastsync_server_path);
if (!client) if (!client)
return 1; return 1;
} else if (config->use_tls) { } else if (config->use_tls) {
+3
View File
@@ -34,6 +34,7 @@ Config* config_create(char* version, char* send_directory, char* receive_directo
config->ssh_port = 22; config->ssh_port = 22;
config->transport = TRANSPORT_TCP; config->transport = TRANSPORT_TCP;
config->ssh_destination = NULL; config->ssh_destination = NULL;
config->fastsync_server_path = NULL;
config->exclude_patterns = NULL; config->exclude_patterns = NULL;
config->exclude_count = 0; config->exclude_count = 0;
config->include_patterns = NULL; config->include_patterns = NULL;
@@ -88,6 +89,7 @@ void config_delete(Config* config) {
free(config->send_directory); free(config->send_directory);
free(config->receive_root_directory); free(config->receive_root_directory);
free(config->ssh_destination); free(config->ssh_destination);
free(config->fastsync_server_path);
for (int i = 0; i < config->exclude_count; i++) for (int i = 0; i < config->exclude_count; i++)
free(config->exclude_patterns[i]); free(config->exclude_patterns[i]);
free(config->exclude_patterns); free(config->exclude_patterns);
@@ -238,6 +240,7 @@ Config* config_receive(int file_descriptor) {
config->ssh_port = 22; config->ssh_port = 22;
config->transport = TRANSPORT_TCP; config->transport = TRANSPORT_TCP;
config->ssh_destination = NULL; config->ssh_destination = NULL;
config->fastsync_server_path = NULL;
config->exclude_patterns = NULL; config->exclude_patterns = NULL;
config->exclude_count = 0; config->exclude_count = 0;
config->include_patterns = NULL; config->include_patterns = NULL;
+1
View File
@@ -24,6 +24,7 @@ typedef struct Config {
int ssh_port; int ssh_port;
TransportType transport; TransportType transport;
char* ssh_destination; char* ssh_destination;
char* fastsync_server_path;
char** exclude_patterns; char** exclude_patterns;
int exclude_count; int exclude_count;
char** include_patterns; char** include_patterns;
+4 -3
View File
@@ -67,7 +67,7 @@ static int parse_remote_dest(const char* dest, RemoteDest* r) {
return 0; return 0;
} }
Client* client_connect_ssh(const char* destination, int port) { Client* client_connect_ssh(const char* destination, int port, const char* server_path) {
RemoteDest r; RemoteDest r;
if (parse_remote_dest(destination, &r) != 0) { if (parse_remote_dest(destination, &r) != 0) {
fprintf(stderr, "Invalid remote destination: %s\n", destination); fprintf(stderr, "Invalid remote destination: %s\n", destination);
@@ -152,7 +152,7 @@ Client* client_connect_ssh(const char* destination, int port) {
_exit(1); _exit(1);
} }
ssh_argv[ac++] = ssh_user; ssh_argv[ac++] = ssh_user;
ssh_argv[ac++] = "fastsync-server"; ssh_argv[ac++] = (char*)(server_path ? server_path : "fastsync-server");
ssh_argv[ac++] = "--stdio"; ssh_argv[ac++] = "--stdio";
ssh_argv[ac] = NULL; ssh_argv[ac] = NULL;
execvp("ssh", ssh_argv); execvp("ssh", ssh_argv);
@@ -174,7 +174,8 @@ Client* client_connect_ssh(const char* destination, int port) {
close(sv[0]); close(sv[0]);
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);
remote_dest_destroy(&r); remote_dest_destroy(&r);
fprintf(stderr, "Error: could not launch 'fastsync-server --stdio' on remote\n"); fprintf(stderr, "Error: could not launch '%s --stdio' on remote\n",
server_path ? server_path : "fastsync-server");
return NULL; return NULL;
} }
+1 -1
View File
@@ -3,6 +3,6 @@
#include "transport_tcp.h" #include "transport_tcp.h"
Client* client_connect_ssh(const char* destination, int port); Client* client_connect_ssh(const char* destination, int port, const char* server_path);
#endif #endif
+4 -4
View File
@@ -9,14 +9,14 @@
static void test_ssh_connect_invalid_dest() { static void test_ssh_connect_invalid_dest() {
/* Missing colon — parse_remote_dest should fail and return NULL */ /* Missing colon — parse_remote_dest should fail and return NULL */
/* cppcheck-suppress constVariablePointer */ /* cppcheck-suppress constVariablePointer */
Client* client = client_connect_ssh("invalid-destination-no-colon", 22); Client* client = client_connect_ssh("invalid-destination-no-colon", 22, NULL);
EXPECT_NULL(client); EXPECT_NULL(client);
} }
/* Test client_connect_ssh with empty destination */ /* Test client_connect_ssh with empty destination */
static void test_ssh_connect_empty_dest() { static void test_ssh_connect_empty_dest() {
/* cppcheck-suppress constVariablePointer */ /* cppcheck-suppress constVariablePointer */
Client* client = client_connect_ssh("", 22); Client* client = client_connect_ssh("", 22, NULL);
EXPECT_NULL(client); EXPECT_NULL(client);
} }
@@ -24,7 +24,7 @@ static void test_ssh_connect_empty_dest() {
* parse_remote_dest succeeds, ssh is exec'd and fails, but the function * parse_remote_dest succeeds, ssh is exec'd and fails, but the function
* creates a Client that must be cleaned up. */ * creates a Client that must be cleaned up. */
static void test_ssh_connect_malformed() { static void test_ssh_connect_malformed() {
Client* client = client_connect_ssh(":", 22); Client* client = client_connect_ssh(":", 22, NULL);
/* ssh binary exists, so exec succeeds; the function returns a Client. /* ssh binary exists, so exec succeeds; the function returns a Client.
* We just verify it doesn't crash and clean up properly. */ * We just verify it doesn't crash and clean up properly. */
if (client != NULL) { if (client != NULL) {
@@ -37,7 +37,7 @@ static void test_ssh_connect_malformed() {
/* Test client_connect_ssh with valid format but unreachable host. /* Test client_connect_ssh with valid format but unreachable host.
* The function launches ssh which will fail to connect, returns a Client. */ * The function launches ssh which will fail to connect, returns a Client. */
static void test_ssh_connect_unreachable() { static void test_ssh_connect_unreachable() {
Client* client = client_connect_ssh("nonexistent.invalid:/remote/path", 22); Client* client = client_connect_ssh("nonexistent.invalid:/remote/path", 22, NULL);
if (client != NULL) { if (client != NULL) {
client_disconnect(client); client_disconnect(client);
client_delete(client); client_delete(client);