annotate lib/sshv2.c @ 518:c6a6e908dbaf

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