Fossil SCM

Add SERVER_SOFTWARE to the set of CGI parameters emitted by /ext

drh 2022-01-20 13:17 trunk
Commit a9a1bd84d8278a4585160786282074decb5b027de468d80b843c634fff3ab00d
1 file changed +12
+12
--- src/extcgi.c
+++ src/extcgi.c
@@ -68,10 +68,11 @@
6868
"SCRIPT_FILENAME",
6969
"SCRIPT_NAME",
7070
"SERVER_NAME",
7171
"SERVER_PORT",
7272
"SERVER_PROTOCOL",
73
+ "SERVER_SOFTWARE",
7374
};
7475
7576
/*
7677
** Check a pathname to determine if it is acceptable for use as
7778
** extension CGI. Some pathnames are excluded for security reasons.
@@ -171,10 +172,11 @@
171172
int rc; /* Reply code from subroutine call */
172173
int nContent = -1; /* Content length */
173174
const char *zPathInfo; /* Original PATH_INFO value */
174175
Blob reply; /* The reply */
175176
char zLine[1000]; /* One line of the CGI reply */
177
+ const char *zSrvSw; /* SERVER_SOFTWARE */
176178
177179
zPathInfo = P("PATH_INFO");
178180
login_check_credentials();
179181
blob_init(&reply, 0, 0);
180182
if( g.zExtRoot==0 ){
@@ -259,10 +261,20 @@
259261
cgi_set_parameter_nocopy("FOSSIL_REPOSITORY", g.zRepositoryName, 0);
260262
cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
261263
cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
262264
db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
263265
g.zLogin ? g.zLogin : "nobody"), 0);
266
+ zSrvSw = P("SERVER_SOFTWARE");
267
+ if( zSrvSw==0 ){
268
+ zSrvSw = get_version();
269
+ }else{
270
+ char *z = mprintf("fossil version %s", get_version());
271
+ if( strncmp(zSrvSw,z,strlen(z)-4)!=0 ){
272
+ zSrvSw = mprintf("%z, %s", z, zSrvSw);
273
+ }
274
+ }
275
+ cgi_replace_parameter("SERVER_SOFTWARE", zSrvSw);
264276
cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
265277
for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
266278
(void)P(azCgiEnv[i]);
267279
}
268280
fossil_clearenv();
269281
--- src/extcgi.c
+++ src/extcgi.c
@@ -68,10 +68,11 @@
68 "SCRIPT_FILENAME",
69 "SCRIPT_NAME",
70 "SERVER_NAME",
71 "SERVER_PORT",
72 "SERVER_PROTOCOL",
 
73 };
74
75 /*
76 ** Check a pathname to determine if it is acceptable for use as
77 ** extension CGI. Some pathnames are excluded for security reasons.
@@ -171,10 +172,11 @@
171 int rc; /* Reply code from subroutine call */
172 int nContent = -1; /* Content length */
173 const char *zPathInfo; /* Original PATH_INFO value */
174 Blob reply; /* The reply */
175 char zLine[1000]; /* One line of the CGI reply */
 
176
177 zPathInfo = P("PATH_INFO");
178 login_check_credentials();
179 blob_init(&reply, 0, 0);
180 if( g.zExtRoot==0 ){
@@ -259,10 +261,20 @@
259 cgi_set_parameter_nocopy("FOSSIL_REPOSITORY", g.zRepositoryName, 0);
260 cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
261 cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
262 db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
263 g.zLogin ? g.zLogin : "nobody"), 0);
 
 
 
 
 
 
 
 
 
 
264 cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
265 for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
266 (void)P(azCgiEnv[i]);
267 }
268 fossil_clearenv();
269
--- src/extcgi.c
+++ src/extcgi.c
@@ -68,10 +68,11 @@
68 "SCRIPT_FILENAME",
69 "SCRIPT_NAME",
70 "SERVER_NAME",
71 "SERVER_PORT",
72 "SERVER_PROTOCOL",
73 "SERVER_SOFTWARE",
74 };
75
76 /*
77 ** Check a pathname to determine if it is acceptable for use as
78 ** extension CGI. Some pathnames are excluded for security reasons.
@@ -171,10 +172,11 @@
172 int rc; /* Reply code from subroutine call */
173 int nContent = -1; /* Content length */
174 const char *zPathInfo; /* Original PATH_INFO value */
175 Blob reply; /* The reply */
176 char zLine[1000]; /* One line of the CGI reply */
177 const char *zSrvSw; /* SERVER_SOFTWARE */
178
179 zPathInfo = P("PATH_INFO");
180 login_check_credentials();
181 blob_init(&reply, 0, 0);
182 if( g.zExtRoot==0 ){
@@ -259,10 +261,20 @@
261 cgi_set_parameter_nocopy("FOSSIL_REPOSITORY", g.zRepositoryName, 0);
262 cgi_set_parameter_nocopy("FOSSIL_URI", g.zTop, 0);
263 cgi_set_parameter_nocopy("FOSSIL_CAPABILITIES",
264 db_text("","SELECT fullcap(cap) FROM user WHERE login=%Q",
265 g.zLogin ? g.zLogin : "nobody"), 0);
266 zSrvSw = P("SERVER_SOFTWARE");
267 if( zSrvSw==0 ){
268 zSrvSw = get_version();
269 }else{
270 char *z = mprintf("fossil version %s", get_version());
271 if( strncmp(zSrvSw,z,strlen(z)-4)!=0 ){
272 zSrvSw = mprintf("%z, %s", z, zSrvSw);
273 }
274 }
275 cgi_replace_parameter("SERVER_SOFTWARE", zSrvSw);
276 cgi_replace_parameter("GATEWAY_INTERFACE","CGI/1.0");
277 for(i=0; i<sizeof(azCgiEnv)/sizeof(azCgiEnv[0]); i++){
278 (void)P(azCgiEnv[i]);
279 }
280 fossil_clearenv();
281

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button