fix: SSH transport - log to stderr, use-after-free, systemd scope conflict
This commit is contained in:
@@ -307,6 +307,10 @@ int main(int argc, char *argv[]) {
|
|||||||
if (is_remote_dest(config->receive_root_directory)) {
|
if (is_remote_dest(config->receive_root_directory)) {
|
||||||
config->transport = TRANSPORT_SSH;
|
config->transport = TRANSPORT_SSH;
|
||||||
config->ssh_destination = str_dup(config->receive_root_directory);
|
config->ssh_destination = str_dup(config->receive_root_directory);
|
||||||
|
char *colon = strchr(config->receive_root_directory, ':');
|
||||||
|
char *path = str_dup(colon + 1);
|
||||||
|
free(config->receive_root_directory);
|
||||||
|
config->receive_root_directory = path;
|
||||||
}
|
}
|
||||||
} else if (positional_count == 1) {
|
} else if (positional_count == 1) {
|
||||||
fprintf(stderr, "Error: missing destination argument\n");
|
fprintf(stderr, "Error: missing destination argument\n");
|
||||||
|
|||||||
+5
-6
@@ -12,14 +12,13 @@ void log_message(LogLevel log_level, char *format, ...) {
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *t = localtime(&now);
|
struct tm *t = localtime(&now);
|
||||||
|
|
||||||
// Print timestamp and log level to the file
|
fprintf(stderr, "%04d-%02d-%02d %02d:%02d:%02d [%s]: ", t->tm_year + 1900,
|
||||||
printf("%04d-%02d-%02d %02d:%02d:%02d [%s]: ", t->tm_year + 1900,
|
t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,
|
||||||
t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,
|
log_level_strings[log_level]);
|
||||||
log_level_strings[log_level]);
|
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vprintf(format, args);
|
vfprintf(stderr, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
printf("\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ def run_profile(profile_name, source_dir, dest_dir):
|
|||||||
for case in SSH_CASES:
|
for case in SSH_CASES:
|
||||||
flags = BASE_CLIENT_FLAGS + (["-M"] if case.get("use_metadata", True) else []) + case["flags"]
|
flags = BASE_CLIENT_FLAGS + (["-M"] if case.get("use_metadata", True) else []) + case["flags"]
|
||||||
ssh_dest = f"localhost:{dest_dir}_ssh"
|
ssh_dest = f"localhost:{dest_dir}_ssh"
|
||||||
cmd = client_prefix + BASE_CLIENT_CMD + [source_dir, ssh_dest] + flags
|
cmd = BASE_CLIENT_CMD + [source_dir, ssh_dest] + flags
|
||||||
print(f"\n --- {case['name']} ---\n Running: {' '.join(cmd)}")
|
print(f"\n --- {case['name']} ---\n Running: {' '.join(cmd)}")
|
||||||
try:
|
try:
|
||||||
r = run_single_test(cmd, case["name"], source_dir, f"{dest_dir}_ssh", no_server=True)
|
r = run_single_test(cmd, case["name"], source_dir, f"{dest_dir}_ssh", no_server=True)
|
||||||
@@ -281,7 +281,7 @@ def run_profile(profile_name, source_dir, dest_dir):
|
|||||||
results.append(r)
|
results.append(r)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
results.append({"name": case["name"], "suite": profile_name, "status": "Error", "time": "N/A", "error": str(e)})
|
results.append({"name": case["name"], "suite": profile_name, "status": "Error", "time": "N/A", "error": str(e)})
|
||||||
|
|
||||||
port, conf, daemon = start_rsync_daemon(source_dir)
|
port, conf, daemon = start_rsync_daemon(source_dir)
|
||||||
try:
|
try:
|
||||||
for case in RSYNC_CASES:
|
for case in RSYNC_CASES:
|
||||||
|
|||||||
Reference in New Issue
Block a user