OpenSSH portability & buildsystem fixes

Jonas 'Sortie' Termansen sortie at maxsi.org
Wed Jan 20 10:23:02 AEDT 2016


Hi,

I recently ported OpenSSH to my hobbyist operating system.  The portable
release is very straightforward to work with, but it had a few minor
issues where it assumes the existence of things that might not be on a
POSIX 2008 system.  This are the list of issues I encountered that I
believe makes sense to upstream.

* <sys/param.h> is included in many files and isn't a standard header.
  The portability layer already handles all the things it might provide
  and I could just remove all its inclusions.  The build system should
  just detect its absence and generate an empty header in
  openbsd-compat/.

* bzero is used in deattack.c (and in regress/) instead of the standard
  memset.  The code should be changed to use memset or the compatibility
  layer should provide its own bzero if absent.

* misc.c uses gettimeofday but doesn't include <sys/time.h> to get it.

* timerclear, timerisset and timercmp are used in misc.c and
  ssh-keyscan.c. They are non-standard BSD extensions from <sys/time.h>.
  The build system should detect their lack and provide its own
  versions, or the code could be rewritten to not use them.

* u_short and u_long are used across the codebase, but defines.h only
  provides u_char and u_int.

* size_t len in openbsd-compat/strptime.c is unused and causes a
  warning. It's used below by code that's commented out and the variable
  should be commented out too.

* utimes in openbsd-compat has char * for the path parameter but that's
  supposed to be const char *.

* loginrec.c in utmpx_perform_login does a call to utmpx_write_direct
  with a parameter named ut, but such a variable does not exist, that
  was probably supposed to be utx.  Though that code isn't implemented
  so not that important.

* DESTDIR is not inherited from the environment in the makefiles, but
  instead assigned to the empty string.  autoconf packages typically
  inherit it from the environment.  This is easily fixed by adding
  DESTDIR?= instead, or simply removing the line as it already defaults
  to the empty string.

* The install makefile target has check-config as a prerequisite, which
  runs the compiled ssh, but this doesn't make sense in a cross 
  compilation situation. The build system should detect cross
  compilation and not do this.  check-config also doesn't have the
  installation of sshd as a prerequisite, so this might cause parallel
  make issues on some make implementations.

* $(LD) is used to link instead of $(CC) but LD might be set to 'ld'.
  This is a problem because C code is linked with the compiler so it
  links with the standard library.  All occurrences of $(LD) should be
  changed to $(CC) in the makefiles.

* config.sub and config.guess are from 2012.  It's important to keep
  them up to date with with the GNU config project, otherwise new
  machine types and operating systems won't be supported.  The git log
  mentions a concern about GPLv3 code.  The latest upstream files are
  GPLv3 but with the exception:

  "if you distribute this file as part of a program that contains a
   configuration script generated by Autoconf, you may include it under
   the same distribution terms that you use for the rest of that
   program". 

  This is the case with OpenSSH so it shouldn't be a problem to
  distribute new versions of those files.

* The install target runs install -s to strip the installed programs.
  However this runs strip(1) on the program, not $STRIP.  This matters
  when cross-compiling where the system strip might not correctly handle
  the programs.  This happened to me where it changed the OSABI ELF
  header value. The build system should instead respect the user CFLAGS
  and install a non-stripped version if that's what's built.  I hear
  some autoconf projects a install-strip target (though I haven't
  checked).  It's probably desirable to change the default from
  --enable-strip to --disable-strip as well.

Hopefully this is useful and things that makes sense to fix in the
official OpenSSH portable, as it would aid future ports to new operating
systems.  I patched around these issues locally.  I reproduced some of
these fixes properly in the OpenSSH portable git and included it as a
git diff below. I think the rest is better solved by you, but I can try
to submit diffs for those items if you prefer that.

This list is to get a process started, not necessarily because it's the
best way to submit work to you.  Please let me know if you would prefer
if I split this into a number of request.  As always, thanks for a great
piece of software.

Jonas

diff --git a/Makefile.in b/Makefile.in
index 9e32641..a020463 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19,7 +19,6 @@ piddir=@piddir@
 srcdir=@srcdir@
 top_srcdir=@top_srcdir@
 
-DESTDIR=
 VPATH=@srcdir@
 SSH_PROGRAM=@bindir@/ssh
 ASKPASS_PROGRAM=$(libexecdir)/ssh-askpass
@@ -163,41 +162,41 @@ libssh.a: $(LIBSSH_OBJS)
 	$(RANLIB) $@
 
 ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
-	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
+	$(CC) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
 
 sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
-	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
+	$(CC) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
 
 scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
-	$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
 
 ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
-	$(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
 
 ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
-	$(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
 
 ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
-	$(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
 
 ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o
-	$(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
 
 ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
-	$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
 
 ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
-	$(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
+	$(CC) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
 
 sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
-	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+	$(CC) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
 
 sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
-	$(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
+	$(CC) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
 
 # test driver for the loginrec code - not built by default
 logintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o
-	$(LD) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)
+	$(CC) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)
 
 $(MANPAGES): $(MANPAGES_IN)
 	if test "$(MANTYPE)" = "cat"; then \
@@ -456,7 +455,7 @@ UNITTESTS_TEST_SSHBUF_OBJS=\
 
 regress/unittests/sshbuf/test_sshbuf$(EXEEXT): ${UNITTESTS_TEST_SSHBUF_OBJS} \
     regress/unittests/test_helper/libtest_helper.a libssh.a
-	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHBUF_OBJS) \
+	$(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHBUF_OBJS) \
 	    regress/unittests/test_helper/libtest_helper.a \
 	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
 
@@ -469,7 +468,7 @@ UNITTESTS_TEST_SSHKEY_OBJS=\
 
 regress/unittests/sshkey/test_sshkey$(EXEEXT): ${UNITTESTS_TEST_SSHKEY_OBJS} \
     regress/unittests/test_helper/libtest_helper.a libssh.a
-	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHKEY_OBJS) \
+	$(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHKEY_OBJS) \
 	    regress/unittests/test_helper/libtest_helper.a \
 	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
 
@@ -478,7 +477,7 @@ UNITTESTS_TEST_BITMAP_OBJS=\
 
 regress/unittests/bitmap/test_bitmap$(EXEEXT): ${UNITTESTS_TEST_BITMAP_OBJS} \
     regress/unittests/test_helper/libtest_helper.a libssh.a
-	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_BITMAP_OBJS) \
+	$(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_BITMAP_OBJS) \
 	    regress/unittests/test_helper/libtest_helper.a \
 	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
 
@@ -489,7 +488,7 @@ UNITTESTS_TEST_KEX_OBJS=\
 
 regress/unittests/kex/test_kex$(EXEEXT): ${UNITTESTS_TEST_KEX_OBJS} \
     regress/unittests/test_helper/libtest_helper.a libssh.a
-	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_KEX_OBJS) \
+	$(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_KEX_OBJS) \
 	    regress/unittests/test_helper/libtest_helper.a \
 	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
 
@@ -500,7 +499,7 @@ UNITTESTS_TEST_HOSTKEYS_OBJS=\
 regress/unittests/hostkeys/test_hostkeys$(EXEEXT): \
     ${UNITTESTS_TEST_HOSTKEYS_OBJS} \
     regress/unittests/test_helper/libtest_helper.a libssh.a
-	$(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_HOSTKEYS_OBJS) \
+	$(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_HOSTKEYS_OBJS) \
 	    regress/unittests/test_helper/libtest_helper.a \
 	    -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
 
diff --git a/contrib/cygwin/Makefile b/contrib/cygwin/Makefile
index a0261f4..89c7dfd 100644
--- a/contrib/cygwin/Makefile
+++ b/contrib/cygwin/Makefile
@@ -14,8 +14,6 @@ inetdefdir=$(defaultsdir)/inetd.d
 PRIVSEP_PATH=/var/empty
 INSTALL=/usr/bin/install -c
 
-DESTDIR=
-
 all:
 	@echo
 	@echo "Use \`make cygwin-postinstall DESTDIR=[package directory]'"
diff --git a/deattack.c b/deattack.c
index e76481a..e5193db 100644
--- a/deattack.c
+++ b/deattack.c
@@ -97,7 +97,7 @@ check_crc(const u_char *S, const u_char *buf, u_int32_t len)
 void
 deattack_init(struct deattack_ctx *dctx)
 {
-	bzero(dctx, sizeof(*dctx));
+	memset(dctx, sizeof(*dctx));
 	dctx->n = HASH_MINSIZE / HASH_ENTRYSIZE;
 }
 
diff --git a/loginrec.c b/loginrec.c
index 788553e..332da3e 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -1032,7 +1032,7 @@ utmpx_perform_login(struct logininfo *li)
 		return (0);
 	}
 # else
-	if (!utmpx_write_direct(li, &ut)) {
+	if (!utmpx_write_direct(li, &utx)) {
 		logit("%s: utmp_write_direct() failed", __func__);
 		return (0);
 	}
diff --git a/misc.c b/misc.c
index 3170218..aee3631 100644
--- a/misc.c
+++ b/misc.c
@@ -29,6 +29,9 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
 #include <sys/un.h>
 
 #include <limits.h>
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 2a788e4..97ccf70 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -105,7 +105,7 @@ const char *strerror(int e)
 #endif
 
 #ifndef HAVE_UTIMES
-int utimes(char *filename, struct timeval *tvp)
+int utimes(const char *filename, struct timeval *tvp)
 {
 	struct utimbuf ub;
 
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 0d81d17..7e77bd2 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -63,7 +63,7 @@ struct timeval {
 }
 #endif /* HAVE_STRUCT_TIMEVAL */
 
-int utimes(char *, struct timeval *);
+int utimes(const char *, struct timeval *);
 #endif /* HAVE_UTIMES */
 
 #ifndef HAVE_TRUNCATE
diff --git a/openbsd-compat/strptime.c b/openbsd-compat/strptime.c
index d8d83d9..8958767 100644
--- a/openbsd-compat/strptime.c
+++ b/openbsd-compat/strptime.c
@@ -68,7 +68,9 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int initialize)
 {
 	unsigned char c;
 	const unsigned char *bp;
+#if 0
 	size_t len;
+#endif
 	int alt_format, i;
 	static int century, relyear;
 
diff --git a/regress/modpipe.c b/regress/modpipe.c
index e854f9e..0ccd222 100755
--- a/regress/modpipe.c
+++ b/regress/modpipe.c
@@ -78,7 +78,7 @@ parse_modification(const char *s, struct modification Hi,

I recently ported OpenSSH to my hobbyist operating system. The portable
release is very straightforward to work with, but it had a few minor issues
where it assumes the existence of things that might not be on a POSIX 2008
system. This are the list of issues I encountered that I believe makes
sense to upstream.

* <sys/param.h> is included in many files and isn't a standard header. The
portability layer already handles all the things it might provide and I
could just remove all its inclusions. The build system should just detect
its absence and generate an empty header in openbsd-compat/.

* bzero is used in deattack.c (and in regress/) instead of the standard
memset. The code should be changed to use memset or the compatibility
layer should provide its own bzero if absent.

* misc.c uses gettimeofday but doesn't include <sys/time.h> to get it.

* timerclear, timerisset and timercmp are used in misc.c and ssh-keyscan.c.
They are non-standard BSD extensions from <sys/time.h>. The build system
should detect their lack and provide its own versions, or the code could
be rewritten to not use them.

* u_short and u_long are used across the codebase, but defines.h only
provides u_char and u_int.

* size_t len in openbsd-compat/strptime.c is unused and causes a warning.
It's used below by code that's commented out and the variable should be
commented out too.

* utimes in openbsd-compat has char * for the path parameter but that's
supposed to be const char *.

* loginrec.c in utmpx_perform_login does a call to utmpx_write_direct with a
parameter named ut, but such a variable does not exist, that was probably
supposed to be utx. Though that code isn't implemented so not that
important.

* DESTDIR is not inherited from the environment in the makefiles, but
instead assigned to the empty string. autoconf packages typically inherit
it from the environment. This is easily fixed by adding DESTDIR?=
instead, or simply removing the line as it already defaults to the empty
string.

* The install makefile target has check-config as a prerequisite, which runs
the compiled ssh, but this doesn't make sense in a cross-compilation
situation. The build system should detect cross-compilation and not do
this. check-config also doesn't have the installation of sshd as a
prerequisite, so this might cause parallel make issues on some make
implementations.

* $(LD) is used to link instead of $(CC) but LD might be set to 'ld'. This
is a problem because C code is linked with the compiler so it links with
the standard library. All occurrences of $(LD) should be changed to $(CC)
in the makefiles.

* config.sub and config.guess are from 2012. It's important to keep them up
to date with with the GNU config project, otherwise new machine types and
operating systems won't be supported. The git log mentions a concern
about GPLv3 code. The latest upstream files are GPLv3 but with the
exception:

"if you distribute this file as part of a program that contains a
configuration script generated by Autoconf, you may include it under the
same distribution terms that you use for the rest of that program".

This is the case with OpenSSH so it shouldn't be a problem to distribute
new versions of those files.

* The install target runs install -s to strip the installed programs.
However this runs strip(1) on the program, not $STRIP. This matters when
cross-compiling where the system strip might not correctly handle the
programs. This happened to me where it changed the OSABI ELF header
value. The build system should instead respect the user CFLAGS and install
a non-stripped version if that's what's built. I hear some autoconf
projects a install-strip target (though I haven't checked). It's probably
desirable to change the default from --enable-strip to --disable-strip as
well.

Hopefully this is useful and things that makes sense to fix in the official
OpenSSH portable, as it would aid future ports to new operating systems. I
patched around these issues locally. I reproduced some of these fixes
properly in the OpenSSH portable git and included it as a git diff below. I
think the rest is better solved by you, but I can try to submit diffs for
those items if you prefer that.

This list is to get a process started, not necessarily because it's the best
way to submit work to you. Please let me know if you would prefer if I
split this into a number of request. As always, thanks for a great piece
of software.

Jonas

diff --git a/Makefile.in b/Makefile.in
index 9e32641..a020463 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19,7 +19,6 @@ piddir=@piddir@
srcdir=@srcdir@
top_srcdir=@top_srcdir@

-DESTDIR=
VPATH=@srcdir@
SSH_PROGRAM=@bindir@/ssh
ASKPASS_PROGRAM=$(libexecdir)/ssh-askpass
@@ -163,41 +162,41 @@ libssh.a: $(LIBSSH_OBJS)
$(RANLIB) $@

ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
- $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
+ $(CC) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)

sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
- $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
+ $(CC) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)

scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
- $(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)

ssh-add$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-add.o
- $(LD) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ ssh-add.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)

ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o ssh-pkcs11-client.o
- $(LD) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ ssh-agent.o ssh-pkcs11-client.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)

ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
- $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)

ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o readconf.o
- $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)

ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11.o
- $(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)

ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
- $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
+ $(CC) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)

sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
- $(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ $(CC) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)

sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
- $(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
+ $(CC) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)

# test driver for the loginrec code - not built by default
logintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o
- $(LD) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)
+ $(CC) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)

$(MANPAGES): $(MANPAGES_IN)
if test "$(MANTYPE)" = "cat"; then \
@@ -456,7 +455,7 @@ UNITTESTS_TEST_SSHBUF_OBJS=\

regress/unittests/sshbuf/test_sshbuf$(EXEEXT): ${UNITTESTS_TEST_SSHBUF_OBJS} \
regress/unittests/test_helper/libtest_helper.a libssh.a
- $(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHBUF_OBJS) \
+ $(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHBUF_OBJS) \
regress/unittests/test_helper/libtest_helper.a \
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)

@@ -469,7 +468,7 @@ UNITTESTS_TEST_SSHKEY_OBJS=\

regress/unittests/sshkey/test_sshkey$(EXEEXT): ${UNITTESTS_TEST_SSHKEY_OBJS} \
regress/unittests/test_helper/libtest_helper.a libssh.a
- $(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHKEY_OBJS) \
+ $(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_SSHKEY_OBJS) \
regress/unittests/test_helper/libtest_helper.a \
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)

@@ -478,7 +477,7 @@ UNITTESTS_TEST_BITMAP_OBJS=\

regress/unittests/bitmap/test_bitmap$(EXEEXT): ${UNITTESTS_TEST_BITMAP_OBJS} \
regress/unittests/test_helper/libtest_helper.a libssh.a
- $(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_BITMAP_OBJS) \
+ $(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_BITMAP_OBJS) \
regress/unittests/test_helper/libtest_helper.a \
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)

@@ -489,7 +488,7 @@ UNITTESTS_TEST_KEX_OBJS=\

regress/unittests/kex/test_kex$(EXEEXT): ${UNITTESTS_TEST_KEX_OBJS} \
regress/unittests/test_helper/libtest_helper.a libssh.a
- $(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_KEX_OBJS) \
+ $(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_KEX_OBJS) \
regress/unittests/test_helper/libtest_helper.a \
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)

@@ -500,7 +499,7 @@ UNITTESTS_TEST_HOSTKEYS_OBJS=\
regress/unittests/hostkeys/test_hostkeys$(EXEEXT): \
${UNITTESTS_TEST_HOSTKEYS_OBJS} \
regress/unittests/test_helper/libtest_helper.a libssh.a
- $(LD) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_HOSTKEYS_OBJS) \
+ $(CC) -o $@ $(LDFLAGS) $(UNITTESTS_TEST_HOSTKEYS_OBJS) \
regress/unittests/test_helper/libtest_helper.a \
-lssh -lopenbsd-compat -lssh -lopenbsd-compat $(LIBS)

diff --git a/contrib/cygwin/Makefile b/contrib/cygwin/Makefile
index a0261f4..89c7dfd 100644
--- a/contrib/cygwin/Makefile
+++ b/contrib/cygwin/Makefile
@@ -14,8 +14,6 @@ inetdefdir=$(defaultsdir)/inetd.d
PRIVSEP_PATH=/var/empty
INSTALL=/usr/bin/install -c

-DESTDIR=
-
all:
@echo
@echo "Use \`make cygwin-postinstall DESTDIR=[package directory]'"
diff --git a/deattack.c b/deattack.c
index e76481a..e5193db 100644
--- a/deattack.c
+++ b/deattack.c
@@ -97,7 +97,7 @@ check_crc(const u_char *S, const u_char *buf, u_int32_t len)
void
deattack_init(struct deattack_ctx *dctx)
{
- bzero(dctx, sizeof(*dctx));
+ memset(dctx, sizeof(*dctx));
dctx->n = HASH_MINSIZE / HASH_ENTRYSIZE;
}

diff --git a/loginrec.c b/loginrec.c
index 788553e..332da3e 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -1032,7 +1032,7 @@ utmpx_perform_login(struct logininfo *li)
return (0);
}
# else
- if (!utmpx_write_direct(li, &ut)) {
+ if (!utmpx_write_direct(li, &utx)) {
logit("%s: utmp_write_direct() failed", __func__);
return (0);
}
diff --git a/misc.c b/misc.c
index 3170218..aee3631 100644
--- a/misc.c
+++ b/misc.c
@@ -29,6 +29,9 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/un.h>

#include <limits.h>
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 2a788e4..97ccf70 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -105,7 +105,7 @@ const char *strerror(int e)
#endif

#ifndef HAVE_UTIMES
-int utimes(char *filename, struct timeval *tvp)
+int utimes(const char *filename, struct timeval *tvp)
{
struct utimbuf ub;

diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 0d81d17..7e77bd2 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -63,7 +63,7 @@ struct timeval {
}
#endif /* HAVE_STRUCT_TIMEVAL */

-int utimes(char *, struct timeval *);
+int utimes(const char *, struct timeval *);
#endif /* HAVE_UTIMES */

#ifndef HAVE_TRUNCATE
diff --git a/openbsd-compat/strptime.c b/openbsd-compat/strptime.c
index d8d83d9..8958767 100644
--- a/openbsd-compat/strptime.c
+++ b/openbsd-compat/strptime.c
@@ -68,7 +68,9 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int initialize)
{
unsigned char c;
const unsigned char *bp;
+#if 0
size_t len;
+#endif
int alt_format, i;
static int century, relyear;

diff --git a/regress/modpipe.c b/regress/modpipe.c
index e854f9e..0ccd222 100755
--- a/regress/modpipe.c
+++ b/regress/modpipe.c
@@ -78,7 +78,7 @@ parse_modification(const char *s, struct modification *m)
char what[16+1];
int n, m1, m2;

- bzero(m, sizeof(*m));
+ memset(m, 0, sizeof(*m));
if ((n = sscanf(s, "%16[^:]%*[:]%llu%*[:]%i%*[:]%i",
what, &m->offset, &m1, &m2)) < 3)
errx(1, "Invalid modification spec \"%s\"", s);
diff --git a/regress/netcat.c b/regress/netcat.c
index 6234ba0..198a838 100644
--- a/regress/netcat.c
+++ b/regress/netcat.c
@@ -1061,7 +1061,7 @@ fdpass(int nfd)
msg.msg_iov = &vec;
msg.msg_iovlen = 1;

- bzero(&pfd, sizeof(pfd));
+ memset(&pfd, 0, sizeof(pfd));
pfd.fd = STDOUT_FILENO;
for (;;) {
r = sendmsg(STDOUT_FILENO, &msg, 0);*m)
 	char what[16+1];
 	int n, m1, m2;
 
-	bzero(m, sizeof(*m));
+	memset(m, 0, sizeof(*m));
 	if ((n = sscanf(s, "%16[^:]%*[:]%llu%*[:]%i%*[:]%i",
 	    what, &m->offset, &m1, &m2)) < 3)
 		errx(1, "Invalid modification spec \"%s\"", s);
diff --git a/regress/netcat.c b/regress/netcat.c
index 6234ba0..198a838 100644
--- a/regress/netcat.c
+++ b/regress/netcat.c
@@ -1061,7 +1061,7 @@ fdpass(int nfd)
 	msg.msg_iov = &vec;
 	msg.msg_iovlen = 1;
 
-	bzero(&pfd, sizeof(pfd));
+	memset(&pfd, 0, sizeof(pfd));
 	pfd.fd = STDOUT_FILENO;
 	for (;;) {
 		r = sendmsg(STDOUT_FILENO, &msg, 0);


More information about the openssh-unix-dev mailing list