Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Install the library headers.
[ashd.git]
/
src
/
callcgi.c
diff --git
a/src/callcgi.c
b/src/callcgi.c
index
72f814a
..
14430aa
100644
(file)
--- a/
src/callcgi.c
+++ b/
src/callcgi.c
@@
-30,6
+30,7
@@
#endif
#include <utils.h>
#include <log.h>
#endif
#include <utils.h>
#include <log.h>
+#include <req.h>
static char **environ;
static char **environ;
@@
-53,7
+54,7
@@
static int passdata(FILE *in, FILE *out)
}
}
if(ret > 0) {
}
}
if(ret > 0) {
- if(pfds[0].revents &
POLLIN
) {
+ if(pfds[0].revents &
(POLLIN | POLLERR | POLLHUP)
) {
ret = fread(buf, 1, 65536, in);
if(ferror(in)) {
flog(LOG_ERR, "callcgi: could not read input: %s", strerror(errno));
ret = fread(buf, 1, 65536, in);
if(ferror(in)) {
flog(LOG_ERR, "callcgi: could not read input: %s", strerror(errno));
@@
-88,6
+89,7
@@
static pid_t forkchild(int inpath, char *prog, char *file, char *method, char *u
char *qp, **env, *name;
int inp[2], outp[2];
pid_t pid;
char *qp, **env, *name;
int inp[2], outp[2];
pid_t pid;
+ char *unqr;
pipe(inp);
pipe(outp);
pipe(inp);
pipe(outp);
@@
-109,7
+111,8
@@
static pid_t forkchild(int inpath, char *prog, char *file, char *method, char *u
if(getenv("HTTP_VERSION"))
putenv(sprintf2("SERVER_PROTOCOL=%s", getenv("HTTP_VERSION")));
putenv(sprintf2("REQUEST_METHOD=%s", method));
if(getenv("HTTP_VERSION"))
putenv(sprintf2("SERVER_PROTOCOL=%s", getenv("HTTP_VERSION")));
putenv(sprintf2("REQUEST_METHOD=%s", method));
- putenv(sprintf2("PATH_INFO=%s", rest));
+ unqr = unquoteurl(rest);
+ putenv(sprintf2("PATH_INFO=%s", unqr?unqr:rest));
name = url;
/* XXX: This is an ugly hack (I think), but though I can think
* of several alternatives, none seem to be better. */
name = url;
/* XXX: This is an ugly hack (I think), but though I can think
* of several alternatives, none seem to be better. */
@@
-127,6
+130,8
@@
static pid_t forkchild(int inpath, char *prog, char *file, char *method, char *u
putenv("HTTPS=on");
if(getenv("REQ_X_ASH_ADDRESS"))
putenv(sprintf2("REMOTE_ADDR=%s", getenv("REQ_X_ASH_ADDRESS")));
putenv("HTTPS=on");
if(getenv("REQ_X_ASH_ADDRESS"))
putenv(sprintf2("REMOTE_ADDR=%s", getenv("REQ_X_ASH_ADDRESS")));
+ if(getenv("REQ_X_ASH_REMOTE_USER"))
+ putenv(sprintf2("REMOTE_USER=%s", getenv("REQ_X_ASH_REMOTE_USER")));
if(getenv("REQ_CONTENT_TYPE"))
putenv(sprintf2("CONTENT_TYPE=%s", getenv("REQ_CONTENT_TYPE")));
if(getenv("REQ_CONTENT_LENGTH"))
if(getenv("REQ_CONTENT_TYPE"))
putenv(sprintf2("CONTENT_TYPE=%s", getenv("REQ_CONTENT_TYPE")));
if(getenv("REQ_CONTENT_LENGTH"))
@@
-162,7
+167,7
@@
static void trim(struct charbuf *buf)
for(p = buf->b + buf->d - 1; (p > buf->b) && isspace(*p); p--, buf->d--);
}
for(p = buf->b + buf->d - 1; (p > buf->b) && isspace(*p); p--, buf->d--);
}
-static char **parseheaders(FILE *s)
+static char **parse
cgi
headers(FILE *s)
{
int c, state;
struct charvbuf hbuf;
{
int c, state;
struct charvbuf hbuf;
@@
-369,7
+374,7
@@
int main(int argc, char **argv, char **envp)
passdata(stdin, in); /* Ignore errors, perhaps? */
fclose(in);
out = fdopen(outfd, "r");
passdata(stdin, in); /* Ignore errors, perhaps? */
fclose(in);
out = fdopen(outfd, "r");
- if((headers = parseheaders(out)) == NULL) {
+ if((headers = parse
cgi
headers(out)) == NULL) {
flog(LOG_WARNING, "CGI handler returned invalid headers");
exit(1);
}
flog(LOG_WARNING, "CGI handler returned invalid headers");
exit(1);
}