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

Collapse All | Expand All

(-)a/sftp-client.c (-4 / +9 lines)
Lines 1496-1502 download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, Link Here
1496
	int i, ret = 0;
1496
	int i, ret = 0;
1497
	SFTP_DIRENT **dir_entries;
1497
	SFTP_DIRENT **dir_entries;
1498
	char *filename, *new_src = NULL, *new_dst = NULL;
1498
	char *filename, *new_src = NULL, *new_dst = NULL;
1499
	mode_t mode = 0777;
1499
	mode_t mode = 0777, tmpmode = mode;
1500
1500
1501
	if (depth >= MAX_DIR_DEPTH) {
1501
	if (depth >= MAX_DIR_DEPTH) {
1502
		error("Maximum directory depth exceeded: %d levels", depth);
1502
		error("Maximum directory depth exceeded: %d levels", depth);
Lines 1515-1528 download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, Link Here
1515
	if (print_flag)
1515
	if (print_flag)
1516
		mprintf("Retrieving %s\n", src);
1516
		mprintf("Retrieving %s\n", src);
1517
1517
1518
	if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)
1518
	if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
1519
		mode = dirattrib->perm & 01777;
1519
		mode = dirattrib->perm & 01777;
1520
	else {
1520
		tmpmode = mode | (S_IWUSR|S_IXUSR);
1521
	} else {
1521
		debug("Server did not send permissions for "
1522
		debug("Server did not send permissions for "
1522
		    "directory \"%s\"", dst);
1523
		    "directory \"%s\"", dst);
1523
	}
1524
	}
1524
1525
1525
	if (mkdir(dst, mode) == -1 && errno != EEXIST) {
1526
	if (mkdir(dst, tmpmode) == -1 && errno != EEXIST) {
1526
		error("mkdir %s: %s", dst, strerror(errno));
1527
		error("mkdir %s: %s", dst, strerror(errno));
1527
		return -1;
1528
		return -1;
1528
	}
1529
	}
Lines 1577-1582 download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, Link Here
1577
			    "\"%s\"", dst);
1578
			    "\"%s\"", dst);
1578
	}
1579
	}
1579
1580
1581
	if (mode != tmpmode && chmod(dst, mode) == -1)
1582
		error("Can't set final mode on \"%s\": %s", dst,
1583
		    strerror(errno));
1584
1580
	free_sftp_dirents(dir_entries);
1585
	free_sftp_dirents(dir_entries);
1581
1586
1582
	return ret;
1587
	return ret;

Return to bug 3222