提交 d868276d 编写于 作者: M Ming LI 提交者: Adam Lee

gpfdist should reject http request without proper header fields "X-GP-PROTO"

Any http request to gpfdist with pipe will lead original pipe reader process hung.
In order to avoid the situation that random http request to the working gpfdist instance,
gpfdist will check request header.

Any manual request should run as:
wget --header='X-GP-PROTO:0' http://host:port/file
上级 90f59f88
......@@ -106,9 +106,9 @@ static void flush_ssl_buffer(int fd, short event, void* arg);
X-GP-XID - transaction ID
X-GP-CID - command ID
X-GP-SN - session ID
X-GP-PROTO - protocol number
X-GP-PROTO - protocol number, report error if not provided:
X-GP-PROTO = 0 or not provided:
X-GP-PROTO = 0
return the content of the file without any kind of meta info
X-GP-PROTO = 1
......@@ -3218,7 +3218,7 @@ static int request_parse_gp_headers(request_t *r, int opt_g)
const char* xid = 0;
const char* cid = 0;
const char* sn = 0;
const char* gp_proto = "0";
const char* gp_proto = NULL; /* default to invalid, so that report error if not specified*/
int i;
r->csvopt = "";
......@@ -3284,13 +3284,26 @@ static int request_parse_gp_headers(request_t *r, int opt_g)
return -1;
}
}
r->gp_proto = strtol(gp_proto, 0, 0);
if (gp_proto!=NULL)
{
r->gp_proto = strtol(gp_proto, 0, 0);
}
if (r->gp_proto != 0 && r->gp_proto != 1)
if (gp_proto == NULL || (r->gp_proto != 0 && r->gp_proto != 1))
{
gwarning(r, "reject invalid request from %s [%s %s] - X-GP-PROTO invalid '%s'",
if (gp_proto == NULL)
{
gwarning(r, "reject invalid request from %s [%s %s] - no X-GP-PROTO",
r->peer, r->in.req->argv[0], r->in.req->argv[1]);
http_error(r, FDIST_BAD_REQUEST, "invalid request (no gp-proto)");
}
else
{
gwarning(r, "reject invalid request from %s [%s %s] - X-GP-PROTO invalid '%s'",
r->peer, r->in.req->argv[0], r->in.req->argv[1], gp_proto);
http_error(r, FDIST_BAD_REQUEST, "invalid request (invalid gp-proto)");
http_error(r, FDIST_BAD_REQUEST, "invalid request (invalid gp-proto)");
}
request_end(r, 1, 0);
return -1;
}
......
......@@ -77,6 +77,10 @@ SELECT count(*) FROM EXT_NATION_MATCH;
SELECT * FROM EXT_REGION;
SELECT * FROM EXT_REGION as r, EXT_NATION as n WHERE n.N_REGIONKEY = r.R_REGIONKEY;
-- test: http request header needed for gpfdist
\! wget http://@hostname@:7070/exttab1/missing_fields1.data >/dev/null 2>&1 || echo "Execute error";
\! wget --header='X-GP-PROTO:0' http://@hostname@:7070/exttab1/missing_fields1.data >/dev/null 2>&1 && echo "Execute successully";
-- start_ignore
select * from exttab1_gpfdist_stop;
-- end_ignore
......
......@@ -146,6 +146,11 @@ SELECT * FROM EXT_REGION as r, EXT_NATION as n WHERE n.N_REGIONKEY = r.R_REGIONK
4 | MIDDLE EAST | uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl | 4 | EGYPT | 4 | y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
(25 rows)
-- test: http request header needed for gpfdist
\! wget http://@hostname@:7070/exttab1/missing_fields1.data >/dev/null 2>&1 || echo "Execute error";
Execute error
\! wget --header='X-GP-PROTO:0' http://@hostname@:7070/exttab1/missing_fields1.data >/dev/null 2>&1 && echo "Execute successully";
Execute successully
-- start_ignore
-- end_ignore
-- drop tables
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册