SCO patch attempt.

Tim Rice tim at multitalents.net
Mon Jan 15 07:34:06 EST 2001


On Fri, 12 Jan 2001 mouring at etoh.eviladmin.org wrote:

> On Thu, 11 Jan 2001, Tim Rice wrote:
> 
> > l/libexec/ssh-askpass\" -DHAVE_CONFIG_H -c src/bsd-arc4random.c
> > UX:acomp: ERROR: "src/bsd-misc.h", line 59: (struct) tag redeclared: timeval
> > UX:acomp: ERROR: "src/bsd-misc.h", line 64: invalid type combination
> > gmake: *** [bsd-arc4random.o] Error 1
> > ...
> 
> Ermm.. What other commands use 'timeval'?  If you have a valid
> timeval.  Then one is going to have to test the existance of timeval like
> they do other structures and set or not-set accordingly.

Yup, that's obvious after a good nights sleep. ;-)

I did some work on your patch and it now builds on 
Solaris 7 
UnixWare 2.03
UnixWare 2.1.3
UnixWare 7.1.0
Caldera eDesktop 2.4
RedHat 6.2
SCO Open Server 5.0.4

It would build on SCO Open Server 3 (aka 3.2v4.2) but there is no
fchmod() in this platform.
...
gcc -o sftp-server sftp-server.o log-server.o -L.  -L/usr/local/lib -L/usr/local
/ssl/lib -L/usr/local/ssl -lssh -lopenbsd-compat -lz -lsocket  -lgen -lsocket -l
os -lprot -lx -ltinfo -lm -lcrypto
undefined                       first referenced
 symbol                             in file
fchmod                              sftp-server.o
ld fatal: Symbol referencing errors. No output written to sftp-server
gmake: *** [sftp-server] Error 1
...

I didn't see an easy way to do an #ifdef HAVE_FCHMOD like
in scp.c

> 
> - Ben
> 

-- 
Tim Rice				Multitalents	(707) 887-1469
tim at multitalents.net


-------------- next part --------------
--- openssh_cvs/acconfig.h.old	Thu Jan 11 20:30:18 2001
+++ openssh_cvs/acconfig.h	Fri Jan 12 12:17:01 2001
@@ -103,6 +103,9 @@
  * message at run-time. */
 #undef RSAREF
 
+/* struct timeval */
+#undef HAVE_STRUCT_TIMEVAL
+
 /* struct utmp and struct utmpx fields */
 #undef HAVE_HOST_IN_UTMP
 #undef HAVE_HOST_IN_UTMPX
--- openssh_cvs/bsd-misc.c.old	Thu Nov 16 19:47:20 2000
+++ openssh_cvs/bsd-misc.c	Fri Jan 12 10:30:14 2001
@@ -80,3 +80,15 @@
 		return(sys_errlist[e]);
 }
 #endif
+
+#ifndef HAVE_UTIMES
+int utimes(char *filename, struct timeval *tvp)
+{
+	struct utimbuf ub;
+
+	ub.actime = tvp->tv_sec;
+	ub.modtime = tvp->tv_usec;
+	
+	return(utime(filename, &ub));
+}
+#endif 
--- openssh_cvs/bsd-misc.h.old	Thu Nov 16 19:47:20 2000
+++ openssh_cvs/bsd-misc.h	Fri Jan 12 12:18:41 2001
@@ -54,4 +54,17 @@
 const char *strerror(int e);
 #endif 
 
+
+#ifndef HAVE_UTIMES
+#ifndef HAVE_STRUCT_TIMEVAL
+struct timeval {
+	long tv_sec;
+	long tv_usec;
+}
+#endif /* HAVE_STRUCT_TIMEVAL */
+
+int utimes(char *filename, struct timeval *tvp);
+#endif /* HAVE_UTIMES */
+
+
 #endif /* _BSD_MISC_H */
--- openssh_cvs/bufaux.c.old	Thu Jan 11 20:30:20 2001
+++ openssh_cvs/bufaux.c	Fri Jan 12 12:47:50 2001
@@ -152,6 +152,7 @@
 	return GET_32BIT(buf);
 }
 
+#ifdef HAVE_U_INT64_T
 u_int64_t
 buffer_get_int64(Buffer *buffer)
 {
@@ -159,6 +160,7 @@
 	buffer_get(buffer, (char *) buf, 8);
 	return GET_64BIT(buf);
 }
+#endif
 
 /*
  * Stores an integer in the buffer in 4 bytes, msb first.
@@ -171,6 +173,7 @@
 	buffer_append(buffer, buf, 4);
 }
 
+#ifdef HAVE_U_INT64_T
 void
 buffer_put_int64(Buffer *buffer, u_int64_t value)
 {
@@ -178,6 +181,7 @@
 	PUT_64BIT(buf, value);
 	buffer_append(buffer, buf, 8);
 }
+#endif
 
 /*
  * Returns an arbitrary binary string from the buffer.  The string cannot
--- openssh_cvs/bufaux.h.old	Thu Jan 11 20:30:20 2001
+++ openssh_cvs/bufaux.h	Fri Jan 12 12:47:50 2001
@@ -30,11 +30,15 @@
 
 /* Returns an integer from the buffer (4 bytes, msb first). */
 u_int buffer_get_int(Buffer * buffer);
+#ifdef HAVE_U_INT64_T
 u_int64_t buffer_get_int64(Buffer *buffer);
+#endif
 
 /* Stores an integer in the buffer in 4 bytes, msb first. */
 void    buffer_put_int(Buffer * buffer, u_int value);
+#ifdef HAVE_U_INT64_T
 void	buffer_put_int64(Buffer *buffer, u_int64_t value);
+#endif
 
 /* Returns a character from the buffer (0 - 255). */
 int     buffer_get_char(Buffer * buffer);
--- openssh_cvs/configure.in.old	Thu Jan 11 20:30:25 2001
+++ openssh_cvs/configure.in	Fri Jan 12 18:01:35 2001
@@ -313,10 +313,10 @@
 )
 
 # Checks for header files.
-AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h getopt.h lastlog.h limits.h login.h login_cap.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/queue.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h sys/un.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h vis.h)
+AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h getopt.h lastlog.h limits.h login.h login_cap.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/queue.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h sys/un.h stddef.h time.h ttyent.h usersec.h util.h utime.h utmp.h utmpx.h vis.h)
 
 dnl    Checks for library functions.
-AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock fchmod freeaddrinfo futimes gai_strerror getcwd getaddrinfo getnameinfo getrlimit getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty realpath rresvport_af setdtablesize setenv seteuid setlogin setproctitle setreuid setrlimit setsid sigaction sigvec snprintf strerror strlcat strlcpy strsep strtok_r sysconf vsnprintf vhangup vis waitpid _getpty __b64_ntop)
+AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock fchmod freeaddrinfo futimes gai_strerror getcwd getaddrinfo getnameinfo getrlimit getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty realpath rresvport_af setdtablesize setenv seteuid setlogin setproctitle setreuid setrlimit setsid sigaction sigvec snprintf strerror strlcat strlcpy strsep strtok_r sysconf utime utimes vsnprintf vhangup vis waitpid _getpty __b64_ntop)
 dnl    Checks for time functions
 AC_CHECK_FUNCS(gettimeofday time)
 dnl    Checks for libutil functions
@@ -825,14 +825,27 @@
 	AC_DEFINE(HAVE_STRUCT_ADDRINFO)
 fi
 
+AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
+	AC_TRY_COMPILE(
+		[ #include <sys/time.h> ], 
+		[ struct timeval tv; tv.tv_sec = 1;], 
+		[ ac_cv_have_struct_timeval="yes" ],
+		[ ac_cv_have_struct_timeval="no" ]
+	)
+])
+if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
+	AC_DEFINE(HAVE_STRUCT_TIMEVAL)
+	have_struct_timeval=1
+fi
+
 # If we don't have int64_t then we can't compile sftp-server.  So don't
 # even attempt to do it. 
-if test "x$ac_cv_have_int64_t" = "xno" -a \
-	"x$ac_cv_sizeof_long_int" != "x8" -a \
-	"x$ac_cv_sizeof_long_long_int" = "x0" ; then
-	NO_SFTP='#'
-	AC_SUBST(NO_SFTP)
-fi
+#if test "x$ac_cv_have_int64_t" = "xno" -a \
+#	"x$ac_cv_sizeof_long_int" != "x8" -a \
+#	"x$ac_cv_sizeof_long_long_int" = "x0" ; then
+#	NO_SFTP='#'
+#fi
+AC_SUBST(NO_SFTP)
 
 dnl Checks for structure members
 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
--- openssh_cvs/defines.h.old	Thu Jan 11 20:30:26 2001
+++ openssh_cvs/defines.h	Fri Jan 12 12:46:05 2001
@@ -171,20 +171,22 @@
 #ifndef HAVE_INT64_T
 # if (SIZEOF_LONG_INT == 8)
 typedef long int int64_t;
+#   define HAVE_INT64_T 1
 # else
 #  if (SIZEOF_LONG_LONG_INT == 8)
 typedef long long int int64_t;
-#   define HAVE_INTXX_T 1
+#   define HAVE_INT64_T 1
 #  endif
 # endif
 #endif
 #ifndef HAVE_U_INT64_T
 # if (SIZEOF_LONG_INT == 8)
 typedef unsigned long int u_int64_t;
+#   define HAVE_U_INT64_T 1
 # else
 #  if (SIZEOF_LONG_LONG_INT == 8)
 typedef unsigned long long int u_int64_t;
-#   define HAVE_U_INTXX_T 1
+#   define HAVE_U_INT64_T 1
 #  endif
 # endif
 #endif
--- openssh_cvs/getput.h.old	Thu Jan 11 20:30:26 2001
+++ openssh_cvs/getput.h	Fri Jan 12 12:47:50 2001
@@ -18,6 +18,7 @@
 
 /*------------ macros for storing/extracting msb first words -------------*/
 
+#ifdef HAVE_U_INT64_T
 #define GET_64BIT(cp) (((u_int64_t)(u_char)(cp)[0] << 56) | \
 		       ((u_int64_t)(u_char)(cp)[1] << 48) | \
 		       ((u_int64_t)(u_char)(cp)[2] << 40) | \
@@ -26,6 +27,7 @@
 		       ((u_int64_t)(u_char)(cp)[5] << 16) | \
 		       ((u_int64_t)(u_char)(cp)[6] << 8) | \
 		       ((u_int64_t)(u_char)(cp)[7]))
+#endif
 
 #define GET_32BIT(cp) (((u_long)(u_char)(cp)[0] << 24) | \
 		       ((u_long)(u_char)(cp)[1] << 16) | \
@@ -35,6 +37,7 @@
 #define GET_16BIT(cp) (((u_long)(u_char)(cp)[0] << 8) | \
 		       ((u_long)(u_char)(cp)[1]))
 
+#ifdef HAVE_U_INT64_T
 #define PUT_64BIT(cp, value) do { \
   (cp)[0] = (value) >> 56; \
   (cp)[1] = (value) >> 48; \
@@ -44,6 +47,7 @@
   (cp)[5] = (value) >> 16; \
   (cp)[6] = (value) >> 8; \
   (cp)[7] = (value); } while (0)
+#endif
 
 #define PUT_32BIT(cp, value) do { \
   (cp)[0] = (value) >> 24; \
--- openssh_cvs/includes.h.old	Thu Jan 11 20:30:26 2001
+++ openssh_cvs/includes.h	Thu Jan 11 22:16:57 2001
@@ -85,6 +85,9 @@
 #ifdef HAVE_SYS_SYSMACROS_H
 # include <sys/sysmacros.h>
 #endif
+#ifdef HAVE_UTIME_H
+# include <utime.h>
+#endif
 #ifdef HAVE_VIS_H
 # include <vis.h>
 #endif
--- openssh_cvs/sftp-server.c.old	Thu Jan 11 20:30:32 2001
+++ openssh_cvs/sftp-server.c	Fri Jan 12 16:08:26 2001
@@ -33,9 +33,11 @@
 #include "sftp.h"
 
 /* helper */
-#define get_int64()			buffer_get_int64(&iqueue);
-#define get_int()			buffer_get_int(&iqueue);
-#define get_string(lenp)		buffer_get_string(&iqueue, lenp);
+#ifdef HAVE_U_INT64_T
+#define get_int64()			buffer_get_int64(&iqueue)
+#endif
+#define get_int()			buffer_get_int(&iqueue)
+#define get_string(lenp)		buffer_get_string(&iqueue, lenp)
 #define TRACE				debug
 
 #ifdef HAVE___PROGNAME
@@ -56,7 +58,12 @@
 struct Attrib
 {
 	u_int32_t	flags;
+#ifndef HAVE_U_INT64_T
+	u_int32_t	high_size;
+	u_int32_t	low_size;
+#else
 	u_int64_t	size;
+#endif
 	u_int32_t	uid;
 	u_int32_t	gid;
 	u_int32_t	perm;
@@ -126,7 +133,12 @@
 attrib_clear(Attrib *a)
 {
 	a->flags = 0;
+#ifndef HAVE_U_INT64_T
+	a->high_size = 0;
+	a->low_size = 0;
+#else
 	a->size = 0;
+#endif
 	a->uid = 0;
 	a->gid = 0;
 	a->perm = 0;
@@ -141,7 +153,12 @@
 	attrib_clear(&a);
 	a.flags = buffer_get_int(b);
 	if (a.flags & SSH2_FILEXFER_ATTR_SIZE) {
+#ifndef HAVE_U_INT64_T
+		a.high_size = buffer_get_int(b);
+		a.low_size = buffer_get_int(b);
+#else
 		a.size = buffer_get_int64(b);
+#endif
 	}
 	if (a.flags & SSH2_FILEXFER_ATTR_UIDGID) {
 		a.uid = buffer_get_int(b);
@@ -174,7 +191,12 @@
 {
 	buffer_put_int(b, a->flags);
 	if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
+#ifndef HAVE_U_INT64_T
+		buffer_put_int(b, a->high_size);
+		buffer_put_int(b, a->low_size);
+#else
 		buffer_put_int64(b, a->size);
+#endif
 	}
 	if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
 		buffer_put_int(b, a->uid);
@@ -196,7 +218,12 @@
 	attrib_clear(&a);
 	a.flags = 0;
 	a.flags |= SSH2_FILEXFER_ATTR_SIZE;
+#ifndef HAVE_U_INT64_T
+	a.low_size = st->st_size;
+	a.high_size = 0;
+#else
 	a.size = st->st_size;
+#endif
 	a.flags |= SSH2_FILEXFER_ATTR_UIDGID;
 	a.uid = st->st_uid;
 	a.gid = st->st_gid;
@@ -495,11 +522,23 @@
 	char buf[64*1024];
 	u_int32_t id, len;
 	int handle, fd, ret, status = SSH2_FX_FAILURE;
+#ifndef HAVE_U_INT64_T
+	u_int32_t off;
+#else
 	u_int64_t off;
+#endif
 
 	id = get_int();
 	handle = get_handle();
+#ifndef HAVE_U_INT64_T
+	if (get_int() > 0) {
+		send_status(id, SSH2_FX_OP_UNSUPPORTED);
+		return;
+	}
+	off = get_int();
+#else
 	off = get_int64();
+#endif
 	len = get_int();
 
 	TRACE("read id %d handle %d off %lld len %d", id, handle, off, len);
@@ -532,14 +571,26 @@
 process_write(void)
 {
 	u_int32_t id;
+#ifndef HAVE_U_INT64_T
+	u_int32_t off;
+#else
 	u_int64_t off;
+#endif
 	u_int len;
 	int handle, fd, ret, status = SSH2_FX_FAILURE;
 	char *data;
 
 	id = get_int();
 	handle = get_handle();
+#ifndef HAVE_U_INT64_T
+	if (get_int() > 0) {
+		send_status(id, SSH2_FX_OP_UNSUPPORTED);
+		return;
+	}
+	off = get_int();
+#else
 	off = get_int64();
+#endif
 	data = get_string(&len);
 
 	TRACE("write id %d handle %d off %lld len %d", id, handle, off, len);
@@ -741,9 +792,15 @@
 ls_file(char *name, struct stat *st)
 {
 	char buf[1024];
+#ifdef HAVE_U_INT64_T
 	snprintf(buf, sizeof buf, "0%o %d %d %lld %d %s",
 	    st->st_mode, st->st_uid, st->st_gid, (long long)st->st_size,
            (int)st->st_mtime, name);
+#else
+	snprintf(buf, sizeof buf, "0%o %d %d %lld %d %s",
+	    st->st_mode, st->st_uid, st->st_gid, st->st_size,
+           (int)st->st_mtime, name);
+#endif
 	return xstrdup(buf);
 }
 


More information about the openssh-unix-dev mailing list