Bugzilla – Attachment 1603 Details for
Bug 1555
add attribute extensions to sftp-server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
add attribute configuration message
sftp-server-attrconfig.patch (text/plain), 5.34 KB, created by
Miklos Szeredi
on 2009-02-13 22:10:54 AEDT
(
hide
)
Description:
add attribute configuration message
Filename:
MIME Type:
Creator:
Miklos Szeredi
Created:
2009-02-13 22:10:54 AEDT
Size:
5.34 KB
patch
obsolete
>--- > sftp-server.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > sftp.h | 3 + > 2 files changed, 111 insertions(+), 1 deletion(-) > >Index: ssh/sftp-server.c >=================================================================== >--- ssh.orig/sftp-server.c 2009-02-12 14:11:30.000000000 +0100 >+++ ssh/sftp-server.c 2009-02-12 14:37:39.000000000 +0100 >@@ -61,6 +61,45 @@ Buffer oqueue; > /* Version of client */ > int version; > >+/* Attributes which this implementation can send */ >+#define SUPPORTED_ATTR ( \ >+ SSH2_FILEXFER_ATTR_SIZE | \ >+ SSH2_FILEXFER_ATTR_UIDGID | \ >+ SSH2_FILEXFER_ATTR_PERMISSIONS | \ >+ SSH2_FILEXFER_ATTR_ACMODTIME \ >+ ) >+ >+/* Extra attributes which this implementation can send */ >+#define SUPPORTED_EXT_ATTR ( \ >+ SSH2_FXE_EXTATTR_DEV | \ >+ SSH2_FXE_EXTATTR_INO | \ >+ SSH2_FXE_EXTATTR_NLINK | \ >+ SSH2_FXE_EXTATTR_RDEV | \ >+ SSH2_FXE_EXTATTR_BLKSIZE | \ >+ SSH2_FXE_EXTATTR_BLOCKS | \ >+ SSH2_FXE_EXTATTR_ATIME | \ >+ SSH2_FXE_EXTATTR_ATIMENSEC | \ >+ SSH2_FXE_EXTATTR_MTIME | \ >+ SSH2_FXE_EXTATTR_MTIMENSEC | \ >+ SSH2_FXE_EXTATTR_CTIME | \ >+ SSH2_FXE_EXTATTR_CTIMENSEC \ >+ ) >+ >+/* Attributes to send in the stat reply */ >+u_int stat_attr_mask = SUPPORTED_ATTR; >+ >+/* Extra attributes to send in the stat reply */ >+u_int stat_ext_attr_mask = 0; >+ >+/* Attributes to send in the readdir reply */ >+u_int dir_attr_mask = SUPPORTED_ATTR; >+ >+/* Extra attributes to send in the readdir reply */ >+u_int dir_ext_attr_mask = 0; >+ >+/* If false, send empty long name in the readdir reply */ >+int dir_send_long_name = 1; >+ > /* portable attributes, etc. */ > > typedef struct Stat Stat; >@@ -502,6 +541,28 @@ send_statvfs(u_int32_t id, struct statvf > buffer_free(&msg); > } > >+static void >+send_attrconfig_reply(u_int32_t id) >+{ >+ Buffer msg; >+ int flags = 0; >+ >+ /* Send the actual value of the masks */ >+ if (!dir_send_long_name) >+ flags |= SSH2_FXE_ATTRCONFIG_NOLONGNAME; >+ >+ buffer_init(&msg); >+ buffer_put_char(&msg, SSH2_FXP_EXTENDED_REPLY); >+ buffer_put_int(&msg, id); >+ buffer_put_int(&msg, flags); >+ buffer_put_int(&msg, stat_attr_mask); >+ buffer_put_int(&msg, stat_ext_attr_mask); >+ buffer_put_int(&msg, dir_attr_mask); >+ buffer_put_int(&msg, dir_ext_attr_mask); >+ send_msg(&msg); >+ buffer_free(&msg); >+} >+ > /* parse incoming */ > > static void >@@ -526,6 +587,9 @@ process_init(void) > /* link extension */ > buffer_put_cstring(&msg, "link@openssh.com"); > buffer_put_cstring(&msg, "1"); /* version */ >+ /* attrconfig extension */ >+ buffer_put_cstring(&msg, "attrconfig@openssh.com"); >+ buffer_put_cstring(&msg, "1"); /* version */ > send_msg(&msg); > buffer_free(&msg); > } >@@ -677,6 +741,8 @@ process_do_stat(int do_lstat) > status = errno_to_portable(errno); > } else { > stat_to_attrib(&st, &a); >+ a.flags &= stat_attr_mask; >+ a.ext_flags &= stat_ext_attr_mask; > send_attrib(id, &a); > status = SSH2_FX_OK; > } >@@ -716,6 +782,8 @@ process_fstat(void) > status = errno_to_portable(errno); > } else { > stat_to_attrib(&st, &a); >+ a.flags &= stat_attr_mask; >+ a.ext_flags &= stat_ext_attr_mask; > send_attrib(id, &a); > status = SSH2_FX_OK; > } >@@ -891,6 +959,8 @@ process_readdir(void) > > stats = xcalloc(nstats, sizeof(Stat)); > while ((dp = readdir(dirp)) != NULL) { >+ char *long_name; >+ > if (count >= nstats) { > nstats *= 2; > stats = xrealloc(stats, nstats, sizeof(Stat)); >@@ -901,8 +971,16 @@ process_readdir(void) > if (lstat(pathname, &st) < 0) > continue; > stat_to_attrib(&st, &(stats[count].attrib)); >+ >+ if (dir_send_long_name) >+ long_name = ls_file(dp->d_name, &st, 0); >+ else >+ long_name = xstrdup(""); >+ >+ stats[count].attrib.flags &= dir_attr_mask; >+ stats[count].attrib.ext_flags &= dir_ext_attr_mask; > stats[count].name = xstrdup(dp->d_name); >- stats[count].long_name = ls_file(dp->d_name, &st, 0); >+ stats[count].long_name = long_name; > count++; > /* send up to 100 entries in one message */ > /* XXX check packet size instead */ >@@ -1173,6 +1251,33 @@ process_extended_link(u_int32_t id) > } > > static void >+process_extended_attrconfig(u_int32_t id) >+{ >+ u_int flags; >+ u_int mask; >+ >+ flags = get_int(); >+ if (flags & SSH2_FXE_ATTRCONFIG_NOLONGNAME) >+ dir_send_long_name = 0; >+ else >+ dir_send_long_name = 1; >+ >+ mask = get_int(); >+ stat_attr_mask = mask & SUPPORTED_ATTR; >+ mask = get_int(); >+ stat_ext_attr_mask = mask & SUPPORTED_EXT_ATTR; >+ mask = get_int(); >+ dir_attr_mask = mask & SUPPORTED_ATTR; >+ mask = get_int(); >+ dir_ext_attr_mask = mask & SUPPORTED_EXT_ATTR; >+ >+ debug3("request %u: attrconfig", id); >+ >+ send_attrconfig_reply(id); >+} >+ >+ >+static void > process_extended(void) > { > u_int32_t id; >@@ -1188,6 +1293,8 @@ process_extended(void) > process_extended_fstatvfs(id); > else if (strcmp(request, "link@openssh.com") == 0) > process_extended_link(id); >+ else if (strcmp(request, "attrconfig@openssh.com") == 0) >+ process_extended_attrconfig(id); > else > send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */ > xfree(request); >Index: ssh/sftp.h >=================================================================== >--- ssh.orig/sftp.h 2009-02-12 14:11:31.000000000 +0100 >+++ ssh/sftp.h 2009-02-12 14:15:44.000000000 +0100 >@@ -97,6 +97,9 @@ > #define SSH2_FXE_EXTATTR_CTIME 0x00000400 > #define SSH2_FXE_EXTATTR_CTIMENSEC 0x00000800 > >+/* attrconfig@openssh.com flags */ >+#define SSH2_FXE_ATTRCONFIG_NOLONGNAME 0x00000001 >+ > /* status messages */ > #define SSH2_FX_OK 0 > #define SSH2_FX_EOF 1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1555
:
1601
|
1602
| 1603 |
1604
|
1971