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

Collapse All | Expand All

(-)ssh.orig/sftp-server.c (-1 / +108 lines)
Lines 61-66 Buffer oqueue; Link Here
61
/* Version of client */
61
/* Version of client */
62
int version;
62
int version;
63
63
64
/* Attributes which this implementation can send */
65
#define SUPPORTED_ATTR (			\
66
	SSH2_FILEXFER_ATTR_SIZE |		\
67
	SSH2_FILEXFER_ATTR_UIDGID |		\
68
	SSH2_FILEXFER_ATTR_PERMISSIONS |	\
69
	SSH2_FILEXFER_ATTR_ACMODTIME		\
70
	)
71
72
/* Extra attributes which this implementation can send */
73
#define SUPPORTED_EXT_ATTR (			\
74
	SSH2_FXE_EXTATTR_DEV |			\
75
	SSH2_FXE_EXTATTR_INO |			\
76
	SSH2_FXE_EXTATTR_NLINK |		\
77
	SSH2_FXE_EXTATTR_RDEV |			\
78
	SSH2_FXE_EXTATTR_BLKSIZE |		\
79
	SSH2_FXE_EXTATTR_BLOCKS |		\
80
	SSH2_FXE_EXTATTR_ATIME |		\
81
	SSH2_FXE_EXTATTR_ATIMENSEC |		\
82
	SSH2_FXE_EXTATTR_MTIME |		\
83
	SSH2_FXE_EXTATTR_MTIMENSEC |		\
84
	SSH2_FXE_EXTATTR_CTIME |		\
85
	SSH2_FXE_EXTATTR_CTIMENSEC		\
86
	)
87
88
/* Attributes to send in the stat reply */
89
u_int stat_attr_mask = SUPPORTED_ATTR;
90
91
/* Extra attributes to send in the stat reply */
92
u_int stat_ext_attr_mask = 0;
93
94
/* Attributes to send in the readdir reply */
95
u_int dir_attr_mask = SUPPORTED_ATTR;
96
97
/* Extra attributes to send in the readdir reply */
98
u_int dir_ext_attr_mask = 0;
99
100
/* If false, send empty long name in the readdir reply */
101
int dir_send_long_name = 1;
102
64
/* portable attributes, etc. */
103
/* portable attributes, etc. */
65
104
66
typedef struct Stat Stat;
105
typedef struct Stat Stat;
Lines 502-507 send_statvfs(u_int32_t id, struct statvf Link Here
502
	buffer_free(&msg);
541
	buffer_free(&msg);
503
}
542
}
504
543
544
static void
545
send_attrconfig_reply(u_int32_t id)
546
{
547
	Buffer msg;
548
	int flags = 0;
549
550
	/* Send the actual value of the masks */
551
	if (!dir_send_long_name)
552
		flags |= SSH2_FXE_ATTRCONFIG_NOLONGNAME;
553
554
	buffer_init(&msg);
555
	buffer_put_char(&msg, SSH2_FXP_EXTENDED_REPLY);
556
	buffer_put_int(&msg, id);
557
	buffer_put_int(&msg, flags);
558
	buffer_put_int(&msg, stat_attr_mask);
559
	buffer_put_int(&msg, stat_ext_attr_mask);
560
	buffer_put_int(&msg, dir_attr_mask);
561
	buffer_put_int(&msg, dir_ext_attr_mask);
562
	send_msg(&msg);
563
	buffer_free(&msg);
564
}
565
505
/* parse incoming */
566
/* parse incoming */
506
567
507
static void
568
static void
Lines 526-531 process_init(void) Link Here
526
	/* link extension */
587
	/* link extension */
527
	buffer_put_cstring(&msg, "link@openssh.com");
588
	buffer_put_cstring(&msg, "link@openssh.com");
528
	buffer_put_cstring(&msg, "1"); /* version */
589
	buffer_put_cstring(&msg, "1"); /* version */
590
	/* attrconfig extension */
591
	buffer_put_cstring(&msg, "attrconfig@openssh.com");
592
	buffer_put_cstring(&msg, "1"); /* version */
529
	send_msg(&msg);
593
	send_msg(&msg);
530
	buffer_free(&msg);
594
	buffer_free(&msg);
531
}
595
}
Lines 677-682 process_do_stat(int do_lstat) Link Here
677
		status = errno_to_portable(errno);
741
		status = errno_to_portable(errno);
678
	} else {
742
	} else {
679
		stat_to_attrib(&st, &a);
743
		stat_to_attrib(&st, &a);
744
		a.flags &= stat_attr_mask;
745
		a.ext_flags &= stat_ext_attr_mask;
680
		send_attrib(id, &a);
746
		send_attrib(id, &a);
681
		status = SSH2_FX_OK;
747
		status = SSH2_FX_OK;
682
	}
748
	}
Lines 716-721 process_fstat(void) Link Here
716
			status = errno_to_portable(errno);
782
			status = errno_to_portable(errno);
717
		} else {
783
		} else {
718
			stat_to_attrib(&st, &a);
784
			stat_to_attrib(&st, &a);
785
			a.flags &= stat_attr_mask;
786
			a.ext_flags &= stat_ext_attr_mask;
719
			send_attrib(id, &a);
787
			send_attrib(id, &a);
720
			status = SSH2_FX_OK;
788
			status = SSH2_FX_OK;
721
		}
789
		}
Lines 891-896 process_readdir(void) Link Here
891
959
892
		stats = xcalloc(nstats, sizeof(Stat));
960
		stats = xcalloc(nstats, sizeof(Stat));
893
		while ((dp = readdir(dirp)) != NULL) {
961
		while ((dp = readdir(dirp)) != NULL) {
962
			char *long_name;
963
894
			if (count >= nstats) {
964
			if (count >= nstats) {
895
				nstats *= 2;
965
				nstats *= 2;
896
				stats = xrealloc(stats, nstats, sizeof(Stat));
966
				stats = xrealloc(stats, nstats, sizeof(Stat));
Lines 901-908 process_readdir(void) Link Here
901
			if (lstat(pathname, &st) < 0)
971
			if (lstat(pathname, &st) < 0)
902
				continue;
972
				continue;
903
			stat_to_attrib(&st, &(stats[count].attrib));
973
			stat_to_attrib(&st, &(stats[count].attrib));
974
975
			if (dir_send_long_name)
976
				long_name = ls_file(dp->d_name, &st, 0);
977
			else
978
				long_name = xstrdup("");
979
980
			stats[count].attrib.flags &= dir_attr_mask;
981
			stats[count].attrib.ext_flags &= dir_ext_attr_mask;
904
			stats[count].name = xstrdup(dp->d_name);
982
			stats[count].name = xstrdup(dp->d_name);
905
			stats[count].long_name = ls_file(dp->d_name, &st, 0);
983
			stats[count].long_name = long_name;
906
			count++;
984
			count++;
907
			/* send up to 100 entries in one message */
985
			/* send up to 100 entries in one message */
908
			/* XXX check packet size instead */
986
			/* XXX check packet size instead */
Lines 1173-1178 process_extended_link(u_int32_t id) Link Here
1173
}
1251
}
1174
1252
1175
static void
1253
static void
1254
process_extended_attrconfig(u_int32_t id)
1255
{
1256
	u_int flags;
1257
	u_int mask;
1258
1259
	flags = get_int();
1260
	if (flags & SSH2_FXE_ATTRCONFIG_NOLONGNAME)
1261
		dir_send_long_name = 0;
1262
	else
1263
		dir_send_long_name = 1;
1264
1265
	mask = get_int();
1266
	stat_attr_mask = mask & SUPPORTED_ATTR;
1267
	mask = get_int();
1268
	stat_ext_attr_mask = mask & SUPPORTED_EXT_ATTR;
1269
	mask = get_int();
1270
	dir_attr_mask = mask & SUPPORTED_ATTR;
1271
	mask = get_int();
1272
	dir_ext_attr_mask = mask & SUPPORTED_EXT_ATTR;
1273
1274
	debug3("request %u: attrconfig", id);
1275
1276
	send_attrconfig_reply(id);
1277
}
1278
1279
1280
static void
1176
process_extended(void)
1281
process_extended(void)
1177
{
1282
{
1178
	u_int32_t id;
1283
	u_int32_t id;
Lines 1188-1193 process_extended(void) Link Here
1188
		process_extended_fstatvfs(id);
1293
		process_extended_fstatvfs(id);
1189
	else if (strcmp(request, "link@openssh.com") == 0)
1294
	else if (strcmp(request, "link@openssh.com") == 0)
1190
		process_extended_link(id);
1295
		process_extended_link(id);
1296
	else if (strcmp(request, "attrconfig@openssh.com") == 0)
1297
		process_extended_attrconfig(id);
1191
	else
1298
	else
1192
		send_status(id, SSH2_FX_OP_UNSUPPORTED);	/* MUST */
1299
		send_status(id, SSH2_FX_OP_UNSUPPORTED);	/* MUST */
1193
	xfree(request);
1300
	xfree(request);
(-)ssh.orig/sftp.h (+3 lines)
Lines 97-102 Link Here
97
#define SSH2_FXE_EXTATTR_CTIME		0x00000400
97
#define SSH2_FXE_EXTATTR_CTIME		0x00000400
98
#define SSH2_FXE_EXTATTR_CTIMENSEC	0x00000800
98
#define SSH2_FXE_EXTATTR_CTIMENSEC	0x00000800
99
99
100
/* attrconfig@openssh.com flags */
101
#define SSH2_FXE_ATTRCONFIG_NOLONGNAME	0x00000001
102
100
/* status messages */
103
/* status messages */
101
#define SSH2_FX_OK			0
104
#define SSH2_FX_OK			0
102
#define SSH2_FX_EOF			1
105
#define SSH2_FX_EOF			1

Return to bug 1555