View | Details | Raw Unified | Return to bug 1798 | Differences between
and this patch

Collapse All | Expand All

(-)sftp-client.c (-13 / +59 lines)
Lines 75-80 Link Here
75
#define SFTP_EXT_POSIX_RENAME	0x00000001
75
#define SFTP_EXT_POSIX_RENAME	0x00000001
76
#define SFTP_EXT_STATVFS	0x00000002
76
#define SFTP_EXT_STATVFS	0x00000002
77
#define SFTP_EXT_FSTATVFS	0x00000004
77
#define SFTP_EXT_FSTATVFS	0x00000004
78
#define SFTP_EXT_FSYNC		0x00000008
78
	u_int exts;
79
	u_int exts;
79
};
80
};
80
81
Lines 352-361 Link Here
352
		    strcmp(value, "2") == 0) {
353
		    strcmp(value, "2") == 0) {
353
			exts |= SFTP_EXT_STATVFS;
354
			exts |= SFTP_EXT_STATVFS;
354
			known = 1;
355
			known = 1;
355
		} if (strcmp(name, "fstatvfs@openssh.com") == 0 &&
356
		} else if (strcmp(name, "fstatvfs@openssh.com") == 0 &&
356
		    strcmp(value, "2") == 0) {
357
		    strcmp(value, "2") == 0) {
357
			exts |= SFTP_EXT_FSTATVFS;
358
			exts |= SFTP_EXT_FSTATVFS;
358
			known = 1;
359
			known = 1;
360
		} else if (strcmp(name, "fsync@openssh.com") == 0 &&
361
		    strcmp(value, "1") == 0) {
362
			exts |= SFTP_EXT_FSYNC;
363
			known = 1;
359
		}
364
		}
360
		if (known) {
365
		if (known) {
361
			debug2("Server supports extension \"%s\" revision %s",
366
			debug2("Server supports extension \"%s\" revision %s",
Lines 802-807 Link Here
802
	return(status);
807
	return(status);
803
}
808
}
804
809
810
int
811
do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
812
{
813
	Buffer msg;
814
	u_int status, id;
815
816
	/* Silently return if the extension is not supported */
817
	if ((conn->exts & SFTP_EXT_FSYNC) == 0)
818
		return 0;
819
820
	buffer_init(&msg);
821
822
	/* Send fsync request */
823
	id = conn->msg_id++;
824
825
	buffer_put_char(&msg, SSH2_FXP_EXTENDED);
826
	buffer_put_int(&msg, id);
827
	buffer_put_cstring(&msg, "fsync@openssh.com");
828
	buffer_put_string(&msg, handle, handle_len);
829
	send_msg(conn->fd_out, &msg);
830
	debug3("Sent message fsync@openssh.com I:%u", id);
831
	buffer_free(&msg);
832
833
	status = get_status(conn->fd_in, id);
834
	if (status != SSH2_FX_OK)
835
		error("Couldn't sync file: %s", fx2txt(status));
836
837
	return(status);
838
}
839
805
#ifdef notyet
840
#ifdef notyet
806
char *
841
char *
807
do_readlink(struct sftp_conn *conn, char *path)
842
do_readlink(struct sftp_conn *conn, char *path)
Lines 924-930 Link Here
924
959
925
int
960
int
926
do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
961
do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
927
    Attrib *a, int pflag)
962
    Attrib *a, int pflag, int sflag)
928
{
963
{
929
	Attrib junk;
964
	Attrib junk;
930
	Buffer msg;
965
	Buffer msg;
Lines 1153-1158 Link Here
1153
				error("Can't set times on \"%s\": %s",
1188
				error("Can't set times on \"%s\": %s",
1154
				    local_path, strerror(errno));
1189
				    local_path, strerror(errno));
1155
		}
1190
		}
1191
		/* Flush file to disk if requested */
1192
		if (sflag) {
1193
			debug("syncing \"%s\"", local_path);
1194
			if (fsync(local_fd) == -1)
1195
				error("Couldn't sync file \"%s\": %s",
1196
				    local_path, strerror(errno));
1197
		}
1156
	}
1198
	}
1157
	close(local_fd);
1199
	close(local_fd);
1158
	buffer_free(&msg);
1200
	buffer_free(&msg);
Lines 1163-1169 Link Here
1163
1205
1164
static int
1206
static int
1165
download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1207
download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1166
    Attrib *dirattrib, int pflag, int printflag, int depth)
1208
    Attrib *dirattrib, int pflag, int sflag, int printflag, int depth)
1167
{
1209
{
1168
	int i, ret = 0;
1210
	int i, ret = 0;
1169
	SFTP_DIRENT **dir_entries;
1211
	SFTP_DIRENT **dir_entries;
Lines 1215-1226 Link Here
1215
			    strcmp(filename, "..") == 0)
1257
			    strcmp(filename, "..") == 0)
1216
				continue;
1258
				continue;
1217
			if (download_dir_internal(conn, new_src, new_dst,
1259
			if (download_dir_internal(conn, new_src, new_dst,
1218
			    &(dir_entries[i]->a), pflag, printflag,
1260
			    &(dir_entries[i]->a), pflag, sflag, printflag,
1219
			    depth + 1) == -1)
1261
			    depth + 1) == -1)
1220
				ret = -1;
1262
				ret = -1;
1221
		} else if (S_ISREG(dir_entries[i]->a.perm) ) {
1263
		} else if (S_ISREG(dir_entries[i]->a.perm) ) {
1222
			if (do_download(conn, new_src, new_dst,
1264
			if (do_download(conn, new_src, new_dst,
1223
			    &(dir_entries[i]->a), pflag) == -1) {
1265
			    &(dir_entries[i]->a), pflag, sflag) == -1) {
1224
				error("Download of file %s to %s failed",
1266
				error("Download of file %s to %s failed",
1225
				    new_src, new_dst);
1267
				    new_src, new_dst);
1226
				ret = -1;
1268
				ret = -1;
Lines 1253-1259 Link Here
1253
1295
1254
int
1296
int
1255
download_dir(struct sftp_conn *conn, char *src, char *dst,
1297
download_dir(struct sftp_conn *conn, char *src, char *dst,
1256
    Attrib *dirattrib, int pflag, int printflag)
1298
    Attrib *dirattrib, int pflag, int sflag, int printflag)
1257
{
1299
{
1258
	char *src_canon;
1300
	char *src_canon;
1259
	int ret;
1301
	int ret;
Lines 1264-1277 Link Here
1264
	}
1306
	}
1265
1307
1266
	ret = download_dir_internal(conn, src_canon, dst,
1308
	ret = download_dir_internal(conn, src_canon, dst,
1267
	    dirattrib, pflag, printflag, 0);
1309
	    dirattrib, pflag, sflag, printflag, 0);
1268
	xfree(src_canon);
1310
	xfree(src_canon);
1269
	return ret;
1311
	return ret;
1270
}
1312
}
1271
1313
1272
int
1314
int
1273
do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1315
do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1274
    int pflag)
1316
    int pflag, int sflag)
1275
{
1317
{
1276
	int local_fd;
1318
	int local_fd;
1277
	int status = SSH2_FX_OK;
1319
	int status = SSH2_FX_OK;
Lines 1445-1450 Link Here
1445
	if (pflag)
1487
	if (pflag)
1446
		do_fsetstat(conn, handle, handle_len, &a);
1488
		do_fsetstat(conn, handle, handle_len, &a);
1447
1489
1490
	if (sflag)
1491
		(void)do_fsync(conn, handle, handle_len);
1492
1448
	if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
1493
	if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
1449
		status = -1;
1494
		status = -1;
1450
	xfree(handle);
1495
	xfree(handle);
Lines 1454-1460 Link Here
1454
1499
1455
static int
1500
static int
1456
upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1501
upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1457
    int pflag, int printflag, int depth)
1502
    int pflag, int sflag, int printflag, int depth)
1458
{
1503
{
1459
	int ret = 0, status;
1504
	int ret = 0, status;
1460
	DIR *dirp;
1505
	DIR *dirp;
Lines 1523-1532 Link Here
1523
				continue;
1568
				continue;
1524
1569
1525
			if (upload_dir_internal(conn, new_src, new_dst,
1570
			if (upload_dir_internal(conn, new_src, new_dst,
1526
			    pflag, depth + 1, printflag) == -1)
1571
			    pflag, sflag, depth + 1, printflag) == -1)
1527
				ret = -1;
1572
				ret = -1;
1528
		} else if (S_ISREG(sb.st_mode)) {
1573
		} else if (S_ISREG(sb.st_mode)) {
1529
			if (do_upload(conn, new_src, new_dst, pflag) == -1) {
1574
			if (do_upload(conn, new_src, new_dst, pflag,
1575
			    sflag) == -1) {
1530
				error("Uploading of file %s to %s failed!",
1576
				error("Uploading of file %s to %s failed!",
1531
				    new_src, new_dst);
1577
				    new_src, new_dst);
1532
				ret = -1;
1578
				ret = -1;
Lines 1545-1551 Link Here
1545
1591
1546
int
1592
int
1547
upload_dir(struct sftp_conn *conn, char *src, char *dst, int printflag,
1593
upload_dir(struct sftp_conn *conn, char *src, char *dst, int printflag,
1548
    int pflag)
1594
    int pflag, int sflag)
1549
{
1595
{
1550
	char *dst_canon;
1596
	char *dst_canon;
1551
	int ret;
1597
	int ret;
Lines 1555-1561 Link Here
1555
		return -1;
1601
		return -1;
1556
	}
1602
	}
1557
1603
1558
	ret = upload_dir_internal(conn, src, dst_canon, pflag, printflag, 0);
1604
	ret = upload_dir_internal(conn, src, dst_canon, pflag, sflag, printflag, 0);
1559
	xfree(dst_canon);
1605
	xfree(dst_canon);
1560
	return ret;
1606
	return ret;
1561
}
1607
}
(-)sftp-client.h (-4 / +4 lines)
Lines 103-127 Link Here
103
 * Download 'remote_path' to 'local_path'. Preserve permissions and times
103
 * Download 'remote_path' to 'local_path'. Preserve permissions and times
104
 * if 'pflag' is set
104
 * if 'pflag' is set
105
 */
105
 */
106
int do_download(struct sftp_conn *, char *, char *, Attrib *, int);
106
int do_download(struct sftp_conn *, char *, char *, Attrib *, int, int);
107
107
108
/*
108
/*
109
 * Recursively download 'remote_directory' to 'local_directory'. Preserve 
109
 * Recursively download 'remote_directory' to 'local_directory'. Preserve 
110
 * times if 'pflag' is set
110
 * times if 'pflag' is set
111
 */
111
 */
112
int download_dir(struct sftp_conn *, char *, char *, Attrib *, int, int);
112
int download_dir(struct sftp_conn *, char *, char *, Attrib *, int, int, int);
113
113
114
/*
114
/*
115
 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
115
 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
116
 * if 'pflag' is set
116
 * if 'pflag' is set
117
 */
117
 */
118
int do_upload(struct sftp_conn *, char *, char *, int);
118
int do_upload(struct sftp_conn *, char *, char *, int, int);
119
119
120
/*
120
/*
121
 * Recursively upload 'local_directory' to 'remote_directory'. Preserve 
121
 * Recursively upload 'local_directory' to 'remote_directory'. Preserve 
122
 * times if 'pflag' is set
122
 * times if 'pflag' is set
123
 */
123
 */
124
int upload_dir(struct sftp_conn *, char *, char *, int, int);
124
int upload_dir(struct sftp_conn *, char *, char *, int, int, int);
125
125
126
/* Concatenate paths, taking care of slashes. Caller must free result. */
126
/* Concatenate paths, taking care of slashes. Caller must free result. */
127
char *path_append(char *, char *);
127
char *path_append(char *, char *);
(-)sftp-server.c (+25 lines)
Lines 535-540 Link Here
535
	/* fstatvfs extension */
535
	/* fstatvfs extension */
536
	buffer_put_cstring(&msg, "fstatvfs@openssh.com");
536
	buffer_put_cstring(&msg, "fstatvfs@openssh.com");
537
	buffer_put_cstring(&msg, "2"); /* version */
537
	buffer_put_cstring(&msg, "2"); /* version */
538
	/* fsync extension */
539
	buffer_put_cstring(&msg, "fsync@openssh.com");
540
	buffer_put_cstring(&msg, "1"); /* version */
538
	send_msg(&msg);
541
	send_msg(&msg);
539
	buffer_free(&msg);
542
	buffer_free(&msg);
540
}
543
}
Lines 1223-1228 Link Here
1223
}
1226
}
1224
1227
1225
static void
1228
static void
1229
process_extended_fsync(u_int32_t id)
1230
{
1231
	int handle, fd, ret, status = SSH2_FX_NO_SUCH_FILE;
1232
1233
	handle = get_handle();
1234
	debug3("request %u: fsync \"%s\" (handle %u)",
1235
		id, handle_to_name(handle), handle);
1236
	if (readonly)
1237
		status = SSH2_FX_PERMISSION_DENIED;
1238
	else if ((fd = handle_to_fd(handle)) < 0)
1239
		status = SSH2_FX_NO_SUCH_FILE;
1240
	else if (handle_is_ok(handle, HANDLE_FILE)) {
1241
		ret = fsync(fd);
1242
		status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
1243
	}
1244
	send_status(id, status);
1245
}
1246
1247
1248
static void
1226
process_extended(void)
1249
process_extended(void)
1227
{
1250
{
1228
	u_int32_t id;
1251
	u_int32_t id;
Lines 1236-1241 Link Here
1236
		process_extended_statvfs(id);
1259
		process_extended_statvfs(id);
1237
	else if (strcmp(request, "fstatvfs@openssh.com") == 0)
1260
	else if (strcmp(request, "fstatvfs@openssh.com") == 0)
1238
		process_extended_fstatvfs(id);
1261
		process_extended_fstatvfs(id);
1262
	else if (strcmp(request, "fsync@openssh.com") == 0)
1263
		process_extended_fsync(id);
1239
	else
1264
	else
1240
		send_status(id, SSH2_FX_OP_UNSUPPORTED);	/* MUST */
1265
		send_status(id, SSH2_FX_OP_UNSUPPORTED);	/* MUST */
1241
	xfree(request);
1266
	xfree(request);
(-)sftp.1 (-3 / +22 lines)
Lines 31-37 Link Here
31
.Sh SYNOPSIS
31
.Sh SYNOPSIS
32
.Nm sftp
32
.Nm sftp
33
.Bk -words
33
.Bk -words
34
.Op Fl 1246Cpqrv
34
.Op Fl 1246Cfpqrv
35
.Op Fl B Ar buffer_size
35
.Op Fl B Ar buffer_size
36
.Op Fl b Ar batchfile
36
.Op Fl b Ar batchfile
37
.Op Fl c Ar cipher
37
.Op Fl c Ar cipher
Lines 152-157 Link Here
152
.Xr ssh 1 .
152
.Xr ssh 1 .
153
This option is directly passed to
153
This option is directly passed to
154
.Xr ssh 1 .
154
.Xr ssh 1 .
155
.It Fl f
156
Requests that files be flushed to disk immediately after transfer.
157
When uploading files, this feature is only enabled if the server
158
implements the "fsync@openssh.com" extension.
155
.It Fl i Ar identity_file
159
.It Fl i Ar identity_file
156
Selects the file from which the identity (private key) for public key
160
Selects the file from which the identity (private key) for public key
157
authentication is read.
161
authentication is read.
Lines 330-336 Link Here
330
Quit
334
Quit
331
.Nm sftp .
335
.Nm sftp .
332
.It Xo Ic get
336
.It Xo Ic get
333
.Op Fl Ppr
337
.Op Fl fPpr
334
.Ar remote-path
338
.Ar remote-path
335
.Op Ar local-path
339
.Op Ar local-path
336
.Xc
340
.Xc
Lines 350-355 Link Here
350
.Ar local-path
354
.Ar local-path
351
must specify a directory.
355
must specify a directory.
352
.Pp
356
.Pp
357
If the
358
.Fl f
359
flag is specified, then
360
.Xr fsync 2
361
will ba called after the file transfer has completed to flush the file
362
to disk.
363
.Pp
353
If either the
364
If either the
354
.Fl P
365
.Fl P
355
or
366
or
Lines 445-451 Link Here
445
.It Ic progress
456
.It Ic progress
446
Toggle display of progress meter.
457
Toggle display of progress meter.
447
.It Xo Ic put
458
.It Xo Ic put
448
.Op Fl Ppr
459
.Op Fl fPpr
449
.Ar local-path
460
.Ar local-path
450
.Op Ar remote-path
461
.Op Ar remote-path
451
.Xc
462
.Xc
Lines 463-468 Link Here
463
is specified, then
474
is specified, then
464
.Ar remote-path
475
.Ar remote-path
465
must specify a directory.
476
must specify a directory.
477
.Pp
478
If the
479
.Fl f
480
flag is specified, then a request will be sent to the server to call
481
.Xr fsync 2
482
after the file has been transferred.
483
Note that this is only supported by servers that implement the "fsync@openssh.com"
484
extension.
466
.Pp
485
.Pp
467
If ether the
486
If ether the
468
.Fl P
487
.Fl P
(-)sftp.c (-18 / +31 lines)
Lines 89-94 Link Here
89
/* When this option is set, the file transfers will always preserve times */
89
/* When this option is set, the file transfers will always preserve times */
90
int global_pflag = 0;
90
int global_pflag = 0;
91
91
92
/* When this is set, call fsync() after each file */
93
int global_sflag = 0;
94
92
/* SIGINT received during command processing */
95
/* SIGINT received during command processing */
93
volatile sig_atomic_t interrupted = 0;
96
volatile sig_atomic_t interrupted = 0;
94
97
Lines 348-354 Link Here
348
351
349
static int
352
static int
350
parse_getput_flags(const char *cmd, char **argv, int argc, int *pflag,
353
parse_getput_flags(const char *cmd, char **argv, int argc, int *pflag,
351
    int *rflag)
354
    int *rflag, int *sflag)
352
{
355
{
353
	extern int opterr, optind, optopt, optreset;
356
	extern int opterr, optind, optopt, optreset;
354
	int ch;
357
	int ch;
Lines 357-363 Link Here
357
	opterr = 0;
360
	opterr = 0;
358
361
359
	*rflag = *pflag = 0;
362
	*rflag = *pflag = 0;
360
	while ((ch = getopt(argc, argv, "PpRr")) != -1) {
363
	*sflag = global_sflag;
364
	while ((ch = getopt(argc, argv, "FfPpRr")) != -1) {
361
		switch (ch) {
365
		switch (ch) {
362
		case 'p':
366
		case 'p':
363
		case 'P':
367
		case 'P':
Lines 367-372 Link Here
367
		case 'R':
371
		case 'R':
368
			*rflag = 1;
372
			*rflag = 1;
369
			break;
373
			break;
374
		case 'f':
375
		case 'F':
376
			*sflag = 1;
377
			break;
370
		default:
378
		default:
371
			error("%s: Invalid flag -%c", cmd, optopt);
379
			error("%s: Invalid flag -%c", cmd, optopt);
372
			return -1;
380
			return -1;
Lines 492-498 Link Here
492
500
493
static int
501
static int
494
process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
502
process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
495
    int pflag, int rflag)
503
    int pflag, int rflag, int sflag)
496
{
504
{
497
	char *abs_src = NULL;
505
	char *abs_src = NULL;
498
	char *abs_dst = NULL;
506
	char *abs_dst = NULL;
Lines 547-557 Link Here
547
		printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);
555
		printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);
548
		if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
556
		if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
549
			if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, 
557
			if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, 
550
			    pflag || global_pflag, 1) == -1)
558
			    pflag || global_pflag, sflag, 1) == -1)
551
				err = -1;
559
				err = -1;
552
		} else {
560
		} else {
553
			if (do_download(conn, g.gl_pathv[i], abs_dst, NULL,
561
			if (do_download(conn, g.gl_pathv[i], abs_dst, NULL,
554
			    pflag || global_pflag) == -1)
562
			    pflag || global_pflag, sflag) == -1)
555
				err = -1;
563
				err = -1;
556
		}
564
		}
557
		xfree(abs_dst);
565
		xfree(abs_dst);
Lines 566-572 Link Here
566
574
567
static int
575
static int
568
process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
576
process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
569
    int pflag, int rflag)
577
    int pflag, int rflag, int sflag)
570
{
578
{
571
	char *tmp_dst = NULL;
579
	char *tmp_dst = NULL;
572
	char *abs_dst = NULL;
580
	char *abs_dst = NULL;
Lines 632-642 Link Here
632
		printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);
640
		printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);
633
		if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
641
		if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
634
			if (upload_dir(conn, g.gl_pathv[i], abs_dst,
642
			if (upload_dir(conn, g.gl_pathv[i], abs_dst,
635
			    pflag || global_pflag, 1) == -1)
643
			    pflag || global_pflag, sflag, 1) == -1)
636
				err = -1;
644
				err = -1;
637
		} else {
645
		} else {
638
			if (do_upload(conn, g.gl_pathv[i], abs_dst,
646
			if (do_upload(conn, g.gl_pathv[i], abs_dst,
639
			    pflag || global_pflag) == -1)
647
			    pflag || global_pflag, sflag) == -1)
640
				err = -1;
648
				err = -1;
641
		}
649
		}
642
	}
650
	}
Lines 1107-1114 Link Here
1107
}
1115
}
1108
1116
1109
static int
1117
static int
1110
parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag,
1118
parse_args(const char **cpp, int *pflag, int *rflag, int *sflag, int *lflag,
1111
    int *hflag, unsigned long *n_arg, char **path1, char **path2)
1119
    int *iflag, int *hflag, unsigned long *n_arg, char **path1, char **path2)
1112
{
1120
{
1113
	const char *cmd, *cp = *cpp;
1121
	const char *cmd, *cp = *cpp;
1114
	char *cp2, **argv;
1122
	char *cp2, **argv;
Lines 1158-1164 Link Here
1158
	switch (cmdnum) {
1166
	switch (cmdnum) {
1159
	case I_GET:
1167
	case I_GET:
1160
	case I_PUT:
1168
	case I_PUT:
1161
		if ((optidx = parse_getput_flags(cmd, argv, argc, pflag, rflag)) == -1)
1169
		if ((optidx = parse_getput_flags(cmd, argv, argc, pflag, rflag, sflag)) == -1)
1162
			return -1;
1170
			return -1;
1163
		/* Get first pathname (mandatory) */
1171
		/* Get first pathname (mandatory) */
1164
		if (argc - optidx < 1) {
1172
		if (argc - optidx < 1) {
Lines 1278-1284 Link Here
1278
    int err_abort)
1286
    int err_abort)
1279
{
1287
{
1280
	char *path1, *path2, *tmp;
1288
	char *path1, *path2, *tmp;
1281
	int pflag = 0, rflag = 0, lflag = 0, iflag = 0, hflag = 0, cmdnum, i;
1289
	int pflag = 0, rflag = 0, lflag = 0, iflag = 0, hflag = 0, sflag = 0, cmdnum, i;
1282
	unsigned long n_arg = 0;
1290
	unsigned long n_arg = 0;
1283
	Attrib a, *aa;
1291
	Attrib a, *aa;
1284
	char path_buf[MAXPATHLEN];
1292
	char path_buf[MAXPATHLEN];
Lines 1286-1293 Link Here
1286
	glob_t g;
1294
	glob_t g;
1287
1295
1288
	path1 = path2 = NULL;
1296
	path1 = path2 = NULL;
1289
	cmdnum = parse_args(&cmd, &pflag, &rflag, &lflag, &iflag, &hflag, &n_arg,
1297
	cmdnum = parse_args(&cmd, &pflag, &rflag, &sflag, &lflag, &iflag,
1290
	    &path1, &path2);
1298
	    &hflag, &n_arg, &path1, &path2);
1291
1299
1292
	if (iflag != 0)
1300
	if (iflag != 0)
1293
		err_abort = 0;
1301
		err_abort = 0;
Lines 1304-1313 Link Here
1304
		err = -1;
1312
		err = -1;
1305
		break;
1313
		break;
1306
	case I_GET:
1314
	case I_GET:
1307
		err = process_get(conn, path1, path2, *pwd, pflag, rflag);
1315
		err = process_get(conn, path1, path2, *pwd, pflag,
1316
			rflag, sflag);
1308
		break;
1317
		break;
1309
	case I_PUT:
1318
	case I_PUT:
1310
		err = process_put(conn, path1, path2, *pwd, pflag, rflag);
1319
		err = process_put(conn, path1, path2, *pwd, pflag,
1320
			rflag, sflag);
1311
		break;
1321
		break;
1312
	case I_RENAME:
1322
	case I_RENAME:
1313
		path1 = make_absolute(path1, *pwd);
1323
		path1 = make_absolute(path1, *pwd);
Lines 2052-2058 Link Here
2052
	extern char *__progname;
2062
	extern char *__progname;
2053
2063
2054
	fprintf(stderr,
2064
	fprintf(stderr,
2055
	    "usage: %s [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
2065
	    "usage: %s [-1246Cfpqrv] [-B buffer_size] [-b batchfile] [-c cipher]\n"
2056
	    "          [-D sftp_server_path] [-F ssh_config] "
2066
	    "          [-D sftp_server_path] [-F ssh_config] "
2057
	    "[-i identity_file]\n"
2067
	    "[-i identity_file]\n"
2058
	    "          [-o ssh_option] [-P port] [-R num_requests] "
2068
	    "          [-o ssh_option] [-P port] [-R num_requests] "
Lines 2097-2103 Link Here
2097
	infile = stdin;
2107
	infile = stdin;
2098
2108
2099
	while ((ch = getopt(argc, argv,
2109
	while ((ch = getopt(argc, argv,
2100
	    "1246hpqrvCc:D:i:o:s:S:b:B:F:P:R:")) != -1) {
2110
	    "1246fhpqrvCc:D:i:o:s:S:b:B:F:P:R:")) != -1) {
2101
		switch (ch) {
2111
		switch (ch) {
2102
		/* Passed through to ssh(1) */
2112
		/* Passed through to ssh(1) */
2103
		case '4':
2113
		case '4':
Lines 2151-2156 Link Here
2151
			showprogress = 0;
2161
			showprogress = 0;
2152
			batchmode = 1;
2162
			batchmode = 1;
2153
			addargs(&args, "-obatchmode yes");
2163
			addargs(&args, "-obatchmode yes");
2164
			break;
2165
		case 'f':
2166
			global_sflag = 1;
2154
			break;
2167
			break;
2155
		case 'p':
2168
		case 'p':
2156
			global_pflag = 1;
2169
			global_pflag = 1;

Return to bug 1798