From 6f634af4fbb04f1a63a3a11685a7480b4a7bb108 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 19 Sep 2021 17:33:53 +0200 Subject: [PATCH] libssh: Deprecate the SCP API See also https://lists.mindrot.org/pipermail/openssh-unix-dev/2021-September/039616.html Fixes #91 Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen --- include/libssh/libssh.h | 36 +++++++++++++------------- src/scp.c | 56 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 92801941..803d5e2a 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -552,6 +552,24 @@ 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_scp_accept_request(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason); +SSH_DEPRECATED LIBSSH_API void ssh_scp_free(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_init(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location); +SSH_DEPRECATED LIBSSH_API int ssh_scp_pull_request(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode); +SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms); +SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms); +SSH_DEPRECATED LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size); +SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp); +SSH_DEPRECATED LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len); LIBSSH_API int ssh_get_random(void *where,int len,int strong); @@ -718,24 +736,6 @@ LIBSSH_API void ssh_print_hash(enum ssh_publickey_hash_type type, unsigned char LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data); LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display); LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds); -LIBSSH_API int ssh_scp_accept_request(ssh_scp scp); -LIBSSH_API int ssh_scp_close(ssh_scp scp); -LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason); -LIBSSH_API void ssh_scp_free(ssh_scp scp); -LIBSSH_API int ssh_scp_init(ssh_scp scp); -LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp); -LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location); -LIBSSH_API int ssh_scp_pull_request(ssh_scp scp); -LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode); -LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms); -LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms); -LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size); -LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp); -LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp); -LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp); -LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp); -LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp); -LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len); LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd, fd_set *readfds, struct timeval *timeout); LIBSSH_API int ssh_service_request(ssh_session session, const char *service); diff --git a/src/scp.c b/src/scp.c index 2e4b8620..ab9c30b3 100644 --- a/src/scp.c +++ b/src/scp.c @@ -37,10 +37,14 @@ * * SCP protocol over SSH functions * + * @deprecated Please use SFTP instead + * * @{ */ /** + * @deprecated Please use SFTP instead + * * @brief Create a new scp session. * * @param[in] session The SSH session to use. @@ -108,6 +112,8 @@ error: } /** + * @deprecated Please use SFTP instead + * * @brief Initialize the scp channel. * * @param[in] scp The scp context to initialize. @@ -230,6 +236,8 @@ int ssh_scp_init(ssh_scp scp) } /** + * @deprecated Please use SFTP instead + * * @brief Close the scp channel. * * @param[in] scp The scp context to close. @@ -277,6 +285,8 @@ int ssh_scp_close(ssh_scp scp) } /** + * @deprecated Please use SFTP instead + * * @brief Free a scp context. * * @param[in] scp The context to free. @@ -304,6 +314,8 @@ void ssh_scp_free(ssh_scp scp) } /** + * @deprecated Please use SFTP instead + * * @brief Create a directory in a scp in sink mode. * * @param[in] scp The scp handle. @@ -399,6 +411,8 @@ error: } /** + * @deprecated Please use SFTP instead + * * @brief Leave a directory. * * @returns SSH_OK if the directory has been left, SSH_ERROR if an @@ -436,6 +450,8 @@ int ssh_scp_leave_directory(ssh_scp scp) } /** + * @deprecated Please use SFTP instead + * * @brief Initialize the sending of a file to a scp in sink mode, using a 64-bit * size. * @@ -540,6 +556,8 @@ error: } /** + * @deprecated Please use SFTP instead + * * @brief Initialize the sending of a file to a scp in sink mode. * * @param[in] scp The scp handle. @@ -562,6 +580,8 @@ int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int mode) /** * @internal * + * @deprecated Please use SFTP instead + * * @brief Wait for a response of the scp server. * * @param[in] scp The scp handle. @@ -628,6 +648,8 @@ int ssh_scp_response(ssh_scp scp, char **response) } /** + * @deprecated Please use SFTP instead + * * @brief Write into a remote scp file. * * @param[in] scp The scp handle. @@ -702,6 +724,8 @@ int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len) } /** + * @deprecated Please use SFTP instead + * * @brief Read a string on a channel, terminated by '\n' * * @param[in] scp The scp handle. @@ -748,6 +772,8 @@ int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len) } /** + * @deprecated Please use SFTP instead + * * @brief Wait for a scp request (file, directory). * * @returns SSH_SCP_REQUEST_NEWFILE: The other side is sending @@ -869,6 +895,8 @@ error: } /** + * @deprecated Please use SFTP instead + * * @brief Deny the transfer of a file or creation of a directory coming from the * remote party. * @@ -915,6 +943,8 @@ int ssh_scp_deny_request(ssh_scp scp, const char *reason) } /** + * @deprecated Please use SFTP instead + * * @brief Accepts transfer of a file or creation of a directory coming from the * remote party. * @@ -951,7 +981,11 @@ int ssh_scp_accept_request(ssh_scp scp) return SSH_OK; } -/** @brief Read from a remote scp file +/** + * @deprecated Please use SFTP instead + * + * @brief Read from a remote scp file + * * @param[in] scp The scp handle. * * @param[in] buffer The destination buffer. @@ -1022,6 +1056,8 @@ int ssh_scp_read(ssh_scp scp, void *buffer, size_t size) } /** + * @deprecated Please use SFTP instead + * * @brief Get the name of the directory or file being pushed from the other * party. * @@ -1038,6 +1074,8 @@ const char *ssh_scp_request_get_filename(ssh_scp scp) } /** + * @deprecated Please use SFTP instead + * * @brief Get the permissions of the directory or file being pushed from the * other party. * @@ -1052,7 +1090,10 @@ int ssh_scp_request_get_permissions(ssh_scp scp) return scp->request_mode; } -/** @brief Get the size of the file being pushed from the other party. +/** + * @deprecated Please use SFTP instead + * + * @brief Get the size of the file being pushed from the other party. * * @returns The numeric size of the file being read. * @warning The real size may not fit in a 32 bits field and may @@ -1067,7 +1108,10 @@ size_t ssh_scp_request_get_size(ssh_scp scp) return (size_t)scp->filelen; } -/** @brief Get the size of the file being pushed from the other party. +/** + * @deprecated Please use SFTP instead + * + * @brief Get the size of the file being pushed from the other party. * * @returns The numeric size of the file being read. */ @@ -1080,6 +1124,8 @@ uint64_t ssh_scp_request_get_size64(ssh_scp scp) } /** + * @deprecated Please use SFTP instead + * * @brief Convert a scp text mode to an integer. * * @param[in] mode The mode to convert, e.g. "0644". @@ -1093,6 +1139,8 @@ int ssh_scp_integer_mode(const char *mode) } /** + * @deprecated Please use SFTP instead + * * @brief Convert a unix mode into a scp string. * * @param[in] mode The mode to convert, e.g. 420 or 0644. @@ -1108,6 +1156,8 @@ char *ssh_scp_string_mode(int mode) } /** + * @deprecated Please use SFTP instead + * * @brief Get the warning string from a scp handle. * * @param[in] scp The scp handle.