From 4b3a6342db92408072f6237ae60b8d3353a17307 Mon Sep 17 00:00:00 2001 From: Sahana Prasad Date: Wed, 16 Sep 2020 19:03:39 +0200 Subject: [PATCH] Deprecate duplicate/ unused functions and fix obvious naming mistakes, mostly in documentation Signed-off-by: Sahana Prasad Reviewed-by: Andreas Schneider --- examples/sshd_direct-tcpip.c | 2 +- include/libssh/callbacks.h | 6 +++--- include/libssh/legacy.h | 1 + include/libssh/libssh.h | 4 ++-- include/libssh/libsshpp.hpp | 4 ++-- include/libssh/server.h | 35 ++++++++++++++++++++++------------- src/channels.c | 14 +++++--------- src/legacy.c | 2 +- src/scp.c | 1 - 9 files changed, 37 insertions(+), 32 deletions(-) diff --git a/examples/sshd_direct-tcpip.c b/examples/sshd_direct-tcpip.c index 4d437411..0346219c 100644 --- a/examples/sshd_direct-tcpip.c +++ b/examples/sshd_direct-tcpip.c @@ -422,7 +422,7 @@ my_fd_data_function(UNUSED_PARAM(socket_t fd), break; } wr += i; - _ssh_log(SSH_LOG_FUNCTIONS, "=== my_fd_data_function", "channel_write (%d from %d)", wr, len); + _ssh_log(SSH_LOG_FUNCTIONS, "=== my_fd_data_function", "ssh_channel_write (%d from %d)", wr, len); } while (i > 0 && wr < len); } else { diff --git a/include/libssh/callbacks.h b/include/libssh/callbacks.h index 972314cb..f0948025 100644 --- a/include/libssh/callbacks.h +++ b/include/libssh/callbacks.h @@ -221,8 +221,8 @@ typedef int (*ssh_auth_gssapi_mic_callback) (ssh_session session, const char *us * @param user User that wants to authenticate * @param pubkey public key used for authentication * @param signature_state SSH_PUBLICKEY_STATE_NONE if the key is not signed (simple public key probe), - * SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be - * replied with a SSH_AUTH_DENIED. + * SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be + * replied with a SSH_AUTH_DENIED. * @param userdata Userdata to be passed to the callback function. * @returns SSH_AUTH_SUCCESS Authentication is accepted. * @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed. @@ -272,7 +272,7 @@ typedef ssh_string (*ssh_gssapi_select_oid_callback) (ssh_session session, const * @param session current session handler * @param[in] input_token input token provided by client * @param[out] output_token output of the gssapi accept_sec_context method, - * NULL after completion. + * NULL after completion. * @returns SSH_OK if the token was generated correctly or accept_sec_context * returned GSS_S_COMPLETE * @returns SSH_ERROR in case of error diff --git a/include/libssh/legacy.h b/include/libssh/legacy.h index 911173ee..bbcb00d7 100644 --- a/include/libssh/legacy.h +++ b/include/libssh/legacy.h @@ -117,4 +117,5 @@ SSH_DEPRECATED LIBSSH_API size_t string_len(ssh_string str); SSH_DEPRECATED LIBSSH_API ssh_string string_new(size_t size); SSH_DEPRECATED LIBSSH_API char *string_to_char(ssh_string str); +SSH_DEPRECATED LIBSSH_API const char* ssh_message_channel_request_x11_auth_cookie(ssh_message msg); #endif /* LEGACY_H_ */ diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 121729f1..deb9af9a 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -478,8 +478,6 @@ LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connectio const char *cookie, int screen_number); LIBSSH_API int ssh_channel_request_auth_agent(ssh_channel channel); LIBSSH_API int ssh_channel_send_eof(ssh_channel channel); -LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct - timeval * timeout); LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking); LIBSSH_API void ssh_channel_set_counter(ssh_channel channel, ssh_counter counter); @@ -557,6 +555,8 @@ SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session); SSH_DEPRECATED LIBSSH_API char *ssh_dump_knownhost(ssh_session session); SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session); SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len); +SSH_DEPRECATED LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct + timeval * timeout); SSH_DEPRECATED LIBSSH_API int ssh_scp_accept_request(ssh_scp scp); SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp); diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp index a523af18..a678d375 100644 --- a/include/libssh/libsshpp.hpp +++ b/include/libssh/libsshpp.hpp @@ -630,8 +630,8 @@ public: * @param is_stderr write should be done on the stderr channel (server only) * @returns number of bytes written * @throws SshException in case of error - * @see channel_write - * @see channel_write_stderr + * @see ssh_channel_write + * @see ssh_channel_write_stderr */ int write(const void *data, size_t len, bool is_stderr=false){ int ret; diff --git a/include/libssh/server.h b/include/libssh/server.h index 0e8412f7..27ee5790 100644 --- a/include/libssh/server.h +++ b/include/libssh/server.h @@ -284,8 +284,10 @@ LIBSSH_API const char *ssh_message_auth_user(ssh_message msg); * * @see ssh_message_get() * @see ssh_message_type() + * @warning This function should not be used anymore as there is a + * callback based server implementation now auth_password_function. */ -LIBSSH_API const char *ssh_message_auth_password(ssh_message msg); +SSH_DEPRECATED LIBSSH_API const char *ssh_message_auth_password(ssh_message msg); /** * @brief Get the publickey of the authenticated user. @@ -300,11 +302,16 @@ LIBSSH_API const char *ssh_message_auth_password(ssh_message msg); * @see ssh_key_cmp() * @see ssh_message_get() * @see ssh_message_type() + * @warning This function should not be used anymore as there is a + * callback based server implementation auth_pubkey_function. */ -LIBSSH_API ssh_key ssh_message_auth_pubkey(ssh_message msg); +SSH_DEPRECATED LIBSSH_API ssh_key ssh_message_auth_pubkey(ssh_message msg); LIBSSH_API int ssh_message_auth_kbdint_is_response(ssh_message msg); -LIBSSH_API enum ssh_publickey_state_e ssh_message_auth_publickey_state(ssh_message msg); + +/* Replaced by callback based server implementation auth_pubkey_function */ +SSH_DEPRECATED LIBSSH_API enum ssh_publickey_state_e ssh_message_auth_publickey_state(ssh_message msg); + LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial); LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey); LIBSSH_API int ssh_message_auth_reply_pk_ok_simple(ssh_message msg); @@ -333,11 +340,12 @@ LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg); -LIBSSH_API const char *ssh_message_channel_request_pty_term(ssh_message msg); -LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg); -LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg); -LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg); -LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg); +/* Replaced by callback based server implementation function channel_pty_request_function*/ +SSH_DEPRECATED LIBSSH_API const char *ssh_message_channel_request_pty_term(ssh_message msg); +SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg); +SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg); +SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg); +SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg); LIBSSH_API const char *ssh_message_channel_request_env_name(ssh_message msg); LIBSSH_API const char *ssh_message_channel_request_env_value(ssh_message msg); @@ -346,17 +354,18 @@ LIBSSH_API const char *ssh_message_channel_request_command(ssh_message msg); LIBSSH_API const char *ssh_message_channel_request_subsystem(ssh_message msg); -LIBSSH_API int ssh_message_channel_request_x11_single_connection(ssh_message msg); -LIBSSH_API const char *ssh_message_channel_request_x11_auth_protocol(ssh_message msg); -LIBSSH_API const char *ssh_message_channel_request_x11_auth_cookie(ssh_message msg); -LIBSSH_API int ssh_message_channel_request_x11_screen_number(ssh_message msg); +/* Replaced by callback based server implementation function channel_open_request_x11_function*/ +SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_x11_single_connection(ssh_message msg); +SSH_DEPRECATED LIBSSH_API const char *ssh_message_channel_request_x11_auth_protocol(ssh_message msg); +SSH_DEPRECATED LIBSSH_API const char *ssh_message_channel_request_x11_auth_cookie(ssh_message msg); +SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_x11_screen_number(ssh_message msg); LIBSSH_API const char *ssh_message_global_request_address(ssh_message msg); LIBSSH_API int ssh_message_global_request_port(ssh_message msg); LIBSSH_API int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport); -LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, +LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port); LIBSSH_API int ssh_channel_request_send_exit_status(ssh_channel channel, diff --git a/src/channels.c b/src/channels.c index 93f79c9c..86613034 100644 --- a/src/channels.c +++ b/src/channels.c @@ -1036,7 +1036,7 @@ int ssh_channel_open_auth_agent(ssh_channel channel) * * @warning This function does not bind the local port and does not automatically * forward the content of a socket to the channel. You still have to - * use channel_read and channel_write for this. + * use ssh_channel_read and ssh_channel_write for this. */ int ssh_channel_open_forward(ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport) @@ -1108,7 +1108,7 @@ error: * * @warning This function does not bind the local port and does not * automatically forward the content of a socket to the channel. - * You still have to use channel_read and channel_write for this. + * You still have to use ssh_channel_read and ssh_channel_write for this. * @warning Requires support of OpenSSH for UNIX domain socket forwarding. */ int ssh_channel_open_forward_unix(ssh_channel channel, @@ -1551,7 +1551,7 @@ static int channel_write_common(ssh_channel channel, } SSH_LOG(SSH_LOG_PACKET, - "channel_write wrote %ld bytes", (long int) effectivelen); + "ssh_channel_write wrote %ld bytes", (long int) effectivelen); channel->remote_window -= effectivelen; len -= effectivelen; @@ -2940,8 +2940,6 @@ static int ssh_channel_read_termination(void *s) * * @warning This function may return less than count bytes of data, and won't * block until count bytes have been read. - * @warning The read function using a buffer has been renamed to - * channel_read_buffer(). */ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr) { @@ -2972,8 +2970,6 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std * * @warning This function may return less than count bytes of data, and won't * block until count bytes have been read. - * @warning The read function using a buffer has been renamed to - * channel_read_buffer(). */ int ssh_channel_read_timeout(ssh_channel channel, void *dest, @@ -3604,7 +3600,7 @@ int ssh_channel_write_stderr(ssh_channel channel, const void *data, uint32_t len * * @warning This function does not bind the local port and does not automatically * forward the content of a socket to the channel. You still have to - * use channel_read and channel_write for this. + * use ssh_channel_read and ssh_channel_write for this. */ int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport) @@ -3668,7 +3664,7 @@ error: * to be done again. * @warning This function does not bind the local port and does not automatically * forward the content of a socket to the channel. You still have to - * use channel_read and channel_write for this. + * use shh_channel_read and ssh_channel_write for this. */ int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port) diff --git a/src/legacy.c b/src/legacy.c index de523403..ac4393d4 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -735,7 +735,7 @@ int ssh_accept(ssh_session session) { } int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len) { - return ssh_channel_write(channel, data, len); + return ssh_channel_write_stderr(channel, data, len); } /** @deprecated diff --git a/src/scp.c b/src/scp.c index cbb301fd..ef5aa139 100644 --- a/src/scp.c +++ b/src/scp.c @@ -693,7 +693,6 @@ int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len) scp->processed += w; } else { scp->state = SSH_SCP_ERROR; - //return = channel_get_exit_status(scp->channel); return SSH_ERROR; }