diff --unified --recursive --unidirectional-new-file --ignore-space-change ../ncftp170/Makefile ./Makefile --- ../ncftp170/Makefile Wed Mar 16 20:16:03 1994 +++ ./Makefile Sun Mar 27 16:02:06 1994 @@ -23,8 +23,8 @@ # Choose your compiler and flags below. Make sure you use an ANSI compiler # that handles new style function declarations and prototypes (gcc should). #-------------------------------------------------------------------------- -CC = cc -#CC = gcc +#CC = cc +CC = gcc #CFLAGS = -O CFLAGS = -O2 @@ -52,14 +52,14 @@ # You'll need to know where the Rconnect.o object file is if you want # to use Socks. #-------------------------------------------------------------------------- -LIBS = +#LIBS = #LIBS = -ldbmalloc #LIBS = -lgetline #LIBS = -lreadline -lcurses #LIBS = ../lib/Rconnect.o #LIBS = -lnet -lnsl -lsocket -lcurses +LIBS = -lcurses -ltermcap - # If the libraries are in a non-standard directory, or you if want to use # getline or readline and they aren't installed system-wide, add the # extra directories to look in here, using -L's. @@ -68,6 +68,9 @@ #LIBDIRS = -L../getline #LIBDIRS = -L../readline +# To make term sources define this to your term directory +#TERMSRC = +TERMSRC = /usr/local/src/term114 # Additional headers. # @@ -95,11 +98,12 @@ # locations. # To inhibit the installation of either, unset MANDIR/CATMANDIR. #-------------------------------------------------------------------------- -BINDIR = /usr/lbin +#BINDIR = /usr/lbin +BINDIR = /usr/local/bin MANDIR = /usr/man/man1 #MANDIR = -CATMANDIR = /usr/catman/LOCAL/g1 -#CATMANDIR = +#CATMANDIR = /usr/catman/LOCAL/g1 +CATMANDIR = NROFF = /usr/ucb/nroff PACK = pack TEST = test @@ -134,9 +138,22 @@ all: $(NAME) done +term: term$(NAME) done + $(NAME): $(OBJS) $(CC) $(LFLAGS) $(LIBDIRS) $(OBJS) -o $(NAME) $(LIBS) +term$(NAME): + $(MAKE) LIBS="$(LIBS) $(TERMSRC)/client.a" HDRDIRS="$(HDRDIRS) -I$(TERMSRC)" \ + CFLAGS="$(CFLAGS) -DTERM_FTP" NAME=term$(NAME) term$(NAME) + +install_term: term$(NAME) + $(CP) term$(NAME) $(BINDIR)/term$(NAME) + @if $(TEST) -n '$(MANDIR)'; then \ + $(MAKE) install_termman ; else true ; fi + @if $(TEST) -n '$(CATMANDIR)'; then \ + $(MAKE) install_termcatman ; else true ; fi + install: $(NAME) $(CP) $(NAME) $(BINDIR)/$(NAME) @if $(TEST) -n '$(MANDIR)'; then \ @@ -147,16 +164,27 @@ install_man: $(CP) $(MAN) $(MANDIR)/$(MAN) +install_termman: + $(CP) $(MAN) $(MANDIR)/term$(MAN) + install_catman: $(CATMAN) $(CP) $(CATMAN) $(CATMANDIR)/$(CATMAN) +install_termcatman: $(CATMAN) + $(CP) $(CATMAN) $(CATMANDIR)/term$(CATMAN) + uninstall: $(RM) $(BINDIR)/$(NAME) $(RM) $(MANDIR)/$(MAN) $(RM) $(CATMANDIR)/$(CATMAN) +uninstall_term: + $(RM) $(BINDIR)/term$(NAME) + $(RM) $(MANDIR)/term$(MAN) + $(RM) $(CATMANDIR)/term$(CATMAN) + $(CATMAN): $(MAN) - rm -f tmp + $(RM) tmp $(NROFF) -man -Tlp $(MAN) > tmp $(PACK) -f tmp mv tmp.z $(CATMAN) @@ -172,7 +200,7 @@ -@echo 'Done.' clean: - rm -f $(OBJS) $(NAME) + rm -f $(OBJS) $(NAME) term$(NAME) # Dependencies: cmds.o: cmds.c diff --unified --recursive --unidirectional-new-file --ignore-space-change ../ncftp170/cmds.c ./cmds.c --- ../ncftp170/cmds.c Wed Mar 16 20:16:02 1994 +++ ./cmds.c Sun Mar 27 15:56:23 1994 @@ -1093,6 +1093,10 @@ if (strcmp(namep, "sh") != 0) str[0] = '+'; dbprintf ("%s\n", theShell); +#if defined(BSD) || defined(_POSIX_SOURCE) + setreuid(-1,getuid()); + setregid(-1,getgid()); +#endif if (argc > 1) (void) execl(theShell, str, "-c", altarg, (char *)0); else diff --unified --recursive --unidirectional-new-file --ignore-space-change ../ncftp170/ftp.c ./ftp.c --- ../ncftp170/ftp.c Wed Mar 16 20:16:02 1994 +++ ./ftp.c Sun Mar 27 16:59:40 1994 @@ -104,13 +104,28 @@ #endif #ifdef TERM_FTP -#include +#include extern int lcompression, rcompression; int compress_toggle = 0; extern int compress_toggle; #endif +#if defined(TERM_FTP) && (defined(BSD) || defined(_POSIX_SOURCE)) +FILE *safeopen(int s, char *lmode){ + FILE *file; + + setreuid(geteuid(),getuid()); + setregid(getegid(),getgid()); + file=fdopen(s, lmode); + setreuid(geteuid(),getuid()); + setregid(getegid(),getgid()); + return(file); +} +#else +#define safeopen fdopen +#endif + #ifdef TERM_FTP int hookup(char *host, unsigned int port) @@ -126,11 +141,10 @@ } send_command(s, C_PORT, 0, "%s:%d", host, ntohs(port)); send_command(s, C_DUMB, 1, 0); - cin = fdopen(s, "r"); cout = fdopen(dup(s), "w"); if (cin == NULL || cout == NULL) { - fprintf(stderr, "ftp: fdopen failed.\n"); + fprintf(stderr, "ftp: safeopen failed.\n"); goto bad; } Strncpy(hostname, host); @@ -235,10 +249,10 @@ PERROR("hookup", "getsockname"); goto bad; } - cin = fdopen(s, "r"); - cout = fdopen(dup(s), "w"); + cin = safeopen(s, "r"); + cout = safeopen(dup(s), "w"); if (cin == NULL || cout == NULL) { - (void) fprintf(stderr, "ftp: fdopen failed.\n"); + (void) fprintf(stderr, "ftp: safeopen failed.\n"); close_streams(0); goto bad; } @@ -273,7 +287,7 @@ done: return (hErr); } /* hookup */ -#endif +#endif /* TERM_FTP */ /* This registers the user's username, password, and account with the remote @@ -1741,7 +1755,7 @@ FILE *dataconn(char *lmode) { - return (fdopen(data, lmode)); + return (safeopen(data, lmode)); } /* dataconn_term */ #else /* not TERM_FTP */ @@ -1857,7 +1871,7 @@ } else { (void) close(data); data = s; - fp = fdopen(data, mode); + fp = safeopen(data, mode); } return (fp); } /* dataconn */