Re: Respect X-Forwarded-Proto in httpd

2021-04-27 Thread Raymond E. Pasco
On Tue Apr 27, 2021 at 4:55 PM EDT, Stuart Henderson wrote:
> It's the other way round, this (or proto= in the newer standardised
> Forwarded header) would be set by a reverse proxy to indicate the
> protocol that the client request came in on so that something running on
> the webserver could react accordingly (either in URL construction or to
> issue a redirect to https if wanted).

Yeah - out in the wild, reverse proxies rewrite Location themselves (in
potentially more complicated ways, because whatever they're proxying
might think it's http://web-internal-123:). E.g., nginx proxy_pass
does this, and it can be manually changed with proxy_redirect.

What I don't think nginx does is rewrite its own Location headers based
on incoming forwarding headers, like this diff does. If I generate a 301
from nginx over nc with X-Forwarded-Proto: https, the Location it gives
me starts with http://. It can probably be *configured* to do it
somehow, it's a behemoth.



Re: Respect X-Forwarded-Proto in httpd

2021-04-27 Thread Raymond E. Pasco
On Tue Apr 27, 2021 at 3:40 PM EDT, Stuart Henderson wrote:
> How does this work with other web servers? For example, I don't see the
> string X-Forwarded-Proto in nginx or Apache httpd (and the use of other
> X-Forwarded headers in them are only for adding to requests when running
> as a proxy itself, or picking up the client IP from headers rather than
> TCP).

I think this header is usually set by administrators in a configuration
file, at least for nginx; something that aims to be more out-of-the-box
like Caddy sets it automatically.

My understanding is that common reverse proxies can be told to rewrite
the Location header in this and similar cases, but I haven't looked
closely at it.



[PATCH] df(1): add -m, -g to display megabyte and gigabyte blocks

2021-04-27 Thread Raymond E. Pasco
For parity with NetBSD/FreeBSD df(1). I made them incompatible with -P,
as -h is; NetBSD also only supports 512/1024 with -P and FreeBSD uses -P
to force 512.
---
 bin/df/df.1 | 30 +-
 bin/df/df.c | 33 -
 2 files changed, 53 insertions(+), 10 deletions(-)

diff --git a/bin/df/df.1 b/bin/df/df.1
index 89dd51aac8d..f4a29f67d99 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -64,6 +64,14 @@ options, below).
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl g
+By default, all sizes are reported in 512-byte block counts.
+The
+.Fl g
+option causes the numbers to be reported in gigabyte counts.
+This option is incompatible with the
+.Fl P
+option.
 .It Fl h
 "Human-readable" output.
 Use unit suffixes: Byte, Kilobyte, Megabyte,
@@ -88,6 +96,14 @@ Display statistics only about mounted file systems with the
 flag set.
 If a non-local file system is given as an argument, a
 warning is issued and no information is given on that file system.
+.It Fl m
+By default, all sizes are reported in 512-byte block counts.
+The
+.Fl m
+option causes the numbers to be reported in megabyte counts.
+This option is incompatible with the
+.Fl P
+option.
 .It Fl n
 Print out the previously obtained statistics from the file systems.
 This option should be used if it is possible that one or more
@@ -117,9 +133,11 @@ that file system.
 .Pp
 It is not an error to specify more than one of
 the mutually exclusive options
-.Fl h
+.Fl h ,
+.Fl k ,
+.Fl m ,
 and
-.Fl k .
+.Fl g .
 Where more than one of these options is specified,
 the last option given overrides the others.
 .Sh ENVIRONMENT
@@ -128,9 +146,11 @@ the last option given overrides the others.
 If the environment variable
 .Ev BLOCKSIZE
 is set, and the
-.Fl h
+.Fl h ,
+.Fl k ,
+.Fl m ,
 or
-.Fl k
+.Fl g
 options are not specified, the block counts will be displayed in units of that
 size block.
 .El
@@ -159,7 +179,7 @@ utility is compliant with the
 specification.
 .Pp
 The flags
-.Op Fl hiln ,
+.Op Fl ghilmn ,
 as well as the
 .Ev BLOCKSIZE
 environment variable,
diff --git a/bin/df/df.c b/bin/df/df.c
index fd51f906f89..b33370792d7 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -63,7 +63,7 @@ extern int e2fs_df(int, char *, struct statfs *);
 extern int  ffs_df(int, char *, struct statfs *);
 static int  raw_df(char *, struct statfs *);
 
-inthflag, iflag, kflag, lflag, nflag, Pflag;
+intgflag, hflag, iflag, kflag, lflag, mflag, nflag, Pflag;
 char   **typelist = NULL;
 
 int
@@ -79,11 +79,19 @@ main(int argc, char *argv[])
if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");
 
-   while ((ch = getopt(argc, argv, "hiklnPt:")) != -1)
+   while ((ch = getopt(argc, argv, "ghiklmnPt:")) != -1)
switch (ch) {
+   case 'g':
+   gflag = 1;
+   hflag = 0;
+   kflag = 0;
+   mflag = 0;
+   break;
case 'h':
hflag = 1;
kflag = 0;
+   mflag = 0;
+   gflag = 0;
break;
case 'i':
iflag = 1;
@@ -91,10 +99,17 @@ main(int argc, char *argv[])
case 'k':
kflag = 1;
hflag = 0;
+   mflag = 0;
+   gflag = 0;
break;
case 'l':
lflag = 1;
break;
+   case 'm':
+   mflag = 1;
+   hflag = 0;
+   kflag = 0;
+   break;
case 'n':
nflag = 1;
break;
@@ -112,8 +127,8 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
 
-   if ((iflag || hflag) && Pflag) {
-   warnx("-h and -i are incompatible with -P");
+   if ((gflag || iflag || hflag || mflag) && Pflag) {
+   warnx("-g, -h, -i, and -m are incompatible with -P");
usage();
}
 
@@ -357,6 +372,14 @@ bsdprint(struct statfs *mntbuf, long mntsize, int maxwidth)
blocksize = 1024;
header = "1K-blocks";
headerlen = strlen(header);
+   } else if (mflag) {
+   blocksize = 1048576;
+   header = "1M-blocks";
+   headerlen = strlen(header);
+   } else if (gflag) {
+   blocksize = 1073741824;
+   header = "1G-blocks";
+   headerlen = strlen(header);
} else
header = getbsize(&headerlen, &blocksize);
(void)printf("%-*.*s %s  Used Avail Capacity",
@@ -455,7 +478,7 @@ st

[PATCH] www/faq/faq14.html: make disklabel(8) prompts match the actual program

2020-07-27 Thread Raymond E. Pasco
When there are unwritten changes to the disklabel, disklabel(8) adds an
'*' to the prompt. Just a minor erratum I noticed doing an install.

diff --git a/faq/faq14.html b/faq/faq14.html
index f53d45180..377f8c7b2 100644
--- a/faq/faq14.html
+++ b/faq/faq14.html
@@ -569,7 +569,7 @@ sd0> a a
 offset: [64]
 size: [39825135] *
 FS type: [4.2BSD] RAID
-sd0> w
+sd0*> w
 sd0> q
 No label changes.
 
@@ -713,7 +713,7 @@ sd0> a a 
 offset: [64]
 size: [39825135] *
 FS type: [4.2BSD] RAID
-sd0> w
+sd0*> w
 sd0> q
 No label changes.
 
-- 
2.28.0