mirror of git://anongit.mindrot.org/openssh.git
parent
cb978aa057
commit
1addabd491
|
@ -134,6 +134,9 @@
|
|||
- millert@cvs.openbsd.org 2001/03/03 21:41:07
|
||||
[packet.c]
|
||||
Dynamically allocate fd_set; deraadt@ OK
|
||||
- deraadt@cvs.openbsd.org 2001/03/03 22:07:50
|
||||
[sftp-server.c]
|
||||
KNF
|
||||
|
||||
20010304
|
||||
- (bal) Remove make-ssh-known-hosts.1 since it's no longer valid.
|
||||
|
@ -4326,4 +4329,4 @@
|
|||
- Wrote replacements for strlcpy and mkdtemp
|
||||
- Released 1.0pre1
|
||||
|
||||
$Id: ChangeLog,v 1.892 2001/03/05 07:07:49 mouring Exp $
|
||||
$Id: ChangeLog,v 1.893 2001/03/05 07:09:11 mouring Exp $
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: sftp-server.c,v 1.21 2001/03/03 21:40:30 millert Exp $");
|
||||
RCSID("$OpenBSD: sftp-server.c,v 1.22 2001/03/03 22:07:50 deraadt Exp $");
|
||||
|
||||
#include "buffer.h"
|
||||
#include "bufaux.h"
|
||||
|
@ -63,6 +63,7 @@ int
|
|||
errno_to_portable(int unixerrno)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (unixerrno) {
|
||||
case 0:
|
||||
ret = SSH2_FX_OK;
|
||||
|
@ -93,6 +94,7 @@ int
|
|||
flags_from_portable(int pflags)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if ((pflags & SSH2_FXF_READ) &&
|
||||
(pflags & SSH2_FXF_WRITE)) {
|
||||
flags = O_RDWR;
|
||||
|
@ -125,17 +127,20 @@ struct Handle {
|
|||
int fd;
|
||||
char *name;
|
||||
};
|
||||
|
||||
enum {
|
||||
HANDLE_UNUSED,
|
||||
HANDLE_DIR,
|
||||
HANDLE_FILE
|
||||
};
|
||||
|
||||
Handle handles[100];
|
||||
|
||||
void
|
||||
handle_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < sizeof(handles)/sizeof(Handle); i++)
|
||||
handles[i].use = HANDLE_UNUSED;
|
||||
}
|
||||
|
@ -144,6 +149,7 @@ int
|
|||
handle_new(int use, char *name, int fd, DIR *dirp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < sizeof(handles)/sizeof(Handle); i++) {
|
||||
if (handles[i].use == HANDLE_UNUSED) {
|
||||
handles[i].use = use;
|
||||
|
@ -178,6 +184,7 @@ int
|
|||
handle_from_string(char *handle, u_int hlen)
|
||||
{
|
||||
int val;
|
||||
|
||||
if (hlen != sizeof(int32_t))
|
||||
return -1;
|
||||
val = GET_32BIT(handle);
|
||||
|
@ -216,6 +223,7 @@ int
|
|||
handle_close(int handle)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (handle_is_ok(handle, HANDLE_FILE)) {
|
||||
ret = close(handles[handle].fd);
|
||||
handles[handle].use = HANDLE_UNUSED;
|
||||
|
@ -234,6 +242,7 @@ get_handle(void)
|
|||
char *handle;
|
||||
int val = -1;
|
||||
u_int hlen;
|
||||
|
||||
handle = get_string(&hlen);
|
||||
if (hlen < 256)
|
||||
val = handle_from_string(handle, hlen);
|
||||
|
@ -247,6 +256,7 @@ void
|
|||
send_msg(Buffer *m)
|
||||
{
|
||||
int mlen = buffer_len(m);
|
||||
|
||||
buffer_put_int(&oqueue, mlen);
|
||||
buffer_append(&oqueue, buffer_ptr(m), mlen);
|
||||
buffer_consume(m, mlen);
|
||||
|
@ -256,6 +266,7 @@ void
|
|||
send_status(u_int32_t id, u_int32_t error)
|
||||
{
|
||||
Buffer msg;
|
||||
|
||||
TRACE("sent status id %d error %d", id, error);
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, SSH2_FXP_STATUS);
|
||||
|
@ -268,6 +279,7 @@ void
|
|||
send_data_or_handle(char type, u_int32_t id, char *data, int dlen)
|
||||
{
|
||||
Buffer msg;
|
||||
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, type);
|
||||
buffer_put_int(&msg, id);
|
||||
|
@ -288,6 +300,7 @@ send_handle(u_int32_t id, int handle)
|
|||
{
|
||||
char *string;
|
||||
int hlen;
|
||||
|
||||
handle_to_string(handle, &string, &hlen);
|
||||
TRACE("sent handle id %d handle %d", id, handle);
|
||||
send_data_or_handle(SSH2_FXP_HANDLE, id, string, hlen);
|
||||
|
@ -299,6 +312,7 @@ send_names(u_int32_t id, int count, Stat *stats)
|
|||
{
|
||||
Buffer msg;
|
||||
int i;
|
||||
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, SSH2_FXP_NAME);
|
||||
buffer_put_int(&msg, id);
|
||||
|
@ -317,6 +331,7 @@ void
|
|||
send_attrib(u_int32_t id, Attrib *a)
|
||||
{
|
||||
Buffer msg;
|
||||
|
||||
TRACE("sent attrib id %d have 0x%x", id, a->flags);
|
||||
buffer_init(&msg);
|
||||
buffer_put_char(&msg, SSH2_FXP_ATTRS);
|
||||
|
@ -533,6 +548,7 @@ struct timeval *
|
|||
attrib_to_tv(Attrib *a)
|
||||
{
|
||||
static struct timeval tv[2];
|
||||
|
||||
tv[0].tv_sec = a->atime;
|
||||
tv[0].tv_usec = 0;
|
||||
tv[1].tv_sec = a->mtime;
|
||||
|
|
Loading…
Reference in New Issue