1 --- hpn-ssh-hpn-18.4.2/Makefile.in.orig
2 +++ hpn-ssh-hpn-18.4.2/Makefile.in
4 monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-ecdsa-sk.o \
5 ssh-ed25519-sk.o ssh-rsa.o dh.o \
6 msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
8 ssh-pkcs11.o smult_curve25519_ref.o \
9 poly1305.o chacha.o cipher-chachapoly.o cipher-chachapoly-libcrypto.o \
10 cipher-chachapoly-libcrypto-mt.o \
12 srclimit.o sftp-server.o sftp-common.o \
13 sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
14 sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-pledge.o \
15 - sandbox-solaris.o uidswap.o cipher-switch.o $(SKOBJS)
16 + sandbox-solaris.o uidswap.o cipher-switch.o sftp_provider.o $(SKOBJS)
18 SFTP_CLIENT_OBJS=sftp-common.o sftp-client.o sftp-glob.o
22 SSHKEYSCAN_OBJS=ssh-keyscan.o $(SKOBJS)
24 -SFTPSERVER_OBJS=sftp-common.o sftp-server.o sftp-server-main.o
25 +SFTPSERVER_OBJS=sftp-common.o sftp-server.o sftp-server-main.o sftp_provider.o
26 +ROOTDLIBDIR=$(DESTDIR)/usr/lib/dtrace
28 SFTP_OBJS= sftp.o sftp-usergroup.o progressmeter.o $(SFTP_CLIENT_OBJS)
35 +sftp_provider.h: $(srcdir)/sftp_provider.d
36 + /usr/sbin/dtrace -xnolibs -h -s $(srcdir)/sftp_provider.d \
37 + -o $(srcdir)/sftp_provider.h
39 +sftp_provider.o: sftp_provider.d sftp_provider.h sftp-server.o
40 + /usr/sbin/dtrace -G -64 -xnolibs -s $(srcdir)/sftp_provider.d \
41 + sftp-server.o -o sftp_provider.o
43 +# special case for sftp-server.o, it includes sftp_provider.h
44 +sftp-server.o: sftp_provider.h sftp-server.c
45 + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(srcdir)/sftp-server.c
48 rm -f *.o *.lo *.a $(TARGETS) logintest config.cache config.log
49 - rm -f *.out core survey
50 + rm -f *.out core survey sftp_provider.h
51 rm -f regress/check-perm$(EXEEXT)
52 rm -f regress/mkdtemp$(EXEEXT)
53 rm -f regress/unittests/test_helper/*.a
55 $(INSTALL) -m 644 hpnssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/hpnssh-keysign.8
56 $(INSTALL) -m 644 hpnssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/hpnssh-pkcs11-helper.8
57 $(INSTALL) -m 644 hpnssh-sk-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/hpnssh-sk-helper.8
58 + mkdir -p $(ROOTDLIBDIR) && cp $(srcdir)/hpnsftp.d $(ROOTDLIBDIR)/
61 $(MKDIR_P) $(DESTDIR)$(sysconfdir)
62 --- hpn-ssh-hpn-18.4.2/sftp-server.c.orig
63 +++ hpn-ssh-hpn-18.4.2/sftp-server.c
67 #include "sftp-common.h"
69 +#include "sftp_provider_impl.h"
72 char *sftp_realpath(const char *, char *); /* sftp-realpath.c */
76 int r, handle, fd, ret, status = SSH2_FX_FAILURE;
80 if ((r = get_handle(iqueue, &handle)) != 0 ||
81 (r = sshbuf_get_u64(iqueue, &off)) != 0 ||
82 (r = sshbuf_get_u32(iqueue, &len)) != 0)
85 + fpath = handle_to_name(handle);
87 debug("request %u: read \"%s\" (handle %d) off %llu len %u",
88 - id, handle_to_name(handle), handle, (unsigned long long)off, len);
89 + id, fpath, handle, (unsigned long long)off, len);
90 if ((fd = handle_to_fd(handle)) == -1)
92 if (len > SFTP_MAX_READ_LENGTH) {
98 + SFTP_TRANSFER_START_OP("read", fd, fpath, len);
101 /* weird, but not strictly disallowed */
103 @@ -841,11 +850,18 @@
104 status = SSH2_FX_EOF;
108 + SFTP_TRANSFER_DONE_OP("read", fd, fpath, ret);
110 send_data(id, buf, ret);
111 handle_update_read(handle, ret);
116 + if (status != SSH2_FX_OK)
117 + SFTP_TRANSFER_DONE_OP("read", fd, fpath, ret);
119 if (status != SSH2_FX_OK)
120 send_status(id, status);
122 @@ -857,14 +873,17 @@
124 int r, handle, fd, ret, status;
128 if ((r = get_handle(iqueue, &handle)) != 0 ||
129 (r = sshbuf_get_u64(iqueue, &off)) != 0 ||
130 (r = sshbuf_get_string(iqueue, &data, &len)) != 0)
131 fatal_fr(r, "parse");
133 + fpath = handle_to_name(handle);
135 debug("request %u: write \"%s\" (handle %d) off %llu len %zu",
136 - id, handle_to_name(handle), handle, (unsigned long long)off, len);
137 + id, fpath, handle, (unsigned long long)off, len);
138 fd = handle_to_fd(handle);
146 + SFTP_TRANSFER_START_OP("write", fd, fpath, len);
148 ret = write(fd, data, len);
150 + SFTP_TRANSFER_DONE_OP("write", fd, fpath, ret);
153 status = errno_to_portable(errno);
154 error_f("write \"%.100s\": %s",
156 +++ hpn-ssh-hpn-18.4.2/hpnsftp.d
159 + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
162 +#pragma D depends_on library net.d
163 +#pragma D depends_on library io.d
164 +#pragma D depends_on module lofs
166 +typedef struct hpnsftpinfo {
167 + string sfi_user; /* user name */
168 + string sfi_operation; /* SFTP Operation */
169 + ssize_t sfi_nbytes; /* bytes transferred, if any */
170 + string sfi_pathname; /* pathname of transfer */
171 + string sfi_fsresource; /* Dataset(ZFS) or resource name */
175 + * This structure must match the definition of same in sftp_provider_impl.h.
177 +typedef struct hpnsftpproto {
178 + int64_t sftp_nbytes; /* bytes written or read */
179 + uint64_t sftp_user; /* user name */
180 + uint64_t sftp_operation; /* SFTP operation */
181 + uint64_t sftp_raddr; /* remote address */
182 + uint64_t sftp_pathname; /* path with file name */
183 + int32_t sftp_fd; /* fd for transfer, if any */
186 +#pragma D binding "1.6.1" translator
187 +translator conninfo_t <hpnsftpproto_t *s> {
188 + ci_protocol = "tcp";
189 + ci_remote = copyinstr((uintptr_t)
190 + *(uint64_t *)copyin((uintptr_t)&s->sftp_raddr, sizeof (uint64_t)));
191 + ci_local = "<unknown>";
194 +#pragma D binding "1.6.1" translator
195 +translator hpnsftpinfo_t <hpnsftpproto_t *s> {
196 + sfi_user = copyinstr((uintptr_t)
197 + *(uint64_t *)copyin((uintptr_t)&s->sftp_user, sizeof (uint64_t)));
198 + sfi_operation = copyinstr((uintptr_t)
199 + *(uint64_t *)copyin((uintptr_t)&s->sftp_operation,
200 + sizeof (uint64_t)));
202 + *(uint64_t *)copyin((uintptr_t)&s->sftp_nbytes, sizeof (uint64_t));
203 + sfi_fsresource = stringof(fds[*(int32_t *)copyin((uintptr_t)&s->sftp_fd,
204 + sizeof (int32_t))].fi_fs) == "lofs" ? stringof(((struct loinfo *)
205 + curthread->t_procp->p_user.u_finfo.fi_list[*(int32_t *)copyin(
206 + (uintptr_t)&s->sftp_fd, sizeof (int32_t))].uf_file->f_vnode->
207 + v_vfsp->vfs_data)->li_realvfs->vfs_resource->rs_string) :
208 + stringof(curthread->t_procp->p_user.u_finfo.fi_list[
209 + *(int32_t *)copyin((uintptr_t)&s->sftp_fd, sizeof (int32_t))].
210 + uf_file->f_vnode->v_vfsp->vfs_resource->rs_string);
211 + sfi_pathname = copyinstr((uintptr_t)*(uint64_t *)copyin(
212 + (uintptr_t)&s->sftp_pathname, sizeof (uint64_t)));
215 +++ hpn-ssh-hpn-18.4.2/sftp_provider.d
218 + * CDDL HEADER START
220 + * The contents of this file are subject to the terms of the
221 + * Common Development and Distribution License (the "License").
222 + * You may not use this file except in compliance with the License.
224 + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
225 + * or http://www.opensolaris.org/os/licensing.
226 + * See the License for the specific language governing permissions
227 + * and limitations under the License.
229 + * When distributing Covered Code, include this CDDL HEADER in each
230 + * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
231 + * If applicable, add the following below this CDDL HEADER, with the
232 + * fields enclosed by brackets "[]" replaced with your own identifying
233 + * information: Portions Copyright [yyyy] [name of copyright owner]
238 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
242 + * We seem currently unable to depend properly on existing D libraries (like
243 + * hpnsftp.d). But the definitions for conninfo_t and sftpinfo_t are stored there
244 + * (and have to be, since that's where the real translators live). So we're
245 + * forced to define something here to satisfy dtrace(8), but none of the
246 + * definitions or translators here are actually used.
248 +typedef struct sftpinfo {
252 +typedef struct sftpproto {
256 +typedef struct conninfo {
260 +translator conninfo_t <sftpproto_t *dp> {
263 +translator sftpinfo_t <sftpproto_t *dp> {
267 + probe transfer__start(sftpproto_t *p) :
268 + (conninfo_t *p, sftpinfo_t *p);
269 + probe transfer__done(sftpproto_t *p) :
270 + (conninfo_t *p, sftpinfo_t *p);
273 +#pragma D attributes Evolving/Evolving/ISA provider sftp provider
274 +#pragma D attributes Private/Private/Unknown provider sftp module
275 +#pragma D attributes Private/Private/Unknown provider sftp function
276 +#pragma D attributes Private/Private/ISA provider sftp name
277 +#pragma D attributes Evolving/Evolving/ISA provider sftp args
279 +++ hpn-ssh-hpn-18.4.2/sftp_provider_impl.h
282 + * CDDL HEADER START
284 + * The contents of this file are subject to the terms of the
285 + * Common Development and Distribution License (the "License").
286 + * You may not use this file except in compliance with the License.
288 + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
289 + * or http://www.opensolaris.org/os/licensing.
290 + * See the License for the specific language governing permissions
291 + * and limitations under the License.
293 + * When distributing Covered Code, include this CDDL HEADER in each
294 + * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
295 + * If applicable, add the following below this CDDL HEADER, with the
296 + * fields enclosed by brackets "[]" replaced with your own identifying
297 + * information: Portions Copyright [yyyy] [name of copyright owner]
302 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
305 +#ifndef _SFTP_PROVIDER_IMPL_H
306 +#define _SFTP_PROVIDER_IMPL_H
313 + * This structure must match the definition of same in hpnsftp.d.
315 +typedef struct sftpproto {
316 + int64_t sftp_nbytes; /* bytes writtten or read */
317 + const char *sftp_user; /* user name */
318 + const char *sftp_operation; /* SFTP Operation */
319 + const char *sftp_raddr; /* remote address */
320 + const char *sftp_pathname; /* path with file name */
321 + int32_t sftp_fd; /* fd for transfer, if any */
324 +#define SFTP_TRANSFER_PROTO(proto, op, fd, path, len) \
325 + bzero((proto), sizeof (struct sftpproto)); \
326 + (proto)->sftp_user = (pw->pw_name ? pw->pw_name : "UNKNOWN"); \
327 + (proto)->sftp_operation = (op ? op : "UNKNOWN"); \
328 + (proto)->sftp_raddr = (client_addr); \
329 + (proto)->sftp_fd = (fd); \
330 + (proto)->sftp_pathname = (path ? path : "UNKNOWN"); \
331 + (proto)->sftp_nbytes = (len); \
333 +#define SFTP_TRANSFER_START_OP(op, fd, path, len) \
334 + if (SFTP_TRANSFER_START_ENABLED()) { \
335 + sftpproto_t proto; \
336 + SFTP_TRANSFER_PROTO(&proto, op, fd, path, len); \
337 + SFTP_TRANSFER_START(&proto); \
340 +#define SFTP_TRANSFER_DONE_OP(op, fd, path, len) \
341 + if (SFTP_TRANSFER_DONE_ENABLED()) { \
342 + sftpproto_t proto; \
343 + SFTP_TRANSFER_PROTO(&proto, op, fd, path, len); \
344 + SFTP_TRANSFER_DONE(&proto); \
347 +#include "sftp_provider.h"
353 +#endif /* _SFTP_PROVIDER_IMPL_H */