popen.c (36072) | popen.c (36140) |
---|---|
1/* 2 * Copyright (c) 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software written by Ken Arnold and 6 * published in UNIX Review, Vol. 6, No. 8. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94"; 40#endif 41static const char rcsid[] = | 1/* 2 * Copyright (c) 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software written by Ken Arnold and 6 * published in UNIX Review, Vol. 6, No. 8. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94"; 40#endif 41static const char rcsid[] = |
42 "$Id: popen.c,v 1.13 1998/05/15 16:30:09 ache Exp $"; | 42 "$Id: popen.c,v 1.14 1998/05/15 16:51:06 ache Exp $"; |
43#endif /* not lint */ 44 45#include <sys/types.h> 46#include <sys/wait.h> 47 48#include <errno.h> 49#include <glob.h> 50#include <signal.h> 51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <unistd.h> 55 56#include "extern.h" 57#ifdef INTERNAL_LS 58#include "pathnames.h" 59#include <syslog.h> | 43#endif /* not lint */ 44 45#include <sys/types.h> 46#include <sys/wait.h> 47 48#include <errno.h> 49#include <glob.h> 50#include <signal.h> 51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <unistd.h> 55 56#include "extern.h" 57#ifdef INTERNAL_LS 58#include "pathnames.h" 59#include <syslog.h> |
60#include <time.h> |
|
60#include <varargs.h> 61#endif 62 63#define MAXUSRARGS 100 64#define MAXGLOBARGS 1000 65 66/* 67 * Special version of popen which avoids call to shell. This ensures noone --- 6 unchanged lines hidden (view full) --- 74FILE * 75ftpd_popen(program, type) 76 char *program, *type; 77{ 78 char *cp; 79 FILE *iop; 80 int argc, gargc, pdes[2], pid; 81 char **pop, *argv[MAXUSRARGS], *gargv[MAXGLOBARGS]; | 61#include <varargs.h> 62#endif 63 64#define MAXUSRARGS 100 65#define MAXGLOBARGS 1000 66 67/* 68 * Special version of popen which avoids call to shell. This ensures noone --- 6 unchanged lines hidden (view full) --- 75FILE * 76ftpd_popen(program, type) 77 char *program, *type; 78{ 79 char *cp; 80 FILE *iop; 81 int argc, gargc, pdes[2], pid; 82 char **pop, *argv[MAXUSRARGS], *gargv[MAXGLOBARGS]; |
82 static char *envtz[2] = {"TZ=", NULL}; | |
83 84 if (((*type != 'r') && (*type != 'w')) || type[1]) 85 return (NULL); 86 87 if (!pids) { 88 if ((fds = getdtablesize()) <= 0) 89 return (NULL); 90 if ((pids = (int *)malloc((u_int)(fds * sizeof(int)))) == NULL) --- 57 unchanged lines hidden (view full) --- 148 } 149#ifdef INTERNAL_LS 150 if (strcmp(gargv[0], _PATH_LS) == 0) { 151 extern int optreset; 152 /* Reset getopt for ls_main() */ 153 optreset = optind = optopt = 1; 154 /* Close syslogging to remove pwd.db missing msgs */ 155 closelog(); | 83 84 if (((*type != 'r') && (*type != 'w')) || type[1]) 85 return (NULL); 86 87 if (!pids) { 88 if ((fds = getdtablesize()) <= 0) 89 return (NULL); 90 if ((pids = (int *)malloc((u_int)(fds * sizeof(int)))) == NULL) --- 57 unchanged lines hidden (view full) --- 148 } 149#ifdef INTERNAL_LS 150 if (strcmp(gargv[0], _PATH_LS) == 0) { 151 extern int optreset; 152 /* Reset getopt for ls_main() */ 153 optreset = optind = optopt = 1; 154 /* Close syslogging to remove pwd.db missing msgs */ 155 closelog(); |
156 setenv("TZ", "", 1); | 156 /* Trigger to sense new /etc/localtime after chroot */ 157 if (getenv("TZ") == NULL) { 158 setenv("TZ", "", 0); 159 tzset(); 160 unsetenv("TZ"); 161 tzset(); 162 } |
157 exit(ls_main(gargc, gargv)); 158 } 159#endif | 163 exit(ls_main(gargc, gargv)); 164 } 165#endif |
160 execve(gargv[0], gargv, envtz); | 166 execv(gargv[0], gargv); |
161 _exit(1); 162 } 163 /* parent; assume fdopen can't fail... */ 164 if (*type == 'r') { 165 iop = fdopen(pdes[0], type); 166 (void)close(pdes[1]); 167 } else { 168 iop = fdopen(pdes[1], type); --- 35 unchanged lines hidden --- | 167 _exit(1); 168 } 169 /* parent; assume fdopen can't fail... */ 170 if (*type == 'r') { 171 iop = fdopen(pdes[0], type); 172 (void)close(pdes[1]); 173 } else { 174 iop = fdopen(pdes[1], type); --- 35 unchanged lines hidden --- |