View | Details | Raw Unified | Return to bug 634
Collapse All | Expand All

(-)sftp.c.orig (-8 / +19 lines)
Lines 145-151 Link Here
145
	{ NULL,			-1}
145
	{ NULL,			-1}
146
};
146
};
147
147
148
int interactive_loop(int fd_in, int fd_out, char *file1, char *file2);
148
int interactive_loop(int fd_in, int fd_out, char *file1, char *file2, char *op);
149
149
150
static void
150
static void
151
killchild(int signo)
151
killchild(int signo)
Lines 1221-1227 Link Here
1221
#endif
1247
#endif
1222
1248
1223
int
1249
int
1224
interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
1250
interactive_loop(int fd_in, int fd_out, char *file1, char *file2, char *op)
1225
{
1251
{
1226
	char *pwd;
1252
	char *pwd;
1227
	char *dir = NULL;
1253
	char *dir = NULL;
Lines 1260-1266 Link Here
1260
1286
1261
	if (file1 != NULL) {
1287
	if (file1 != NULL) {
1262
		dir = xstrdup(file1);
1288
		dir = xstrdup(file1);
1263
		dir = make_absolute(dir, pwd);
1289
		if (strcmp(op, "get") == 0)
1290
			dir = make_absolute(dir, pwd);
1264
1291
1265
		if (remote_is_dir(conn, dir) && file2 == NULL) {
1292
		if (remote_is_dir(conn, dir) && file2 == NULL) {
1266
			printf("Changing to: %s\n", dir);
1293
			printf("Changing to: %s\n", dir);
Lines 1269-1277 Link Here
1269
				return (-1);
1296
				return (-1);
1270
		} else {
1297
		} else {
1271
			if (file2 == NULL)
1298
			if (file2 == NULL)
1272
				snprintf(cmd, sizeof cmd, "get %s", dir);
1299
				snprintf(cmd, sizeof cmd, "%s %s", op, dir);
1273
			else
1300
			else
1274
				snprintf(cmd, sizeof cmd, "get %s %s", dir,
1301
				snprintf(cmd, sizeof cmd, "%s %s %s", op, dir,
1275
				    file2);
1302
				    file2);
1276
1303
1277
			err = parse_dispatch_command(conn, cmd, &pwd, 1);
1304
			err = parse_dispatch_command(conn, cmd, &pwd, 1);
Lines 1411-1417 Link Here
1411
main(int argc, char **argv)
1438
main(int argc, char **argv)
1412
{
1439
{
1413
	int in, out, ch, err;
1440
	int in, out, ch, err;
1414
	char *host, *userhost, *cp, *file2 = NULL;
1441
	char *host, *userhost, *cp, *file2 = NULL, *op = "get";
1415
	int debug_level = 0, sshver = 2;
1442
	int debug_level = 0, sshver = 2;
1416
	char *file1 = NULL, *sftp_server = NULL;
1443
	char *file1 = NULL, *sftp_server = NULL;
1417
	char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL;
1444
	char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL;
Lines 1499-1504 Link Here
1499
1526
1500
		userhost = xstrdup(argv[optind]);
1527
		userhost = xstrdup(argv[optind]);
1501
		file2 = argv[optind+1];
1528
		file2 = argv[optind+1];
1529
		
1530
		if (file2 && colon(file2)) { /* dest is remote host */
1531
			xfree(userhost);
1532
			userhost = xstrdup(file2);
1533
			file1 = argv[optind];
1534
			cp = colon(userhost);
1535
			*cp++ = '\0';
1536
			file2 = cp;
1537
			op = "put";
1538
		}
1502
1539
1503
		if ((host = strrchr(userhost, '@')) == NULL)
1540
		if ((host = strrchr(userhost, '@')) == NULL)
1504
			host = userhost;
1541
			host = userhost;
Lines 1511-1517 Link Here
1511
			addargs(&args, "-l%s",userhost);
1548
			addargs(&args, "-l%s",userhost);
1512
		}
1549
		}
1513
1550
1514
		if ((cp = colon(host)) != NULL) {
1551
		if (!file1 && (cp = colon(host)) != NULL) {
1515
			*cp++ = '\0';
1552
			*cp++ = '\0';
1516
			file1 = cp;
1553
			file1 = cp;
1517
		}
1554
		}
Lines 1545-1551 Link Here
1545
		connect_to_server(sftp_direct, args.list, &in, &out);
1582
		connect_to_server(sftp_direct, args.list, &in, &out);
1546
	}
1583
	}
1547
1584
1548
	err = interactive_loop(in, out, file1, file2);
1585
	err = interactive_loop(in, out, file1, file2, op);
1549
1586
1550
#if !defined(USE_PIPES)
1587
#if !defined(USE_PIPES)
1551
       shutdown(in, SHUT_RDWR);
1588
       shutdown(in, SHUT_RDWR);

Return to bug 634