summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c102
1 files changed, 3 insertions, 99 deletions
diff --git a/sftp-server.c b/sftp-server.c
index a3e11ce5b..0e0040094 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: sftp-server.c,v 1.14 2001/01/21 19:05:56 markus Exp $"); 25RCSID("$OpenBSD: sftp-server.c,v 1.15 2001/02/04 11:11:54 djm Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "bufaux.h" 28#include "bufaux.h"
@@ -31,6 +31,7 @@ RCSID("$OpenBSD: sftp-server.c,v 1.14 2001/01/21 19:05:56 markus Exp $");
31#include "xmalloc.h" 31#include "xmalloc.h"
32 32
33#include "sftp.h" 33#include "sftp.h"
34#include "sftp-common.h"
34 35
35/* helper */ 36/* helper */
36#define get_int64() buffer_get_int64(&iqueue); 37#define get_int64() buffer_get_int64(&iqueue);
@@ -50,22 +51,9 @@ Buffer oqueue;
50 51
51/* portable attibutes, etc. */ 52/* portable attibutes, etc. */
52 53
53typedef struct Attrib Attrib;
54typedef struct Stat Stat; 54typedef struct Stat Stat;
55 55
56struct Attrib 56struct Stat {
57{
58 u_int32_t flags;
59 u_int64_t size;
60 u_int32_t uid;
61 u_int32_t gid;
62 u_int32_t perm;
63 u_int32_t atime;
64 u_int32_t mtime;
65};
66
67struct Stat
68{
69 char *name; 57 char *name;
70 char *long_name; 58 char *long_name;
71 Attrib attrib; 59 Attrib attrib;
@@ -122,90 +110,6 @@ flags_from_portable(int pflags)
122 return flags; 110 return flags;
123} 111}
124 112
125void
126attrib_clear(Attrib *a)
127{
128 a->flags = 0;
129 a->size = 0;
130 a->uid = 0;
131 a->gid = 0;
132 a->perm = 0;
133 a->atime = 0;
134 a->mtime = 0;
135}
136
137Attrib *
138decode_attrib(Buffer *b)
139{
140 static Attrib a;
141 attrib_clear(&a);
142 a.flags = buffer_get_int(b);
143 if (a.flags & SSH2_FILEXFER_ATTR_SIZE) {
144 a.size = buffer_get_int64(b);
145 }
146 if (a.flags & SSH2_FILEXFER_ATTR_UIDGID) {
147 a.uid = buffer_get_int(b);
148 a.gid = buffer_get_int(b);
149 }
150 if (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
151 a.perm = buffer_get_int(b);
152 }
153 if (a.flags & SSH2_FILEXFER_ATTR_ACMODTIME) {
154 a.atime = buffer_get_int(b);
155 a.mtime = buffer_get_int(b);
156 }
157 /* vendor-specific extensions */
158 if (a.flags & SSH2_FILEXFER_ATTR_EXTENDED) {
159 char *type, *data;
160 int i, count;
161 count = buffer_get_int(b);
162 for (i = 0; i < count; i++) {
163 type = buffer_get_string(b, NULL);
164 data = buffer_get_string(b, NULL);
165 xfree(type);
166 xfree(data);
167 }
168 }
169 return &a;
170}
171
172void
173encode_attrib(Buffer *b, Attrib *a)
174{
175 buffer_put_int(b, a->flags);
176 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
177 buffer_put_int64(b, a->size);
178 }
179 if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
180 buffer_put_int(b, a->uid);
181 buffer_put_int(b, a->gid);
182 }
183 if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
184 buffer_put_int(b, a->perm);
185 }
186 if (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME) {
187 buffer_put_int(b, a->atime);
188 buffer_put_int(b, a->mtime);
189 }
190}
191
192void
193stat_to_attrib(struct stat *st, Attrib *a)
194{
195 attrib_clear(a);
196 a->flags = 0;
197 a->flags |= SSH2_FILEXFER_ATTR_SIZE;
198 a->size = st->st_size;
199 a->flags |= SSH2_FILEXFER_ATTR_UIDGID;
200 a->uid = st->st_uid;
201 a->gid = st->st_gid;
202 a->flags |= SSH2_FILEXFER_ATTR_PERMISSIONS;
203 a->perm = st->st_mode;
204 a->flags |= SSH2_FILEXFER_ATTR_ACMODTIME;
205 a->atime = st->st_atime;
206 a->mtime = st->st_mtime;
207}
208
209Attrib * 113Attrib *
210get_attrib(void) 114get_attrib(void)
211{ 115{