diff options
author | davidn <davidn@FreeBSD.org> | 1997-04-26 12:12:10 +0000 |
---|---|---|
committer | davidn <davidn@FreeBSD.org> | 1997-04-26 12:12:10 +0000 |
commit | a1afe7148074c37601ddb27c0db42c7e7e29ac69 (patch) | |
tree | 91a142b078eba657ed76e534ddca5851a3f61c20 /libexec/ftpd/popen.c | |
parent | 6323aa10bffe459912ba8b2f8592c7ac4ffd8705 (diff) | |
download | FreeBSD-src-a1afe7148074c37601ddb27c0db42c7e7e29ac69.zip FreeBSD-src-a1afe7148074c37601ddb27c0db42c7e7e29ac69.tar.gz |
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.
Diffstat (limited to 'libexec/ftpd/popen.c')
-rw-r--r-- | libexec/ftpd/popen.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libexec/ftpd/popen.c b/libexec/ftpd/popen.c index b00235a..ac0b76a 100644 --- a/libexec/ftpd/popen.c +++ b/libexec/ftpd/popen.c @@ -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); } |