implement fastcgi strip number

This commit is contained in:
Omar Polo 2023-08-08 17:35:11 +00:00
parent 4f7492c36e
commit 03d671e2aa
4 changed files with 14 additions and 8 deletions

14
fcgi.c
View File

@ -374,10 +374,9 @@ void
fcgi_req(struct client *c, struct location *loc)
{
char buf[22], path[GEMINI_URL_LEN];
char *qs, *pathinfo, *scriptname = NULL;
char *qs, *p, *pathinfo, *scriptname = NULL;
size_t l;
time_t tim;
int r;
struct tm tminfo;
struct envlist *p;
@ -390,12 +389,11 @@ fcgi_req(struct client *c, struct location *loc)
if (scriptname == NULL)
scriptname = "";
r = snprintf(path, sizeof(path), "/%s", c->iri.path);
if (r < 0 || (size_t)r >= sizeof(c->iri.path)) {
log_warn("snprintf failure?");
fcgi_error(c->cgibev, EVBUFFER_ERROR, c);
return;
}
p = strip_path(c->iri.path, loc->fcgi_strip);
if (*p != '/')
snprintf(path, sizeof(path), "/%s", p);
else
strlcpy(path, p, sizeof(path));
pathinfo = path;
l = strlen(scriptname);

View File

@ -318,6 +318,10 @@ is interpreted as a hostname or an IP address.
can be either a port number or the name of a service enclosed in
double quotes.
If not specified defaults to 9000.
.It Ic strip Ar number
Strip
.Ar number
leading path components from the
.El
.Pp
The FastCGI handler will be given the following variables by default:

1
gmid.h
View File

@ -183,6 +183,7 @@ struct location {
int disable_log;
int fcgi;
int nofcgi;
int fcgi_strip;
struct envhead params;
char dir[PATH_MAX];

View File

@ -601,6 +601,9 @@ fastcgiopt : PARAM string '=' string {
free($3);
free($5);
}
| STRIP NUM {
loc->fcgi_strip = $2;
}
;
types : TYPES '{' optnl mediaopts_l '}' ;