summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/sftp-server.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2010-12-04 00:18:01 +0000
committerdjm <djm@openbsd.org>2010-12-04 00:18:01 +0000
commit9c120764945bba2d58b76f1a3d3415080c96b731 (patch)
tree2dab79ddb549e3d45f23248f19830e01a53b6a22 /usr.bin/ssh/sftp-server.c
parentmove check for revoked keys to run earlier (in auth_rsa_key_allowed) (diff)
downloadwireguard-openbsd-9c120764945bba2d58b76f1a3d3415080c96b731.tar.xz
wireguard-openbsd-9c120764945bba2d58b76f1a3d3415080c96b731.zip
add a protocol extension to support a hard link operation. It is
available through the "ln" command in the client. The old "ln" behaviour of creating a symlink is available using its "-s" option or through the preexisting "symlink" command; based on a patch from miklos AT szeredi.hu in bz#1555; ok markus@
Diffstat (limited to 'usr.bin/ssh/sftp-server.c')
-rw-r--r--usr.bin/ssh/sftp-server.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c
index 1e5b0d9d295..b16c9036307 100644
--- a/usr.bin/ssh/sftp-server.c
+++ b/usr.bin/ssh/sftp-server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-server.c,v 1.92 2010/11/04 02:45:34 djm Exp $ */
+/* $OpenBSD: sftp-server.c,v 1.93 2010/12/04 00:18:01 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
@@ -526,6 +526,9 @@ process_init(void)
/* fstatvfs extension */
buffer_put_cstring(&msg, "fstatvfs@openssh.com");
buffer_put_cstring(&msg, "2"); /* version */
+ /* hardlink extension */
+ buffer_put_cstring(&msg, "hardlink@openssh.com");
+ buffer_put_cstring(&msg, "1"); /* version */
send_msg(&msg);
buffer_free(&msg);
}
@@ -1195,6 +1198,27 @@ process_extended_fstatvfs(u_int32_t id)
}
static void
+process_extended_hardlink(u_int32_t id)
+{
+ char *oldpath, *newpath;
+ int ret, status;
+
+ oldpath = get_string(NULL);
+ newpath = get_string(NULL);
+ debug3("request %u: hardlink", id);
+ logit("hardlink old \"%s\" new \"%s\"", oldpath, newpath);
+ if (readonly)
+ status = SSH2_FX_PERMISSION_DENIED;
+ else {
+ ret = link(oldpath, newpath);
+ status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
+ }
+ send_status(id, status);
+ xfree(oldpath);
+ xfree(newpath);
+}
+
+static void
process_extended(void)
{
u_int32_t id;
@@ -1208,6 +1232,8 @@ process_extended(void)
process_extended_statvfs(id);
else if (strcmp(request, "fstatvfs@openssh.com") == 0)
process_extended_fstatvfs(id);
+ else if (strcmp(request, "hardlink@openssh.com") == 0)
+ process_extended_hardlink(id);
else
send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
xfree(request);