mirror of
http://galexander.org/git/simplesshd.git
synced 2025-02-28 15:02:01 +00:00
the patches necessary to make sftp-server build... mostly removing
etc.
This commit is contained in:
parent
53abe6d4e4
commit
baaf67f2be
@ -22,7 +22,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "log.h"
|
||||
#include "ssherr.h"
|
||||
|
||||
int
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "log.h"
|
||||
#include "ssherr.h"
|
||||
|
||||
void
|
||||
|
27
openssh/config.h
Normal file
27
openssh/config.h
Normal file
@ -0,0 +1,27 @@
|
||||
#define HAVE_U_INT 1
|
||||
#define HAVE_INTXX_T 1
|
||||
#define HAVE_U_INTXX_T 1
|
||||
#define HAVE_UINTXX_T 1
|
||||
#define HAVE_INTMAX_T 1
|
||||
#define HAVE_UINTMAX_T 1
|
||||
#define HAVE_U_CHAR 1
|
||||
#define HAVE_SIZE_T 1
|
||||
#define HAVE_SSIZE_T 1
|
||||
#define HAVE_CLOCK_T 1
|
||||
#define HAVE_SA_FAMILY_T 1
|
||||
#define HAVE_PID_T 1
|
||||
#define HAVE_MODE_T 1
|
||||
#define GETPGRP_VOID 1
|
||||
#define HAVE___func__ 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_UTIMES 1
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_STRUCT_TIMESPEC 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
#define HAVE_MBLEN 1
|
||||
#define HAVE_SYS_UN_H 1
|
||||
|
||||
#define error(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
|
||||
#define fatal(fmt, ...) { fprintf(stderr, fmt, ##__VA_ARGS__); cleanup_exit(255); }
|
@ -22,6 +22,8 @@
|
||||
#define _GNU_SOURCE /* activate extra prototypes for glibc */
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h> /* For CMSG_* */
|
||||
|
||||
@ -168,10 +170,6 @@
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "openbsd-compat/openbsd-compat.h"
|
||||
#include "openbsd-compat/bsd-nextstep.h"
|
||||
|
||||
#include "entropy.h"
|
||||
|
||||
#endif /* INCLUDES_H */
|
||||
|
@ -58,8 +58,6 @@
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
#include "ssh.h"
|
||||
|
||||
/* remove newline at end of string */
|
||||
char *
|
||||
@ -358,23 +356,6 @@ convtime(const char *s)
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a standardized host+port identifier string.
|
||||
* Caller must free returned string.
|
||||
*/
|
||||
char *
|
||||
put_host_port(const char *host, u_short port)
|
||||
{
|
||||
char *hoststr;
|
||||
|
||||
if (port == 0 || port == SSH_DEFAULT_PORT)
|
||||
return(xstrdup(host));
|
||||
if (asprintf(&hoststr, "[%s]:%d", host, (int)port) < 0)
|
||||
fatal("put_host_port: asprintf: %s", strerror(errno));
|
||||
debug3("put_host_port: %s", hoststr);
|
||||
return hoststr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for next delimiter between hostnames/addresses and ports.
|
||||
* Argument may be modified (for termination).
|
||||
|
@ -59,7 +59,8 @@
|
||||
* getopt opterr optind optopt optreset optarg are all in defines.h which is
|
||||
* pulled in by includes.h.
|
||||
*/
|
||||
#define warnx logit
|
||||
|
||||
#define warnx(fmt,...) fprintf(stderr, fmt, ##__VA_ARGS__)
|
||||
|
||||
#if 0
|
||||
#include <err.h>
|
||||
@ -70,8 +71,6 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
int opterr = 1; /* if error message should be printed */
|
||||
int optind = 1; /* index into parent argv vector */
|
||||
int optopt = '?'; /* character checked for validity */
|
||||
|
@ -35,16 +35,7 @@
|
||||
#include <pwd.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
/* OpenBSD function replacements */
|
||||
#include "base64.h"
|
||||
#include "sigact.h"
|
||||
#include "glob.h"
|
||||
#include "readpassphrase.h"
|
||||
#include "vis.h"
|
||||
#include "getrrsetbyname.h"
|
||||
#include "sha2.h"
|
||||
#include "blf.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef HAVE_BASENAME
|
||||
char *basename(const char *path);
|
||||
@ -153,13 +144,6 @@ int BSDgetopt(int argc, char * const *argv, const char *opts);
|
||||
int writev(int, struct iovec *, int);
|
||||
#endif
|
||||
|
||||
/* Home grown routines */
|
||||
#include "bsd-misc.h"
|
||||
#include "bsd-setres_id.h"
|
||||
#include "bsd-statvfs.h"
|
||||
#include "bsd-waitpid.h"
|
||||
#include "bsd-poll.h"
|
||||
|
||||
#ifndef HAVE_GETPEEREID
|
||||
int getpeereid(int , uid_t *, gid_t *);
|
||||
#endif
|
||||
@ -254,20 +238,6 @@ void *xmmap(size_t size);
|
||||
char *xcrypt(const char *password, const char *salt);
|
||||
char *shadow_pw(struct passwd *pw);
|
||||
|
||||
/* rfc2553 socket API replacements */
|
||||
#include "fake-rfc2553.h"
|
||||
|
||||
/* Routines for a single OS platform */
|
||||
#include "bsd-cray.h"
|
||||
#include "bsd-cygwin_util.h"
|
||||
|
||||
#include "port-aix.h"
|
||||
#include "port-irix.h"
|
||||
#include "port-linux.h"
|
||||
#include "port-solaris.h"
|
||||
#include "port-tun.h"
|
||||
#include "port-uw.h"
|
||||
|
||||
/* _FORTIFY_SOURCE breaks FD_ISSET(n)/FD_SET(n) for n > FD_SETSIZE. Avoid. */
|
||||
#if defined(HAVE_FEATURES_H) && defined(_FORTIFY_SOURCE)
|
||||
# include <features.h>
|
||||
|
@ -43,7 +43,6 @@
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "buffer.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "sftp.h"
|
||||
#include "sftp-common.h"
|
||||
@ -128,7 +127,6 @@ decode_attrib(Buffer *b)
|
||||
for (i = 0; i < count; i++) {
|
||||
type = buffer_get_string(b, NULL);
|
||||
data = buffer_get_string(b, NULL);
|
||||
debug3("Got file attribute \"%s\"", type);
|
||||
free(type);
|
||||
free(data);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "sftp.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@ -44,7 +46,6 @@
|
||||
#include "buffer.h"
|
||||
#include "misc.h"
|
||||
#include "match.h"
|
||||
#include "uidswap.h"
|
||||
|
||||
#include "sftp.h"
|
||||
#include "sftp-common.h"
|
||||
@ -153,23 +154,19 @@ request_permitted(struct sftp_handler *h)
|
||||
char *result;
|
||||
|
||||
if (readonly && h->does_write) {
|
||||
verbose("Refusing %s request in read-only mode", h->name);
|
||||
return 0;
|
||||
}
|
||||
if (request_blacklist != NULL &&
|
||||
((result = match_list(h->name, request_blacklist, NULL))) != NULL) {
|
||||
free(result);
|
||||
verbose("Refusing blacklisted %s request", h->name);
|
||||
return 0;
|
||||
}
|
||||
if (request_whitelist != NULL &&
|
||||
((result = match_list(h->name, request_whitelist, NULL))) != NULL) {
|
||||
free(result);
|
||||
debug2("Permitting whitelisted %s request", h->name);
|
||||
return 1;
|
||||
}
|
||||
if (request_whitelist != NULL) {
|
||||
verbose("Refusing non-whitelisted %s request", h->name);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -486,7 +483,6 @@ send_status(u_int32_t id, u_int32_t status)
|
||||
{
|
||||
Buffer msg;
|
||||
|
||||
debug3("request %u: sent status %u", id, status);
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, SSH2_FXP_STATUS);
|
||||
buffer_put_int(&msg, id);
|
||||
@ -514,7 +510,6 @@ send_data_or_handle(char type, u_int32_t id, const char *data, int dlen)
|
||||
static void
|
||||
send_data(u_int32_t id, const char *data, int dlen)
|
||||
{
|
||||
debug("request %u: sent data len %d", id, dlen);
|
||||
send_data_or_handle(SSH2_FXP_DATA, id, data, dlen);
|
||||
}
|
||||
|
||||
@ -525,7 +520,6 @@ send_handle(u_int32_t id, int handle)
|
||||
int hlen;
|
||||
|
||||
handle_to_string(handle, &string, &hlen);
|
||||
debug("request %u: sent handle handle %d", id, handle);
|
||||
send_data_or_handle(SSH2_FXP_HANDLE, id, string, hlen);
|
||||
free(string);
|
||||
}
|
||||
@ -540,7 +534,6 @@ send_names(u_int32_t id, int count, const Stat *stats)
|
||||
buffer_put_char(&msg, SSH2_FXP_NAME);
|
||||
buffer_put_int(&msg, id);
|
||||
buffer_put_int(&msg, count);
|
||||
debug("request %u: sent names count %d", id, count);
|
||||
for (i = 0; i < count; i++) {
|
||||
buffer_put_cstring(&msg, stats[i].name);
|
||||
buffer_put_cstring(&msg, stats[i].long_name);
|
||||
@ -555,7 +548,6 @@ send_attrib(u_int32_t id, const Attrib *a)
|
||||
{
|
||||
Buffer msg;
|
||||
|
||||
debug("request %u: sent attrib have 0x%x", id, a->flags);
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, SSH2_FXP_ATTRS);
|
||||
buffer_put_int(&msg, id);
|
||||
@ -573,7 +565,6 @@ process_init(void)
|
||||
Buffer msg;
|
||||
|
||||
version = get_int();
|
||||
verbose("received client version %u", version);
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, SSH2_FXP_VERSION);
|
||||
buffer_put_int(&msg, SSH2_FILEXFER_VERSION);
|
||||
@ -600,14 +591,12 @@ process_open(u_int32_t id)
|
||||
|
||||
name = get_string(NULL);
|
||||
pflags = get_int(); /* portable flags */
|
||||
debug3("request %u: open flags %d", id, pflags);
|
||||
a = get_attrib();
|
||||
flags = flags_from_portable(pflags);
|
||||
mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666;
|
||||
if (readonly &&
|
||||
((flags & O_ACCMODE) == O_WRONLY ||
|
||||
(flags & O_ACCMODE) == O_RDWR)) {
|
||||
verbose("Refusing open request in read-only mode");
|
||||
status = SSH2_FX_PERMISSION_DENIED;
|
||||
} else {
|
||||
fd = open(name, flags, mode);
|
||||
@ -634,7 +623,6 @@ process_close(u_int32_t id)
|
||||
int handle, ret, status = SSH2_FX_FAILURE;
|
||||
|
||||
handle = get_handle();
|
||||
debug3("request %u: close handle %u", id, handle);
|
||||
ret = handle_close(handle);
|
||||
status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
|
||||
send_status(id, status);
|
||||
@ -652,11 +640,8 @@ process_read(u_int32_t id)
|
||||
off = get_int64();
|
||||
len = get_int();
|
||||
|
||||
debug("request %u: read \"%s\" (handle %d) off %llu len %d",
|
||||
id, handle_to_name(handle), handle, (unsigned long long)off, len);
|
||||
if (len > sizeof buf) {
|
||||
len = sizeof buf;
|
||||
debug2("read change len %d", len);
|
||||
}
|
||||
fd = handle_to_fd(handle);
|
||||
if (fd >= 0) {
|
||||
@ -692,8 +677,6 @@ process_write(u_int32_t id)
|
||||
off = get_int64();
|
||||
data = get_string(&len);
|
||||
|
||||
debug("request %u: write \"%s\" (handle %d) off %llu len %d",
|
||||
id, handle_to_name(handle), handle, (unsigned long long)off, len);
|
||||
fd = handle_to_fd(handle);
|
||||
|
||||
if (fd < 0)
|
||||
@ -713,7 +696,6 @@ process_write(u_int32_t id)
|
||||
status = SSH2_FX_OK;
|
||||
handle_update_write(handle, ret);
|
||||
} else {
|
||||
debug2("nothing at all written");
|
||||
status = SSH2_FX_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -731,8 +713,6 @@ process_do_stat(u_int32_t id, int do_lstat)
|
||||
int ret, status = SSH2_FX_FAILURE;
|
||||
|
||||
name = get_string(NULL);
|
||||
debug3("request %u: %sstat", id, do_lstat ? "l" : "");
|
||||
verbose("%sstat name \"%s\"", do_lstat ? "l" : "", name);
|
||||
ret = do_lstat ? lstat(name, &st) : stat(name, &st);
|
||||
if (ret < 0) {
|
||||
status = errno_to_portable(errno);
|
||||
@ -766,8 +746,6 @@ process_fstat(u_int32_t id)
|
||||
int fd, ret, handle, status = SSH2_FX_FAILURE;
|
||||
|
||||
handle = get_handle();
|
||||
debug("request %u: fstat \"%s\" (handle %u)",
|
||||
id, handle_to_name(handle), handle);
|
||||
fd = handle_to_fd(handle);
|
||||
if (fd >= 0) {
|
||||
ret = fstat(fd, &st);
|
||||
@ -804,7 +782,6 @@ process_setstat(u_int32_t id)
|
||||
|
||||
name = get_string(NULL);
|
||||
a = get_attrib();
|
||||
debug("request %u: setstat name \"%s\"", id, name);
|
||||
if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
|
||||
ret = truncate(name, a->size);
|
||||
if (ret == -1)
|
||||
@ -843,7 +820,6 @@ process_fsetstat(u_int32_t id)
|
||||
|
||||
handle = get_handle();
|
||||
a = get_attrib();
|
||||
debug("request %u: fsetstat handle %d", id, handle);
|
||||
fd = handle_to_fd(handle);
|
||||
if (fd < 0)
|
||||
status = SSH2_FX_FAILURE;
|
||||
@ -921,8 +897,6 @@ process_readdir(u_int32_t id)
|
||||
int handle;
|
||||
|
||||
handle = get_handle();
|
||||
debug("request %u: readdir \"%s\" (handle %d)", id,
|
||||
handle_to_name(handle), handle);
|
||||
dirp = handle_to_dir(handle);
|
||||
path = handle_to_name(handle);
|
||||
if (dirp == NULL || path == NULL) {
|
||||
@ -1021,8 +995,6 @@ process_realpath(u_int32_t id)
|
||||
free(path);
|
||||
path = xstrdup(".");
|
||||
}
|
||||
debug3("request %u: realpath", id);
|
||||
verbose("realpath \"%s\"", path);
|
||||
if (realpath(path, resolvedname) == NULL) {
|
||||
send_status(id, errno_to_portable(errno));
|
||||
} else {
|
||||
@ -1098,8 +1070,6 @@ process_readlink(u_int32_t id)
|
||||
char *path;
|
||||
|
||||
path = get_string(NULL);
|
||||
debug3("request %u: readlink", id);
|
||||
verbose("readlink \"%s\"", path);
|
||||
if ((len = readlink(path, buf, sizeof(buf) - 1)) == -1)
|
||||
send_status(id, errno_to_portable(errno));
|
||||
else {
|
||||
@ -1165,8 +1135,6 @@ process_extended_fsync(u_int32_t id)
|
||||
int handle, fd, ret, status = SSH2_FX_OP_UNSUPPORTED;
|
||||
|
||||
handle = get_handle();
|
||||
debug3("request %u: fsync (handle %u)", id, handle);
|
||||
verbose("fsync \"%s\"", handle_to_name(handle));
|
||||
if ((fd = handle_to_fd(handle)) < 0)
|
||||
status = SSH2_FX_NO_SUCH_FILE;
|
||||
else if (handle_is_ok(handle, HANDLE_FILE)) {
|
||||
@ -1336,9 +1304,6 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
|
||||
fatal("Invalid umask \"%s\"", optarg);
|
||||
(void)umask((mode_t)mask);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
sftp_server_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1416,7 +1381,6 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
|
||||
if (FD_ISSET(in, rset)) {
|
||||
len = read(in, buf, sizeof buf);
|
||||
if (len == 0) {
|
||||
debug("read eof");
|
||||
sftp_server_cleanup_exit(0);
|
||||
} else if (len < 0) {
|
||||
error("read: %s", strerror(errno));
|
||||
|
2444
openssh/sftp.c
2444
openssh/sftp.c
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "log.h"
|
||||
|
||||
void *
|
||||
xmalloc(size_t size)
|
||||
|
Loading…
Reference in New Issue
Block a user