version 1.30, 2001/07/31 12:42:50 |
version 1.30.2.1, 2002/03/07 17:37:47 |
|
|
/* |
/* |
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
* Copyright (c) 2000, 2001, 2002 Markus Friedl. All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* modification, are permitted provided that the following conditions |
|
|
{ |
{ |
int i; |
int i; |
|
|
for(i = 0; i < sizeof(handles)/sizeof(Handle); i++) |
for (i = 0; i < sizeof(handles)/sizeof(Handle); i++) |
handles[i].use = HANDLE_UNUSED; |
handles[i].use = HANDLE_UNUSED; |
} |
} |
|
|
|
|
{ |
{ |
int i; |
int i; |
|
|
for(i = 0; i < sizeof(handles)/sizeof(Handle); i++) { |
for (i = 0; i < sizeof(handles)/sizeof(Handle); i++) { |
if (handles[i].use == HANDLE_UNUSED) { |
if (handles[i].use == HANDLE_UNUSED) { |
handles[i].use = use; |
handles[i].use = use; |
handles[i].dirp = dirp; |
handles[i].dirp = dirp; |
|
|
name = get_string(NULL); |
name = get_string(NULL); |
a = get_attrib(); |
a = get_attrib(); |
TRACE("setstat id %d name %s", id, name); |
TRACE("setstat id %d name %s", id, name); |
|
if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { |
|
ret = truncate(name, a->size); |
|
if (ret == -1) |
|
status = errno_to_portable(errno); |
|
} |
if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { |
if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { |
ret = chmod(name, a->perm & 0777); |
ret = chmod(name, a->perm & 0777); |
if (ret == -1) |
if (ret == -1) |
|
|
if (fd < 0) { |
if (fd < 0) { |
status = SSH2_FX_FAILURE; |
status = SSH2_FX_FAILURE; |
} else { |
} else { |
|
if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { |
|
ret = ftruncate(fd, a->size); |
|
if (ret == -1) |
|
status = errno_to_portable(errno); |
|
} |
if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { |
if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { |
ret = fchmod(fd, a->perm & 0777); |
ret = fchmod(fd, a->perm & 0777); |
if (ret == -1) |
if (ret == -1) |
|
|
} |
} |
if (count > 0) { |
if (count > 0) { |
send_names(id, count, stats); |
send_names(id, count, stats); |
for(i = 0; i < count; i++) { |
for (i = 0; i < count; i++) { |
xfree(stats[i].name); |
xfree(stats[i].name); |
xfree(stats[i].long_name); |
xfree(stats[i].long_name); |
} |
} |
|
|
send_status(id, errno_to_portable(errno)); |
send_status(id, errno_to_portable(errno)); |
else { |
else { |
Stat s; |
Stat s; |
|
|
link[len] = '\0'; |
link[len] = '\0'; |
attrib_clear(&s.attrib); |
attrib_clear(&s.attrib); |
s.name = s.long_name = link; |
s.name = s.long_name = link; |
|
|
|
|
if (buffer_len(&iqueue) < 5) |
if (buffer_len(&iqueue) < 5) |
return; /* Incomplete message. */ |
return; /* Incomplete message. */ |
cp = (u_char *) buffer_ptr(&iqueue); |
cp = buffer_ptr(&iqueue); |
msg_len = GET_32BIT(cp); |
msg_len = GET_32BIT(cp); |
if (msg_len > 256 * 1024) { |
if (msg_len > 256 * 1024) { |
error("bad message "); |
error("bad message "); |