components/openssh/patches/013-dtrace_sftp.patch
changeset 5819 c5f05bd2a9bc
parent 4503 bf30d46ab06e
equal deleted inserted replaced
5818:5f0e7a0f17c2 5819:c5f05bd2a9bc
     3 # some observability of SFTP data transfer. This was developed in-house. 
     3 # some observability of SFTP data transfer. This was developed in-house. 
     4 # Because this is Solaris-specific and not suitable for upstream, we will not
     4 # Because this is Solaris-specific and not suitable for upstream, we will not
     5 # contribute the changes to the upstream community.
     5 # contribute the changes to the upstream community.
     6 #
     6 #
     7 diff -pur old/Makefile.in new/Makefile.in
     7 diff -pur old/Makefile.in new/Makefile.in
     8 --- old/Makefile.in	2015-03-28 14:10:39.426859283 +0100
     8 --- old/Makefile.in
     9 +++ new/Makefile.in	2015-03-28 14:16:12.472203388 +0100
     9 +++ new/Makefile.in
    10 @@ -26,6 +26,7 @@ ASKPASS_PROGRAM=$(libexecdir)/ssh-askpas
    10 @@ -26,6 +26,7 @@ ASKPASS_PROGRAM=$(libexecdir)/ssh-askpas
    11  SFTP_SERVER=$(libexecdir)/sftp-server
    11  SFTP_SERVER=$(libexecdir)/sftp-server
    12  SSH_KEYSIGN=$(libexecdir)/ssh-keysign
    12  SSH_KEYSIGN=$(libexecdir)/ssh-keysign
    13  SSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
    13  SSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
    14 +ROOTDLIBDIR64=$(DESTDIR)/usr/lib/dtrace/64
    14 +ROOTDLIBDIR64=$(DESTDIR)/usr/lib/dtrace/64
    21  	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
    21  	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
    22 +	sftp_provider.o \
    22 +	sftp_provider.o \
    23  	ssh-pkcs11.o smult_curve25519_ref.o \
    23  	ssh-pkcs11.o smult_curve25519_ref.o \
    24  	poly1305.o chacha.o cipher-chachapoly.o \
    24  	poly1305.o chacha.o cipher-chachapoly.o \
    25  	ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
    25  	ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
    26 @@ -110,7 +112,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passw
    26 @@ -107,7 +109,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passw
    27  	sftp-server.o sftp-common.o \
    27  	monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \
    28  	roaming_common.o roaming_serv.o \
    28  	auth2-gss.o gss-serv.o gss-serv-krb5.o \
       
    29  	loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
       
    30 -	sftp-server.o sftp-common.o \
       
    31 +	sftp-server.o sftp-common.o sftp_provider.o \
    29  	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
    32  	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
    30 -	sandbox-seccomp-filter.o sandbox-capsicum.o
    33  	sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-pledge.o \
    31 +	sandbox-seccomp-filter.o sandbox-capsicum.o sftp_provider.o
    34  	sandbox-solaris.o
    32  
       
    33  MANPAGES	= moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
       
    34  MANPAGES_IN	= moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
       
    35 @@ -187,8 +189,8 @@ ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT)
    35 @@ -187,8 +189,8 @@ ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT)
    36  ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
    36  ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o
    37  	$(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
    37  	$(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
    38  
    38  
    39 -sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
    39 -sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
    40 -	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
    40 -	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
    41 +sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o sftp_provider.o
    41 +sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o sftp_provider.o
    42 +	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o sftp_provider.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
    42 +	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o sftp_provider.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
    61 -	rm -f *.out core survey
    61 -	rm -f *.out core survey
    62 +	rm -f *.out core survey sftp_provider.h
    62 +	rm -f *.out core survey sftp_provider.h
    63  	rm -f regress/unittests/test_helper/*.a
    63  	rm -f regress/unittests/test_helper/*.a
    64  	rm -f regress/unittests/test_helper/*.o
    64  	rm -f regress/unittests/test_helper/*.o
    65  	rm -f regress/unittests/sshbuf/*.o
    65  	rm -f regress/unittests/sshbuf/*.o
    66 @@ -340,6 +351,7 @@ install-files:
    66 @@ -336,6 +347,7 @@ install-files:
    67  	ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
    67  	$(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
    68  	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
    68  	$(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
    69  	ln -s ./ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
    69  	$(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
    70 +	mkdir -p $(ROOTDLIBDIR64) && cp $(srcdir)/sftp64.d $(ROOTDLIBDIR64)/sftp64.d
    70 +	mkdir -p $(ROOTDLIBDIR64) && cp $(srcdir)/sftp64.d $(ROOTDLIBDIR64)/sftp64.d
    71  
    71  
    72  install-sysconf:
    72  install-sysconf:
    73  	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
    73  	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
    74 diff -pur old/sftp-server.c new/sftp-server.c
    74 diff -pur old/sftp-server.c new/sftp-server.c
    75 --- old/sftp-server.c	2015-03-17 06:49:20.000000000 +0100
    75 --- old/sftp-server.c
    76 +++ new/sftp-server.c	2015-03-28 14:27:55.661510029 +0100
    76 +++ new/sftp-server.c
    77 @@ -55,6 +55,9 @@
    77 @@ -54,6 +54,9 @@
    78  
    78  
    79  #include "sftp.h"
    79  #include "sftp.h"
    80  #include "sftp-common.h"
    80  #include "sftp-common.h"
    81 +#ifdef DTRACE_SFTP
    81 +#ifdef DTRACE_SFTP
    82 +#include "sftp_provider_impl.h"
    82 +#include "sftp_provider_impl.h"
    83 +#endif
    83 +#endif
    84  
    84  
    85  /* Our verbosity */
    85  /* Our verbosity */
    86  static LogLevel log_level = SYSLOG_LEVEL_ERROR;
    86  static LogLevel log_level = SYSLOG_LEVEL_ERROR;
    87 @@ -741,14 +744,17 @@ process_read(u_int32_t id)
    87 @@ -740,14 +743,17 @@ process_read(u_int32_t id)
    88  	u_int32_t len;
    88  	u_int32_t len;
    89  	int r, handle, fd, ret, status = SSH2_FX_FAILURE;
    89  	int r, handle, fd, ret, status = SSH2_FX_FAILURE;
    90  	u_int64_t off;
    90  	u_int64_t off;
    91 +	char *fpath;
    91 +	char *fpath;
    92  
    92  
   102 + 	debug("request %u: read \"%s\" (handle %d) off %llu len %d",
   102 + 	debug("request %u: read \"%s\" (handle %d) off %llu len %d",
   103 +	    id, fpath, handle, (unsigned long long)off, len);
   103 +	    id, fpath, handle, (unsigned long long)off, len);
   104  	if (len > sizeof buf) {
   104  	if (len > sizeof buf) {
   105  		len = sizeof buf;
   105  		len = sizeof buf;
   106  		debug2("read change len %d", len);
   106  		debug2("read change len %d", len);
   107 @@ -759,7 +765,13 @@ process_read(u_int32_t id)
   107 @@ -758,7 +764,13 @@ process_read(u_int32_t id)
   108  			error("process_read: seek failed");
   108  			error("process_read: seek failed");
   109  			status = errno_to_portable(errno);
   109  			status = errno_to_portable(errno);
   110  		} else {
   110  		} else {
   111 +#ifdef DTRACE_SFTP
   111 +#ifdef DTRACE_SFTP
   112 +		        SFTP_TRANSFER_START_OP("read", fd, fpath, len);
   112 +		        SFTP_TRANSFER_START_OP("read", fd, fpath, len);
   116 +                        SFTP_TRANSFER_DONE_OP("read", fd, fpath, ret);
   116 +                        SFTP_TRANSFER_DONE_OP("read", fd, fpath, ret);
   117 +#endif
   117 +#endif
   118  			if (ret < 0) {
   118  			if (ret < 0) {
   119  				status = errno_to_portable(errno);
   119  				status = errno_to_portable(errno);
   120  			} else if (ret == 0) {
   120  			} else if (ret == 0) {
   121 @@ -782,14 +794,16 @@ process_write(u_int32_t id)
   121 @@ -781,14 +793,16 @@ process_write(u_int32_t id)
   122  	size_t len;
   122  	size_t len;
   123  	int r, handle, fd, ret, status;
   123  	int r, handle, fd, ret, status;
   124  	u_char *data;
   124  	u_char *data;
   125 +	char *fpath;
   125 +	char *fpath;
   126  
   126  
   134 -	    id, handle_to_name(handle), handle, (unsigned long long)off, len);
   134 -	    id, handle_to_name(handle), handle, (unsigned long long)off, len);
   135 +	    id, fpath, handle, (unsigned long long)off, len);
   135 +	    id, fpath, handle, (unsigned long long)off, len);
   136  	fd = handle_to_fd(handle);
   136  	fd = handle_to_fd(handle);
   137  
   137  
   138  	if (fd < 0)
   138  	if (fd < 0)
   139 @@ -801,7 +815,14 @@ process_write(u_int32_t id)
   139 @@ -800,7 +814,14 @@ process_write(u_int32_t id)
   140  			error("process_write: seek failed");
   140  			error("process_write: seek failed");
   141  		} else {
   141  		} else {
   142  /* XXX ATOMICIO ? */
   142  /* XXX ATOMICIO ? */
   143 +#ifdef DTRACE_SFTP
   143 +#ifdef DTRACE_SFTP
   144 +		        SFTP_TRANSFER_START_OP("write", fd, fpath, len);
   144 +		        SFTP_TRANSFER_START_OP("write", fd, fpath, len);