[w3m-dev 03646] setup child process, local CGI
* etc.c (reset_signals): static don't ignore SIGUSR1 (close_all_fds_except): static DEV_NULL_PATH (setup_child): added (myExec): rewrite (mySystem): rewrite * file.c (readHeader): check image_source (loadGeneralFile): check image_source (doExternal): use setup_child (_doFileCopy): use setup_child (doFileSave): use setup_child (uncompress_stream): check image_source use setup_child * image.c (getCharSize): no need stderr redirect (openImgdisplay): use setup_child (loadImage): use setup_child (getImageSize): no need stderr redirect * local.c (writeLocalCookie): check Local_cookie_file (localcgi_popen_rw): added (localcgi_popen_r): deleted (localcgi_post): rewrite (localcgi_get): deleted * proto.h (localcgi_get): defined by localcgi_post (reset_signals): deleted (close_all_fds_except): deleted (close_all_fds): deleted (setup_child): added * search.c (open_migemo): use setup_child, myExec * w3mimgdisplay.c (main): use DEV_NULL_PATH From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
@@ -1,3 +1,37 @@
|
|||||||
|
2003-01-18 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||||
|
|
||||||
|
* [w3m-dev 03646] setup child process, local CGI
|
||||||
|
* etc.c (reset_signals): static
|
||||||
|
don't ignore SIGUSR1
|
||||||
|
(close_all_fds_except): static
|
||||||
|
DEV_NULL_PATH
|
||||||
|
(setup_child): added
|
||||||
|
(myExec): rewrite
|
||||||
|
(mySystem): rewrite
|
||||||
|
* file.c (readHeader): check image_source
|
||||||
|
(loadGeneralFile): check image_source
|
||||||
|
(doExternal): use setup_child
|
||||||
|
(_doFileCopy): use setup_child
|
||||||
|
(doFileSave): use setup_child
|
||||||
|
(uncompress_stream): check image_source
|
||||||
|
use setup_child
|
||||||
|
* image.c (getCharSize): no need stderr redirect
|
||||||
|
(openImgdisplay): use setup_child
|
||||||
|
(loadImage): use setup_child
|
||||||
|
(getImageSize): no need stderr redirect
|
||||||
|
* local.c (writeLocalCookie): check Local_cookie_file
|
||||||
|
(localcgi_popen_rw): added
|
||||||
|
(localcgi_popen_r): deleted
|
||||||
|
(localcgi_post): rewrite
|
||||||
|
(localcgi_get): deleted
|
||||||
|
* proto.h (localcgi_get): defined by localcgi_post
|
||||||
|
(reset_signals): deleted
|
||||||
|
(close_all_fds_except): deleted
|
||||||
|
(close_all_fds): deleted
|
||||||
|
(setup_child): added
|
||||||
|
* search.c (open_migemo): use setup_child, myExec
|
||||||
|
* w3mimgdisplay.c (main): use DEV_NULL_PATH
|
||||||
|
|
||||||
2003-01-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
2003-01-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||||
|
|
||||||
* [w3m-dev 03644] Re: Other user can see local cookie.
|
* [w3m-dev 03644] Re: Other user can see local cookie.
|
||||||
@@ -6519,4 +6553,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.685 2003/01/15 17:13:21 ukai Exp $
|
$Id: ChangeLog,v 1.686 2003/01/17 16:57:17 ukai Exp $
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: etc.c,v 1.49 2003/01/15 17:13:21 ukai Exp $ */
|
/* $Id: etc.c,v 1.50 2003/01/17 16:57:18 ukai Exp $ */
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include "myctype.h"
|
#include "myctype.h"
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "terms.h"
|
#include "terms.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if defined(HAVE_WAITPID) || defined(HAVE_WAIT3)
|
#if defined(HAVE_WAITPID) || defined(HAVE_WAIT3)
|
||||||
@@ -1279,7 +1280,7 @@ romanAlphabet(int n)
|
|||||||
#define SIGIOT SIGABRT
|
#define SIGIOT SIGABRT
|
||||||
#endif /* not SIGIOT */
|
#endif /* not SIGIOT */
|
||||||
|
|
||||||
void
|
static void
|
||||||
reset_signals(void)
|
reset_signals(void)
|
||||||
{
|
{
|
||||||
signal(SIGHUP, SIG_DFL); /* terminate process */
|
signal(SIGHUP, SIG_DFL); /* terminate process */
|
||||||
@@ -1298,23 +1299,22 @@ reset_signals(void)
|
|||||||
#ifdef SIGPIPE
|
#ifdef SIGPIPE
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
signal(SIGUSR1, SIG_IGN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FOPEN_MAX
|
#ifndef FOPEN_MAX
|
||||||
#define FOPEN_MAX 1024 /* XXX */
|
#define FOPEN_MAX 1024 /* XXX */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
static void
|
||||||
close_all_fds_except(int i, int f)
|
close_all_fds_except(int i, int f)
|
||||||
{
|
{
|
||||||
switch (i) { /* fall through */
|
switch (i) { /* fall through */
|
||||||
case 0:
|
case 0:
|
||||||
dup2(open("/dev/null", O_RDONLY), 0);
|
dup2(open(DEV_NULL_PATH, O_RDONLY), 0);
|
||||||
case 1:
|
case 1:
|
||||||
dup2(open("/dev/null", O_WRONLY), 1);
|
dup2(open(DEV_NULL_PATH, O_WRONLY), 1);
|
||||||
case 2:
|
case 2:
|
||||||
dup2(open("/dev/null", O_WRONLY), 2);
|
dup2(open(DEV_NULL_PATH, O_WRONLY), 2);
|
||||||
}
|
}
|
||||||
/* close all other file descriptors (socket, ...) */
|
/* close all other file descriptors (socket, ...) */
|
||||||
for (i = 3; i < FOPEN_MAX; i++) {
|
for (i = 3; i < FOPEN_MAX; i++) {
|
||||||
@@ -1323,27 +1323,37 @@ close_all_fds_except(int i, int f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SETPGRP
|
void
|
||||||
|
setup_child(int child, int i, int f)
|
||||||
|
{
|
||||||
|
reset_signals();
|
||||||
|
signal(SIGINT, SIG_IGN);
|
||||||
|
if (!child)
|
||||||
|
SETPGRP();
|
||||||
|
close_tty();
|
||||||
|
close_all_fds_except(i, f);
|
||||||
|
QuietMessage = TRUE;
|
||||||
|
fmInitialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
myExec(char *command)
|
myExec(char *command)
|
||||||
{
|
{
|
||||||
reset_signals();
|
signal(SIGINT, SIG_DFL);
|
||||||
SETPGRP();
|
|
||||||
close_tty();
|
|
||||||
close_all_fds(0);
|
|
||||||
execl("/bin/sh", "sh", "-c", command, NULL);
|
execl("/bin/sh", "sh", "-c", command, NULL);
|
||||||
exit(127);
|
exit(127);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mySystem(char *command, int background)
|
mySystem(char *command, int background)
|
||||||
{
|
{
|
||||||
if (background) {
|
if (background) {
|
||||||
#ifdef HAVE_SETPGRP
|
#ifndef __EMX__
|
||||||
flush_tty();
|
flush_tty();
|
||||||
if (!fork())
|
if (!fork()) {
|
||||||
|
setup_child(FALSE, 0, -1);
|
||||||
myExec(command);
|
myExec(command);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
Str cmd = Strnew_charp("start /f ");
|
Str cmd = Strnew_charp("start /f ");
|
||||||
Strcat_charp(cmd, command);
|
Strcat_charp(cmd, command);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: file.c,v 1.187 2003/01/15 17:13:21 ukai Exp $ */
|
/* $Id: file.c,v 1.188 2003/01/17 16:57:19 ukai Exp $ */
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "myctype.h"
|
#include "myctype.h"
|
||||||
@@ -594,7 +594,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu)
|
|||||||
else
|
else
|
||||||
http_response_code = 0;
|
http_response_code = 0;
|
||||||
|
|
||||||
if (thru && !newBuf->header_source) {
|
if (thru && !newBuf->header_source && !image_source) {
|
||||||
Str tmpf = tmpfname(TMPF_DFL, NULL);
|
Str tmpf = tmpfname(TMPF_DFL, NULL);
|
||||||
src = fopen(tmpf->ptr, "w");
|
src = fopen(tmpf->ptr, "w");
|
||||||
if (src)
|
if (src)
|
||||||
@@ -1885,6 +1885,8 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
|
|||||||
page_loaded:
|
page_loaded:
|
||||||
if (page) {
|
if (page) {
|
||||||
FILE *src;
|
FILE *src;
|
||||||
|
if (image_source)
|
||||||
|
return NULL;
|
||||||
tmp = tmpfname(TMPF_SRC, ".html");
|
tmp = tmpfname(TMPF_SRC, ".html");
|
||||||
src = fopen(tmp->ptr, "w");
|
src = fopen(tmp->ptr, "w");
|
||||||
if (src) {
|
if (src) {
|
||||||
@@ -7315,11 +7317,7 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,
|
|||||||
!(mcap->flags & MAILCAP_NEEDSTERMINAL) && BackgroundExtViewer) {
|
!(mcap->flags & MAILCAP_NEEDSTERMINAL) && BackgroundExtViewer) {
|
||||||
flush_tty();
|
flush_tty();
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
reset_signals();
|
setup_child(FALSE, 0, UFfileno(&uf));
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
close_tty();
|
|
||||||
QuietMessage = TRUE;
|
|
||||||
fmInitialized = FALSE;
|
|
||||||
if (save2tmp(uf, tmpf->ptr) < 0)
|
if (save2tmp(uf, tmpf->ptr) < 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
UFclose(&uf);
|
UFclose(&uf);
|
||||||
@@ -7484,13 +7482,7 @@ _doFileCopy(char *tmpf, char *defstr, int download)
|
|||||||
flush_tty();
|
flush_tty();
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
reset_signals();
|
setup_child(FALSE, 0, -1);
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
SETPGRP();
|
|
||||||
close_tty();
|
|
||||||
close_all_fds(2);
|
|
||||||
QuietMessage = TRUE;
|
|
||||||
fmInitialized = FALSE;
|
|
||||||
if (!_MoveFile(tmpf, p) && PreserveTimestamp && !is_pipe &&
|
if (!_MoveFile(tmpf, p) && PreserveTimestamp && !is_pipe &&
|
||||||
!stat(tmpf, &st))
|
!stat(tmpf, &st))
|
||||||
setModtime(p, st.st_mtime);
|
setModtime(p, st.st_mtime);
|
||||||
@@ -7591,13 +7583,7 @@ doFileSave(URLFile uf, char *defstr)
|
|||||||
flush_tty();
|
flush_tty();
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
reset_signals();
|
setup_child(FALSE, 0, UFfileno(&uf));
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
SETPGRP();
|
|
||||||
close_tty();
|
|
||||||
close_all_fds_except(2, UFfileno(&uf));
|
|
||||||
QuietMessage = TRUE;
|
|
||||||
fmInitialized = FALSE;
|
|
||||||
if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1)
|
if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1)
|
||||||
setModtime(p, uf.modtime);
|
setModtime(p, uf.modtime);
|
||||||
UFclose(&uf);
|
UFclose(&uf);
|
||||||
@@ -7733,7 +7719,7 @@ uncompress_stream(URLFile *uf, char **src)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uf->scheme != SCM_LOCAL) {
|
if (uf->scheme != SCM_LOCAL && !image_source) {
|
||||||
tmpf = tmpfname(TMPF_DFL, ext)->ptr;
|
tmpf = tmpfname(TMPF_DFL, ext)->ptr;
|
||||||
if (save2tmp(*uf, tmpf) < 0) {
|
if (save2tmp(*uf, tmpf) < 0) {
|
||||||
UFclose(uf);
|
UFclose(uf);
|
||||||
@@ -7752,15 +7738,10 @@ uncompress_stream(URLFile *uf, char **src)
|
|||||||
flush_tty();
|
flush_tty();
|
||||||
/* fd1[0]: read, fd1[1]: write */
|
/* fd1[0]: read, fd1[1]: write */
|
||||||
if ((pid1 = fork()) == 0) {
|
if ((pid1 = fork()) == 0) {
|
||||||
reset_signals();
|
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
close_tty();
|
|
||||||
QuietMessage = TRUE;
|
|
||||||
fmInitialized = FALSE;
|
|
||||||
close(fd1[0]);
|
close(fd1[0]);
|
||||||
dup2(fd1[1], 1);
|
dup2(fd1[1], 1);
|
||||||
dup2(fd1[1], 2);
|
dup2(fd1[1], 2);
|
||||||
close_all_fds_except(-1, UFfileno(uf));
|
setup_child(TRUE, -1, UFfileno(uf));
|
||||||
if (tmpf) {
|
if (tmpf) {
|
||||||
#ifdef USE_BINMODE_STREAM
|
#ifdef USE_BINMODE_STREAM
|
||||||
int tmpfd = open(tmpf, O_RDONLY | O_BINARY);
|
int tmpfd = open(tmpf, O_RDONLY | O_BINARY);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: image.c,v 1.25 2003/01/15 16:11:43 ukai Exp $ */
|
/* $Id: image.c,v 1.26 2003/01/17 16:57:19 ukai Exp $ */
|
||||||
|
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -54,7 +54,7 @@ getCharSize()
|
|||||||
tmp = Strnew();
|
tmp = Strnew();
|
||||||
if (!strchr(Imgdisplay, '/'))
|
if (!strchr(Imgdisplay, '/'))
|
||||||
Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL);
|
Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL);
|
||||||
Strcat_m_charp(tmp, Imgdisplay, " -test 2> /dev/null", NULL);
|
Strcat_m_charp(tmp, Imgdisplay, " -test", NULL);
|
||||||
f = popen(tmp->ptr, "r");
|
f = popen(tmp->ptr, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -103,23 +103,18 @@ openImgdisplay()
|
|||||||
goto err2;
|
goto err2;
|
||||||
if (Imgdisplay_pid == 0) {
|
if (Imgdisplay_pid == 0) {
|
||||||
/* child */
|
/* child */
|
||||||
reset_signals();
|
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
set_environ("W3M_TTY", ttyname_tty());
|
|
||||||
SETPGRP();
|
|
||||||
close_tty();
|
|
||||||
close(fdr[0]);
|
close(fdr[0]);
|
||||||
close(fdw[1]);
|
close(fdw[1]);
|
||||||
dup2(fdw[0], 0);
|
dup2(fdw[0], 0);
|
||||||
dup2(fdr[1], 1);
|
dup2(fdr[1], 1);
|
||||||
close_all_fds(2);
|
setup_child(FALSE, 2, -1);
|
||||||
|
set_environ("W3M_TTY", ttyname_tty());
|
||||||
if (!strchr(Imgdisplay, '/'))
|
if (!strchr(Imgdisplay, '/'))
|
||||||
cmd = Strnew_m_charp(w3m_auxbin_dir(), "/", Imgdisplay, NULL)->ptr;
|
cmd = Strnew_m_charp(w3m_auxbin_dir(), "/", Imgdisplay, NULL)->ptr;
|
||||||
else
|
else
|
||||||
cmd = Imgdisplay;
|
cmd = Imgdisplay;
|
||||||
execl("/bin/sh", "sh", "-c", cmd, NULL);
|
myExec(cmd);
|
||||||
/* XXX: ifndef HAVE_SETPGRP, use start /f ? */
|
/* XXX: ifdef __EMX__, use start /f ? */
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
close(fdr[1]);
|
close(fdr[1]);
|
||||||
close(fdw[0]);
|
close(fdw[0]);
|
||||||
@@ -453,12 +448,7 @@ loadImage(int flag)
|
|||||||
flush_tty();
|
flush_tty();
|
||||||
if ((cache->pid = fork()) == 0) {
|
if ((cache->pid = fork()) == 0) {
|
||||||
Buffer *b;
|
Buffer *b;
|
||||||
reset_signals();
|
setup_child(TRUE, 0, -1);
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
close_tty();
|
|
||||||
close_all_fds(2);
|
|
||||||
QuietMessage = TRUE;
|
|
||||||
fmInitialized = FALSE;
|
|
||||||
image_source = cache->file;
|
image_source = cache->file;
|
||||||
b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL);
|
b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL);
|
||||||
if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6))
|
if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6))
|
||||||
@@ -554,8 +544,7 @@ getImageSize(ImageCache * cache)
|
|||||||
tmp = Strnew();
|
tmp = Strnew();
|
||||||
if (!strchr(Imgdisplay, '/'))
|
if (!strchr(Imgdisplay, '/'))
|
||||||
Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL);
|
Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL);
|
||||||
Strcat_m_charp(tmp, Imgdisplay, " -size ", shell_quote(cache->file),
|
Strcat_m_charp(tmp, Imgdisplay, " -size ", shell_quote(cache->file), NULL);
|
||||||
" 2> /dev/null", NULL);
|
|
||||||
f = popen(tmp->ptr, "r");
|
f = popen(tmp->ptr, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: local.c,v 1.21 2003/01/15 17:13:22 ukai Exp $ */
|
/* $Id: local.c,v 1.22 2003/01/17 16:57:20 ukai Exp $ */
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -32,6 +32,8 @@ writeLocalCookie()
|
|||||||
|
|
||||||
if (no_rc_dir)
|
if (no_rc_dir)
|
||||||
return;
|
return;
|
||||||
|
if (Local_cookie_file)
|
||||||
|
return;
|
||||||
Local_cookie_file = tmpfname(TMPF_COOKIE, NULL)->ptr;
|
Local_cookie_file = tmpfname(TMPF_COOKIE, NULL)->ptr;
|
||||||
set_environ("LOCAL_COOKIE_FILE", Local_cookie_file);
|
set_environ("LOCAL_COOKIE_FILE", Local_cookie_file);
|
||||||
f = fopen(Local_cookie_file, "wb");
|
f = fopen(Local_cookie_file, "wb");
|
||||||
@@ -351,61 +353,59 @@ cgi_filename(char *fn, int *status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static pid_t
|
static pid_t
|
||||||
localcgi_popen_r(FILE ** p_fp)
|
localcgi_popen_rw(int *p_fdr, int *p_fdw)
|
||||||
{
|
{
|
||||||
int fd[2];
|
int fdr[2], fdw[2];
|
||||||
FILE *fp;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
Str emsg;
|
Str emsg;
|
||||||
|
|
||||||
if (pipe(fd) < 0) {
|
if (pipe(fdr) < 0) {
|
||||||
emsg = Sprintf("localcgi_popen_r: pipe: %s", strerror(errno));
|
emsg = Sprintf("localcgi_popen_rw: pipe: %s", strerror(errno));
|
||||||
disp_err_message(emsg->ptr, FALSE);
|
goto pipe_err0;
|
||||||
return (pid_t) - 1;
|
}
|
||||||
|
if (p_fdw && pipe(fdw) < 0) {
|
||||||
|
emsg = Sprintf("localcgi_popen_rw: pipe: %s", strerror(errno));
|
||||||
|
goto pipe_err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flush_tty();
|
flush_tty();
|
||||||
if ((pid = fork()) < 0) {
|
if ((pid = fork()) < 0) {
|
||||||
emsg = Sprintf("localcgi_popen_r: fork: %s", strerror(errno));
|
emsg = Sprintf("localcgi_popen_rw: fork: %s", strerror(errno));
|
||||||
disp_err_message(emsg->ptr, FALSE);
|
goto pipe_err2;
|
||||||
close(fd[0]);
|
|
||||||
close(fd[1]);
|
|
||||||
return (pid_t) - 1;
|
|
||||||
}
|
}
|
||||||
else if (!pid) {
|
else if (!pid) {
|
||||||
close_tty();
|
close(fdr[0]);
|
||||||
dup2(fd[1], 1);
|
dup2(fdr[1], 1);
|
||||||
|
if (p_fdw) {
|
||||||
if (fd[1] > 1)
|
close(fdw[1]);
|
||||||
close(fd[1]);
|
dup2(fdw[0], 0);
|
||||||
|
}
|
||||||
close(fd[0]);
|
setup_child(TRUE, 2, -1);
|
||||||
close_all_fds(2);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
close(fd[1]);
|
close(fdr[1]);
|
||||||
|
*p_fdr = fdr[0];
|
||||||
if (!(fp = fdopen(fd[0], "r"))) {
|
if (p_fdw) {
|
||||||
emsg =
|
close(fdw[0]);
|
||||||
Sprintf("localcgi_popen_r: fdopen(%d, \"r\"): %s", fd[0],
|
*p_fdw = fdw[1];
|
||||||
strerror(errno));
|
|
||||||
disp_err_message(emsg->ptr, FALSE);
|
|
||||||
kill(pid, SIGTERM);
|
|
||||||
close(fd[0]);
|
|
||||||
return (pid_t) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*p_fp = fp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
|
pipe_err2:
|
||||||
|
close(fdw[0]);
|
||||||
|
close(fdw[1]);
|
||||||
|
pipe_err1:
|
||||||
|
close(fdr[0]);
|
||||||
|
close(fdr[1]);
|
||||||
|
pipe_err0:
|
||||||
|
disp_err_message(emsg->ptr, FALSE);
|
||||||
|
return (pid_t) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
|
localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
|
||||||
{
|
{
|
||||||
FILE *f, *f1;
|
int fdr, fdw = -1;
|
||||||
Str tmp1;
|
|
||||||
int status;
|
int status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char *file;
|
char *file;
|
||||||
@@ -414,49 +414,46 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
|
|||||||
if (check_local_cgi(file, status) < 0)
|
if (check_local_cgi(file, status) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
writeLocalCookie();
|
writeLocalCookie();
|
||||||
tmp1 = tmpfname(TMPF_DFL, NULL);
|
if (request && request->enctype != FORM_ENCTYPE_MULTIPART)
|
||||||
if ((pid = localcgi_popen_r(&f)) < 0)
|
pid = localcgi_popen_rw(&fdr, &fdw);
|
||||||
|
else
|
||||||
|
pid = localcgi_popen_rw(&fdr, NULL);
|
||||||
|
if (pid < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (pid)
|
else if (pid) {
|
||||||
return f;
|
if (fdw > 0) {
|
||||||
f1 = fopen(tmp1->ptr, "w");
|
write(fdw, request->body, request->length);
|
||||||
if (f1 == NULL)
|
close(fdw);
|
||||||
exit(1);
|
}
|
||||||
if (qstr == NULL) {
|
return fdopen(fdr, "r");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qstr == NULL)
|
||||||
set_cgi_environ(uri, file, uri);
|
set_cgi_environ(uri, file, uri);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
set_cgi_environ(uri, file, Strnew_m_charp(uri, "?", qstr, NULL)->ptr);
|
set_cgi_environ(uri, file, Strnew_m_charp(uri, "?", qstr, NULL)->ptr);
|
||||||
}
|
if (referer && referer != NO_REFERER)
|
||||||
|
set_environ("HTTP_REFERER", referer);
|
||||||
|
if (request) {
|
||||||
set_environ("REQUEST_METHOD", "POST");
|
set_environ("REQUEST_METHOD", "POST");
|
||||||
if (qstr)
|
if (qstr)
|
||||||
set_environ("QUERY_STRING", qstr);
|
set_environ("QUERY_STRING", qstr);
|
||||||
set_environ("CONTENT_LENGTH", Sprintf("%d", request->length)->ptr);
|
set_environ("CONTENT_LENGTH", Sprintf("%d", request->length)->ptr);
|
||||||
if (referer && referer != NO_REFERER)
|
|
||||||
set_environ("HTTP_REFERER", referer);
|
|
||||||
if (request->enctype == FORM_ENCTYPE_MULTIPART) {
|
if (request->enctype == FORM_ENCTYPE_MULTIPART) {
|
||||||
set_environ("CONTENT_TYPE",
|
set_environ("CONTENT_TYPE",
|
||||||
Sprintf("multipart/form-data; boundary=%s",
|
Sprintf("multipart/form-data; boundary=%s",
|
||||||
request->boundary)->ptr);
|
request->boundary)->ptr);
|
||||||
|
freopen(request->body, "r", stdin);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
set_environ("CONTENT_TYPE", "application/x-www-form-urlencoded");
|
set_environ("CONTENT_TYPE", "application/x-www-form-urlencoded");
|
||||||
}
|
}
|
||||||
if (request->enctype == FORM_ENCTYPE_MULTIPART) {
|
|
||||||
FILE *fd;
|
|
||||||
int c;
|
|
||||||
fd = fopen(request->body, "r");
|
|
||||||
if (fd != NULL) {
|
|
||||||
while ((c = fgetc(fd)) != EOF)
|
|
||||||
fputc(c, f1);
|
|
||||||
fclose(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
fputs(request->body, f1);
|
set_environ("REQUEST_METHOD", "GET");
|
||||||
|
set_environ("QUERY_STRING", qstr ? qstr : "");
|
||||||
|
freopen(DEV_NULL_PATH, "r", stdin);
|
||||||
}
|
}
|
||||||
fclose(f1);
|
|
||||||
freopen(tmp1->ptr, "r", stdin);
|
|
||||||
#ifdef HAVE_CHDIR /* ifndef __EMX__ ? */
|
#ifdef HAVE_CHDIR /* ifndef __EMX__ ? */
|
||||||
chdir(mydirname(file));
|
chdir(mydirname(file));
|
||||||
#endif
|
#endif
|
||||||
@@ -466,41 +463,3 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
|
|||||||
exit(1);
|
exit(1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
|
||||||
localcgi_get(char *uri, char *request, char *referer)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
int status;
|
|
||||||
pid_t pid;
|
|
||||||
char *file;
|
|
||||||
|
|
||||||
file = cgi_filename(uri, &status);
|
|
||||||
if (check_local_cgi(file, status) < 0)
|
|
||||||
return NULL;
|
|
||||||
writeLocalCookie();
|
|
||||||
if ((pid = localcgi_popen_r(&f)) < 0)
|
|
||||||
return NULL;
|
|
||||||
else if (pid)
|
|
||||||
return f;
|
|
||||||
if (request == NULL) {
|
|
||||||
set_cgi_environ(Strnew_charp(uri)->ptr, file, Strnew_charp(uri)->ptr);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
set_cgi_environ(Strnew_charp(uri)->ptr, file,
|
|
||||||
Strnew_m_charp(uri, "?", request, NULL)->ptr);
|
|
||||||
}
|
|
||||||
if (referer && referer != NO_REFERER)
|
|
||||||
set_environ("HTTP_REFERER", referer);
|
|
||||||
set_environ("REQUEST_METHOD", "GET");
|
|
||||||
set_environ("QUERY_STRING", request ? request : "");
|
|
||||||
freopen(DEV_NULL_PATH, "r", stdin);
|
|
||||||
#ifdef HAVE_CHDIR /* ifndef __EMX__? */
|
|
||||||
chdir(mydirname(file));
|
|
||||||
#endif
|
|
||||||
execl(file, mybasename(file), NULL);
|
|
||||||
fprintf(stderr, "execl(\"%s\", \"%s\", NULL): %s\n",
|
|
||||||
file, mybasename(file), strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: proto.h,v 1.79 2003/01/15 17:13:22 ukai Exp $ */
|
/* $Id: proto.h,v 1.80 2003/01/17 16:57:20 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* This file was automatically generated by version 1.7 of cextract.
|
* This file was automatically generated by version 1.7 of cextract.
|
||||||
* Manual editing not recommended.
|
* Manual editing not recommended.
|
||||||
@@ -574,7 +574,7 @@ extern void setLocalCookie(void);
|
|||||||
extern Str loadLocalDir(char *dirname);
|
extern Str loadLocalDir(char *dirname);
|
||||||
extern void set_environ(char *var, char *value);
|
extern void set_environ(char *var, char *value);
|
||||||
extern FILE *localcgi_post(char *, char *, FormList *, char *);
|
extern FILE *localcgi_post(char *, char *, FormList *, char *);
|
||||||
extern FILE *localcgi_get(char *, char *, char *);
|
#define localcgi_get(u, q, r) localcgi_post((u), (q), NULL, (r))
|
||||||
extern FILE *openSecretFile(char *fname);
|
extern FILE *openSecretFile(char *fname);
|
||||||
extern void loadPasswd(void);
|
extern void loadPasswd(void);
|
||||||
extern void loadPreForm(void);
|
extern void loadPreForm(void);
|
||||||
@@ -586,12 +586,8 @@ extern void add_auth_cookie(char *host, int port, char *file, char *realm,
|
|||||||
extern char *last_modified(Buffer *buf);
|
extern char *last_modified(Buffer *buf);
|
||||||
extern Str romanNumeral(int n);
|
extern Str romanNumeral(int n);
|
||||||
extern Str romanAlphabet(int n);
|
extern Str romanAlphabet(int n);
|
||||||
extern void reset_signals(void);
|
extern void setup_child(int child, int i, int f);
|
||||||
extern void close_all_fds_except(int i, int f);
|
|
||||||
#define close_all_fds(i) close_all_fds_except(i, -1)
|
|
||||||
#ifdef HAVE_SETPGRP
|
|
||||||
extern void myExec(char *command);
|
extern void myExec(char *command);
|
||||||
#endif
|
|
||||||
extern void mySystem(char *command, int background);
|
extern void mySystem(char *command, int background);
|
||||||
extern Str myExtCommand(char *cmd, char *arg, int redirect);
|
extern Str myExtCommand(char *cmd, char *arg, int redirect);
|
||||||
extern Str myEditor(char *cmd, char *file, int line);
|
extern Str myEditor(char *cmd, char *file, int line);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: search.c,v 1.23 2002/12/18 16:33:19 ukai Exp $ */
|
/* $Id: search.c,v 1.24 2003/01/17 16:57:20 ukai Exp $ */
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include "regex.h"
|
#include "regex.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -50,17 +50,13 @@ open_migemo(char *migemo_command)
|
|||||||
goto err2;
|
goto err2;
|
||||||
if (migemo_pid == 0) {
|
if (migemo_pid == 0) {
|
||||||
/* child */
|
/* child */
|
||||||
reset_signals();
|
|
||||||
SETPGRP();
|
|
||||||
close_tty();
|
|
||||||
close(fdr[0]);
|
close(fdr[0]);
|
||||||
close(fdw[1]);
|
close(fdw[1]);
|
||||||
dup2(fdw[0], 0);
|
dup2(fdw[0], 0);
|
||||||
dup2(fdr[1], 1);
|
dup2(fdr[1], 1);
|
||||||
close_all_fds(2);
|
setup_child(FALSE, 2, -1);
|
||||||
execl("/bin/sh", "sh", "-c", migemo_command, NULL);
|
myExec(migemo_command);
|
||||||
/* XXX: ifndef HAVE_SETPGRP, use "start /f"? */
|
/* XXX: ifdef __EMX__, use start /f ? */
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
close(fdr[1]);
|
close(fdr[1]);
|
||||||
close(fdw[0]);
|
close(fdw[0]);
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: w3mimgdisplay.c,v 1.11 2002/12/25 16:14:45 ukai Exp $ */
|
/* $Id: w3mimgdisplay.c,v 1.12 2003/01/17 16:57:21 ukai Exp $ */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -37,7 +37,7 @@ main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
GetOption(argc, argv);
|
GetOption(argc, argv);
|
||||||
if (!defined_debug)
|
if (!defined_debug)
|
||||||
freopen("/dev/null", "w", stderr);
|
freopen(DEV_NULL_PATH, "w", stderr);
|
||||||
|
|
||||||
#ifdef W3MIMGDISPLAY_SETUID
|
#ifdef W3MIMGDISPLAY_SETUID
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user