Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > df524f73c71c55c575efad0cd3a37ad7 > files > 25

krb5-appl-1.0.1-2.3.2.mga1.src.rpm

* Turn on large file support in gssftp and rcp (and the rest of the bsd
  applications) using AC_SYS_LARGEFILE.
* The size of off_t might now be greater than that of an int or a long, so
  if we have a "long long" type, assume that format specifiers for it work
  correctly and that we can cast off_t values to long long for displaying
  and logging.
* Check for fseeko(), which takes an off_t, and if we find it, use it
  instead of fseek(), which takes a long and might not handle the full
  range of values.
RT#6524

diff -up krb5-appl-1.0.1/bsd/krcp.c krb5-appl-1.0.1/bsd/krcp.c
--- krb5-appl-1.0.1/bsd/krcp.c	2010-05-24 10:16:57.565286960 -0400
+++ krb5-appl-1.0.1/bsd/krcp.c	2010-05-24 10:16:57.682292360 -0400
@@ -748,8 +748,13 @@ void source(argc, argv)
 		continue;
 	    }
 	}
+#ifdef HAVE_LONG_LONG_INT
+	(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-appl-1.0.1/configure.ac krb5-appl-1.0.1/configure.ac
--- krb5-appl-1.0.1/configure.ac	2010-05-24 10:16:57.000000000 -0400
+++ krb5-appl-1.0.1/configure.ac	2010-05-24 10:17:22.658042178 -0400
@@ -103,6 +103,10 @@ case $host in
     ;;
 esac
 
+AC_SYS_LARGEFILE
+AC_FUNC_FSEEKO
+AC_TYPE_LONG_LONG_INT
+AC_TYPE_UNSIGNED_LONG_LONG_INT
 AC_CHECK_FUNCS(_getpty cgetent getcwd getenv gettosbyname getusershell getutmp)
 AC_CHECK_FUNCS(getutmpx grantpt inet_aton initgroups isatty killpg killpg)
 AC_CHECK_FUNCS(line_push ptsname revoke rmufile rresvport_af)
diff -up krb5-appl-1.0.1/gssftp/ftpd/ftpcmd.y krb5-appl-1.0.1/gssftp/ftpd/ftpcmd.y
--- krb5-appl-1.0.1/gssftp/ftpd/ftpcmd.y	2009-11-05 15:15:06.000000000 -0500
+++ krb5-appl-1.0.1/gssftp/ftpd/ftpcmd.y	2010-05-24 10:16:57.688293200 -0400
@@ -1499,12 +1499,20 @@ char *filename;
 		    (stbuf.st_mode&S_IFMT) != S_IFREG)
 			reply(550, "%s: not a plain file.", filename);
 		else
+#ifdef HAVE_LONG_LONG_INT
+			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_INT
+		register long long count;
+#else
 		register long count;
+#endif
 		struct stat stbuf;
 		fin = fopen(filename, "r");
 		if (fin == NULL) {
@@ -1526,7 +1534,11 @@ char *filename;
 		}
 		(void) fclose(fin);
 
+#ifdef HAVE_LONG_LONG_INT
+		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-appl-1.0.1/gssftp/ftpd/ftpd.c krb5-appl-1.0.1/gssftp/ftpd/ftpd.c
--- krb5-appl-1.0.1/gssftp/ftpd/ftpd.c	2010-05-24 10:16:57.459288560 -0400
+++ krb5-appl-1.0.1/gssftp/ftpd/ftpd.c	2010-05-24 10:16:57.692286520 -0400
@@ -1205,8 +1205,13 @@ retrieve(cmd, name)
 done:
 	(*closefunc)(fin);
 	if (logging > 2 && !cmd) {
+#ifdef HAVE_UNSIGNED_LONG_LONG_INT
+		syslog(LOG_NOTICE, "get: %llu bytes transferred",
+		       (unsigned long long) byte_count);
+#else
 	        syslog(LOG_NOTICE, "get: %lu bytes transferred",
 		       (unsigned long) byte_count);
+#endif
 	}
 }
 
@@ -1252,7 +1257,7 @@ store_file(name, fmode, unique)
 			 * 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;
 			}
@@ -1277,8 +1282,13 @@ store_file(name, fmode, unique)
 done:
 	(*closefunc)(fout);
 	if (logging > 2) {
+#ifdef HAVE_UNSIGNED_LONG_LONG_INT
+		syslog(LOG_NOTICE, "put: %llu bytes transferred",
+		       (unsigned long long) byte_count);
+#else
 	        syslog(LOG_NOTICE, "put: %lu bytes transferred",
 		       (unsigned long) byte_count);
+#endif
 	}
 }
 
@@ -1341,8 +1351,13 @@ dataconn(name, size, fmode)
 	byte_count = 0;
 	if (size != (off_t) -1)
 		/* cast size to long in case sizeof(off_t) > sizeof(long) */
+#ifdef HAVE_LONG_LONG_INT
+		(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) {
@@ -2063,6 +2078,15 @@ myoob(sig)
 		siglongjmp(urgcatch, 1);
 	}
 	if (strcmp(cp, "STAT") == 0) {
+#ifdef HAVE_LONG_LONG_INT
+		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, 
@@ -2070,6 +2094,7 @@ myoob(sig)
 		else
 			reply(213, "Status: %lu bytes transferred", 
 			      (unsigned long) byte_count);
+#endif
 	}
 }
 
diff -up krb5-appl-1.0.1/gssftp/ftpd/ftpd_var.h krb5-appl-1.0.1/gssftp/ftpd/ftpd_var.h
--- krb5-appl-1.0.1/gssftp/ftpd/ftpd_var.h	2009-11-05 15:15:06.000000000 -0500
+++ krb5-appl-1.0.1/gssftp/ftpd/ftpd_var.h	2010-05-24 10:16:57.697287880 -0400
@@ -41,6 +41,12 @@
 char *radix_error (int);
 int radix_encode (unsigned char *, unsigned char *, size_t *, 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(unsigned char *);
diff -up krb5-appl-1.0.1/gssftp/ftp/ftp.c krb5-appl-1.0.1/gssftp/ftp/ftp.c
--- krb5-appl-1.0.1/gssftp/ftp/ftp.c	2010-05-24 10:16:57.667041880 -0400
+++ krb5-appl-1.0.1/gssftp/ftp/ftp.c	2010-05-24 10:16:57.703289360 -0400
@@ -156,7 +156,11 @@ void user_gss_error (OM_uint32, OM_uint3
 
 static void proxtrans (char *, char *, char *);
 static int initconn (void);
+#ifdef HAVE_LONG_LONG_INT
+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 *);
@@ -787,7 +791,11 @@ void sendrequest(char *cmd, char *local,
 	FILE *volatile fin, *volatile dout = 0;
 	int (*volatile closefunc)();
 	volatile sig_t oldintr, oldintp;
+#ifdef HAVE_LONG_LONG_INT
+	volatile long long bytes = 0, hashbytes = HASHBYTES;
+#else
 	volatile long bytes = 0, hashbytes = HASHBYTES;
+#endif
 	char *volatile lmode;
 	char buf[FTP_BUFSIZ], *bufp;
 
@@ -884,7 +892,7 @@ void sendrequest(char *cmd, char *local,
 
 	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;
@@ -1279,7 +1287,7 @@ void recvrequest(char *cmd, char *volati
 		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;) {
@@ -1288,7 +1296,7 @@ void recvrequest(char *cmd, char *volati
 				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));
@@ -1553,8 +1561,13 @@ dataconn(char *lmode)
 	return (FDOPEN_SOCKET(data, lmode));
 }
 
+#ifdef HAVE_LONG_LONG_INT
+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;
@@ -1564,8 +1577,13 @@ static void ptransfer(char *direction, l
 		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_INT
+		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
 	}
 }
 
diff -up krb5-appl-1.0.1/gssftp/ftp/ftp_var.h krb5-appl-1.0.1/gssftp/ftp/ftp_var.h
--- krb5-appl-1.0.1/gssftp/ftp/ftp_var.h	2010-05-24 10:16:57.628038560 -0400
+++ krb5-appl-1.0.1/gssftp/ftp/ftp_var.h	2010-05-24 10:16:57.706287440 -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