fix: reject unsupported rsync debug categories
CI / lint (pull_request) Successful in 11s
CI / sanitizers (address) (pull_request) Successful in 38s
CI / sanitizers (undefined) (pull_request) Successful in 38s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 11s
CI / sanitizers (address) (pull_request) Successful in 38s
CI / sanitizers (undefined) (pull_request) Successful in 38s
CI / fuzz-build (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m15s
CI / valgrind (pull_request) Successful in 33s
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ This document maps rsync's full feature set to FastSync's current implementation
|
||||
| `--help` | Show help | ✅ Implemented | Prints usage and exits; `-h` is not accepted |
|
||||
| `-V`, `--version` | Print version | ✅ Implemented | |
|
||||
| `--info=FLAGS` | Fine-grained info verbosity | ❌ Not Implemented | Removed because it had no effect |
|
||||
| `--debug=FLAGS` | Fine-grained debug verbosity | ❌ Not Implemented | Removed because it had no effect |
|
||||
| `--debug=FLAGS` | Fine-grained debug verbosity | ⚠️ Partial | `io`, `proto`, `pack`, and `util` are supported; other rsync categories are rejected |
|
||||
| `--stderr=MODE` | Change stderr output mode | ❌ Not Implemented | |
|
||||
| `--no-motd` | Suppress daemon MOTD | ❌ Not Implemented | |
|
||||
| `--exclude=PATTERN` | Exclude files matching pattern | ✅ Implemented | Glob matching in scanner |
|
||||
|
||||
+1
-45
@@ -123,52 +123,8 @@ static int parse_debug_flags(const char* value, Config* config) {
|
||||
flag = LOG_DEBUG_PACK;
|
||||
} else if (strcmp(token, "util") == 0) {
|
||||
flag = LOG_DEBUG_UTIL;
|
||||
} else if (strcmp(token, "acl") == 0) {
|
||||
flag = LOG_DEBUG_ACL;
|
||||
} else if (strcmp(token, "backup") == 0) {
|
||||
flag = LOG_DEBUG_BACKUP;
|
||||
} else if (strcmp(token, "bind") == 0) {
|
||||
flag = LOG_DEBUG_BIND;
|
||||
} else if (strcmp(token, "chksum") == 0) {
|
||||
flag = LOG_DEBUG_CHKSUM;
|
||||
} else if (strcmp(token, "connect") == 0) {
|
||||
flag = LOG_DEBUG_CONNECT;
|
||||
} else if (strcmp(token, "cmd") == 0) {
|
||||
flag = LOG_DEBUG_CMD;
|
||||
} else if (strcmp(token, "del") == 0) {
|
||||
flag = LOG_DEBUG_DEL;
|
||||
} else if (strcmp(token, "digest") == 0) {
|
||||
flag = LOG_DEBUG_DIGEST;
|
||||
} else if (strcmp(token, "dflt") == 0) {
|
||||
flag = LOG_DEBUG_DFLT;
|
||||
} else if (strcmp(token, "flist") == 0) {
|
||||
flag = LOG_DEBUG_FLIST;
|
||||
} else if (strcmp(token, "fuzzer") == 0) {
|
||||
flag = LOG_DEBUG_FUZZER;
|
||||
} else if (strcmp(token, "genr") == 0) {
|
||||
flag = LOG_DEBUG_GENR;
|
||||
} else if (strcmp(token, "hash") == 0) {
|
||||
flag = LOG_DEBUG_HASH;
|
||||
} else if (strcmp(token, "hlink") == 0) {
|
||||
flag = LOG_DEBUG_HLINK;
|
||||
} else if (strcmp(token, "iconv") == 0) {
|
||||
flag = LOG_DEBUG_ICONV;
|
||||
} else if (strcmp(token, "nstr") == 0) {
|
||||
flag = LOG_DEBUG_NSTR;
|
||||
} else if (strcmp(token, "own") == 0) {
|
||||
flag = LOG_DEBUG_OWN;
|
||||
} else if (strcmp(token, "proc") == 0) {
|
||||
flag = LOG_DEBUG_PROC;
|
||||
} else if (strcmp(token, "recv") == 0) {
|
||||
flag = LOG_DEBUG_RECV;
|
||||
} else if (strcmp(token, "send") == 0) {
|
||||
flag = LOG_DEBUG_SEND;
|
||||
} else if (strcmp(token, "time") == 0) {
|
||||
flag = LOG_DEBUG_TIME;
|
||||
} else if (strcmp(token, "tls") == 0) {
|
||||
flag = LOG_DEBUG_TLS;
|
||||
} else {
|
||||
log_message(LOG_LEVEL_ERROR, "unknown --debug flag: %s", token);
|
||||
log_message(LOG_LEVEL_ERROR, "unsupported --debug flag: %s", token);
|
||||
free(flags);
|
||||
return -1;
|
||||
}
|
||||
|
||||
+2
-3
@@ -75,8 +75,7 @@ void print_usage(void) {
|
||||
}
|
||||
|
||||
void print_debug_usage(void) {
|
||||
printf("Debug flags: ACL,BACKUP,BIND,CHKSUM,CONNECT,CMD,DEL,DIGEST,DFLT,FLIST,\n");
|
||||
printf(" FUZZER,GENR,HASH,HLINK,ICONV,IO,NSTR,OWN,PACK,PROC,PROTO,\n");
|
||||
printf(" RECV,SEND,TIME,TLS,UTIL,ALL,NONE\n");
|
||||
printf("Supported debug flags: IO,PROTO,PACK,UTIL,ALL,NONE\n");
|
||||
printf("Flags may be comma-separated, for example: --debug=io,proto\n");
|
||||
printf("Other rsync debug flags are unsupported and rejected.\n");
|
||||
}
|
||||
|
||||
+1
-23
@@ -11,29 +11,7 @@ typedef enum {
|
||||
LOG_DEBUG_PROTO = 1u << 1,
|
||||
LOG_DEBUG_PACK = 1u << 2,
|
||||
LOG_DEBUG_UTIL = 1u << 3,
|
||||
LOG_DEBUG_ACL = 1u << 4,
|
||||
LOG_DEBUG_BACKUP = 1u << 5,
|
||||
LOG_DEBUG_BIND = 1u << 6,
|
||||
LOG_DEBUG_CHKSUM = 1u << 7,
|
||||
LOG_DEBUG_CONNECT = 1u << 8,
|
||||
LOG_DEBUG_CMD = 1u << 9,
|
||||
LOG_DEBUG_DEL = 1u << 10,
|
||||
LOG_DEBUG_DIGEST = 1u << 11,
|
||||
LOG_DEBUG_DFLT = 1u << 12,
|
||||
LOG_DEBUG_FLIST = 1u << 13,
|
||||
LOG_DEBUG_FUZZER = 1u << 14,
|
||||
LOG_DEBUG_GENR = 1u << 15,
|
||||
LOG_DEBUG_HASH = 1u << 16,
|
||||
LOG_DEBUG_HLINK = 1u << 17,
|
||||
LOG_DEBUG_ICONV = 1u << 18,
|
||||
LOG_DEBUG_NSTR = 1u << 19,
|
||||
LOG_DEBUG_OWN = 1u << 20,
|
||||
LOG_DEBUG_PROC = 1u << 21,
|
||||
LOG_DEBUG_RECV = 1u << 22,
|
||||
LOG_DEBUG_SEND = 1u << 23,
|
||||
LOG_DEBUG_TIME = 1u << 24,
|
||||
LOG_DEBUG_TLS = 1u << 25,
|
||||
LOG_DEBUG_ALL = (1u << 26) - 1,
|
||||
LOG_DEBUG_ALL = (1u << 4) - 1,
|
||||
} LogDebugFlag;
|
||||
|
||||
void log_message(LogLevel log_level, const char* message, ...);
|
||||
|
||||
+15
-5
@@ -250,18 +250,28 @@ static void test_parse_args_valid_compression_level() {
|
||||
|
||||
static void test_parse_args_debug_flags() {
|
||||
Config* cfg = config_create();
|
||||
char* argv[] = {"fastsync", "--debug=io,proto", "/src", "/dst"};
|
||||
char* argv[] = {"fastsync", "--debug=io,proto,pack,util", "/src", "/dst"};
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
EXPECT_EQ_INT(parse_args(cfg, 4, argv, positional_args, &positional_count), 0);
|
||||
EXPECT_EQ_INT(cfg->debug_level, LOG_DEBUG_IO | LOG_DEBUG_PROTO);
|
||||
EXPECT_EQ_INT(get_log_debug_flags(), LOG_DEBUG_IO | LOG_DEBUG_PROTO);
|
||||
EXPECT_EQ_INT(cfg->debug_level, LOG_DEBUG_ALL);
|
||||
EXPECT_EQ_INT(get_log_debug_flags(), LOG_DEBUG_ALL);
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
static void test_parse_args_debug_help() {
|
||||
Config* cfg = config_create();
|
||||
char* argv[] = {"fastsync", "--debug=help"};
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
EXPECT_EQ_INT(parse_args(cfg, 2, argv, positional_args, &positional_count), 1);
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
static void test_parse_args_debug_flags_validation() {
|
||||
static const char* const values[] = {"", "io,", ",io", "io,,proto", "unknown"};
|
||||
static const char* const values[] = {"", "io,", ",io", "io,,proto", "acl", "tls", "unknown"};
|
||||
for (size_t i = 0; i < sizeof(values) / sizeof(values[0]); i++) {
|
||||
Config* cfg = config_create();
|
||||
char option[64];
|
||||
@@ -306,7 +316,6 @@ static void test_parse_args_rejects_unimplemented_options() {
|
||||
"--itemize-changes",
|
||||
"--out-format",
|
||||
"--info",
|
||||
"--debug",
|
||||
"--list-only",
|
||||
"-h",
|
||||
"--human-readable",
|
||||
@@ -386,6 +395,7 @@ void test_client_cli() {
|
||||
test_parse_args_invalid_compression_level();
|
||||
test_parse_args_valid_compression_level();
|
||||
test_parse_args_debug_flags();
|
||||
test_parse_args_debug_help();
|
||||
test_parse_args_debug_flags_validation();
|
||||
test_parse_args_unknown_option();
|
||||
test_parse_args_rejects_unimplemented_options();
|
||||
|
||||
Reference in New Issue
Block a user