mirror of https://github.com/omar-polo/gmid.git
fix remote_user for CGI and add -6 flag to enable ipv6
This commit is contained in:
parent
33756bd235
commit
85dff1f9c3
|
@ -1,3 +1,7 @@
|
||||||
|
2021-01-11 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
|
* gmid.c (main): ipv6 disabled by default and -6 flag to enable it
|
||||||
|
|
||||||
2021-01-10 Omar Polo <op@omarpolo.com>
|
2021-01-10 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
* gmid.c (logs): log also the port of the client
|
* gmid.c (logs): log also the port of the client
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
**gmid**
|
**gmid**
|
||||||
\[**-fh**]
|
\[**-6fh**]
|
||||||
\[**-c** *cert.pem*]
|
\[**-c** *cert.pem*]
|
||||||
\[**-d** *docs*]
|
\[**-d** *docs*]
|
||||||
\[**-k** *key.pem*]
|
\[**-k** *key.pem*]
|
||||||
|
@ -51,6 +51,10 @@ file inside that directory.
|
||||||
|
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
|
|
||||||
|
**-6**
|
||||||
|
|
||||||
|
> Enable IPv6.
|
||||||
|
|
||||||
**-c** *cert.pem*
|
**-c** *cert.pem*
|
||||||
|
|
||||||
> The certificate to use, by default is
|
> The certificate to use, by default is
|
||||||
|
|
4
gmid.1
4
gmid.1
|
@ -20,7 +20,7 @@
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Bk -words
|
.Bk -words
|
||||||
.Op Fl fh
|
.Op Fl 6fh
|
||||||
.Op Fl c Ar cert.pem
|
.Op Fl c Ar cert.pem
|
||||||
.Op Fl d Ar docs
|
.Op Fl d Ar docs
|
||||||
.Op Fl k Ar key.pem
|
.Op Fl k Ar key.pem
|
||||||
|
@ -64,6 +64,8 @@ file inside that directory.
|
||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width 12m
|
.Bl -tag -width 12m
|
||||||
|
.It Fl 6
|
||||||
|
Enable IPv6.
|
||||||
.It Fl c Ar cert.pem
|
.It Fl c Ar cert.pem
|
||||||
The certificate to use, by default is
|
The certificate to use, by default is
|
||||||
.Pa cert.pem .
|
.Pa cert.pem .
|
||||||
|
|
24
gmid.c
24
gmid.c
|
@ -348,8 +348,9 @@ start_cgi(const char *spath, const char *relpath, const char *query,
|
||||||
|
|
||||||
case 0: { /* child */
|
case 0: { /* child */
|
||||||
char *ex, *requri, *portno;
|
char *ex, *requri, *portno;
|
||||||
char addr[INET_ADDRSTRLEN];
|
char addr[NI_MAXHOST];
|
||||||
char *argv[] = { NULL, NULL, NULL };
|
char *argv[] = { NULL, NULL, NULL };
|
||||||
|
int ec;
|
||||||
|
|
||||||
close(p[0]);
|
close(p[0]);
|
||||||
if (dup2(p[1], 1) == -1)
|
if (dup2(p[1], 1) == -1)
|
||||||
|
@ -358,6 +359,13 @@ start_cgi(const char *spath, const char *relpath, const char *query,
|
||||||
if (inet_ntop(c->af, &c->addr, addr, sizeof(addr)) == NULL)
|
if (inet_ntop(c->af, &c->addr, addr, sizeof(addr)) == NULL)
|
||||||
goto childerr;
|
goto childerr;
|
||||||
|
|
||||||
|
ec = getnameinfo((struct sockaddr*)&c->addr, sizeof(c->addr),
|
||||||
|
addr, sizeof(addr),
|
||||||
|
NULL, 0,
|
||||||
|
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||||
|
if (ec != 0)
|
||||||
|
goto childerr;
|
||||||
|
|
||||||
if (asprintf(&portno, "%d", port) == -1)
|
if (asprintf(&portno, "%d", port) == -1)
|
||||||
goto childerr;
|
goto childerr;
|
||||||
|
|
||||||
|
@ -853,7 +861,7 @@ main(int argc, char **argv)
|
||||||
const char *cert = "cert.pem", *key = "key.pem";
|
const char *cert = "cert.pem", *key = "key.pem";
|
||||||
struct tls *ctx = NULL;
|
struct tls *ctx = NULL;
|
||||||
struct tls_config *conf;
|
struct tls_config *conf;
|
||||||
int sock4, sock6, ch;
|
int sock4, sock6, enable_ipv6, ch;
|
||||||
connected_clients = 0;
|
connected_clients = 0;
|
||||||
|
|
||||||
if ((dir = absolutify_path("docs")) == NULL)
|
if ((dir = absolutify_path("docs")) == NULL)
|
||||||
|
@ -862,9 +870,14 @@ main(int argc, char **argv)
|
||||||
cgi = NULL;
|
cgi = NULL;
|
||||||
port = 1965;
|
port = 1965;
|
||||||
foreground = 0;
|
foreground = 0;
|
||||||
|
enable_ipv6 = 0;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "c:d:fhk:p:x:")) != -1) {
|
while ((ch = getopt(argc, argv, "6c:d:fhk:p:x:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case '6':
|
||||||
|
enable_ipv6 = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
cert = optarg;
|
cert = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -946,7 +959,10 @@ main(int argc, char **argv)
|
||||||
errx(1, "tls_configure: %s", tls_error(ctx));
|
errx(1, "tls_configure: %s", tls_error(ctx));
|
||||||
|
|
||||||
sock4 = make_socket(port, AF_INET);
|
sock4 = make_socket(port, AF_INET);
|
||||||
sock6 = make_socket(port, AF_INET6);
|
if (enable_ipv6)
|
||||||
|
sock6 = make_socket(port, AF_INET6);
|
||||||
|
else
|
||||||
|
sock6 = -1;
|
||||||
|
|
||||||
if ((dirfd = open(dir, O_RDONLY | O_DIRECTORY)) == -1)
|
if ((dirfd = open(dir, O_RDONLY | O_DIRECTORY)) == -1)
|
||||||
err(1, "open: %s", dir);
|
err(1, "open: %s", dir);
|
||||||
|
|
Loading…
Reference in New Issue