aboutsummaryrefslogtreecommitdiff
path: root/include/libssh/sftp.h
AgeCommit message (Collapse)AuthorFilesLines
2024-03-06updated documentation of sftp_tell64Abdelrahman Yossef1-2/+1
Signed-off-by: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-02-13sftp: Fix copy&paste error in the doxygen commentJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-02-13sftp: Handle read/write limits in the old low-level SFTP APIJakub Jelen1-3/+9
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-01-15sftp_aio.c, sftp.h: Add capping to sftp aio write APIEshan Kelkar1-12/+16
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15sftp_aio.c, sftp.h: Add capping to the sftp aio read APIEshan Kelkar1-6/+15
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15sftp.c, sftp.h: Store the limits in the sftp_sessionEshan Kelkar1-0/+1
In the sftp_init() call, the limits are stored in the sftp_sesssion. If the limits@openssh.com extension is supported the limits are retrieved from the server, else libssh uses the default limits. The sftp library functions that require the limits can access them using the sftp session. The library user can call sftp_limits() to get a copy of the limits stored in the sftp session. Since the limits were already retrieved from the server during sftp_init(), this sftp_limits() call requires no communication with the server. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04sftp.h : Deprecate the old sftp async API for readingEshan Kelkar1-2/+6
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-12-04Introduce sftp async i/o (aio) apiEshan Kelkar1-0/+211
The existing sftp async read api has two problems : 1. sftp_async_read() assumes that the value of the third parameter count is same as the number of bytes requested to read in the corresponding call to sftp_async_read_begin(). But the documentation of sftp_async_read() allows the value of count parameter to be more than that requested length. If value of count parameter is more than that requested length then sftp_async_read() updates the file->offset incorrectly which leads to further read/writes occuring from incorrect offsets. The problem here is that sftp_async_read() doesn't know about the number of bytes requested to read specified in the call to sftp_async_read_begin(), and it wrongly assumes the value of its count parameter (which is actually the size of the buffer to store the read data) to be the same as the number of bytes requested to read. 2. sftp_async_read_begin() returns an uint32_t type value type casted to int as a request identifier, whereas sftp_async_read() expects an uint32_t type value as a request identifier. Due to this the user has to typecast the identifier returned by sftp_async_read_begin() from int to uint32_t and then pass it to sftp_async_read(). This type casting is cumbersome for the user and hence the approach is not user-friendly. This commit solves the above two problems by introducing a new sftp aio api. The sftp_aio_begin_*() functions in the api send an i/o request to the sftp server and provide the caller a dynamically allocated structure storing information about the sent request. Information like number of bytes requested for i/o, id of sent request etc is stored in the structure. That structure should be provided to the sftp_aio_wait_*() functions in the api which wait for the response corresponding to the request whose info is stored in the provided structure. The libssh user is supposed to handle that structure through an opaque type sftp_aio. Since the structure stores the number of bytes requested for i/o, sftp_aio_wait_*() knows about the number of bytes requested for i/o (specified in the call to sftp_aio_begin_*()) and hence updates the file->offset correctly solving problem #1 present in the existing async api. Since the structure provided by sftp_aio_begin_*() (containing the request id) is supplied to sftp_aio_wait_*(), no casting of id's needs to be done by the user solving problem #2 of the existing async api. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-11-22Adding expand-path@openssh.com extension for clientanshul agrawal1-0/+13
Signed-off-by: anshul agrawal <anshulagrawal2902@gmail.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-09-25Adding support for limits@openssh.com on client sideanfanite3961-0/+29
Signed-off-by: anfanite396 <dipamt1729@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-09-15sftp: Cap maximum SFTP writeJakub Jelen1-0/+4
The curl does not do any (or enough) chunking when writing large files using the sftp_write() function which causes some servers to choke [1]. The simplest solution is to limit the SFTP packet size according the SFTP specification recommendation which is 32768 B and not write more. This means the function will not write the whole amount of data it was asked to write and the calling applications are required to handle the return values correctly. More complicated solution would be to send several SFTP packet from the single sftp_write() function by iterating over the all data passed. The next improvement in the long term should be respecting the value reported by the server in the limits@openssh.com extension, which specifies the maximum packet size and reads/writes explicitly (if supported). [1] https://github.com/curl/curl/pull/11804 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-06-06Deprecate untested function sftp_server_initJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2023-06-06Remove needless new symbols and add required to APIJakub Jelen1-44/+0
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2023-06-06sftpserver: Move duplicate code handling SFTP operations to libraryJakub Jelen1-2/+2
These can be replaced by user-provided functions when needed. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2023-06-06sftp: fix format problems, style nit and building problemstatataeki1-9/+44
Signed-off-by: tatataeki <shengzeyu19_98@163.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2023-06-06examples: add sftpserver example and fix problemstatataeki1-1/+0
Signed-off-by: tatataeki <shengzeyu19_98@163.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2023-06-06sftp: add sftp api for sftpservertatataeki1-0/+10
Signed-off-by: tatataeki <shengzeyu19_98@163.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2023-04-24Add support for hardlink@openssh.comEshan Kelkar1-0/+16
sftp_hardlink() has been introduced which when called sends a SSH_FXP_EXTENDED request to server for creating a hardlink. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-01-09include: Document the need to free the returned bufferJakub Jelen1-0/+2
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2022-10-12sftp: Add comment about limitation of sftp_setstatJakub Jelen1-0/+5
Fixes: #138 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-08-12sftp: Fix more typosJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-08-12sftp: fix documentation typosHarald Sitter1-8/+8
Signed-off-by: Harald Sitter <sitter@kde.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-12-09sftp: Remove internal function from sftp.hAndreas Schneider1-7/+0
Those are not marked as LIBSSH_API so not part of the public API and the symbols aren't exported! Fixes T188 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-16sftp: Improve the documentation of sftp_init() and sftp_new()Jakub Jelen1-2/+10
Fixes: T137 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-04-29sftp server: Implementation of sftp_server_free() as counterpart to ↵David Wedderwille1-0/+7
sftp_server_new() Fixes T143 Signed-off-by: David Wedderwille <davidwe@posteo.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-27sftp: Document how to free memory retruned by sftp_canonicalize_path()Andreas Schneider1-1/+3
Fixes T129 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-17priv: Add ssize_t if not available with MSVCAndreas Schneider1-3/+8
Fixes T113 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Tested-by: Wolf Wolfswinkel <wolf.wolfswinkel@objectplus.nl>
2018-09-20sftpserver: Support some openssh extensionsChris Townsend1-0/+3
Add support for "hardlink@openssh.com" and "posix-rename@openssh.com" extensions. Signed-off-by: Chris Townsend <christopher.townsend@canonical.com> Signed-off-by: Alberto Aguirre <albaguirre@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17sftp: Keep a ssh_packet for reading in the sftp handleAndreas Schneider1-0/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28Remove vim modelines from all filesAndreas Schneider1-1/+0
If you want modelines use my vim plugin: https://github.com/cryptomilk/git-modeline.vim git config --add vim.modeline "ts=4 sw=4 et" Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-22sftp: Remove stray semi-colon in sftp.h headerAlberto Aguirre1-1/+1
The stray semi-colon in sftp.h is flagged when using -pedantic which affects clients that include the header and use -pedantic and -Werror on their codebase. Signed-off-by: Alberto Aguirre <albaguirre@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11sftp-server: Fix LIBSSH_APIDavidWed1-10/+10
Fixes T44 Signed-off-by: DavidWedderwille <davidwe@posteo.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06sftp: Add sftp_fsync() functionAndreas Schneider1-0/+16
BUG: https://red.libssh.org/issues/141 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-30define our own platform-independent S_IF macrosTilo Eckert1-0/+10
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-06buffers: adapt sftp.c to ssh_buffer_(un)pack()Aris Adamantiadis1-4/+4
Reviewed-by: Andreas Schneider <asn@samba.org>
2013-07-13sftp: more flexibility on channelsAris Adamantiadis1-1/+15
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13sftp: added useful server APIsAris Adamantiadis1-2/+9
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-01-23include: Fix the LGPL header.Andreas Schneider1-14/+13
This has been reported by rpmlint: libssh-devel.x86_64: W: incorrect-fsf-address libssh.h
2011-11-17sftp: Add references to sftp_get_error() to docs.Andreas Schneider1-0/+36
2011-08-28sftp: Don't create file page.Andreas Schneider1-7/+1
2011-08-28sftp: Improve documentation.Andreas Schneider1-16/+38
2010-08-28Added missing /** in doxygen @}'sAris Adamantiadis1-1/+1
2010-08-27doc: Document the server responses.Andreas Schneider1-1/+23
2010-02-23Added owner and group information in sftp attributes.Andreas Schneider1-4/+3
Parse the longname which is the output of 'ls -l' and set the owner and group if we are talking to an openssh server.
2010-02-07Rename the libssh sftp documentation group.Andreas Schneider1-1/+1
2009-11-06Improve MSVC support. Better binary compatibility.Andreas Schneider1-1/+1
Patch by Patrick Spendrin from KDE.
2009-11-03Fix warnings on old gcc'sAris Adamantiadis1-5/+5
they don't like variable names having type names
2009-10-13Remove deprecated functions.Andreas Schneider1-21/+0
2009-10-10updated the sftp subsystem to follow the type convAris Adamantiadis1-104/+114
2009-09-29Fix warnings on opensolarisAris Adamantiadis1-4/+4