SCO patch attempt.

mouring at etoh.eviladmin.org mouring at etoh.eviladmin.org
Fri Jan 12 15:00:26 EST 2001


Since I don't have a SCO access I need you to try this, Tim.

1. Added utimes() support via utime() interface.
2. First wack at 32bit sftp-server.  

Markus,

Can you skim the patch?  The only aspect that I think is wrong (looking
back) is the use of SSH2_OP_UNSUPPORTED in read/write.  There should be
SSH2_FX_TRUNCATE in the specs to account for such a case, but maybe I
should be using SSH2_FX_EOF.  Or maybe in process_open() should return
SSH2_OP_UNSUPPORTED  if a->high_size > 0.. But.. There is nothing in the
sftp specs to handle such a case.  So I suspect some odd behavior
eitherway.

- Ben

diff -ur openssh/bsd-misc.c ossh/bsd-misc.c
--- openssh/bsd-misc.c	Thu Nov 16 21:47:20 2000
+++ ossh/bsd-misc.c	Thu Jan 11 21:32:30 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 
diff -ur openssh/bsd-misc.h ossh/bsd-misc.h
--- openssh/bsd-misc.h	Thu Nov 16 21:47:20 2000
+++ ossh/bsd-misc.h	Thu Jan 11 21:34:12 2001
@@ -54,4 +54,15 @@
 const char *strerror(int e);
 #endif 
 
+
+#ifndef HAVE_UTIMES
+struct timeval {
+	long tv_sec;
+	long tv_usec;
+}
+
+int utimes(char *filename, struct timeval *tvp);
+#endif 
+
+
 #endif /* _BSD_MISC_H */
diff -ur openssh/bufaux.c ossh/bufaux.c
--- openssh/bufaux.c	Thu Jan 11 00:56:25 2001
+++ ossh/bufaux.c	Thu Jan 11 21:28:32 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
diff -ur openssh/bufaux.h ossh/bufaux.h
--- openssh/bufaux.h	Thu Jan 11 00:56:25 2001
+++ ossh/bufaux.h	Thu Jan 11 21:29:10 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);
diff -ur openssh/configure.in ossh/configure.in
--- openssh/configure.in	Wed Jan 10 21:46:49 2001
+++ ossh/configure.in	Thu Jan 11 21:38:14 2001
@@ -316,7 +316,7 @@
 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)
 
 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 utimes vsnprintf vhangup vis waitpid _getpty __b64_ntop)
 dnl    Checks for time functions
 AC_CHECK_FUNCS(gettimeofday time)
 dnl    Checks for libutil functions
@@ -830,7 +830,7 @@
 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='#'
+	NO_SFTP=""
 	AC_SUBST(NO_SFTP)
 fi
 
diff -ur openssh/getput.h ossh/getput.h
--- openssh/getput.h	Thu Jan 11 00:56:25 2001
+++ ossh/getput.h	Thu Jan 11 21:27: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; \
diff -ur openssh/sftp-server.c ossh/sftp-server.c
--- openssh/sftp-server.c	Thu Jan 11 21:09:05 2001
+++ ossh/sftp-server.c	Thu Jan 11 21:27:00 2001
@@ -33,7 +33,9 @@
 #include "sftp.h"
 
 /* helper */
+#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
@@ -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_int32(b);
+		a.low_size = buffer_get_int32(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_int32(b, a->high_size);
+		buffer_put_int32(b, a->high_low);
+#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_int32() > 0) {
+		send_status(id, SSH2_OP_UNSUPPORTED);
+		return;
+	}
+	off = get_int32();
+#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_int32() > 0) {
+		send_status(id, SSH2_OP_UNSUPPORTED);
+		return;
+	}
+	off = get_int32();
+#else
 	off = get_int64();
+#endif
 	data = get_string(&len);
 
 	TRACE("write id %d handle %d off %lld len %d", id, handle, off, len);







More information about the openssh-unix-dev mailing list