mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-18 15:20:56 +03:00
- introduce the concept of a project level setup header `src/libssh2_setup.h`, that is used by `src`, `example` and `tests` alike. Move there all common platform/compiler configuration from `src/libssh2_priv.h`, individual sources and `CMakeFiles.txt` files. Also move there our hand-crafted (= not auto-generated by CMake or autotools) configuration `win32/libssh2-config.h`. - `win32` directory is empty now, delete it. - `Makefile.mk`: adapt to the above. Build-directory is the target triplet, or any custom name set via `BLD_DIR`. - sync header path order between build systems: build/src -> source/src -> source/include - delete redundant references to `windows.h`, `winsock2.h`, `ws2tcpip.h`. - delete unnecessary #includes, update order (`libssh2_setup.h` first, `winsock2.h` first), simplify where possible. This makes the code warning-free without `WIN32_LEAN_AND_MEAN`. At the same time this patch applies this macro globally, to avoid header bloat. - example: add missing *nix header guards. - example: fix misindented `HAVE_UNISTD_H` `#ifdef`s. - set `WIN32` with all build-tools. - set `HAVE_SYS_PARAM_H` in the hand-crafted config for MinGW. To match auto-detection. - move a source-specific macro to `misc.c` from `libssh2_priv.h`. See the PR's individual commits for step-by-step updates. Closes #932
36 lines
1017 B
C
36 lines
1017 B
C
#include "runner.h"
|
|
|
|
static const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
|
static const char *KEY_FILE_PRIVATE = "key_dsa_wrong";
|
|
static const char *KEY_FILE_PUBLIC = "key_dsa_wrong.pub";
|
|
|
|
int test(LIBSSH2_SESSION *session)
|
|
{
|
|
int rc;
|
|
|
|
const char *userauth_list =
|
|
libssh2_userauth_list(session, USERNAME,
|
|
(unsigned int)strlen(USERNAME));
|
|
if(userauth_list == NULL) {
|
|
print_last_session_error("libssh2_userauth_list");
|
|
return 1;
|
|
}
|
|
|
|
if(strstr(userauth_list, "publickey") == NULL) {
|
|
fprintf(stderr, "'publickey' was expected in userauth list: %s\n",
|
|
userauth_list);
|
|
return 1;
|
|
}
|
|
|
|
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) {
|
|
fprintf(stderr, "Public-key auth succeeded with wrong key\n");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|