mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-01 11:26:53 +03:00
tidy-up: example, tests continued
- fix skip auth if `userauthlist` is NULL. Closes #836 (Reported-by: @sudipm-mukherjee on github) - fix most silenced `checksrc` warnings. - sync examples/tests code between each other. (output messages, error handling, declaration order, comments) - stop including unnecessary headers. - always deinitialize in case of error. - drop some redundant variables. - add error handling where missing. - show more error codes. - switch `perror()` to `fprintf()`. - fix some `printf()`s to be `fprintf()`. - formatting. Closes #960
This commit is contained in:
@ -32,12 +32,12 @@ int test(LIBSSH2_SESSION *session)
|
||||
const char *userauth_list =
|
||||
libssh2_userauth_list(session, USERNAME,
|
||||
(unsigned int)strlen(USERNAME));
|
||||
if(userauth_list == NULL) {
|
||||
if(!userauth_list) {
|
||||
print_last_session_error("libssh2_userauth_list");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(strstr(userauth_list, "publickey") == NULL) {
|
||||
if(!strstr(userauth_list, "publickey")) {
|
||||
fprintf(stderr, "'publickey' was expected in userauth list: %s\n",
|
||||
userauth_list);
|
||||
return 1;
|
||||
@ -46,7 +46,7 @@ int test(LIBSSH2_SESSION *session)
|
||||
rc = libssh2_userauth_publickey_fromfile_ex(
|
||||
session, USERNAME, (unsigned int)strlen(USERNAME),
|
||||
srcdir_path(KEY_FILE_PUBLIC), srcdir_path(KEY_FILE_PRIVATE), NULL);
|
||||
if(rc != 0) {
|
||||
if(rc) {
|
||||
print_last_session_error("libssh2_userauth_publickey_fromfile_ex");
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user