annotate lib/sshv2.c @ 871:f9a71e63edab

Updated (British) English docs translation
author dlodge
date Wed, 24 Jan 2007 07:15:05 +0000
parents 1fae947d4418
children d7cbef177dfc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* sshv2.c - functions that will use the sshv2 protocol */
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include "gftp.h"
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
21 static const char cvsid[] = "$Id$";
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
23 #define SSH_MAX_HANDLE_SIZE 256
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24 #define SSH_MAX_STRING_SIZE 34000
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
26 static gftp_config_vars config_vars[] =
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
27 {
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 219
diff changeset
28 {"", N_("SSH"), gftp_option_type_notebook, NULL, NULL,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 219
diff changeset
29 GFTP_CVARS_FLAGS_SHOW_BOOKMARK, NULL, GFTP_PORT_GTK, NULL},
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
30
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
31 {"ssh_prog_name", N_("SSH Prog Name:"),
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
32 gftp_option_type_text, "ssh", NULL, 0,
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
33 N_("The path to the SSH executable"), GFTP_PORT_ALL, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
34 {"ssh_extra_params", N_("SSH Extra Params:"),
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
35 gftp_option_type_text, NULL, NULL, 0,
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
36 N_("Extra parameters to pass to the SSH program"), GFTP_PORT_ALL, NULL},
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
37
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
38 {"ssh_need_userpass", N_("Need SSH User/Pass"),
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 219
diff changeset
39 gftp_option_type_checkbox, GINT_TO_POINTER(1), NULL,
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 219
diff changeset
40 GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
41 N_("Require a username/password for SSH connections"), GFTP_PORT_ALL, NULL},
227
a85a097bbb02 2003-7-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 219
diff changeset
42
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
43 {NULL, NULL, 0, NULL, NULL, 0, NULL, 0, NULL}
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
44 };
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
45
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
46
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
47 typedef struct sshv2_message_tag
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
48 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
49 guint32 length;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
50 char command;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
51 char *buffer,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
52 *pos,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
53 *end;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 } sshv2_message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 typedef struct sshv2_params_tag
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57 {
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 284
diff changeset
58 char handle[SSH_MAX_HANDLE_SIZE + 4], /* We'll encode the ID in here too */
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
59 *transfer_buffer;
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
60 size_t handle_len, transfer_buffer_len;
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 284
diff changeset
61
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
62 guint32 id,
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
63 count;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
64 sshv2_message message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
65
296
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 284
diff changeset
66 unsigned int initialized : 1,
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 284
diff changeset
67 dont_log_status : 1; /* For uploading files */
51725086634d 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 284
diff changeset
68
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69 #ifdef G_HAVE_GINT64
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
70 guint64 offset;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71 #else
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
72 guint32 offset;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
73 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74 } sshv2_params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
75
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 #define SSH_MY_VERSION 3
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 #define SSH_FXP_INIT 1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 #define SSH_FXP_VERSION 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81 #define SSH_FXP_OPEN 3
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 #define SSH_FXP_CLOSE 4
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83 #define SSH_FXP_READ 5
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84 #define SSH_FXP_WRITE 6
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 #define SSH_FXP_LSTAT 7
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86 #define SSH_FXP_FSTAT 8
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 #define SSH_FXP_SETSTAT 9
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 #define SSH_FXP_FSETSTAT 10
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 #define SSH_FXP_OPENDIR 11
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90 #define SSH_FXP_READDIR 12
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91 #define SSH_FXP_REMOVE 13
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92 #define SSH_FXP_MKDIR 14
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93 #define SSH_FXP_RMDIR 15
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
94 #define SSH_FXP_REALPATH 16
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95 #define SSH_FXP_STAT 17
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 #define SSH_FXP_RENAME 18
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
97 #define SSH_FXP_READLINK 19
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
98 #define SSH_FXP_SYMLINK 20
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
99
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 #define SSH_FXP_STATUS 101
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 #define SSH_FXP_HANDLE 102
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102 #define SSH_FXP_DATA 103
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 #define SSH_FXP_NAME 104
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 #define SSH_FXP_ATTRS 105
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 #define SSH_FXP_EXTENDED 200
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 #define SSH_FXP_EXTENDED_REPLY 201
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 #define SSH_FILEXFER_ATTR_SIZE 0x00000001
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 #define SSH_FILEXFER_ATTR_UIDGID 0x00000002
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 #define SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 #define SSH_FILEXFER_ATTR_ACMODTIME 0x00000008
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112 #define SSH_FILEXFER_ATTR_EXTENDED 0x80000000
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
114 #define SSH_FILEXFER_TYPE_REGULAR 1
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
115 #define SSH_FILEXFER_TYPE_DIRECTORY 2
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
116 #define SSH_FILEXFER_TYPE_SYMLINK 3
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
117 #define SSH_FILEXFER_TYPE_SPECIAL 4
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
118 #define SSH_FILEXFER_TYPE_UNKNOWN 5
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
119
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 #define SSH_FXF_READ 0x00000001
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 #define SSH_FXF_WRITE 0x00000002
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 #define SSH_FXF_APPEND 0x00000004
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 #define SSH_FXF_CREAT 0x00000008
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 #define SSH_FXF_TRUNC 0x00000010
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 #define SSH_FXF_EXCL 0x00000020
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 #define SSH_FX_OK 0
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 #define SSH_FX_EOF 1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 #define SSH_FX_NO_SUCH_FILE 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 #define SSH_FX_PERMISSION_DENIED 3
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 #define SSH_FX_FAILURE 4
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 #define SSH_FX_BAD_MESSAGE 5
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 #define SSH_FX_NO_CONNECTION 6
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 #define SSH_FX_CONNECTION_LOST 7
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 #define SSH_FX_OP_UNSUPPORTED 8
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
137 #define SSH_LOGIN_BUFSIZE 200
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
138 #define SSH_ERROR_BADPASS -1
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
139 #define SSH_ERROR_QUESTION -2
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
140
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
141
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
142 static char *
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
143 sshv2_initialize_buffer (gftp_request * request, size_t len)
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
144 {
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
145 sshv2_params * params;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
146 guint32 num;
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
147 char *ret;
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
148
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
149 params = request->protocol_data;
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 747
diff changeset
150 ret = g_malloc0 ((gulong) len + 1);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
151
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
152 num = htonl (params->id++);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
153 memcpy (ret, &num, 4);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
154
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
155 return (ret);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
156 }
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
157
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
158
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
159 static void
839
0d9a3d4188c3 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
160 sshv2_add_string_to_buf (char *buf, const char *str, size_t len)
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
161 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
162 guint32 num;
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
163
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
164 num = htonl (strlen (str));
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
165 memcpy (buf, &num, 4);
839
0d9a3d4188c3 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
166 memcpy (buf + 4, str, len);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
167 }
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
168
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
169
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
170 static char *
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
171 sshv2_initialize_buffer_with_i18n_string (gftp_request * request,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
172 const char *str, size_t *msglen)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
173 {
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
174 const char *addstr;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
175 char *utf8, *ret;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
176 size_t pathlen;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
177
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
178 utf8 = gftp_filename_from_utf8 (request, str, &pathlen);
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
179 if (utf8 != NULL)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
180 addstr = utf8;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
181 else
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
182 {
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
183 addstr = str;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
184 pathlen = strlen (str);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
185 }
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
186
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
187 *msglen += pathlen + 8;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
188 ret = sshv2_initialize_buffer (request, *msglen);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
189 sshv2_add_string_to_buf (ret + 4, addstr, pathlen);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
190
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
191 if (utf8 != NULL)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
192 g_free (utf8);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
193
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
194 return (ret);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
195 }
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
196
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
197
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
198 static char *
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
199 _sshv2_generate_utf8_path (gftp_request * request, const char *str, size_t *len)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
200 {
865
1fae947d4418 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
201 char *path, *utf8;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
202
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
203 if (*str == '/')
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
204 path = g_strdup (str);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
205 else
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
206 path = gftp_build_path (request, request->directory, str, NULL);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
207
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
208 utf8 = gftp_filename_from_utf8 (request, path, len);
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
209 if (utf8 != NULL)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
210 {
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
211 g_free (path);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
212 return (utf8);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
213 }
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
214 else
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
215 {
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
216 *len = strlen (path);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
217 return (path);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
218 }
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
219 }
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
220
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
221
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
222 static char *
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
223 sshv2_initialize_buffer_with_two_i18n_paths (gftp_request * request,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
224 const char *str1,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
225 const char *str2, size_t *msglen)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
226 {
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
227 char *first_utf8, *sec_utf8, *ret;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
228 size_t pathlen1, pathlen2;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
229
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
230 first_utf8 = _sshv2_generate_utf8_path (request, str1, &pathlen1);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
231 sec_utf8 = _sshv2_generate_utf8_path (request, str2, &pathlen2);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
232
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
233 *msglen += pathlen1 + pathlen2 + 12;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
234 ret = sshv2_initialize_buffer (request, *msglen);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
235 sshv2_add_string_to_buf (ret + 4, first_utf8, pathlen1);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
236 sshv2_add_string_to_buf (ret + 8 + pathlen1, sec_utf8, pathlen2);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
237
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
238 if (first_utf8 != str1)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
239 g_free (first_utf8);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
240
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
241 if (sec_utf8 != str2)
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
242 g_free (sec_utf8);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
243
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
244 return (ret);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
245 }
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
246
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
247
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
248 static char *
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
249 sshv2_initialize_string_with_path (gftp_request * request, const char *path,
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
250 size_t *len, char **endpos)
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
251 {
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
252 char *ret, *tempstr;
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
253 size_t origlen;
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
254
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
255 origlen = *len;
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
256 if (*path == '/')
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
257 ret = sshv2_initialize_buffer_with_i18n_string (request, path, len);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
258 else
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
259 {
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 553
diff changeset
260 tempstr = gftp_build_path (request, request->directory, path, NULL);
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
261 ret = sshv2_initialize_buffer_with_i18n_string (request, tempstr, len);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
262 g_free (tempstr);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
263 }
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
264
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
265 if (endpos != NULL)
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
266 *endpos = ret + *len - origlen;
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
267
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
268 return (ret);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
269 }
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
270
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
271
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
272 static void
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
273 sshv2_add_exec_args (char **logstr, size_t *logstr_len, char ***args,
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
274 size_t *args_len, size_t *args_max, char *first, ...)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
275 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
276 char tempstr[2048], *curpos, *endpos, save_char;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
277 va_list argp;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
278 int at_end;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
279
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
280 va_start (argp, first);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
281 g_vsnprintf (tempstr, sizeof (tempstr), first, argp);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
282 va_end (argp);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
283
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
284 *logstr_len += strlen (tempstr);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 747
diff changeset
285 *logstr = g_realloc (*logstr, (gulong) *logstr_len + 1);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
286 strcat (*logstr, tempstr);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
287
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
288 curpos = tempstr;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
289 while (*curpos == ' ')
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
290 curpos++;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
291
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
292 save_char = ' ';
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
293 at_end = 0;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
294 while (!at_end)
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
295 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
296 if (*curpos == '"')
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
297 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
298 curpos++;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
299 endpos = strchr (curpos + 1, '"');
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
300 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
301 else
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
302 endpos = strchr (curpos, ' ');
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
303
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
304 if (endpos == NULL)
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
305 at_end = 1;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
306 else
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
307 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
308 save_char = *endpos;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
309 *endpos = '\0';
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
310 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
311
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
312 if (*args_max == *args_len + 1)
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
313 {
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
314 *args_max += 10;
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
315 *args = g_realloc (*args, sizeof (char *) * *args_max);
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
316 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
317
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
318 (*args)[(*args_len)++] = g_strdup (curpos);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
319 (*args)[*args_len] = NULL;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
320
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
321 if (!at_end)
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
322 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
323 *endpos = save_char;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
324 curpos = endpos + 1;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
325 while (*curpos == ' ')
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
326 curpos++;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
327 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
328 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
329 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
330
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
331
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
332 static char **
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
333 sshv2_gen_exec_args (gftp_request * request)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
334 {
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
335 size_t logstr_len, args_len, args_cur;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
336 char **args, *tempstr, *logstr;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
337
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
338 gftp_lookup_request_option (request, "ssh_prog_name", &tempstr);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
339 if (tempstr == NULL || *tempstr == '\0')
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
340 tempstr = "ssh";
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
341
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
342 args_len = 1;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
343 args_cur = 15;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
344 args = g_malloc (sizeof (char *) * args_cur);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
345 args[0] = g_strdup (tempstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
346
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
347 logstr = g_strdup (args[0]);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
348 logstr_len = strlen (logstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
349
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
350 gftp_lookup_request_option (request, "ssh_extra_params", &tempstr);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
351 if (tempstr != NULL && *tempstr != '\0')
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
352 sshv2_add_exec_args (&logstr, &logstr_len, &args, &args_len, &args_cur,
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
353 "%s", tempstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
354
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
355 sshv2_add_exec_args (&logstr, &logstr_len, &args, &args_len, &args_cur,
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
356 " -e none");
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
357
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
358 if (request->username && *request->username != '\0')
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
359 sshv2_add_exec_args (&logstr, &logstr_len, &args, &args_len, &args_cur,
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
360 " -l %s", request->username);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
361
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
362 sshv2_add_exec_args (&logstr, &logstr_len, &args, &args_len, &args_cur,
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
363 " -p %d", request->port);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
364
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
365 sshv2_add_exec_args (&logstr, &logstr_len, &args, &args_len, &args_cur,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
366 " %s -s sftp", request->hostname);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
367
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
368 request->logging_function (gftp_logging_misc, request,
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
369 _("Running program %s\n"), logstr);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
370 g_free (logstr);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
371 return (args);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
372 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
373
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
374
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
375 static int
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
376 sshv2_start_login_sequence (gftp_request * request, int fdm, int ptymfd)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
377 {
541
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
378 static char *pwstrs[] = {N_("Enter passphrase for RSA key"),
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
379 N_("Enter passphrase for key '"),
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
380 N_("Password"),
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
381 N_("password"),
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
382 NULL};
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
383 char *tempstr, *temp1str, *pwstr, *yesstr = "yes\n", *securid_pass;
541
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
384 int wrotepw, ok, maxfd, ret, clear_tempstr, pwidx;
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
385 size_t rem, len, diff;
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
386 fd_set rset, eset;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
387 ssize_t rd;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
388
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
389 rem = len = SSH_LOGIN_BUFSIZE;
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
390 diff = 0;
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 747
diff changeset
391 tempstr = g_malloc0 ((gulong) len + 1);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
392 wrotepw = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
393 ok = 1;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
394
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
395 if (gftp_fd_set_sockblocking (request, fdm, 1) == -1)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
396 return (GFTP_ERETRYABLE);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
397
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
398 if (gftp_fd_set_sockblocking (request, ptymfd, 1) == -1)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
399 return (GFTP_ERETRYABLE);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
400
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
401 if (request->password == NULL)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
402 pwstr = g_strdup ("\n");
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
403 else
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
404 pwstr = g_strconcat (request->password, "\n", NULL);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
405
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
406 FD_ZERO (&rset);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
407 FD_ZERO (&eset);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
408 maxfd = fdm > ptymfd ? fdm : ptymfd;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
409
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
410 errno = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
411 while (1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
412 {
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
413 FD_SET (fdm, &rset);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
414 FD_SET (ptymfd, &rset);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
415
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
416 FD_SET (fdm, &eset);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
417 FD_SET (ptymfd, &eset);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
418
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
419 ret = select (maxfd + 1, &rset, NULL, &eset, NULL);
546
5d13fa48c275 2004-9-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 541
diff changeset
420 if (ret < 0 && (errno == EINTR || errno == EAGAIN))
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
421 continue;
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
422
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
423 if (ret < 0)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
424 {
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
425 request->logging_function (gftp_logging_error, request,
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
426 _("Connection to %s timed out\n"),
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
427 request->hostname);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
428 gftp_disconnect (request);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
429 return (GFTP_ERETRYABLE);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
430 }
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
431
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
432 if (FD_ISSET (fdm, &eset) || FD_ISSET (ptymfd, &eset))
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
433 {
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
434 request->logging_function (gftp_logging_error, request,
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
435 _("Error: Could not read from socket: %s\n"),
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
436 g_strerror (errno));
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
437 gftp_disconnect (request);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
438 return (GFTP_ERETRYABLE);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
439 }
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
440
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
441 if (FD_ISSET (fdm, &rset))
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
442 {
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
443 ok = 1;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
444 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
445 }
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
446 else if (!FD_ISSET (ptymfd, &rset))
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
447 continue;
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
448
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
449 rd = gftp_fd_read (request, tempstr + diff, rem - 1, ptymfd);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
450 if (rd < 0)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
451 return (rd);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
452 else if (rd == 0)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
453 continue;
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
454
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
455 tempstr[diff + rd] = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
456 request->logging_function (gftp_logging_recv, request, "%s", tempstr + diff);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
457 rem -= rd;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
458 diff += rd;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
459
541
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
460 /* See if we are at the enter password prompt... */
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
461 for (pwidx = 0; pwstrs[pwidx] != NULL; pwidx++)
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
462 {
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
463 if (strstr (tempstr, pwstrs[pwidx]) != NULL ||
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
464 strstr (tempstr, _(pwstrs[pwidx])) != NULL)
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
465 break;
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
466 }
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
467
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 747
diff changeset
468 clear_tempstr = 0;
541
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
469 if (pwstrs[pwidx] != NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
470 {
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
471 clear_tempstr = 1;
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
472 if (wrotepw)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
473 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
474 ok = SSH_ERROR_BADPASS;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
475 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
476 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
477
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
478 wrotepw = 1;
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
479 if (gftp_fd_write (request, pwstr, strlen (pwstr), ptymfd) < 0)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
480 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
481 ok = 0;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
482 break;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
483 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
484 }
541
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
485 else if (strstr (tempstr, "(yes/no)?") != NULL ||
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
486 strstr (tempstr, _("(yes/no)?")) != NULL)
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
487 {
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
488 clear_tempstr = 1;
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
489 if (!gftpui_protocol_ask_yes_no (request, request->hostname, tempstr))
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
490 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
491 ok = SSH_ERROR_QUESTION;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
492 break;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
493 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
494 else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
495 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
496 if (gftp_fd_write (request, yesstr, strlen (yesstr), ptymfd) < 0)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
497 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
498 ok = 0;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
499 break;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
500 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
501 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
502 }
541
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
503 else if (strstr (tempstr, "Enter PASSCODE:") != NULL ||
e46278e7ef1d 2004-8-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 538
diff changeset
504 strstr (tempstr, _("Enter PASSCODE:")) != NULL)
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
505 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
506 clear_tempstr = 1;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
507 securid_pass = gftpui_protocol_ask_user_input (request,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
508 _("Enter Password"),
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
509 _("Enter SecurID Password:"), 0);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
510
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
511 if (securid_pass == NULL || *securid_pass == '\0')
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
512 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
513 ok = SSH_ERROR_BADPASS;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
514 break;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
515 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
516
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
517 temp1str = g_strconcat (securid_pass, "\n", NULL);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
518
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
519 ret = gftp_fd_write (request, temp1str, strlen (temp1str), ptymfd);
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
520
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
521 memset (temp1str, 0, strlen (temp1str));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
522 g_free (temp1str);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
523 memset (securid_pass, 0, strlen (securid_pass));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
524 g_free (securid_pass);
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
525
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
526 if (ret <= 0)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
527 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
528 ok = 0;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
529 break;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
530 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
531 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
532 else if (rem <= 1)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
533 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
534 len += SSH_LOGIN_BUFSIZE;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
535 rem += SSH_LOGIN_BUFSIZE;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
536 tempstr = g_realloc (tempstr, len);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
537 continue;
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
538 }
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
539
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
540 if (clear_tempstr)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
541 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
542 *tempstr = '\0';
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
543 rem = SSH_LOGIN_BUFSIZE;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
544 diff = 0;
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
545 }
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
546 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
547
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
548 g_free (pwstr);
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
549 g_free (tempstr);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
550
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
551 if (ok <= 0)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
552 {
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
553 request->logging_function (gftp_logging_error, request, "\n");
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
554
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
555 if (ok == SSH_ERROR_BADPASS)
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
556 request->logging_function (gftp_logging_error, request,
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
557 _("Error: An incorrect password was entered\n"));
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
558
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 458
diff changeset
559 gftp_disconnect (request);
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
560 return (GFTP_EFATAL);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
561 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
562
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
563 return (0);
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
564 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
565
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
566
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
567 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
568 sshv2_log_command (gftp_request * request, gftp_logging_level level,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
569 char type, char *message, size_t length)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
570 {
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
571 guint32 id, num, attr, stattype;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
572 char *descr, *pos, oldchar;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
573 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
574
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
575 params = request->protocol_data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
576 memcpy (&id, message, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
577 id = ntohl (id);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
578 switch (type)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
579 {
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
580 case SSH_FXP_DATA:
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
581 case SSH_FXP_READ:
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
582 case SSH_FXP_WRITE:
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
583 break;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
584 case SSH_FXP_INIT:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
585 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
586 _("%d: Protocol Initialization\n"), id);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
587 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
588 case SSH_FXP_VERSION:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
589 request->logging_function (level, request,
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
590 _("%d: Protocol version %d\n"), id, id);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
591 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
592 case SSH_FXP_OPEN:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
593 memcpy (&num, message + 4, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
594 num = ntohl (num);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
595 pos = message + 12 + num - 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
596 oldchar = *pos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
597 *pos = '\0';
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
598 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
599 _("%d: Open %s\n"), id, message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
600 *pos = oldchar;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
601 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
602 case SSH_FXP_CLOSE:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
603 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
604 _("%d: Close\n"), id);
765
d553d14a2565 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 747
diff changeset
605 break;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
606 case SSH_FXP_OPENDIR:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
607 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
608 _("%d: Open Directory %s\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
609 message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
610 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
611 case SSH_FXP_READDIR:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
612 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
613 _("%d: Read Directory\n"), id);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
614 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
615 case SSH_FXP_REMOVE:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
616 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
617 _("%d: Remove file %s\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
618 message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
619 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
620 case SSH_FXP_MKDIR:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
621 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
622 _("%d: Make directory %s\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
623 message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
624 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
625 case SSH_FXP_RMDIR:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
626 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
627 _("%d: Remove directory %s\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
628 message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
629 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
630 case SSH_FXP_REALPATH:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
631 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
632 _("%d: Realpath %s\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
633 message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
634 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
635 case SSH_FXP_ATTRS:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
636 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
637 _("%d: File attributes\n"), id);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
638 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
639 case SSH_FXP_STAT:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
640 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
641 _("%d: Stat %s\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
642 message + 8);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
643 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
644 case SSH_FXP_SETSTAT:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
645 memcpy (&num, message + 4, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
646 num = ntohl (num);
529
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
647
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
648 memcpy (&stattype, message + 8 + num, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
649 stattype = ntohl (stattype);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
650 memcpy (&attr, message + 12 + num, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
651 attr = ntohl (attr);
529
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
652
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
653 pos = message + 8 + num;
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
654 oldchar = *pos;
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
655 *pos = '\0';
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
656
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
657 switch (stattype)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
658 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
659 case SSH_FILEXFER_ATTR_PERMISSIONS:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
660 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
661 _("%d: Chmod %s %o\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
662 message + 8, attr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
663 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
664 case SSH_FILEXFER_ATTR_ACMODTIME:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
665 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
666 _("%d: Utime %s %d\n"), id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
667 message + 8, attr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
668 }
529
c36a475ecf5a 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 528
diff changeset
669
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
670 *pos = oldchar;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
671 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
672 case SSH_FXP_STATUS:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
673 if (params->dont_log_status)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
674 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
675 memcpy (&num, message + 4, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
676 num = ntohl (num);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
677 switch (num)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
678 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
679 case SSH_FX_OK:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
680 descr = _("OK");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
681 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
682 case SSH_FX_EOF:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
683 descr = _("EOF");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
684 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
685 case SSH_FX_NO_SUCH_FILE:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
686 descr = _("No such file or directory");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
687 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
688 case SSH_FX_PERMISSION_DENIED:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
689 descr = _("Permission denied");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
690 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
691 case SSH_FX_FAILURE:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
692 descr = _("Failure");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
693 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
694 case SSH_FX_BAD_MESSAGE:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
695 descr = _("Bad message");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
696 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
697 case SSH_FX_NO_CONNECTION:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
698 descr = _("No connection");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
699 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
700 case SSH_FX_CONNECTION_LOST:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
701 descr = _("Connection lost");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
702 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
703 case SSH_FX_OP_UNSUPPORTED:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
704 descr = _("Operation unsupported");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
705 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
706 default:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
707 descr = _("Unknown message returned from server");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
708 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
709 }
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
710 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
711 "%d: %s\n", id, descr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
712 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
713 case SSH_FXP_HANDLE:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
714 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
715 "%d: File handle\n", id);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
716 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
717 case SSH_FXP_NAME:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
718 memcpy (&num, message + 4, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
719 num = ntohl (num);
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
720 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
721 "%d: Filenames (%d entries)\n", id,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
722 num);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
723 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
724 default:
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
725 request->logging_function (level, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
726 "Command: %x\n", type);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
727 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
728 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
729
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
730
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
731 static int
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
732 sshv2_send_command (gftp_request * request, char type, char *command,
321
3e6d0c26e37b 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 309
diff changeset
733 size_t len)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
734 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
735 char buf[34000];
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
736 guint32 clen;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
737 int ret;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
738
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
739 if (len > 33995)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
740 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
741 request->logging_function (gftp_logging_error, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
742 _("Error: Message size %d too big\n"), len);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
743 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
744 return (GFTP_EFATAL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
745 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
746
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
747 clen = htonl (len + 1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
748 memcpy (buf, &clen, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
749 buf[4] = type;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
750 memcpy (&buf[5], command, len);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
751 buf[len + 5] = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
752
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
753 #ifdef DEBUG
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
754 printf ("\rSending to FD %d: ", request->datafd);
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
755 for (clen=0; clen<len + 5; clen++)
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
756 printf ("%x ", buf[clen] & 0xff);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
757 printf ("\n");
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
758 #endif
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
759
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
760 sshv2_log_command (request, gftp_logging_send, type, buf + 5, len);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
761
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
762 if ((ret = gftp_fd_write (request, buf, len + 5, request->datafd)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
763 return (ret);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
764
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
765 return (0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
766 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
767
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
768
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
769 static int
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
770 sshv2_read_response (gftp_request * request, sshv2_message * message,
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
771 int fd)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
772 {
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
773 char buf[6], error_buffer[255], *pos;
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
774 sshv2_params * params;
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
775 ssize_t numread;
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
776 size_t rem;
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
777
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
778 params = request->protocol_data;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
779
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
780 if (fd <= 0)
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
781 fd = request->datafd;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
782
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
783 pos = buf;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
784 rem = 5;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
785 while (rem > 0)
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
786 {
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
787 if ((numread = gftp_fd_read (request, pos, rem, fd)) < 0)
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
788 return (numread);
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
789 rem -= numread;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
790 pos += numread;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
791 }
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
792 buf[5] = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
793
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
794 memcpy (&message->length, buf, 4);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
795 message->length = ntohl (message->length);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
796 if (message->length > 34000)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
797 {
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
798 if (params->initialized)
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
799 {
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
800 request->logging_function (gftp_logging_error, request,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
801 _("Error: Message size %d too big from server\n"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
802 message->length);
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
803 }
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
804 else
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
805 {
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
806 request->logging_function (gftp_logging_error, request,
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
807 _("There was an error initializing a SSH connection with the remote server. The error message from the remote server follows:\n"), buf);
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
808
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
809 request->logging_function (gftp_logging_error, request, "%s", buf);
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
810
243
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 232
diff changeset
811 if (gftp_fd_set_sockblocking (request, fd, 0) == -1)
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 232
diff changeset
812 return (GFTP_EFATAL);
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 232
diff changeset
813
b42e7233533a 2003-7-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 232
diff changeset
814 if ((numread = gftp_fd_read (NULL, error_buffer,
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
815 sizeof (error_buffer) - 1,
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
816 fd)) > 0)
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
817 {
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
818 error_buffer[numread] = '\0';
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
819 request->logging_function (gftp_logging_error, request,
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
820 "%s", error_buffer);
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
821 }
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
822 }
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
823
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
824 memset (message, 0, sizeof (*message));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
825 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
826 return (GFTP_EFATAL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
827 }
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
828
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
829 message->command = buf[4];
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
830 message->buffer = g_malloc (message->length + 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
831
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
832 message->pos = message->buffer;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
833 message->end = message->buffer + message->length - 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
834
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
835 pos = message->buffer;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
836 rem = message->length - 1;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
837 while (rem > 0)
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
838 {
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
839 if ((numread = gftp_fd_read (request, pos, rem, fd)) < 0)
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
840 return (numread);
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
841 rem -= numread;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
842 pos += numread;
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
843 }
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
844
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
845 #ifdef DEBUG
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
846 printf ("\rReceived message: ");
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
847 for (rem=0; rem<message->length; rem++)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
848 printf ("%x ", message->buffer[rem] & 0xff);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
849 printf ("\n");
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
850 #endif
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
851
61
42df9e4be8e0 2002-11-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
852 message->buffer[message->length] = '\0';
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
853
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
854 sshv2_log_command (request, gftp_logging_recv, message->command,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
855 message->buffer, message->length);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
856
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
857 return (message->command);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
858 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
859
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
860
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
861 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
862 sshv2_destroy (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
863 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
864 g_return_if_fail (request != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
865 g_return_if_fail (request->protonum == GFTP_SSHV2_NUM);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
866
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
867 g_free (request->protocol_data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
868 request->protocol_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
869 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
870
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
871
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
872 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
873 sshv2_message_free (sshv2_message * message)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
874 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
875 if (message->buffer)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
876 g_free (message->buffer);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
877 memset (message, 0, sizeof (*message));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
878 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
879
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
880
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
881 static int
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
882 sshv2_wrong_response (gftp_request * request, sshv2_message * message)
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
883 {
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
884 request->logging_function (gftp_logging_error, request,
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
885 _("Received wrong response from server, disconnecting\n"));
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
886 gftp_disconnect (request);
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
887
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
888 if (message != NULL)
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
889 sshv2_message_free (message);
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
890
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
891 return (GFTP_EFATAL);
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
892 }
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
893
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
894
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
895 static int
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
896 sshv2_read_status_response (gftp_request * request, sshv2_message * message,
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
897 int fd, int fxp_is_retryable, int fxp_is_wrong)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
898 {
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
899 guint32 num;
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
900 int ret;
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
901
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
902 memset (message, 0, sizeof (*message));
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
903 ret = sshv2_read_response (request, message, -1);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
904 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
905 return (ret);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
906 else if (fxp_is_retryable > 0 && ret == fxp_is_retryable)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
907 {
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
908 memcpy (&num, message->buffer + 4, 4);
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
909 num = ntohl (num);
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
910
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
911 sshv2_message_free (message);
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
912
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
913 if (num == SSH_FX_PERMISSION_DENIED)
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
914 return (GFTP_EFATAL);
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
915 else
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
916 return (GFTP_ERETRYABLE);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
917 }
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
918 else if (fxp_is_wrong > 0 && ret != fxp_is_wrong)
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
919 return (sshv2_wrong_response (request, message));
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
920
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
921 return (ret);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
922 }
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
923
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
924
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
925 static int
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
926 sshv2_response_return_code (gftp_request * request, sshv2_message * message,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
927 unsigned int ret)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
928 {
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
929 switch (ret)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
930 {
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
931 case SSH_FX_OK:
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
932 case SSH_FX_EOF:
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
933 case SSH_FX_NO_SUCH_FILE:
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
934 case SSH_FX_FAILURE:
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
935 case SSH_FX_OP_UNSUPPORTED:
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
936 return (GFTP_ERETRYABLE);
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
937 case SSH_FX_PERMISSION_DENIED:
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 849
diff changeset
938 return (GFTP_EFATAL);
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
939 default:
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
940 return (sshv2_wrong_response (request, message));
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
941 }
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
942 }
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
943
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
944
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
945 static int
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
946 sshv2_buffer_get_int32 (gftp_request * request, sshv2_message * message,
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
947 unsigned int expected_response, int check_response,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
948 guint32 * num)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
949 {
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
950 guint32 snum;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
951
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
952 if (message->end - message->pos < 4)
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
953 return (sshv2_wrong_response (request, message));
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
954
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
955 memcpy (&snum, message->pos, 4);
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
956 snum = ntohl (snum);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
957 message->pos += 4;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
958
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
959 if (check_response && snum != expected_response)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
960 return (sshv2_response_return_code (request, message, snum));
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
961
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
962 if (num != NULL)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
963 *num = snum;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
964
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
965 return (0);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
966 }
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
967
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
968
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
969 static int
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
970 sshv2_buffer_get_int64 (gftp_request * request, sshv2_message * message,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
971 unsigned int expected_response, int check_response,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
972 #if G_HAVE_GINT64
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
973 guint64 * num)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
974 {
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
975 guint64 snum;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
976 #else
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
977 guint32 * num)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
978 {
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
979 guint32 snum;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
980 #endif
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
981 guint32 hinum, lonum;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
982 int ret;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
983
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
984 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &hinum)) < 0)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
985 return (ret);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
986
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
987 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &lonum)) < 0)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
988 return (ret);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
989
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
990 #if G_HAVE_GINT64
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
991 snum = (gint64) lonum | ((gint64) hinum >> 32);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
992 #else
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
993 snum = lonum;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
994 #endif
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
995
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
996 if (check_response && snum != expected_response)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
997 return (sshv2_response_return_code (request, message, snum));
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
998
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
999 if (num != NULL)
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1000 *num = snum;
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1001
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1002 return (0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1003 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1004
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1005
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1006 static char *
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1007 sshv2_buffer_get_string (gftp_request * request, sshv2_message * message,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1008 int return_string)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1009 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1010 guint32 len, buflen;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1011 char *string;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1012
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1013 if (sshv2_buffer_get_int32 (request, message, 0, 0, &len) < 0)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1014 return (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1015
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1016 buflen = message->end - message->pos;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1017 if (len > SSH_MAX_STRING_SIZE || (buflen < len))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1018 {
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
1019 sshv2_wrong_response (request, message);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1020 return (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1021 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1022
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1023 if (return_string)
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1024 {
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1025 string = g_malloc (len + 1);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1026 memcpy (string, message->pos, len);
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1027 string[len] = '\0';
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1028 }
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1029 else
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1030 string = NULL;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1031
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1032 message->pos += len;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1033 return (string);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1034 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1035
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1036
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1037 static int
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1038 sshv2_getcwd (gftp_request * request)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1039 {
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1040 char *tempstr, *dir, *utf8;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1041 sshv2_message message;
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1042 size_t len;
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1043 int ret;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1044
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1045 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1046 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1047
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1048 if (request->directory == NULL || *request->directory == '\0')
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1049 dir = ".";
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1050 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1051 dir = request->directory;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1052
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
1053 len = 0;
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1054 tempstr = sshv2_initialize_buffer_with_i18n_string (request, dir, &len);
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1055 ret = sshv2_send_command (request, SSH_FXP_REALPATH, tempstr, len);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1056 g_free (tempstr);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1057 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1058 return (ret);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1059
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1060 if (request->directory)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1061 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1062 g_free (request->directory);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1063 request->directory = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1064 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1065
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1066 ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS,
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1067 SSH_FXP_NAME);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1068 if (ret < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1069 return (ret);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1070
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1071 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1072 if ((ret = sshv2_buffer_get_int32 (request, &message, 1, 1, NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1073 return (ret);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1074
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1075 if ((dir = sshv2_buffer_get_string (request, &message, 1)) == NULL)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1076 return (GFTP_EFATAL);
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1077
845
8263cc35c027 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 843
diff changeset
1078 utf8 = gftp_filename_to_utf8 (request, dir, &len);
843
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1079 if (utf8 != NULL)
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1080 {
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1081 request->directory = utf8;
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1082 g_free (dir);
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1083 }
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1084 else
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1085 request->directory = dir;
32dbed7e0dc4 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 840
diff changeset
1086
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1087 sshv2_message_free (&message);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1088 return (0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1089 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1090
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1091
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1092 static void
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1093 sshv2_free_args (char **args)
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1094 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1095 int i;
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1096
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1097 for (i=0; args[i] != NULL; i++)
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1098 g_free (args[i]);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1099 g_free (args);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1100 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1101
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1102
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1103 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1104 sshv2_connect (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1105 {
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1106 struct servent serv_struct;
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1107 sshv2_params * params;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1108 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1109 int ret, fdm, ptymfd;
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1110 guint32 version;
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1111 char **args;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1112 pid_t child;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1113
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1114 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1115 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1116 g_return_val_if_fail (request->hostname != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1117
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1118 if (request->datafd > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1119 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1120
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1121 params = request->protocol_data;
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1122
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1123 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1124 _("Opening SSH connection to %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1125 request->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1126
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1127 if (request->port == 0)
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1128 {
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1129 if (!r_getservbyname ("ssh", "tcp", &serv_struct, NULL))
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1130 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1131 request->logging_function (gftp_logging_error, request,
124
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1132 _("Cannot look up service name %s/tcp. Please check your services file\n"),
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1133 "ssh");
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1134 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1135 else
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1136 request->port = ntohs (serv_struct.s_port);
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1137 }
65048c959029 2003-4-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 122
diff changeset
1138
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
1139 args = sshv2_gen_exec_args (request);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1140
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1141 child = gftp_exec (request, &fdm, &ptymfd, args);
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1142
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1143 if (child == 0)
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1144 exit (0);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1145
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1146 sshv2_free_args (args);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1147
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1148 if (child < 0)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1149 return (GFTP_ERETRYABLE);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1150
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1151 request->datafd = fdm;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1152
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1153 version = htonl (SSH_MY_VERSION);
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1154 if ((ret = sshv2_send_command (request, SSH_FXP_INIT, (char *)
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1155 &version, 4)) < 0)
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1156 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1157
458
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1158 ret = sshv2_start_login_sequence (request, fdm, ptymfd);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1159 if (ret < 0)
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1160 return (ret);
656a0b3d1403 2004-4-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 399
diff changeset
1161
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1162 memset (&message, 0, sizeof (message));
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1163 ret = sshv2_read_response (request, &message, -1);
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1164 if (ret < 0)
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1165 {
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1166 sshv2_message_free (&message);
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1167 return (ret);
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1168 }
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1169 else if (ret != SSH_FXP_VERSION)
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
1170 return (sshv2_wrong_response (request, &message));
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1171
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1172 sshv2_message_free (&message);
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1173
219
b9584a877daf 2003-7-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 218
diff changeset
1174 params->initialized = 1;
210
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1175 request->logging_function (gftp_logging_misc, request,
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1176 _("Successfully logged into SSH server %s\n"),
82ebd1b05345 2003-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
1177 request->hostname);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1178
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1179 if (sshv2_getcwd (request) < 0)
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1180 {
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1181 if (request->directory)
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1182 g_free (request->directory);
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1183
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1184 request->directory = g_strdup (".");
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1185 if ((ret = sshv2_getcwd (request)) < 0)
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1186 {
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1187 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1188 return (ret);
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1189 }
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1190 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1191
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1192 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1193 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1194
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1195
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1196 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1197 sshv2_disconnect (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1198 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1199 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1200
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1201 g_return_if_fail (request != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1202 g_return_if_fail (request->protonum == GFTP_SSHV2_NUM);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1203
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1204 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1205
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1206 if (request->datafd > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1207 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1208 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1209 _("Disconnecting from site %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1210 request->hostname);
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
1211
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1212 if (close (request->datafd) < 0)
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1213 request->logging_function (gftp_logging_error, request,
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
1214 _("Error closing file descriptor: %s\n"),
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
1215 g_strerror (errno));
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
1216
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1217 request->datafd = -1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1218 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1220 if (params->message.buffer != NULL)
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1221 {
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1222 sshv2_message_free (&params->message);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1223 params->message.buffer = NULL;
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1224 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1225 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1226
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1227
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1228 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1229 sshv2_end_transfer (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1230 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1231 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1232 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1233 guint32 len;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1234 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1235
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1236 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1237 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1238
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1239 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1240 if (params->message.buffer != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1241 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1242 sshv2_message_free (&params->message);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1243 params->message.buffer = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1244 params->count = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1245 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1246
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1247 if (params->handle_len > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1248 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1249 len = htonl (params->id++);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1250 memcpy (params->handle, &len, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1251
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1252 if ((ret = sshv2_send_command (request, SSH_FXP_CLOSE, params->handle,
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1253 params->handle_len)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1254 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1255
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1256 ret = sshv2_read_status_response (request, &message, -1, 0,
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1257 SSH_FXP_STATUS);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1258 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1259 return (ret);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1260
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1261 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1262 params->handle_len = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1263 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1264
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1265 if (params->transfer_buffer != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1266 {
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1267 g_free (params->transfer_buffer);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1268 params->transfer_buffer = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1269 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1270
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1271 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1272 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1273
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1274
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1275 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1276 sshv2_list_files (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1277 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1278 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1279 sshv2_message message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1280 char *tempstr;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1281 size_t msglen;
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1282 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1283
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1284 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1285 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1286 g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1287
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1288 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1289
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1290 request->logging_function (gftp_logging_misc, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1291 _("Retrieving directory listing...\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1292
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
1293 msglen = 0;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1294 tempstr = sshv2_initialize_buffer_with_i18n_string (request,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1295 request->directory,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1296 &msglen);
839
0d9a3d4188c3 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 832
diff changeset
1297 ret = sshv2_send_command (request, SSH_FXP_OPENDIR, tempstr, msglen);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1298 g_free (tempstr);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1299 if (ret < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1300 return (ret);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1301
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1302 ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS,
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1303 SSH_FXP_HANDLE);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1304 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1305 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1306
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1307 if (message.length - 4 > SSH_MAX_HANDLE_SIZE)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1308 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1309 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1310 _("Error: Message size %d too big from server\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1311 message.length - 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1312 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1313 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1314 return (GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1315 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1316
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1317 memset (params->handle, 0, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1318 memcpy (params->handle + 4, message.buffer + 4, message.length - 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1319 params->handle_len = message.length - 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1320 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1321 params->count = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1322 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1323 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1324
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1325
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1326 static int
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1327 sshv2_decode_file_attributes (gftp_request * request, sshv2_message * message,
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1328 gftp_file * fle)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1329 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1330 guint32 attrs, num, count, i;
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1331 int ret;
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1332
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1333 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &attrs)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1334 return (ret);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1335
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1336 if (attrs & SSH_FILEXFER_ATTR_SIZE)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1337 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1338 if ((ret = sshv2_buffer_get_int64 (request, message, 0, 0, &fle->size)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1339 return (ret);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1340 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1341
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1342 if (attrs & SSH_FILEXFER_ATTR_UIDGID)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1343 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1344 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1345 return (ret);
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1346 fle->user = g_strdup_printf ("%d", num);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1347
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1348 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1349 return (ret);
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1350 fle->group = g_strdup_printf ("%d", num);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1351 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1352
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1353 if (attrs & SSH_FILEXFER_ATTR_PERMISSIONS)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1354 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1355 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1356 return (ret);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1357
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1358 fle->st_mode = num;
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1359 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1360
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1361 if (attrs & SSH_FILEXFER_ATTR_ACMODTIME)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1362 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1363 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, NULL)) < 0)
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1364 return (num);
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1365
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1366 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1367 return (ret);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1368
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1369 fle->datetime = num;
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1370 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1371
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1372 if (attrs & SSH_FILEXFER_ATTR_EXTENDED)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1373 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1374 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &count)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1375 return (ret);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1376
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1377 for (i=0; i<count; i++)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1378 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1379 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1380 &num)) < 0 ||
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1381 message->pos + num + 4 > message->end)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1382 return (GFTP_EFATAL);
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1383
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1384 message->pos += num + 4;
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1385
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1386 if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0,
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1387 &num)) < 0 ||
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1388 message->pos + num + 4 > message->end)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1389 return (GFTP_EFATAL);
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1390
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1391 message->pos += num + 4;
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1392 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1393 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1394
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1395 return (0);
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1396 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1397
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1398
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1399 static int
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
1400 sshv2_get_next_file (gftp_request * request, gftp_file * fle, int fd)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1401 {
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1402 int ret, retsize, iret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1403 sshv2_params *params;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1404 char *stpos;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1405 guint32 len;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1406
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1407 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1408 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1409 g_return_val_if_fail (fle != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1410
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1411 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1412
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1413 if (request->last_dir_entry)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1414 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1415 g_free (request->last_dir_entry);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1416 request->last_dir_entry = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1417 request->last_dir_entry_len = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1418 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1419 retsize = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1420
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1421 if (params->count > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1422 ret = SSH_FXP_NAME;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1423 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1424 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1425 if (!request->cached)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1426 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1427 if (params->message.buffer != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1428 sshv2_message_free (&params->message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1429
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1430 len = htonl (params->id++);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1431 memcpy (params->handle, &len, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1432
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1433 if ((ret = sshv2_send_command (request, SSH_FXP_READDIR,
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1434 params->handle,
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1435 params->handle_len)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1436 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1437 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1438
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1439 if ((ret = sshv2_read_response (request, &params->message, fd)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1440 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1441
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1442 if (!request->cached)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1443 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1444 request->last_dir_entry = g_malloc (params->message.length + 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1445 len = htonl (params->message.length);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1446 memcpy (request->last_dir_entry, &len, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1447 request->last_dir_entry[4] = params->message.command;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1448 memcpy (request->last_dir_entry + 5, params->message.buffer,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1449 params->message.length - 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1450 request->last_dir_entry_len = params->message.length + 4;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1451 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1452
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1453 if (ret == SSH_FXP_NAME)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1454 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1455 params->message.pos = params->message.buffer + 4;
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1456 if ((iret = sshv2_buffer_get_int32 (request,
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1457 &params->message, 0, 0,
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1458 &params->count)) < 0)
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1459 return (iret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1460 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1461 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1462
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1463 if (ret == SSH_FXP_NAME)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1464 {
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1465 stpos = params->message.pos;
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1466 if ((fle->file = sshv2_buffer_get_string (request, &params->message, 1)) == NULL)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1467 return (GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1468
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1469 sshv2_buffer_get_string (request, &params->message, 0);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1470
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1471 if ((ret = sshv2_decode_file_attributes (request, &params->message,
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1472 fle)) < 0)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1473 {
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 574
diff changeset
1474 gftp_file_destroy (fle, 0);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1475 return (ret);
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1476 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1477
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1478 retsize = params->message.pos - stpos;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1479 params->count--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1480 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1481 else if (ret == SSH_FXP_STATUS)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1482 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1483 sshv2_message_free (&params->message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1484 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1485 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1486 else
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
1487 return (sshv2_wrong_response (request, &params->message));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1488
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1489 return (retsize);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1490 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1491
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1492
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1493 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1494 sshv2_chdir (gftp_request * request, const char *directory)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1495 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1496 sshv2_message message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1497 char *tempstr, *dir;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1498 size_t len;
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1499 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1500
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1501 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1502 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1503
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1504 len = 0;
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1505 tempstr = sshv2_initialize_string_with_path (request, directory, &len, NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1506
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1507 ret = sshv2_send_command (request, SSH_FXP_REALPATH, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1508
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1509 g_free (tempstr);
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1510 if (ret < 0)
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1511 return (ret);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1512
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1513 ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS,
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1514 SSH_FXP_NAME);
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1515 if (ret < 0)
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1516 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1517
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1518 message.pos += 4;
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1519 if ((ret = sshv2_buffer_get_int32 (request, &message, 1, 1, NULL)) < 0)
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1520 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1521
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1522 if ((dir = sshv2_buffer_get_string (request, &message, 1)) == NULL)
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1523 return (GFTP_EFATAL);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1524
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1525 if (request->directory)
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1526 g_free (request->directory);
284
9f121f62284b 2003-10-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
1527
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1528 request->directory = dir;
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1529 sshv2_message_free (&message);
284
9f121f62284b 2003-10-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 245
diff changeset
1530 return (0);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1531 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1532
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1533
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1534 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1535 sshv2_rmdir (gftp_request * request, const char *directory)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1536 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1537 sshv2_message message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1538 char *tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1539 size_t len;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1540 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1541
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1542 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1543 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1544 g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1545
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1546 len = 0;
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1547 tempstr = sshv2_initialize_string_with_path (request, directory, &len, NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1548
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1549 ret = sshv2_send_command (request, SSH_FXP_RMDIR, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1550
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1551 g_free (tempstr);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1552 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1553 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1554
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1555 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1556 if ((ret = sshv2_read_response (request, &message, -1)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1557 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1558
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1559 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1560 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1, NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1561 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1562
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1563 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1564
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1565 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1566 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1567
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1568
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1569 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1570 sshv2_rmfile (gftp_request * request, const char *file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1571 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1572 sshv2_message message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1573 char *tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1574 size_t len;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1575 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1576
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1577 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1578 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1579 g_return_val_if_fail (file != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1580
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1581 len = 0;
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1582 tempstr = sshv2_initialize_string_with_path (request, file, &len, NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1583
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1584 ret = sshv2_send_command (request, SSH_FXP_REMOVE, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1585
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1586 g_free (tempstr);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1587 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1588 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1589
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1590 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1591 if ((ret = sshv2_read_response (request, &message, -1)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1592 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1593
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1594 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1595 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1, NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1596 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1597
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1598 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1599
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1600 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1601 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1602
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1603
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1604 static int
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 498
diff changeset
1605 sshv2_chmod (gftp_request * request, const char *file, mode_t mode)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1606 {
531
65cd664cbf32 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 529
diff changeset
1607 char *tempstr, *endpos;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1608 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1609 guint32 num;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1610 size_t len;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1611 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1612
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1613 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1614 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1615 g_return_val_if_fail (file != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1616
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1617 len = 8; /* For attributes */
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1618 tempstr = sshv2_initialize_string_with_path (request, file, &len, &endpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1619
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1620 num = htonl (SSH_FILEXFER_ATTR_PERMISSIONS);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1621 memcpy (endpos, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1622
531
65cd664cbf32 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 529
diff changeset
1623 num = htonl (mode);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1624 memcpy (endpos + 4, &num, 4);
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1625
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1626 ret = sshv2_send_command (request, SSH_FXP_SETSTAT, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1627
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1628 g_free (tempstr);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1629 if (ret < 0)
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1630 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1631
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1632 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1633 if ((ret = sshv2_read_response (request, &message, -1)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1634 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1635
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1636 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1637 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1, NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1638 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1639
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1640 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1641
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1642 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1643 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1644
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1645
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1646 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1647 sshv2_mkdir (gftp_request * request, const char *newdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1648 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1649 sshv2_message message;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1650 char *tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1651 size_t len;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1652 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1653
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1654 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1655 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1656 g_return_val_if_fail (newdir != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1657
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1658 len = 4; /* For attributes */
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1659 tempstr = sshv2_initialize_string_with_path (request, newdir, &len, NULL);
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1660
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1661 /* No need to set attributes since all characters of the tempstr buffer is
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1662 initialized to 0 */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1663
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1664 ret = sshv2_send_command (request, SSH_FXP_MKDIR, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1665
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1666 g_free (tempstr);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1667 if (ret < 0)
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1668 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1669
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1670 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1671 if ((ret = sshv2_read_response (request, &message, -1)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1672 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1673
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1674 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1675 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1, NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1676 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1677
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1678 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1679
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1680 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1681 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1682
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1683
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1684 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1685 sshv2_rename (gftp_request * request, const char *oldname, const char *newname)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1686 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1687 sshv2_message message;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1688 char *tempstr;
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1689 size_t msglen;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1690 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1691
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1692 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1693 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1694 g_return_val_if_fail (oldname != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1695 g_return_val_if_fail (newname != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1696
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
1697 msglen = 0;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1698 tempstr = sshv2_initialize_buffer_with_two_i18n_paths (request,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1699 oldname, newname,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1700 &msglen);
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1701 ret = sshv2_send_command (request, SSH_FXP_RENAME, tempstr, msglen);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1702 g_free (tempstr);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1703 if (ret < 0)
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1704 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1705
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1706 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1707 if ((ret = sshv2_read_response (request, &message, -1)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1708 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1709
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1710 message.pos += 4;
840
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1711 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1,
dd83cd01dc30 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 839
diff changeset
1712 NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1713 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1714
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1715 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1716
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1717 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1718 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1719
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1720
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1721 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1722 sshv2_set_file_time (gftp_request * request, const char *file, time_t datetime)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1723 {
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1724 char *tempstr, *endpos;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1725 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1726 guint32 num;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1727 size_t len;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1728 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1729
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1730 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1731 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1732 g_return_val_if_fail (file != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1733
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1734 len = 12; /* For date/time */
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1735 tempstr = sshv2_initialize_string_with_path (request, file, &len, &endpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1736
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1737 num = htonl (SSH_FILEXFER_ATTR_ACMODTIME);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1738 memcpy (endpos, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1739
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1740 num = htonl (datetime);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1741 memcpy (endpos + 4, &num, 4);
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1742 memcpy (endpos + 8, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1743
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1744 ret = sshv2_send_command (request, SSH_FXP_SETSTAT, tempstr, len);
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1745
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1746 g_free (tempstr);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1747 if (ret < 0)
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1748 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1749
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1750 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1751 if ((ret = sshv2_read_response (request, &message, -1)) < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1752 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1753
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1754 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1755 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1, NULL)) < 0)
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1756 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1757
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1758 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1759
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1760 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1761 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1762
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1763
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1764 static int
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1765 sshv2_send_stat_command (gftp_request * request, const char *filename,
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1766 gftp_file * fle)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1767 {
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1768 sshv2_message message;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1769 char *tempstr;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1770 size_t len;
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1771 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1772
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1773 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1774 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1775 g_return_val_if_fail (filename != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1776
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1777 len = 0;
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1778 tempstr = sshv2_initialize_string_with_path (request, filename, &len, NULL);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1779
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1780 ret = sshv2_send_command (request, SSH_FXP_STAT, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1781
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1782 g_free (tempstr);
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1783 if (ret < 0)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1784 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1785
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1786 ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS,
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1787 SSH_FXP_ATTRS);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1788 if (ret < 0)
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1789 return (ret);
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1790
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1791 if (message.length < 5)
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1792 return (GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1793
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1794 message.pos += 4;
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1795 if ((ret = sshv2_decode_file_attributes (request, &message, fle)) < 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1796 {
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 574
diff changeset
1797 gftp_file_destroy (fle, 0);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1798 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1799 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1800
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
1801 sshv2_message_free (&message);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1802
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1803 return (0);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1804 }
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1805
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1806
520
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 519
diff changeset
1807 static int
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 519
diff changeset
1808 sshv2_stat_filename (gftp_request * request, const char *filename,
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1809 mode_t * mode, off_t * filesize)
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1810 {
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1811 gftp_file fle;
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
1812 int ret;
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1813
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1814 memset (&fle, 0, sizeof (fle));
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1815 ret = sshv2_send_stat_command (request, filename, &fle);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1816 if (ret < 0)
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1817 return (ret);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1818
520
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 519
diff changeset
1819 *mode = fle.st_mode;
787
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1820 *filesize = fle.size;
3751478bb260 2006-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 765
diff changeset
1821
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 574
diff changeset
1822 gftp_file_destroy (&fle, 0);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1823
520
e67a52327b24 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 519
diff changeset
1824 return (0);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1825 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1826
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1827
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1828 static off_t
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1829 sshv2_get_file_size (gftp_request * request, const char *file)
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1830 {
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1831 gftp_file fle;
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1832 off_t size;
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1833 int ret;
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1834
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1835 memset (&fle, 0, sizeof (fle));
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1836 ret = sshv2_send_stat_command (request, file, &fle);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1837 if (ret < 0)
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1838 return (ret);
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1839
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1840 size = fle.size;
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 574
diff changeset
1841 gftp_file_destroy (&fle, 0);
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1842
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
1843 return (size);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1844 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1845
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1846
537
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1847 static int
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1848 sshv2_open_file (gftp_request * request, const char *file, off_t startsize,
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1849 guint32 mode)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1850 {
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1851 char *tempstr, *endpos;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1852 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1853 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1854 guint32 num;
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1855 size_t len;
64
29128554eb86 2002-11-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
1856 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1857
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1858 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1859 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1860 g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1861
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1862 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1863 params->offset = startsize;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1864
849
0cf4d8c46b82 2006-11-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 845
diff changeset
1865 len = 8; /* For mode */
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1866 tempstr = sshv2_initialize_string_with_path (request, file, &len, &endpos);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1867
537
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1868 num = htonl (mode);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1869 memcpy (endpos, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1870
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1871 ret = sshv2_send_command (request, SSH_FXP_OPEN, tempstr, len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1872
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1873 g_free (tempstr);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1874 if (ret < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1875 return (ret);
489
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1876
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1877 ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS,
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1878 SSH_FXP_HANDLE);
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1879 if (ret < 0)
913ea2819842 2004-6-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 487
diff changeset
1880 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1881
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1882 if (message.length - 4 > SSH_MAX_HANDLE_SIZE)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1883 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
1884 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1885 _("Error: Message size %d too big from server\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1886 message.length - 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1887 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1888 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1889 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1890
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1891 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1892
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1893 memset (params->handle, 0, 4);
321
3e6d0c26e37b 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 309
diff changeset
1894 memcpy (params->handle + 4, message.buffer + 4, message.length - 5);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1895 params->handle_len = message.length - 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1896 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1897
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1898 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1899 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1900
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1901
537
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1902 static off_t
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1903 sshv2_get_file (gftp_request * request, const char *file, int fd,
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1904 off_t startsize)
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1905 {
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1906 int ret;
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1907
746
1b28a63d125a 2006-5-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 654
diff changeset
1908 if ((ret = sshv2_open_file (request, file, startsize, SSH_FXF_READ)) < 0)
537
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1909 return (ret);
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1910
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1911 return (sshv2_get_file_size (request, file));
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1912 }
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1913
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1914
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1915 static int
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1916 sshv2_put_file (gftp_request * request, const char *file, int fd,
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1917 off_t startsize, off_t totalsize)
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1918 {
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1919 guint32 mode;
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1920 int ret;
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1921
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1922 if (startsize > 0)
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1923 mode = SSH_FXF_WRITE | SSH_FXF_CREAT | SSH_FXF_APPEND;
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1924 else
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1925 mode = SSH_FXF_WRITE | SSH_FXF_CREAT | SSH_FXF_TRUNC;
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1926
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1927 if ((ret = sshv2_open_file (request, file, startsize, mode)) < 0)
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1928 return (ret);
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1929
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1930 return (0);
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1931 }
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1932
c568539856d2 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 531
diff changeset
1933
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1934 static void
528
d32b05e07284 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
1935 sshv2_setup_file_offset (sshv2_params * params, char *buf)
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1936 {
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1937 guint32 hinum, lownum;
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1938 #ifdef G_HAVE_GINT64
747
c8e09269c3e1 2006-5-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 746
diff changeset
1939 hinum = htonl(params->offset >> 32);
c8e09269c3e1 2006-5-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 746
diff changeset
1940 lownum = htonl((guint32) params->offset);
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1941 #else
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1942 hinum = 0;
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1943 lownum = htonl (params->offset);
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1944 #endif
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1945
528
d32b05e07284 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
1946 memcpy (buf + params->handle_len, &hinum, 4);
d32b05e07284 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 526
diff changeset
1947 memcpy (buf + params->handle_len + 4, &lownum, 4);
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1948 }
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1949
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1950
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
1951 static ssize_t
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1952 sshv2_get_next_file_chunk (gftp_request * request, char *buf, size_t size)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1953 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1954 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1955 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
1956 guint32 num;
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1957 int ret;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1958
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1959 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1960 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
1961 g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1962 g_return_val_if_fail (buf != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1963
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1964 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1965
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1966 if (params->transfer_buffer == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1967 {
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1968 params->transfer_buffer_len = params->handle_len + 12;
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1969 params->transfer_buffer = g_malloc (params->transfer_buffer_len);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1970 memcpy (params->transfer_buffer, params->handle, params->handle_len);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1971 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1972
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1973 num = htonl (params->id++);
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1974 memcpy (params->transfer_buffer, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1975
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1976 sshv2_setup_file_offset (params, params->transfer_buffer);
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
1977
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1978 num = htonl (size);
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1979 memcpy (params->transfer_buffer + params->handle_len + 8, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1980
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1981 if ((ret = sshv2_send_command (request, SSH_FXP_READ, params->transfer_buffer,
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1982 params->handle_len + 12)) < 0)
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
1983 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1984
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1985 memset (&message, 0, sizeof (message));
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1986 if ((ret = sshv2_read_response (request, &message, -1)) != SSH_FXP_DATA)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1987 {
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1988 if (ret < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1989 return (ret);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
1990
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1991 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
1992 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_EOF, 1,
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1993 NULL)) < 0)
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1994 return (ret);
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 493
diff changeset
1995
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
1996 sshv2_message_free (&message);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1997 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1998 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1999
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2000 memcpy (&num, message.buffer + 4, 4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2001 num = ntohl (num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2002 if (num > size)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2003 {
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 177
diff changeset
2004 request->logging_function (gftp_logging_error, request,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2005 _("Error: Message size %d too big from server\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2006 num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2007 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2008 gftp_disconnect (request);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2009 return (GFTP_ERETRYABLE);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2010
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2011 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2012
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2013 memcpy (buf, message.buffer + 8, num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2014 sshv2_message_free (&message);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2015 params->offset += num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2016 return (num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2017 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2018
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2019
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2020 static ssize_t
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2021 sshv2_put_next_file_chunk (gftp_request * request, char *buf, size_t size)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2022 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2023 sshv2_params * params;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2024 sshv2_message message;
516
fbb5a02beddb 2004-7-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 500
diff changeset
2025 guint32 num;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2026 int ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2027
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2028 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2029 g_return_val_if_fail (request->protonum == GFTP_SSHV2_NUM, GFTP_EFATAL);
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
2030 g_return_val_if_fail (request->datafd > 0, GFTP_EFATAL);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2031 g_return_val_if_fail (buf != NULL, GFTP_EFATAL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2032
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2033 params = request->protocol_data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2034
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2035 if (params->transfer_buffer == NULL)
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2036 {
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2037 params->transfer_buffer_len = params->handle_len + size + 12;
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2038 params->transfer_buffer = g_malloc (params->transfer_buffer_len);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2039 memcpy (params->transfer_buffer, params->handle, params->handle_len);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2040 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2041
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2042 num = htonl (params->id++);
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2043 memcpy (params->transfer_buffer, &num, 4);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2044
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2045 sshv2_setup_file_offset (params, params->transfer_buffer);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2046
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2047 num = htonl (size);
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2048 memcpy (params->transfer_buffer + params->handle_len + 8, &num, 4);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2049 memcpy (params->transfer_buffer + params->handle_len + 12, buf, size);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2050
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2051 if ((ret = sshv2_send_command (request, SSH_FXP_WRITE,
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2052 params->transfer_buffer,
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2053 params->transfer_buffer_len)) < 0)
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2054 return (ret);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2055
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2056 memset (&message, 0, sizeof (message));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2057 params->dont_log_status = 1;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2058 ret = sshv2_read_response (request, &message, -1);
84
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2059 if (ret < 0)
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2060 return (ret);
7ef60ce2bdb2 2002-12-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 64
diff changeset
2061
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2062 params->dont_log_status = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2063 if (ret != SSH_FXP_STATUS)
493
527d5b926928 2004-7-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 489
diff changeset
2064 return (sshv2_wrong_response (request, &message));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2065
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2066 message.pos += 4;
654
f6e2ec8faf56 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 632
diff changeset
2067 if ((ret = sshv2_buffer_get_int32 (request, &message, SSH_FX_OK, 1, &num)) < 0)
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
2068 {
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
2069 if (num == SSH_FX_EOF)
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
2070 return (0);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2071
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
2072 return (ret);
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
2073 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2074
525
7262851e3ae8 2004-8-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
2075 sshv2_message_free (&message);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2076 params->offset += size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2077 return (size);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2078 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2079
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2080
177
aec4b4541d3a 2003-6-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
2081 static int
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2082 sshv2_set_config_options (gftp_request * request)
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2083 {
325
0fcc6468a0af 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 321
diff changeset
2084 intptr_t ssh_need_userpass;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2085
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2086 gftp_lookup_request_option (request, "ssh_need_userpass", &ssh_need_userpass);
553
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 546
diff changeset
2087 request->need_username = ssh_need_userpass;
574
81b957b00691 2004-9-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 571
diff changeset
2088 request->need_password = ssh_need_userpass;
177
aec4b4541d3a 2003-6-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
2089 return (0);
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2090 }
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2091
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2092
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2093 static void
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2094 sshv2_swap_socks (gftp_request * dest, gftp_request * source)
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2095 {
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2096 sshv2_params * sparams, * dparams;
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2097
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2098 sparams = source->protocol_data;
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2099 dparams = dest->protocol_data;
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2100 dparams->id = sparams->id;
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2101 }
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2102
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2103
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2104 void
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2105 sshv2_register_module (void)
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2106 {
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2107 gftp_register_config_vars (config_vars);
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2108 }
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2109
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2110
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2111 static void
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2112 sshv2_copy_message (sshv2_message * src_message, sshv2_message * dest_message)
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2113 {
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2114 dest_message->length = src_message->length;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2115 dest_message->command = src_message->command;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2116 dest_message->buffer = g_strdup (src_message->buffer);
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2117 dest_message->pos = dest_message->buffer + (src_message->pos - src_message->buffer);
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2118 dest_message->end = dest_message->buffer + (src_message->end - src_message->buffer);
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2119 }
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2120
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2121
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2122 static void
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2123 sshv2_copy_param_options (gftp_request * dest_request,
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2124 gftp_request * src_request)
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2125 {
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2126 sshv2_params * dparms, * sparms;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2127
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2128 dparms = dest_request->protocol_data;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2129 sparms = src_request->protocol_data;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2130
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2131 memcpy (dparms->handle, sparms->handle, sizeof (*dparms->handle));
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2132 if (sparms->transfer_buffer != NULL)
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2133 {
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2134 dparms->transfer_buffer = g_malloc (sparms->transfer_buffer_len);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2135 memcpy (dparms->transfer_buffer, sparms->transfer_buffer,
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2136 sparms->transfer_buffer_len);
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2137 }
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2138 else
538
ee182b8d1a54 2004-8-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 537
diff changeset
2139 dparms->transfer_buffer = NULL;
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2140
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2141 sshv2_copy_message (&sparms->message, &dparms->message);
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2142
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2143 dparms->id = sparms->id;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2144 dparms->count = sparms->count;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2145 dparms->handle_len = sparms->handle_len;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2146 dparms->initialized = sparms->initialized;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2147 dparms->dont_log_status = sparms->dont_log_status;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2148 dparms->offset = sparms->offset;
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2149 }
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2150
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2151
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
2152 int
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2153 sshv2_init (gftp_request * request)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2154 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2155 sshv2_params * params;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2156
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
2157 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2158
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2159 request->protonum = GFTP_SSHV2_NUM;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2160 request->init = sshv2_init;
526
990088b18285 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 525
diff changeset
2161 request->copy_param_options = sshv2_copy_param_options;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2162 request->destroy = sshv2_destroy;
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
2163 request->read_function = gftp_fd_read;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
2164 request->write_function = gftp_fd_write;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2165 request->connect = sshv2_connect;
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 146
diff changeset
2166 request->post_connect = NULL;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2167 request->disconnect = sshv2_disconnect;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2168 request->get_file = sshv2_get_file;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2169 request->put_file = sshv2_put_file;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2170 request->transfer_file = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2171 request->get_next_file_chunk = sshv2_get_next_file_chunk;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2172 request->put_next_file_chunk = sshv2_put_next_file_chunk;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2173 request->end_transfer = sshv2_end_transfer;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2174 request->abort_transfer = sshv2_end_transfer; /* NOTE: uses sshv2_end_transfer */
500
ba50a7085d93 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
2175 request->stat_filename = sshv2_stat_filename;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2176 request->list_files = sshv2_list_files;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2177 request->get_next_file = sshv2_get_next_file;
485
7334a74db6f6 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
2178 request->get_next_dirlist_line = NULL;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2179 request->get_file_size = sshv2_get_file_size;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2180 request->chdir = sshv2_chdir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2181 request->rmdir = sshv2_rmdir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2182 request->rmfile = sshv2_rmfile;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2183 request->mkdir = sshv2_mkdir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2184 request->rename = sshv2_rename;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2185 request->chmod = sshv2_chmod;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2186 request->set_file_time = sshv2_set_file_time;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2187 request->site = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2188 request->parse_url = NULL;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
2189 request->set_config_options = sshv2_set_config_options;
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 61
diff changeset
2190 request->swap_socks = sshv2_swap_socks;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2191 request->url_prefix = "ssh2";
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2192 request->need_hostport = 1;
553
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 546
diff changeset
2193 request->need_username = 1;
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 546
diff changeset
2194 request->need_password = 1;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2195 request->use_cache = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2196 request->always_connected = 0;
832
f2772ac00751 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 787
diff changeset
2197 request->use_local_encoding = 0;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2198 request->protocol_data = g_malloc0 (sizeof (sshv2_params));
122
76e2b58a9440 2003-4-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 91
diff changeset
2199 request->server_type = GFTP_DIRTYPE_UNIX;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2200
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2201 params = request->protocol_data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2202 params->id = 1;
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
2203
177
aec4b4541d3a 2003-6-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
2204 return (gftp_set_config_options (request));
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2205 }
487
dd22103b9552 2004-6-22 Brian Masney <masneyb@gftp.org>
masneyb
parents: 485
diff changeset
2206