freebsd-src/crypto/openssh/sftp-client.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

208 lines
6.5 KiB
C
Raw Normal View History

2023-10-04 12:06:41 +00:00
/* $OpenBSD: sftp-client.h,v 1.39 2023/09/08 05:56:13 djm Exp $ */
/*
2004-02-26 10:38:49 +00:00
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
2004-02-26 10:38:49 +00:00
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
2004-02-26 10:38:49 +00:00
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* Client side of SSH2 filexfer protocol */
2002-03-18 09:55:03 +00:00
#ifndef _SFTP_CLIENT_H
#define _SFTP_CLIENT_H
2016-03-10 20:10:25 +00:00
#ifdef USE_SYSTEM_GLOB
# include <glob.h>
#else
# include "openbsd-compat/glob.h"
#endif
typedef struct SFTP_DIRENT SFTP_DIRENT;
struct SFTP_DIRENT {
char *filename;
char *longname;
Attrib a;
};
2008-07-23 09:33:08 +00:00
/*
* Used for statvfs responses on the wire from the server, because the
* server's native format may be larger than the client's.
*/
struct sftp_statvfs {
u_int64_t f_bsize;
u_int64_t f_frsize;
u_int64_t f_blocks;
u_int64_t f_bfree;
u_int64_t f_bavail;
u_int64_t f_files;
u_int64_t f_ffree;
u_int64_t f_favail;
u_int64_t f_fsid;
u_int64_t f_flag;
u_int64_t f_namemax;
};
2021-04-23 19:13:32 +00:00
/* Used for limits response on the wire from the server */
struct sftp_limits {
u_int64_t packet_length;
u_int64_t read_length;
u_int64_t write_length;
u_int64_t open_handles;
};
2021-08-30 19:14:33 +00:00
/* print flag values */
#define SFTP_QUIET 0 /* be quiet during transfers */
#define SFTP_PRINT 1 /* list files and show progress bar */
#define SFTP_PROGRESS_ONLY 2 /* progress bar only */
/*
2005-09-03 06:59:33 +00:00
* Initialise a SSH filexfer connection. Returns NULL on error or
2005-06-05 15:40:50 +00:00
* a pointer to a initialized sftp_conn struct on success.
*/
2023-10-04 12:06:41 +00:00
struct sftp_conn *sftp_init(int, int, u_int, u_int, u_int64_t);
2002-03-18 09:55:03 +00:00
2002-06-29 11:34:13 +00:00
u_int sftp_proto_version(struct sftp_conn *);
2021-04-23 19:13:32 +00:00
/* Query server limits */
2023-10-04 12:06:41 +00:00
int sftp_get_limits(struct sftp_conn *, struct sftp_limits *);
2021-04-23 19:13:32 +00:00
/* Close file referred to by 'handle' */
2023-10-04 12:06:41 +00:00
int sftp_close(struct sftp_conn *, const u_char *, u_int);
/* Read contents of 'path' to NULL-terminated array 'dir' */
2023-10-04 12:06:41 +00:00
int sftp_readdir(struct sftp_conn *, const char *, SFTP_DIRENT ***);
2023-10-04 12:06:41 +00:00
/* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from sftp_readdir) */
void sftp_free_dirents(SFTP_DIRENT **);
/* Delete file 'path' */
2023-10-04 12:06:41 +00:00
int sftp_rm(struct sftp_conn *, const char *);
/* Create directory 'path' */
2023-10-04 12:06:41 +00:00
int sftp_mkdir(struct sftp_conn *, const char *, Attrib *, int);
/* Remove directory 'path' */
2023-10-04 12:06:41 +00:00
int sftp_rmdir(struct sftp_conn *, const char *);
/* Get file attributes of 'path' (follows symlinks) */
2023-10-04 12:06:41 +00:00
int sftp_stat(struct sftp_conn *, const char *, int, Attrib *);
/* Get file attributes of 'path' (does not follow symlinks) */
2023-10-04 12:06:41 +00:00
int sftp_lstat(struct sftp_conn *, const char *, int, Attrib *);
/* Set file attributes of 'path' */
2023-10-04 12:06:41 +00:00
int sftp_setstat(struct sftp_conn *, const char *, Attrib *);
/* Set file attributes of open file 'handle' */
2023-10-04 12:06:41 +00:00
int sftp_fsetstat(struct sftp_conn *, const u_char *, u_int, Attrib *);
2020-02-14 19:47:15 +00:00
/* Set file attributes of 'path', not following symlinks */
2023-10-04 12:06:41 +00:00
int sftp_lsetstat(struct sftp_conn *conn, const char *path, Attrib *a);
2020-02-14 19:47:15 +00:00
/* Canonicalise 'path' - caller must free result */
2023-10-04 12:06:41 +00:00
char *sftp_realpath(struct sftp_conn *, const char *);
2021-08-30 19:14:33 +00:00
/* Canonicalisation with tilde expansion (requires server extension) */
2023-10-04 12:06:41 +00:00
char *sftp_expand_path(struct sftp_conn *, const char *);
2021-08-30 19:14:33 +00:00
/* Returns non-zero if server can tilde-expand paths */
2023-10-04 12:06:41 +00:00
int sftp_can_expand_path(struct sftp_conn *);
2021-08-30 19:14:33 +00:00
2008-07-23 09:33:08 +00:00
/* Get statistics for filesystem hosting file at "path" */
2023-10-04 12:06:41 +00:00
int sftp_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
2008-07-23 09:33:08 +00:00
/* Rename 'oldpath' to 'newpath' */
2023-10-04 12:06:41 +00:00
int sftp_rename(struct sftp_conn *, const char *, const char *, int);
2022-04-08 17:19:17 +00:00
/* Copy 'oldpath' to 'newpath' */
2023-10-04 12:06:41 +00:00
int sftp_copy(struct sftp_conn *, const char *, const char *);
2022-04-08 17:19:17 +00:00
2011-02-17 11:47:40 +00:00
/* Link 'oldpath' to 'newpath' */
2023-10-04 12:06:41 +00:00
int sftp_hardlink(struct sftp_conn *, const char *, const char *);
2011-02-17 11:47:40 +00:00
/* Rename 'oldpath' to 'newpath' */
2023-10-04 12:06:41 +00:00
int sftp_symlink(struct sftp_conn *, const char *, const char *);
2014-01-30 10:56:49 +00:00
/* Call fsync() on open file 'handle' */
2023-10-04 12:06:41 +00:00
int sftp_fsync(struct sftp_conn *conn, u_char *, u_int);
/*
* Download 'remote_path' to 'local_path'. Preserve permissions and times
* if 'pflag' is set
*/
2023-10-04 12:06:41 +00:00
int sftp_download(struct sftp_conn *, const char *, const char *, Attrib *,
2022-10-04 15:10:40 +00:00
int, int, int, int);
2010-03-08 11:19:52 +00:00
/*
2015-07-02 13:18:50 +00:00
* Recursively download 'remote_directory' to 'local_directory'. Preserve
2010-03-08 11:19:52 +00:00
* times if 'pflag' is set
*/
2023-10-04 12:06:41 +00:00
int sftp_download_dir(struct sftp_conn *, const char *, const char *, Attrib *,
2022-10-04 15:10:40 +00:00
int, int, int, int, int, int);
/*
* Upload 'local_path' to 'remote_path'. Preserve permissions and times
* if 'pflag' is set
*/
2023-10-04 12:06:41 +00:00
int sftp_upload(struct sftp_conn *, const char *, const char *,
2022-10-04 15:10:40 +00:00
int, int, int, int);
2002-03-18 09:55:03 +00:00
2010-03-08 11:19:52 +00:00
/*
2015-07-02 13:18:50 +00:00
* Recursively upload 'local_directory' to 'remote_directory'. Preserve
2010-03-08 11:19:52 +00:00
* times if 'pflag' is set
*/
2023-10-04 12:06:41 +00:00
int sftp_upload_dir(struct sftp_conn *, const char *, const char *,
2022-10-04 15:10:40 +00:00
int, int, int, int, int, int);
2021-08-30 19:14:33 +00:00
/*
* Download a 'from_path' from the 'from' connection and upload it to
* to 'to' connection at 'to_path'.
*/
2023-10-04 12:06:41 +00:00
int sftp_crossload(struct sftp_conn *from, struct sftp_conn *to,
2021-08-30 19:14:33 +00:00
const char *from_path, const char *to_path,
Attrib *a, int preserve_flag);
/*
* Recursively download a directory from 'from_path' from the 'from'
* connection and upload it to 'to' connection at 'to_path'.
*/
2023-10-04 12:06:41 +00:00
int sftp_crossload_dir(struct sftp_conn *from, struct sftp_conn *to,
2021-08-30 19:14:33 +00:00
const char *from_path, const char *to_path,
Attrib *dirattrib, int preserve_flag, int print_flag,
int follow_link_flag);
2010-03-08 11:19:52 +00:00
2022-10-04 15:10:40 +00:00
/*
* User/group ID to name translation.
*/
2023-10-04 12:06:41 +00:00
int sftp_can_get_users_groups_by_id(struct sftp_conn *conn);
int sftp_get_users_groups_by_id(struct sftp_conn *conn,
2022-10-04 15:10:40 +00:00
const u_int *uids, u_int nuids,
const u_int *gids, u_int ngids,
char ***usernamesp, char ***groupnamesp);
2010-03-08 11:19:52 +00:00
/* Concatenate paths, taking care of slashes. Caller must free result. */
2023-10-04 12:06:41 +00:00
char *sftp_path_append(const char *, const char *);
2010-03-08 11:19:52 +00:00
2021-04-23 19:10:38 +00:00
/* Make absolute path if relative path and CWD is given. Does not modify
2022-02-23 18:16:45 +00:00
* original if the path is already absolute. */
2023-10-04 12:06:41 +00:00
char *sftp_make_absolute(char *, const char *);
2021-04-23 19:10:38 +00:00
/* Check if remote path is directory */
2023-10-04 12:06:41 +00:00
int sftp_remote_is_dir(struct sftp_conn *conn, const char *path);
2021-04-23 19:10:38 +00:00
/* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
2023-10-04 12:06:41 +00:00
int sftp_globpath_is_dir(const char *pathname);
2021-04-23 19:10:38 +00:00
2002-03-18 09:55:03 +00:00
#endif