- try to merge and clean up all the large file support for ftp and rcp

This commit is contained in:
Nalin Dahyabhai 2009-07-01 17:52:16 +00:00
parent 1917c4e1aa
commit 6f1fb7d51e
4 changed files with 261 additions and 71 deletions

View File

@ -1,28 +0,0 @@
The size might be a long long, so deal with that.
--- krb5-1.3/src/appl/gssftp/ftpd/ftpcmd.y
+++ krb5-1.3/src/appl/gssftp/ftpd/ftpcmd.y
@@ -1515,12 +1515,12 @@
(stbuf.st_mode&S_IFMT) != S_IFREG)
reply(550, "%s: not a plain file.", filename);
else
- reply(213, "%lu", (long) stbuf.st_size);
+ reply(213, "%llu", (long long) stbuf.st_size);
break;}
case TYPE_A: {
FILE *fin;
register int c;
- register long count;
+ register long long count;
struct stat stbuf;
fin = fopen(filename, "r");
if (fin == NULL) {
@@ -1542,7 +1542,7 @@
}
(void) fclose(fin);
- reply(213, "%ld", count);
+ reply(213, "%lld", count);
break;}
default:
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);

250
krb5-1.7-largefile.patch Normal file
View File

@ -0,0 +1,250 @@
Turn on large file support in gssftp and rcp. The size of off_t might
be more than that of a long, so if we have a "long long" type, assume
that format specifiers for it work correctly and that we need to
represent off_t values as such.
diff -up krb5/src/appl/gssftp/configure.in krb5/src/appl/gssftp/configure.in
--- krb5/src/appl/gssftp/configure.in 2009-06-29 17:49:43.000000000 -0400
+++ krb5/src/appl/gssftp/configure.in 2009-06-29 17:49:36.000000000 -0400
@@ -12,6 +12,9 @@ DECLARE_SYS_ERRLIST
AC_HEADER_STDARG
AC_CHECK_HEADER(termios.h,[AC_CHECK_FUNC(cfsetispeed,AC_DEFINE(POSIX_TERMIOS,1,[Define if POSIX termios interface found]))])
AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/select.h sys/sockio.h paths.h)
+AC_SYS_LARGEFILE
+AC_FUNC_FSEEKO
+AC_CHECK_TYPES([long long])
CHECK_UTMP
DECLARE_SYS_ERRLIST
AC_REPLACE_FUNCS(getdtablesize)
--- krb5/src/appl/gssftp/ftpd/ftpcmd.y
+++ krb5/src/appl/gssftp/ftpd/ftpcmd.y
@@ -1515,12 +1515,20 @@
(stbuf.st_mode&S_IFMT) != S_IFREG)
reply(550, "%s: not a plain file.", filename);
else
+#ifdef HAVE_LONG_LONG
+ reply(213, "%llu", (long long) stbuf.st_size);
+#else
reply(213, "%lu", (long) stbuf.st_size);
+#endif
break;}
case TYPE_A: {
FILE *fin;
register int c;
+#ifdef HAVE_LONG_LONG
+ register long long count;
+#else
register long count;
+#endif
struct stat stbuf;
fin = fopen(filename, "r");
if (fin == NULL) {
@@ -1542,7 +1542,11 @@
}
(void) fclose(fin);
+#ifdef HAVE_LONG_LONG
+ reply(213, "%lld", count);
+#else
reply(213, "%ld", count);
+#endif
break;}
default:
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
diff -up krb5/src/appl/bsd/configure.in krb5-1.7/src/appl/bsd/configure.in
--- krb5/src/appl/bsd/configure.in 2009-06-04 14:02:56.000000000 -0400
+++ krb5/src/appl/bsd/configure.in 2009-06-04 14:02:56.000000000 -0400
@@ -53,6 +53,9 @@ AC_FUNC_VFORK
AC_TYPE_MODE_T
AC_CHECK_FUNCS(isatty inet_aton getenv gettosbyname killpg initgroups setpriority setreuid setresuid waitpid setsid ptsname setlogin tcgetpgrp tcsetpgrp setpgid strsave utimes rmufile rresvport_af)
AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/filio.h sys/sockio.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h utmp.h sys/time.h sys/ioctl_compat.h paths.h arpa/nameser.h)
+AC_SYS_LARGEFILE
+AC_FUNC_FSEEKO
+AC_CHECK_TYPES([long long])
AC_HEADER_STDARG
AC_REPLACE_FUNCS(getdtablesize)
dnl
diff -up krb5/src/appl/bsd/krcp.c krb5-1.7/src/appl/bsd/krcp.c
--- krb5/src/appl/bsd/krcp.c 2008-12-15 15:29:01.000000000 -0500
+++ krb5/src/appl/bsd/krcp.c 2009-06-04 14:02:56.000000000 -0400
@@ -764,8 +764,13 @@ void source(argc, argv)
continue;
}
}
+#ifdef HAVE_LONG_LONG
+ (void) snprintf(buf, sizeof(buf), "C%04o %lld %s\n",
+ (int) stb.st_mode&07777, (long long) stb.st_size, last);
+#else
(void) snprintf(buf, sizeof(buf), "C%04o %ld %s\n",
(int) stb.st_mode&07777, (long ) stb.st_size, last);
+#endif
(void) rcmd_stream_write(rem, buf, strlen(buf), 0);
if (response() < 0) {
(void) close(f);
diff -up krb5/src/appl/gssftp/ftp/ftp_var.h krb5/src/appl/gssftp/ftp/ftp_var.h
--- krb5/src/appl/gssftp/ftp/ftp_var.h 2009-06-29 18:01:55.000000000 -0400
+++ krb5/src/appl/gssftp/ftp/ftp_var.h 2009-06-29 18:03:05.000000000 -0400
@@ -46,12 +46,18 @@ FILE* fdopen_socket(SOCKET s, char* mode
#define FDOPEN_SOCKET(s, mode) fdopen_socket(s, mode)
#define SOCKETNO(fd) _get_osfhandle(fd)
#define PERROR_SOCKET(str) do { errno = SOCKET_ERRNO; perror(str); } while(0)
+#define FSEEK(fd, offset, whence) fseek(fd, (long) offset, whence)
#else
#define FCLOSE_SOCKET(f) fclose(f)
FILE* fdopen_socket(int *s, char* mode);
#define FDOPEN_SOCKET(s, mode) fdopen_socket(&s, mode)
#define SOCKETNO(fd) (fd)
#define PERROR_SOCKET(str) perror(str)
+#ifdef HAVE_FSEEKO
+#define FSEEK(fd, offset, whence) fseeko(fd, (off_t) offset, whence)
+#else
+#define FSEEK(fd, offset, whence) fseek(fd, (long) offset, whence)
+#endif
#endif
#ifdef _WIN32
--- krb5/src/appl/gssftp/ftp/ftp.c 2009-06-29 18:05:08.000000000 -0400
+++ krb5/src/appl/gssftp/ftp/ftp.c 2009-06-29 18:05:04.000000000 -0400
@@ -150,7 +150,11 @@
static void proxtrans (char *, char *, char *);
static int initconn (void);
+#ifdef HAVE_LONG_LONG
+static void ptransfer (char *, long long, struct timeval *, struct timeval *);
+#else
static void ptransfer (char *, long, struct timeval *, struct timeval *);
+#endif
static void abort_remote (FILE *);
static void tvsub (struct timeval *, struct timeval *, struct timeval *);
static char *gunique (char *);
@@ -780,7 +784,11 @@
FILE *volatile fin, *volatile dout = 0;
int (*volatile closefunc)();
volatile sig_t oldintr, oldintp;
+#ifdef HAVE_LONG_LONG
+ volatile long long bytes = 0, hashbytes = HASHBYTES;
+#else
volatile long bytes = 0, hashbytes = HASHBYTES;
+#endif
char *volatile lmode;
unsigned char buf[FTP_BUFSIZ], *bufp;
@@ -877,7 +885,7 @@
if (restart_point &&
(strcmp(cmd, "STOR") == 0 || strcmp(cmd, "APPE") == 0)) {
- if (fseek(fin, (long) restart_point, 0) < 0) {
+ if (FSEEK(fin, restart_point, 0) < 0) {
fprintf(stderr, "local: %s: %s\n", local,
strerror(errno));
restart_point = 0;
@@ -1272,7 +1280,7 @@
if (restart_point) {
register int i, n, ch;
- if (fseek(fout, 0L, L_SET) < 0)
+ if (FSEEK(fout, 0L, L_SET) < 0)
goto done;
n = restart_point;
for (i = 0; i++ < n;) {
@@ -1281,7 +1289,7 @@
if (ch == '\n')
i++;
}
- if (fseek(fout, 0L, L_INCR) < 0) {
+ if (FSEEK(fout, 0L, L_INCR) < 0) {
done:
fprintf(stderr, "local: %s: %s\n", local,
strerror(errno));
@@ -1546,8 +1554,13 @@
return (FDOPEN_SOCKET(data, lmode));
}
+#ifdef HAVE_LONG_LONG
+static void ptransfer(char *direction, long long bytes,
+ struct timeval *t0, struct timeval *t1)
+#else
static void ptransfer(char *direction, long bytes,
struct timeval *t0, struct timeval *t1)
+#endif
{
struct timeval td;
float s, kbs;
@@ -1570,8 +1570,13 @@
s = td.tv_sec + (td.tv_usec / 1000000.);
#define nz(x) ((x) == 0 ? 1 : (x))
kbs = (bytes / nz(s))/1024.0;
+#ifdef HAVE_LONG_LONG
+ printf("%lld bytes %s in %.2g seconds (%.2g Kbytes/s)\n",
+ bytes, direction, s, kbs);
+#else
printf("%ld bytes %s in %.2g seconds (%.2g Kbytes/s)\n",
bytes, direction, s, kbs);
+#endif
}
}
--- krb5/src/appl/gssftp/ftpd/ftpd.c 2009-06-29 18:07:16.000000000 -0400
+++ krb5/src/appl/gssftp/ftpd/ftpd.c 2009-06-29 18:07:57.000000000 -0400
@@ -1253,7 +1253,7 @@
* because we are changing from reading to
* writing.
*/
- if (fseek(fout, 0L, L_INCR) < 0) {
+ if (FSEEK(fout, 0L, L_INCR) < 0) {
perror_reply(550, name);
goto done;
}
@@ -1340,8 +1340,13 @@
byte_count = 0;
if (size != (off_t) -1)
/* cast size to long in case sizeof(off_t) > sizeof(long) */
+#ifdef HAVE_LONG_LONG
+ (void) snprintf (sizebuf, sizeof(sizebuf), " (%lld bytes)",
+ (long long)size);
+#else
(void) snprintf (sizebuf, sizeof(sizebuf), " (%ld bytes)",
(long)size);
+#endif
else
sizebuf[0] = '\0';
if (pdata >= 0) {
@@ -2057,6 +2062,15 @@
siglongjmp(urgcatch, 1);
}
if (strcmp(cp, "STAT") == 0) {
+#ifdef HAVE_LONG_LONG
+ if (file_size != (off_t) -1)
+ reply(213, "Status: %llu of %llu bytes transferred",
+ (unsigned long long) byte_count,
+ (unsigned long long) file_size);
+ else
+ reply(213, "Status: %llu bytes transferred",
+ (unsigned long long) byte_count);
+#else
if (file_size != (off_t) -1)
reply(213, "Status: %lu of %lu bytes transferred",
(unsigned long) byte_count,
@@ -2064,6 +2078,7 @@
else
reply(213, "Status: %lu bytes transferred",
(unsigned long) byte_count);
+#endif
}
}
--- krb5/src/appl/gssftp/ftpd/ftpd_var.h 2009-06-29 18:19:02.000000000 -0400
+++ krb5/src/appl/gssftp/ftpd/ftpd_var.h 2009-06-29 18:19:44.000000000 -0400
@@ -41,6 +41,12 @@
char *radix_error (int);
int radix_encode (unsigned char *, unsigned char *, int *, int);
+#ifdef HAVE_FSEEKO
+#define FSEEK(fd, offset, whence) fseeko(fd, (off_t) offset, whence)
+#else
+#define FSEEK(fd, offset, whence) fseek(fd, (long) offset, whence)
+#endif
+
/* ftpd.c */
void ack(char *);
int auth_data(char *);

View File

@ -1,33 +0,0 @@
Fix sending of large files. This isn't *quite* right, because we still have to
open the file right to avoid EFBIG errors, and this patch doesn't fix that.
Either we build with -D_FILE_OFFSET_BITS=64, change open() to open64(), or
pass O_LARGEFILE to open(), none of which are easy to automate.
diff -up krb5-1.7/src/appl/bsd/configure.in krb5-1.7/src/appl/bsd/configure.in
--- krb5-1.7/src/appl/bsd/configure.in 2009-06-04 14:02:56.000000000 -0400
+++ krb5-1.7/src/appl/bsd/configure.in 2009-06-04 14:02:56.000000000 -0400
@@ -53,6 +53,7 @@ AC_FUNC_VFORK
AC_TYPE_MODE_T
AC_CHECK_FUNCS(isatty inet_aton getenv gettosbyname killpg initgroups setpriority setreuid setresuid waitpid setsid ptsname setlogin tcgetpgrp tcsetpgrp setpgid strsave utimes rmufile rresvport_af)
AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/filio.h sys/sockio.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h utmp.h sys/time.h sys/ioctl_compat.h paths.h arpa/nameser.h)
+AC_CHECK_TYPES([long long])
AC_HEADER_STDARG
AC_REPLACE_FUNCS(getdtablesize)
dnl
diff -up krb5-1.7/src/appl/bsd/krcp.c krb5-1.7/src/appl/bsd/krcp.c
--- krb5-1.7/src/appl/bsd/krcp.c 2008-12-15 15:29:01.000000000 -0500
+++ krb5-1.7/src/appl/bsd/krcp.c 2009-06-04 14:02:56.000000000 -0400
@@ -764,8 +764,13 @@ void source(argc, argv)
continue;
}
}
+#ifdef HAVE_LONG_LONG
+ (void) snprintf(buf, sizeof(buf), "C%04o %lld %s\n",
+ (int) stb.st_mode&07777, (long long) stb.st_size, last);
+#else
(void) snprintf(buf, sizeof(buf), "C%04o %ld %s\n",
(int) stb.st_mode&07777, (long ) stb.st_size, last);
+#endif
(void) rcmd_stream_write(rem, buf, strlen(buf), 0);
if (response() < 0) {
(void) close(f);

View File

@ -10,7 +10,7 @@
Summary: The Kerberos network authentication system Summary: The Kerberos network authentication system
Name: krb5 Name: krb5
Version: 1.7 Version: 1.7
Release: 3%{?dist} Release: 4%{?dist}
# Maybe we should explode from the now-available-to-everybody tarball instead? # Maybe we should explode from the now-available-to-everybody tarball instead?
# http://web.mit.edu/kerberos/dist/krb5/1.7/krb5-1.7-signed.tar # http://web.mit.edu/kerberos/dist/krb5/1.7/krb5-1.7-signed.tar
Source0: krb5-%{version}.tar.gz Source0: krb5-%{version}.tar.gz
@ -49,12 +49,10 @@ Patch5: krb5-1.3-ksu-access.patch
Patch6: krb5-1.5-ksu-path.patch Patch6: krb5-1.5-ksu-path.patch
Patch11: krb5-1.2.1-passive.patch Patch11: krb5-1.2.1-passive.patch
Patch12: krb5-1.7-ktany.patch Patch12: krb5-1.7-ktany.patch
Patch13: krb5-1.3-large-file.patch
Patch14: krb5-1.3-ftp-glob.patch Patch14: krb5-1.3-ftp-glob.patch
Patch16: krb5-1.7-buildconf.patch Patch16: krb5-1.7-buildconf.patch
Patch23: krb5-1.3.1-dns.patch Patch23: krb5-1.3.1-dns.patch
Patch26: krb5-1.3.2-efence.patch Patch26: krb5-1.3.2-efence.patch
Patch27: krb5-1.7-rcp-sendlarge.patch
Patch29: krb5-1.7-kprop-mktemp.patch Patch29: krb5-1.7-kprop-mktemp.patch
Patch30: krb5-1.3.4-send-pr-tempfile.patch Patch30: krb5-1.3.4-send-pr-tempfile.patch
Patch33: krb5-1.7-io.patch Patch33: krb5-1.7-io.patch
@ -79,6 +77,7 @@ Patch79: krb5-trunk-ftp_mget_case.patch
Patch86: krb5-1.7-time_t_size.patch Patch86: krb5-1.7-time_t_size.patch
Patch87: krb5-1.7-errs.patch Patch87: krb5-1.7-errs.patch
Patch88: krb5-1.7-sizeof.patch Patch88: krb5-1.7-sizeof.patch
Patch89: krb5-1.7-largefile.patch
License: MIT License: MIT
URL: http://web.mit.edu/kerberos/www/ URL: http://web.mit.edu/kerberos/www/
@ -208,6 +207,14 @@ to obtain initial credentials from a KDC using a private key and a
certificate. certificate.
%changelog %changelog
* Tue Jun 30 2009 Nalin Dahyabhai <nalin@redhat.com> 1.7-4
- try to merge and clean up all the large file support for ftp and rcp
- ftpd no longer prints a negative length when sending a large file
from a 32-bit host
* Tue Jun 30 2009 Nalin Dahyabhai <nalin@redhat.com>
- pam_rhosts_auth.so's been gone, use pam_rhosts.so instead
* Mon Jun 29 2009 Nalin Dahyabhai <nalin@redhat.com> 1.7-3 * Mon Jun 29 2009 Nalin Dahyabhai <nalin@redhat.com> 1.7-3
- switch buildrequires: and requires: on e2fsprogs-devel into - switch buildrequires: and requires: on e2fsprogs-devel into
buildrequires: and requires: on libss-devel, libcom_err-devel, per buildrequires: and requires: on libss-devel, libcom_err-devel, per
@ -1410,13 +1417,11 @@ popd
%patch6 -p1 -b .ksu-path %patch6 -p1 -b .ksu-path
%patch11 -p1 -b .passive %patch11 -p1 -b .passive
%patch12 -p1 -b .ktany %patch12 -p1 -b .ktany
%patch13 -p1 -b .large-file
%patch14 -p1 -b .ftp-glob %patch14 -p1 -b .ftp-glob
%patch16 -p1 -b .buildconf %patch16 -p1 -b .buildconf
%patch23 -p1 -b .dns %patch23 -p1 -b .dns
# Removes a malloc(0) case, nothing more. # Removes a malloc(0) case, nothing more.
# %patch26 -p1 -b .efence # %patch26 -p1 -b .efence
%patch27 -p1 -b .rcp-sendlarge
%patch29 -p1 -b .kprop-mktemp %patch29 -p1 -b .kprop-mktemp
%patch30 -p1 -b .send-pr-tempfile %patch30 -p1 -b .send-pr-tempfile
%patch33 -p1 -b .io %patch33 -p1 -b .io
@ -1438,6 +1443,7 @@ popd
%patch86 -p1 -b .time_t_size %patch86 -p1 -b .time_t_size
%patch87 -p1 -b .errs %patch87 -p1 -b .errs
%patch88 -p1 -b .sizeof %patch88 -p1 -b .sizeof
%patch89 -p1 -b .largefile
gzip doc/*.ps gzip doc/*.ps
sed -i -e '1s!\[twoside\]!!;s!%\(\\usepackage{hyperref}\)!\1!' doc/api/library.tex sed -i -e '1s!\[twoside\]!!;s!%\(\\usepackage{hyperref}\)!\1!' doc/api/library.tex
@ -1490,11 +1496,6 @@ done
%build %build
cd src cd src
INCLUDES=-I%{_includedir}/et INCLUDES=-I%{_includedir}/et
# Get LFS support on systems that need it which aren't already 64-bit.
%ifarch %{ix86} s390 ppc sparcv9
DEFINES="-D_FILE_OFFSET_BITS=64" ; export DEFINES
%endif
# Work out the CFLAGS and CPPFLAGS which we intend to use. # Work out the CFLAGS and CPPFLAGS which we intend to use.
CFLAGS="`echo $RPM_OPT_FLAGS $DEFINES $INCLUDES -fPIC -fno-strict-aliasing`" CFLAGS="`echo $RPM_OPT_FLAGS $DEFINES $INCLUDES -fPIC -fno-strict-aliasing`"
CPPFLAGS="`echo $DEFINES $INCLUDES`" CPPFLAGS="`echo $DEFINES $INCLUDES`"