Adds optional "internal ls" support for ftpd, by collecting
modules from src/bin/ls, and handling exec(_PATH_LS,..) as a special case, very useful in an environment where many users are given chroot access. "~/etc/{s}pwd.db" files are still needed if uid/gid->user/group translation is desired. To enable this it must be compiled with the make variable FTP_INTERNAL_LS defined, either in /etc/make.conf or the environment.
This commit is contained in:
parent
477a642cee
commit
af85d782fd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25165
@ -1,5 +1,5 @@
|
||||
# @(#)Makefile 8.2 (Berkeley) 4/4/94
|
||||
# $Id: Makefile,v 1.19 1997/02/22 14:21:26 peter Exp $
|
||||
# $Id: Makefile,v 1.20 1997/04/23 04:56:39 davidn Exp $
|
||||
|
||||
PROG= ftpd
|
||||
MAN8= ftpd.8
|
||||
@ -12,6 +12,13 @@ DPADD= ${LIBSKEY} ${LIBMD} ${LIBCRYPT} ${LIBUTIL}
|
||||
|
||||
CLEANFILES+=ftpcmd.c y.tab.h
|
||||
|
||||
.ifdef FTPD_INTERNAL_LS
|
||||
LSDIR= ../../bin/ls
|
||||
.PATH: ${.CURDIR}/${LSDIR}
|
||||
SRCS+= ls.c cmp.c print.c stat_flags.c util.c
|
||||
CFLAGS+=-DINTERNAL_LS -Dmain=ls_main -I${.CURDIR}/${LSDIR}
|
||||
.endif
|
||||
|
||||
.if exists(${DESTDIR}/usr/lib/libkrb.a) && defined(MAKE_EBONES)
|
||||
.PATH: ${.CURDIR}/../../usr.bin/login
|
||||
SRCS+= klogin.c
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.2 (Berkeley) 4/4/94
|
||||
* $Id$
|
||||
* $Id: extern.h,v 1.8 1997/02/22 14:21:26 peter Exp $
|
||||
*/
|
||||
|
||||
void blkfree __P((char **));
|
||||
@ -70,3 +70,6 @@ int yyparse __P((void));
|
||||
#if defined(SKEY) && defined(_PWD_H_) /* XXX evil */
|
||||
char *skey_challenge __P((char *, struct passwd *, int));
|
||||
#endif
|
||||
#if defined(INTERNAL_LS)
|
||||
int ls_main __P((int, char **));
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ftpd.c,v 1.34 1997/03/28 15:48:09 imp Exp $
|
||||
* $Id: ftpd.c,v 1.35 1997/04/23 04:56:39 davidn Exp $
|
||||
*/
|
||||
|
||||
#if 0
|
||||
@ -102,7 +102,12 @@ static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#ifdef INTERNAL_LS
|
||||
static char version[] = "Version 6.00LS";
|
||||
#undef main
|
||||
#else
|
||||
static char version[] = "Version 6.00";
|
||||
#endif
|
||||
|
||||
extern off_t restart_point;
|
||||
extern char cbuf[];
|
||||
@ -1388,7 +1393,7 @@ statfilecmd(filename)
|
||||
int c;
|
||||
char line[LINE_MAX];
|
||||
|
||||
(void)snprintf(line, sizeof(line), "/bin/ls -lgA %s", filename);
|
||||
(void)snprintf(line, sizeof(line), _PATH_LS " -lgA %s", filename);
|
||||
fin = ftpd_popen(line, "r");
|
||||
lreply(211, "status of %s:", filename);
|
||||
while ((c = getc(fin)) != EOF) {
|
||||
@ -1899,7 +1904,7 @@ send_file_list(whichf)
|
||||
*/
|
||||
if (dirname[0] == '-' && *dirlist == NULL &&
|
||||
transflag == 0) {
|
||||
retrieve("/bin/ls %s", dirname);
|
||||
retrieve(_PATH_LS " %s", dirname);
|
||||
goto out;
|
||||
}
|
||||
perror_reply(550, whichf);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)pathnames.h 8.1 (Berkeley) 6/4/93
|
||||
* $Id$
|
||||
* $Id: pathnames.h,v 1.8 1997/02/22 14:21:29 peter Exp $
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
@ -40,3 +40,4 @@
|
||||
#define _PATH_FTPWELCOME "/etc/ftpwelcome"
|
||||
#define _PATH_FTPLOGINMESG "/etc/ftpmotd"
|
||||
#define _PATH_FTPDSTATFILE "/var/log/ftpd"
|
||||
#define _PATH_LS "/bin/ls"
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: popen.c,v 1.7 1997/02/22 14:21:31 peter Exp $
|
||||
*/
|
||||
|
||||
#if 0
|
||||
@ -54,6 +54,9 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94";
|
||||
#include <unistd.h>
|
||||
|
||||
#include "extern.h"
|
||||
#ifdef INTERNAL_LS
|
||||
#include "pathnames.h"
|
||||
#endif
|
||||
|
||||
#define MAXUSRARGS 100
|
||||
#define MAXGLOBARGS 1000
|
||||
@ -111,7 +114,13 @@ ftpd_popen(program, type)
|
||||
gargv[gargc] = NULL;
|
||||
|
||||
iop = NULL;
|
||||
switch(pid = vfork()) {
|
||||
#ifdef INTERNAL_LS
|
||||
fflush(NULL);
|
||||
pid = (strcmp(gargv[0], _PATH_LS) == 0) ? fork() : vfork();
|
||||
#else
|
||||
pid = vfork();
|
||||
#endif
|
||||
switch(pid) {
|
||||
case -1: /* error */
|
||||
(void)close(pdes[0]);
|
||||
(void)close(pdes[1]);
|
||||
@ -132,6 +141,14 @@ ftpd_popen(program, type)
|
||||
}
|
||||
(void)close(pdes[1]);
|
||||
}
|
||||
#ifdef INTERNAL_LS
|
||||
if (strcmp(gargv[0], _PATH_LS) == 0) {
|
||||
extern int optreset;
|
||||
/* Reset getopt for ls_main() */
|
||||
optreset = optind = optopt = 1;
|
||||
exit(ls_main(gargc, gargv));
|
||||
}
|
||||
#endif
|
||||
execv(gargv[0], gargv);
|
||||
_exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user