mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-14 04:18:54 +03:00
reformat
Signed-off-by: Debanga Sarma <deb737@proton.me> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
5dd42dfa22
commit
d34bfdab69
@@ -2017,7 +2017,8 @@ static int ssh_bind_set_algo(ssh_bind sshbind,
|
|||||||
* - SSH_LOG_NOLOG: No logging
|
* - SSH_LOG_NOLOG: No logging
|
||||||
* - SSH_LOG_WARNING: Only warnings
|
* - SSH_LOG_WARNING: Only warnings
|
||||||
* - SSH_LOG_PROTOCOL: High level protocol information
|
* - SSH_LOG_PROTOCOL: High level protocol information
|
||||||
* - SSH_LOG_PACKET: Lower level protocol information, packet level
|
* - SSH_LOG_PACKET: Lower level protocol information,
|
||||||
|
* packet level
|
||||||
* - SSH_LOG_FUNCTIONS: Every function path
|
* - SSH_LOG_FUNCTIONS: Every function path
|
||||||
* The default is SSH_LOG_NOLOG.
|
* The default is SSH_LOG_NOLOG.
|
||||||
*
|
*
|
||||||
@@ -2026,8 +2027,8 @@ static int ssh_bind_set_algo(ssh_bind sshbind,
|
|||||||
* string that will be converted to a numerical
|
* string that will be converted to a numerical
|
||||||
* value (e.g. "3") and interpreted according
|
* value (e.g. "3") and interpreted according
|
||||||
* to the values of
|
* to the values of
|
||||||
* SSH_BIND_OPTIONS_LOG_VERBOSITY above (const
|
* SSH_BIND_OPTIONS_LOG_VERBOSITY above
|
||||||
* char *).
|
* (const char *).
|
||||||
*
|
*
|
||||||
* - SSH_BIND_OPTIONS_RSAKEY:
|
* - SSH_BIND_OPTIONS_RSAKEY:
|
||||||
* Deprecated alias to SSH_BIND_OPTIONS_HOSTKEY
|
* Deprecated alias to SSH_BIND_OPTIONS_HOSTKEY
|
||||||
@@ -2048,16 +2049,16 @@ static int ssh_bind_set_algo(ssh_bind sshbind,
|
|||||||
* (ssh_key). It will be free'd by ssh_bind_free().
|
* (ssh_key). It will be free'd by ssh_bind_free().
|
||||||
*
|
*
|
||||||
* - SSH_BIND_OPTIONS_CIPHERS_C_S:
|
* - SSH_BIND_OPTIONS_CIPHERS_C_S:
|
||||||
* Set the symmetric cipher client to server (const char *,
|
* Set the symmetric cipher client to server
|
||||||
* comma-separated list).
|
* (const char *, comma-separated list).
|
||||||
*
|
*
|
||||||
* - SSH_BIND_OPTIONS_CIPHERS_S_C:
|
* - SSH_BIND_OPTIONS_CIPHERS_S_C:
|
||||||
* Set the symmetric cipher server to client (const char *,
|
* Set the symmetric cipher server to client
|
||||||
* comma-separated list).
|
* (const char *, comma-separated list).
|
||||||
*
|
*
|
||||||
* - SSH_BIND_OPTIONS_KEY_EXCHANGE:
|
* - SSH_BIND_OPTIONS_KEY_EXCHANGE:
|
||||||
* Set the key exchange method to be used (const char *,
|
* Set the key exchange method to be used
|
||||||
* comma-separated list). ex:
|
* (const char *, comma-separated list). ex:
|
||||||
* "ecdh-sha2-nistp256,diffie-hellman-group14-sha1"
|
* "ecdh-sha2-nistp256,diffie-hellman-group14-sha1"
|
||||||
*
|
*
|
||||||
* - SSH_BIND_OPTIONS_HMAC_C_S:
|
* - SSH_BIND_OPTIONS_HMAC_C_S:
|
||||||
@@ -2113,9 +2114,12 @@ static int ssh_bind_set_algo(ssh_bind sshbind,
|
|||||||
* datatype which should be used is described at the
|
* datatype which should be used is described at the
|
||||||
* corresponding value of type above.
|
* corresponding value of type above.
|
||||||
*
|
*
|
||||||
* @return 0 on success, < 0 on error, invalid option, or parameter.
|
* @return 0 on success, < 0 on error, invalid option, or
|
||||||
|
* parameter.
|
||||||
*/
|
*/
|
||||||
int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
int
|
||||||
|
ssh_bind_options_set(ssh_bind sshbind,
|
||||||
|
enum ssh_bind_options_e type,
|
||||||
const void *value)
|
const void *value)
|
||||||
{
|
{
|
||||||
bool allowed;
|
bool allowed;
|
||||||
@@ -2182,7 +2186,8 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
|||||||
default:
|
default:
|
||||||
ssh_set_error(sshbind,
|
ssh_set_error(sshbind,
|
||||||
SSH_FATAL,
|
SSH_FATAL,
|
||||||
"Unsupported key type %d", key_type);
|
"Unsupported key type %d",
|
||||||
|
key_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bind_key_loc == NULL) {
|
if (bind_key_loc == NULL) {
|
||||||
@@ -2242,7 +2247,8 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
|||||||
default:
|
default:
|
||||||
ssh_set_error(sshbind,
|
ssh_set_error(sshbind,
|
||||||
SSH_FATAL,
|
SSH_FATAL,
|
||||||
"Unsupported key type %d", key_type);
|
"Unsupported key type %d",
|
||||||
|
key_type);
|
||||||
}
|
}
|
||||||
if (bind_key_loc == NULL)
|
if (bind_key_loc == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -2268,7 +2274,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
|||||||
ssh_set_error_invalid(sshbind);
|
ssh_set_error_invalid(sshbind);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
int *x = (int *) value;
|
int *x = (int *)value;
|
||||||
sshbind->bindport = *x & 0xffffU;
|
sshbind->bindport = *x & 0xffffU;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2297,7 +2303,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
|||||||
ssh_set_error_invalid(sshbind);
|
ssh_set_error_invalid(sshbind);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
int *x = (int *) value;
|
int *x = (int *)value;
|
||||||
ssh_set_log_level(*x & 0xffffU);
|
ssh_set_log_level(*x & 0xffffU);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2484,16 +2490,21 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
|||||||
} else {
|
} else {
|
||||||
int *x = (int *)value;
|
int *x = (int *)value;
|
||||||
if (*x > 0 && *x < 768) {
|
if (*x > 0 && *x < 768) {
|
||||||
ssh_set_error(sshbind, SSH_REQUEST_DENIED,
|
ssh_set_error(sshbind,
|
||||||
|
SSH_REQUEST_DENIED,
|
||||||
"The provided value (%u) for minimal RSA key "
|
"The provided value (%u) for minimal RSA key "
|
||||||
"size is too small. Use at least 768 bits.", *x);
|
"size is too small. Use at least 768 bits.",
|
||||||
|
*x);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sshbind->rsa_min_size = *x;
|
sshbind->rsa_min_size = *x;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ssh_set_error(sshbind, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
|
ssh_set_error(sshbind,
|
||||||
|
SSH_REQUEST_DENIED,
|
||||||
|
"Unknown ssh option %d",
|
||||||
|
type);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2049,7 +2049,8 @@ static int sshbind_teardown(void **state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_bind_options_import_key(void **state)
|
static void
|
||||||
|
torture_bind_options_import_key(void **state)
|
||||||
{
|
{
|
||||||
struct bind_st *test_state;
|
struct bind_st *test_state;
|
||||||
ssh_bind bind;
|
ssh_bind bind;
|
||||||
@@ -2694,95 +2695,182 @@ static void torture_bind_options_set_hostkey_algorithms(void **state)
|
|||||||
|
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
|
int
|
||||||
int torture_run_tests(void)
|
torture_run_tests(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct CMUnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_host, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_host,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_host, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_port, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_port, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_host,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_user, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_user, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_port,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_identity, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_global_knownhosts, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_port,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_global_knownhosts, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_knownhosts, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_knownhosts, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_fd,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_control_master, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_control_path, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_user,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_ciphers, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_ciphers, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_key_exchange, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_user,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_key_exchange, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_hostkey, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_hostkey, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_identity,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_pubkey_accepted_types, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_pubkey_accepted_types, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_macs, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_identity,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_macs, setup, teardown),
|
setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_compression, setup, teardown),
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_get_compression, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_global_knownhosts,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_global_knownhosts,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_set_knownhosts,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_knownhosts,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_proxycommand,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_control_master,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_control_path,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_set_ciphers,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_ciphers,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_set_key_exchange,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_key_exchange,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_set_hostkey,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_hostkey,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(
|
||||||
|
torture_options_set_pubkey_accepted_types,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(
|
||||||
|
torture_options_get_pubkey_accepted_types,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_set_macs,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_macs,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_set_compression,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_options_get_compression,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_copy, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_copy, setup, teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_config_host, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_config_host,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_config_match,
|
cmocka_unit_test_setup_teardown(torture_options_config_match,
|
||||||
setup, teardown),
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_config_match_multi,
|
cmocka_unit_test_setup_teardown(torture_options_config_match_multi,
|
||||||
setup, teardown),
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_getopt,
|
cmocka_unit_test_setup_teardown(torture_options_getopt,
|
||||||
setup, teardown),
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_plus_sign,
|
cmocka_unit_test_setup_teardown(torture_options_plus_sign,
|
||||||
setup, teardown),
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_minus_sign,
|
cmocka_unit_test_setup_teardown(torture_options_minus_sign,
|
||||||
setup, teardown),
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_caret_sign,
|
cmocka_unit_test_setup_teardown(torture_options_caret_sign,
|
||||||
setup, teardown),
|
setup,
|
||||||
|
teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_apply, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_apply, setup, teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_options_set_verbosity, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_verbosity,
|
||||||
|
setup,
|
||||||
|
teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WITH_SERVER
|
#ifdef WITH_SERVER
|
||||||
struct CMUnitTest sshbind_tests[] = {
|
struct CMUnitTest sshbind_tests[] = {
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_import_key,
|
cmocka_unit_test_setup_teardown(torture_bind_options_import_key,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_hostkey,
|
cmocka_unit_test_setup_teardown(torture_bind_options_hostkey,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_bindaddr,
|
cmocka_unit_test_setup_teardown(torture_bind_options_bindaddr,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_bindport,
|
cmocka_unit_test_setup_teardown(torture_bind_options_bindport,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_bindport_str,
|
cmocka_unit_test_setup_teardown(torture_bind_options_bindport_str,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_log_verbosity,
|
cmocka_unit_test_setup_teardown(torture_bind_options_log_verbosity,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_log_verbosity_str,
|
cmocka_unit_test_setup_teardown(torture_bind_options_log_verbosity_str,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_rsakey,
|
cmocka_unit_test_setup_teardown(torture_bind_options_rsakey,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_ecdsakey,
|
cmocka_unit_test_setup_teardown(torture_bind_options_ecdsakey,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
#endif
|
#endif
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_banner,
|
cmocka_unit_test_setup_teardown(torture_bind_options_banner,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_set_ciphers,
|
cmocka_unit_test_setup_teardown(torture_bind_options_set_ciphers,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_set_key_exchange,
|
cmocka_unit_test_setup_teardown(torture_bind_options_set_key_exchange,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_set_macs,
|
cmocka_unit_test_setup_teardown(torture_bind_options_set_macs,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_parse_config,
|
cmocka_unit_test_setup_teardown(torture_bind_options_parse_config,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_config_dir,
|
cmocka_unit_test_setup_teardown(torture_bind_options_config_dir,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_set_pubkey_accepted_key_types,
|
sshbind_teardown),
|
||||||
sshbind_setup, sshbind_teardown),
|
cmocka_unit_test_setup_teardown(
|
||||||
cmocka_unit_test_setup_teardown(torture_bind_options_set_hostkey_algorithms,
|
torture_bind_options_set_pubkey_accepted_key_types,
|
||||||
sshbind_setup, sshbind_teardown),
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(
|
||||||
|
torture_bind_options_set_hostkey_algorithms,
|
||||||
|
sshbind_setup,
|
||||||
|
sshbind_teardown),
|
||||||
};
|
};
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user