Re: [patch] httpd static gzip compression

2022-02-26 Thread Tracey Emery
On Sat, Feb 26, 2022 at 10:55:59AM +0100, prx wrote:
> First, thank you for your interest!
> 
> > > Shouldn't we check for truncation on strlcpy and strlcat and goto fail
> > > in that event?
> > 
> > With goto abort we get an 500 internal server error.
> > 
> 
> Moreover, if the strlcpy and strlcat failed, then the file requested 
> (gpath) is obviously not found, and httpd switch back to original path.
> 
> But to avoid unexpected behaviour, maybe something like this can be enough ?
> 

I'd prefer the hard failure. I'm sure someone else will chime in if they
think otherwise. Thanks! :)

> ```
> int gztoolong = 0;
> 
> /* check Accept-Encoding header */
> key.kv_key = "Accept-Encoding";
> r = kv_find(&req->http_headers, &key);
> 
> if (r != NULL) {
> if (strstr(r->kv_value, "gzip") != NULL) {
> /* append ".gz" to path and check existence */
> if (strlcpy(gzpath, path, sizeof(gzpath)) >= sizeof(gzpath))
> gztoolong = 1;
> if (strlcat(gzpath, ".gz", sizeof(gzpath)) >= sizeof(gzpath))
> gztoolong = 1;
> 
> if ((gztoolong == 0) &&
> (access(gzpath, R_OK) == 0) &&
> (stat(gzpath, &gzst) == 0)) {
>     path = gzpath;
> st = &gzst;
> kv_add(&resp->http_headers,
> "Content-Encoding", "gzip");
> }
> ```
> 

-- 

Tracey Emery



Re: [patch] httpd static gzip compression

2022-02-26 Thread Tracey Emery
  /* send the header without a body */
> - media = media_find_config(env, srv_conf, path);
>   if ((ret = server_response_http(clt, ret, media, -1,
>   MINIMUM(time(NULL), st->st_mtim.tv_sec))) == -1)
>   goto fail;
>   goto done;
>   }
>  
> + /* change path to path.gz if necessary. */
> + if (srv_conf->flags & SRVFLAG_GZIP_STATIC) {
> + struct http_descriptor  *req = clt->clt_descreq;
> + struct http_descriptor  *resp = clt->clt_descresp;
> + struct kv   *r, key;
> +
> + /* check Accept-Encoding header */
> + key.kv_key = "Accept-Encoding";
> + r = kv_find(&req->http_headers, &key);
> +
> + if (r != NULL && strstr(r->kv_value, "gzip") != NULL) {
> + /* append ".gz" to path and check existence */
> + if (strlcpy(gzpath, path, sizeof(gzpath)) >=
> + sizeof(gzpath) ||
> + strlcat(gzpath, ".gz", sizeof(gzpath)) >=
> + sizeof(gzpath))
> + goto abort;
> +
> + if ((access(gzpath, R_OK) == 0) &&
> + (stat(gzpath, &gzst) == 0)) {
> +     path = gzpath;
> + st = &gzst;
> + kv_add(&resp->http_headers,
> + "Content-Encoding", "gzip");
> + }
> + }
> + }
> +
>   /* Now open the file, should be readable or we have another problem */
>   if ((fd = open(path, O_RDONLY)) == -1)
>   goto abort;
>  
> - media = media_find_config(env, srv_conf, path);
>   ret = server_response_http(clt, 200, media, st->st_size,
>   MINIMUM(time(NULL), st->st_mtim.tv_sec));
>   switch (ret) {
> 

-- 

Tracey Emery



Re: [patch] httpd static gzip compression

2022-02-25 Thread Tracey Emery
ing revision 1.127
> diff -u -p -r1.127 parse.y
> --- parse.y   24 Oct 2021 16:01:04 -  1.127
> +++ parse.y   25 Feb 2022 18:24:30 -
> @@ -141,7 +141,7 @@ typedef struct {
>  %token   TIMEOUT TLS TYPE TYPES HSTS MAXAGE SUBDOMAINS DEFAULT PRELOAD 
> REQUEST
>  %token   ERROR INCLUDE AUTHENTICATE WITH BLOCK DROP RETURN PASS REWRITE
>  %token   CA CLIENT CRL OPTIONAL PARAM FORWARDED FOUND NOT
> -%token   ERRDOCS
> +%token   ERRDOCS GZIPSTATIC
>  %token STRING
>  %token NUMBER
>  %typeport
> @@ -553,6 +553,7 @@ serveroptsl   : LISTEN ON STRING opttls po
>   | logformat
>   | fastcgi
>   | authenticate
> + | gzip_static
>   | filter
>   | LOCATION optfound optmatch STRING {
>   struct server   *s;
> @@ -1217,6 +1218,14 @@ fcgiport   : NUMBER{
>   }
>   ;
>  
> +gzip_static  : NO GZIPSTATIC {
> + srv->srv_conf.flags &= ~SRVFLAG_GZIP_STATIC;
> + }
> + | GZIPSTATIC{
> + srv->srv_conf.flags |= SRVFLAG_GZIP_STATIC;
> + }
> + ;
> +
>  tcpip: TCP '{' optnl tcpflags_l '}'
>   | TCP tcpflags
>   ;
> @@ -1441,6 +1450,7 @@ lookup(char *s)
>   { "fastcgi",FCGI },
>   { "forwarded",  FORWARDED },
>   { "found",  FOUND },
> + { "gzip-static",GZIPSTATIC },
>   { "hsts",   HSTS },
>   { "include",INCLUDE },
>   { "index",  INDEX },
> Index: server_file.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/httpd/server_file.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 server_file.c
> --- server_file.c 29 Apr 2021 18:23:07 -  1.70
> +++ server_file.c 25 Feb 2022 18:26:11 -
> @@ -223,26 +223,53 @@ server_file_request(struct httpd *env, s
>   const char  *errstr = NULL;
>   int  fd = -1, ret, code = 500;
>   size_t   bufsiz;
> + struct stat  gzst;
> + char gzpath[PATH_MAX];
>  
>   if ((ret = server_file_method(clt)) != 0) {
>   code = ret;
>   goto abort;
>   }
>  
> + media = media_find_config(env, srv_conf, path);
> +
>   if ((ret = server_file_modified_since(clt->clt_descreq, st)) != -1) {
>   /* send the header without a body */
> - media = media_find_config(env, srv_conf, path);
>   if ((ret = server_response_http(clt, ret, media, -1,
>   MINIMUM(time(NULL), st->st_mtim.tv_sec))) == -1)
>   goto fail;
>   goto done;
>   }
>  
> + /* change path to path.gz if necessary. */
> + if (srv_conf->flags & SRVFLAG_GZIP_STATIC) {
> + struct http_descriptor  *req = clt->clt_descreq;
> + struct http_descriptor  *resp = clt->clt_descresp;
> + struct kv   *r, key;
> +
> + /* check Accept-Encoding header */
> + key.kv_key = "Accept-Encoding";
> + r = kv_find(&req->http_headers, &key);
> +
> + if (r != NULL && strstr(r->kv_value, "gzip") != NULL) {
> + /* append ".gz" to path and check existence */
> + strlcpy(gzpath, path, sizeof(gzpath));
> + strlcat(gzpath, ".gz", sizeof(gzpath));
> +

Shouldn't we check for truncation on strlcpy and strlcat and goto fail
in that event?

Other than that it looks ok to me.

> + if ((access(gzpath, R_OK) == 0) &&
> + (stat(gzpath, &gzst) == 0)) {
> + path = gzpath;
> + st = &gzst;
> + kv_add(&resp->http_headers,
> + "Content-Encoding", "gzip");
> + }
> + }
> + }
> +
>   /* Now open the file, should be readable or we have another problem */
>   if ((fd = open(path, O_RDONLY)) == -1)
>   goto abort;
>  
> - media = media_find_config(env, srv_conf, path);
>   ret = server_response_http(clt, 200, media, st->st_size,
>   MINIMUM(time(NULL), st->st_mtim.tv_sec));
>   switch (ret) {
> 

-- 

Tracey Emery



Re: Fix headphone jack on Cirrus 4206

2021-09-11 Thread Tracey Emery
On Sat, Sep 11, 2021 at 06:07:10PM +0200, Mark Kettenis wrote:
> > Date: Sat, 11 Sep 2021 08:53:00 -0600
> > From: Tracey Emery 
> > 
> > On Sat, Sep 11, 2021 at 02:14:56PM +0200, Mark Kettenis wrote:
> > > > Date: Fri, 10 Sep 2021 18:27:07 -0600
> > > > From: Tracey Emery 
> > > > 
> > > > Hello,
> > > > 
> > > > After reading some Linux commits, it shows the GPIO2 on the CS4206 chips
> > > > needs to be unmuted to make the headphone jack work. The following diff
> > > > fixed the headphone jack problem on my iMac12,2, amd64.
> > > > 
> > > > ok?
> > > 
> > > I don't think this is right.  The Linux code either frobs GPIOs 1 & 2
> > > or GPIOs 1 & 3.
> > > 
> > 
> > The code is a quirk in alsa.
> > 
> > iMac 14,1 requires the same quirk as iMac 12,2, using GPIO 2 and 3 for
> > headphone and speaker output amps.  Add the codec SSID quirk entry
> > (106b:0600) accordingly.
> > 
> > SND_PCI_QUIRK(0x106b, 0x0600, "iMac 14,1", CS420X_IMAC27_122),
> > SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
> > SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
> > SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
> > 
> > An option has to be set in their modprobe.d directory to enable the
> > heaphone jack:
> > 
> > options snd-hda-intel model=imac27
> > 
> > Without the patch below, there is signal on the headphone jack, but its
> > volume is all the way down and not controlable. With GPIO2 unmuted,
> > there is plenty of volume. Perhaps, another approach needs to be taken?
> > Does this break other Macs with that Cirrus audio chip?
> > 
> > > I also don't quite see how this would match the iMac12,2.  Can you
> > > show the pcidump -vxx output for this machine?
> > 
> > I'm sorry, it's 12,1. That is a typo. The pcidump is attached, although
> > rather large.
> 
> So your model is supposed to be handled by:
> 
> /* this conflicts with too many other models */
> /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
> 
> That one is commented out and the comment above it suggests it might
> indeed break other machines.  The comment in our code suggests that
> the same subid is used for the MacbookAir4,1.
> 

Well, if it's going to break other Macs, then I'll just keep the patch
local, so the machine is useful for me with OpenBSD.

> Looking at the Linux code it actually actually applies two quirks.
> There is an imac27_pincfgs fixup and then it chains to the
> CS420X_GPIO13 fixup.  The latter only touches gpio 1 and 3, so I am
> puzzled by your statement that gpio 2 fixes things.

Sorry, I don't know what else to say. With AZ_QRK_GPIO_UNMUTE_2 it
works. If that doesn't mean it unmutes GPIO2, then I must be saying
something incorrectly.

The datasheet for the chip shows three analog outputs:

AOUTA1,AOUTB1
AOUTA2,AOUTB2
AOUTA3,AOUTB3

I figured AZ_QRK_GPIO_UNMUTE_2 enabled AOUTA2/B2 and thought Apple tied
the headphone jack to that output.

I'll drop the diff.

Thanks.

> 
> > > > diff 51d7e35078715d4d1d1e1bf2fb89362bad8797d8 /usr/src
> > > > blob - e3b969d585a96910eca98d31bedc8ba08455f763
> > > > file + sys/dev/pci/azalia_codec.c
> > > > --- sys/dev/pci/azalia_codec.c
> > > > +++ sys/dev/pci/azalia_codec.c
> > > > @@ -71,7 +71,7 @@ azalia_codec_init_vtbl(codec_t *this)
> > > >     this->subid == 0x72708086 ||/* APPLE_MBA4_1 
> > > > */
> > > > this->subid == 0xcb7910de) {/* APPLE_MBP5_5 
> > > > */
> > > > this->qrks |= AZ_QRK_GPIO_UNMUTE_1 |
> > > > -   AZ_QRK_GPIO_UNMUTE_3;
> > > > +   AZ_QRK_GPIO_UNMUTE_2 | AZ_QRK_GPIO_UNMUTE_3;
> > > > }
> > > > break;
> > > > case 0x10134208:
> > > > 
> > > > 
> > 
> > -- 
> > 
> > Tracey Emery
> > 
> > [2:text/plain Show Save:pcidump.txt (333kB)]
> > 

-- 

Tracey Emery



Fix headphone jack on Cirrus 4206

2021-09-10 Thread Tracey Emery
Hello,

After reading some Linux commits, it shows the GPIO2 on the CS4206 chips
needs to be unmuted to make the headphone jack work. The following diff
fixed the headphone jack problem on my iMac12,2, amd64.

ok?

-- 

Tracey Emery

diff 51d7e35078715d4d1d1e1bf2fb89362bad8797d8 /usr/src
blob - e3b969d585a96910eca98d31bedc8ba08455f763
file + sys/dev/pci/azalia_codec.c
--- sys/dev/pci/azalia_codec.c
+++ sys/dev/pci/azalia_codec.c
@@ -71,7 +71,7 @@ azalia_codec_init_vtbl(codec_t *this)
this->subid == 0x72708086 ||/* APPLE_MBA4_1 */
this->subid == 0xcb7910de) {/* APPLE_MBP5_5 */
this->qrks |= AZ_QRK_GPIO_UNMUTE_1 |
-   AZ_QRK_GPIO_UNMUTE_3;
+   AZ_QRK_GPIO_UNMUTE_2 | AZ_QRK_GPIO_UNMUTE_3;
}
break;
case 0x10134208:



Re: httpd(8): fastcgi & Content-Length: 0

2021-05-19 Thread Tracey Emery
On Wed, May 19, 2021 at 08:56:48PM +0200, Paul de Weerd wrote:
> For the record: I tested this on a WordPress instance and it fixed the
> problem for me.  It was also visible in roundcubemail and wikimedia
> (firefox and safari showed the issue, chrome on the company laptop
> did not).
> 
> Thanks Florian!
> 
> Paul
> 
> On Wed, May 19, 2021 at 08:44:47PM +0200, Florian Obser wrote:
> | The whole point of using Transfer-Encoding: chunked for fastcgi was so
> | that we do not need to provide a Content-Length header if upstream
> | doesn't give us one. (We'd need to slurp in all the data ugh).
> | 
> | Now turns out that if we disable chunked encoding for zero sized bodies
> | some browsers are picky and want a Content-Length: 0 (Firefox, Safari)
> | or they'll just sit there and wait for the connection to close.
> | 
> | Problem reported by Matthias Pressfreund with wordpress.
> | Debugged with the help of weerd@ who pointed out that the problem is
> | actually browser dependent. From there it was pretty clear what the
> | problem was.
> | 
> | OK?

Working fine here. ok

> | 
> | diff --git server_fcgi.c server_fcgi.c
> | index 31d7322e9f7..b9dc4f6fe04 100644
> | --- server_fcgi.c
> | +++ server_fcgi.c
> | @@ -636,6 +636,13 @@ server_fcgi_header(struct client *clt, unsigned int 
> code)
> | if (kv_add(&resp->http_headers,
> | "Transfer-Encoding", "chunked") == NULL)
> | return (-1);
> | +   } else {
> | +   key.kv_key = "Content-Length";
> | +   if ((kv = kv_find(&resp->http_headers, &key)) == NULL) {
> | +   if (kv_add(&resp->http_headers,
> | +   "Content-Length", "0") == NULL)
> | +   return (-1);
> | +   }
> | }
> |  
> | /* Is it a persistent connection? */
> | 
> | -- 
> | I'm not entirely sure you are real.
> | 
> 
> -- 
> >[<++>-]<+++.>+++[<-->-]<.>+++[<+
> +++>-]<.>++[<>-]<+.--.[-]
>  http://www.weirdnet.nl/ 

-- 

Tracey Emery



Re: iwm(4) A-MSDU support

2021-03-29 Thread Tracey Emery
On Mon, Mar 29, 2021 at 09:27:31PM +, Brian Callahan wrote:
> Hi Stefan --
> 
> > Stefan Sperling writes:
> >
> > > This patch attempts to add support for receiving A-MSDUs to iwm(4).
> > >
> > > If you are using iwm(4) then please run with this patch and let me
> > >
> > > know if it causes regressions. Thanks!
> >
> 
> All is good on my machine as well.
> 
> iwm0 at pci4 dev 0 function 0 "Intel Dual Band Wireless AC 7260" rev 0xbb, msi
> iwm0: hw rev 0x140, fw ver 17.3216344376.0, address ac:fd:ce:09:87:97
> 
> Thanks!
> 
> ~Brian

Running all day without issue.

iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless-AC 8265" rev 0x78, msi
iwm0: hw rev 0x230, fw ver 34.0.1, address cc:2f:71:9f:86:7a

-- 

Tracey Emery



Increase timeout length for VMs trying to fully shutdown

2021-01-05 Thread Tracey Emery
Hello tech@,

Some of us have been having shutdown issues with our VMs on OpenBSDAms.
I tracked down the problem to too short of a timeout for the shutdown
event.

If there are an additional 1 or 2 package daemons running on the instance,
the timeout triggers before the VM has shutdown the package daemons and
properly synced the disks, resulting in a dirty startup.

I've increased the timeout to 2 minutes instead of 30 seconds. My test
VM on my laptop with 7 additional package daemons succeeded in 60
seconds, but that might not be fast enough for slower disks.

Am I being conservative enough with this number? Should it be another
minute or two?

Thoughts? Ok?

-- 

Tracey Emery

diff 7a6bb14936050379800deb10d4a137c4d2d4a3c4 /usr/src
blob - 9a64973ab998accb810d56c386c1bb92c204ab20
file + usr.sbin/vmd/virtio.h
--- usr.sbin/vmd/virtio.h
+++ usr.sbin/vmd/virtio.h
@@ -38,7 +38,7 @@
 
 /* VMM Control Interface shutdown timeout (in seconds) */
 #define VMMCI_TIMEOUT  3
-#define VMMCI_SHUTDOWN_TIMEOUT 30
+#define VMMCI_SHUTDOWN_TIMEOUT 120
 
 /* All the devices we support have either 1, 2 or 3 queues */
 /* viornd - 1 queue



Re: fix check of return value

2020-09-03 Thread Tracey Emery
On Thu, Sep 03, 2020 at 08:09:08AM -0600, Tracey Emery wrote:
> On Thu, Sep 03, 2020 at 02:52:49PM +0200, Robert Klein wrote:
> > Hi,
> > 
> > on lib/libc/uuid/uuid_to_string.c the return value for asprintf is
> > checked for -1 while the manpage only says "For all these functions if
> > an output or encoding error occurs, a value less than 0 is returned."
> > 
> > The patch below adjusts to code to the man page (checking for less than
> > zero).
> > 
> 
> Where in the man page does it say this?
> 

Ah, I see where it points to all returning less than zero. My search was
failing. Whoops. But, -1 is still correct for asprintf and vasprintf.

> 
> The asprintf() and vasprintf() functions return the number of bytes that
> were output to the newly allocated string (excluding the final ‘\0’).  A
> pointer to the newly allocated string is returned in ret; it should be
> passed to free(3) to release the allocated storage when it is no longer
> needed.  If sufficient space cannot be allocated or some other error
> occurs, these functions return -1.  The value of ret in this situation is
> implementation-dependent.  On OpenBSD, ret is set to the NULL pointer,
> but other implementations may leave ret unchanged.
> 
> 
> The check for -1 is correct.
> 
> Thanks!
> 
> > Best regards
> > Robert
> > 
> > 
> > Index: uuid_to_string.c
> > ===
> > RCS file: /cvs/src/lib/libc/uuid/uuid_to_string.c,v
> > retrieving revision 1.2
> > diff -u -p -r1.2 uuid_to_string.c
> > --- uuid_to_string.c10 Sep 2015 18:13:46 -  1.2
> > +++ uuid_to_string.c3 Sep 2020 12:40:41 -
> > @@ -64,6 +64,6 @@ uuid_to_string(const uuid_t *u, char **s
> > u->clock_seq_hi_and_reserved, u->clock_seq_low, u->node[0],
> >     u->node[1], u->node[2], u->node[3], u->node[4], u->node[5]);
> >  
> > -   if (c == -1 && status != NULL)
> > +   if (c < 0 && status != NULL)
> > *status = uuid_s_no_memory;
> >  }
> 
> -- 
> 
> Tracey Emery

-- 

Tracey Emery



Re: fix check of return value

2020-09-03 Thread Tracey Emery
On Thu, Sep 03, 2020 at 02:52:49PM +0200, Robert Klein wrote:
> Hi,
> 
> on lib/libc/uuid/uuid_to_string.c the return value for asprintf is
> checked for -1 while the manpage only says "For all these functions if
> an output or encoding error occurs, a value less than 0 is returned."
> 
> The patch below adjusts to code to the man page (checking for less than
> zero).
> 

Where in the man page does it say this?


The asprintf() and vasprintf() functions return the number of bytes that
were output to the newly allocated string (excluding the final ‘\0’).  A
pointer to the newly allocated string is returned in ret; it should be
passed to free(3) to release the allocated storage when it is no longer
needed.  If sufficient space cannot be allocated or some other error
occurs, these functions return -1.  The value of ret in this situation is
implementation-dependent.  On OpenBSD, ret is set to the NULL pointer,
but other implementations may leave ret unchanged.


The check for -1 is correct.

Thanks!

> Best regards
> Robert
> 
> 
> Index: uuid_to_string.c
> ===
> RCS file: /cvs/src/lib/libc/uuid/uuid_to_string.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 uuid_to_string.c
> --- uuid_to_string.c  10 Sep 2015 18:13:46 -  1.2
> +++ uuid_to_string.c  3 Sep 2020 12:40:41 -
> @@ -64,6 +64,6 @@ uuid_to_string(const uuid_t *u, char **s
>   u->clock_seq_hi_and_reserved, u->clock_seq_low, u->node[0],
>   u->node[1], u->node[2], u->node[3], u->node[4], u->node[5]);
>  
> - if (c == -1 && status != NULL)
> + if (c < 0 && status != NULL)
>   *status = uuid_s_no_memory;
>  }

-- 

Tracey Emery



Re: additions to unit(1)

2020-08-04 Thread Tracey Emery
On August 4, 2020 1:38:43 PM MDT, Tracey Emery  wrote:
>On August 4, 2020 1:24:18 PM MDT, Florian Obser 
>wrote:
>>Because of reasons I recently had to carry a lot of garbage around for
>>the municipality to pick up. They would only pickup 2 cubic meters in
>>one sitting so I had to check how much I had. Turned out to be 0.9
>m^3.
>>
>>Of course inquisitive minds wanted to know how much that is in
>>buttloads, to my great dismay units(1) did not know!
>>
>>So I had to do it by hand like some savage and of course I got the
>>conversion wrong hence the following diff:
>>
>>You have: 0.9 m3
>>You want: buttloads
>>  * 0.53207987
>>  / 1.8794171
>>
>>About half a buttload, good to know.
>>
>>Extensive research on the subject[1] found definitions for the
>>imperial buttload as well as the related metric assload. Curiously the
>>assload is a measurement of mass while the buttload is a measurement
>>of volume.
>>
>>Comments, OKs?
>>
>>diff --git units.lib units.lib
>>index 0f811786bf3..df792a0a917 100644
>>--- units.lib
>>+++ units.lib
>>@@ -452,6 +452,7 @@ asb   apostilb
>> are  1e+2 m2
>> arpentcan27.52 mi
>> arpentlin191.835 ft
>>+assload  50 kg
>> astronomicalunit AU
>> atmosphere   1.01325e+5 nt/m2
>> atm  atmosphere
>>@@ -477,6 +478,8 @@ bolt  40 yd
>> bottommeasure1|40 in
>> Bq   becquerel
>> britishthermalunit   1.05506e+3 joule fuzz
>>+butt 2 hogsheads
>>+buttload 6 seams
>> btu  britishthermalunit
>> refrigeration12000 btu/ton-hour
>> buck         dollar
>>
>>1) I tossed it into google and arrived at
>>https://en.wiktionary.org/wiki/buttload
>>as well as
>>https://www.ed.ac.uk/files/imports/fileManager/donkey%20fact%20sheet.pdf
>>
>>-- 
>>I'm not entirely sure you are real.
>
>Baaaàhahahahahahaha!
>-- 
>Tracey Emery

Oh I forgot, you absolutely get an ok from me. Bahahahah, but seriously,

Ok
-- 
Tracey Emery

Re: additions to unit(1)

2020-08-04 Thread Tracey Emery
On August 4, 2020 1:24:18 PM MDT, Florian Obser  wrote:
>Because of reasons I recently had to carry a lot of garbage around for
>the municipality to pick up. They would only pickup 2 cubic meters in
>one sitting so I had to check how much I had. Turned out to be 0.9 m^3.
>
>Of course inquisitive minds wanted to know how much that is in
>buttloads, to my great dismay units(1) did not know!
>
>So I had to do it by hand like some savage and of course I got the
>conversion wrong hence the following diff:
>
>You have: 0.9 m3
>You want: buttloads
>   * 0.53207987
>   / 1.8794171
>
>About half a buttload, good to know.
>
>Extensive research on the subject[1] found definitions for the
>imperial buttload as well as the related metric assload. Curiously the
>assload is a measurement of mass while the buttload is a measurement
>of volume.
>
>Comments, OKs?
>
>diff --git units.lib units.lib
>index 0f811786bf3..df792a0a917 100644
>--- units.lib
>+++ units.lib
>@@ -452,6 +452,7 @@ asbapostilb
> are   1e+2 m2
> arpentcan 27.52 mi
> arpentlin 191.835 ft
>+assload   50 kg
> astronomicalunit  AU
> atmosphere1.01325e+5 nt/m2
> atm   atmosphere
>@@ -477,6 +478,8 @@ bolt   40 yd
> bottommeasure 1|40 in
> Bqbecquerel
> britishthermalunit1.05506e+3 joule fuzz
>+butt  2 hogsheads
>+buttload  6 seams
> btu   britishthermalunit
> refrigeration 12000 btu/ton-hour
> buck  dollar
>
>1) I tossed it into google and arrived at
>https://en.wiktionary.org/wiki/buttload
>as well as
>https://www.ed.ac.uk/files/imports/fileManager/donkey%20fact%20sheet.pdf
>
>-- 
>I'm not entirely sure you are real.

Baaaàhahahahahahaha!
-- 
Tracey Emery

Re: 11n Tx aggregation for iwm(4)

2020-06-27 Thread Tracey Emery
On Fri, Jun 26, 2020 at 02:45:53PM +0200, Stefan Sperling wrote:
> This patch adds support for 11n Tx aggregation to iwm(4).
> 
> Please help with testing if you can by running the patch and using wifi
> as usual. Nothing should change, except that Tx speed may potentially
> improve. If you have time to run before/after performance measurements with
> tcpbench or such, that would be nice. But it's not required for testing.
> 
> If Tx aggregation is active then netstat will show a non-zero output block ack
> agreement counter:
> 
> $ netstat -W iwm0 | grep 'output block'
> 3 new output block ack agreements
>   0 output block ack agreements timed out
> 
> It would be great to get at least one test for all the chipsets the driver
> supports: 7260, 7265, 3160, 3165, 3168, 8260, 8265, 9260, 9560
> The behaviour of the access point also matters a great deal. It won't
> hurt to test the same chipset against several different access points.
> 
> I have tested this version on 8265 only so far. I've run older revisions
> of this patch on 7265 so I'm confident that this chip will work, too.
> So far, the APs I have tested against are athn(4) in 11a mode and in 11n
> mode with the 'nomimo' nwflag, and a Sagemcom 11ac AP. All on 5Ghz channels.
> 

Sure you've got plenty of 8265 tests, but the diff tripled my speed
against my apple airport extreme.

iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless-AC 8265" rev
0x78, msi

-- 

Tracey Emery



Re: Include /var/www/tmp into base install

2020-04-07 Thread Tracey Emery
On Tue, Apr 07, 2020 at 11:17:23AM -0400, Bryan Steele wrote:
> On Tue, Apr 07, 2020 at 04:56:31PM +0200, Martijn van Duren wrote:
> > This came up during u2k20 while discussing tempfiles for gotweb inside a
> > chroot. At the moment we don't include it by default and ports have to
> > create it themselves. Since I assume we want web applications to run
> > inside a /var/www chroot as much as possible and even some libc
> > functions depend on /tmp being available I'd argue we should include it
> > by default.
> 
> WIth FastCGI, perhaps I'm confused, but why do web applications need to
> be inside the /var/www chroot? Can't they be anywhere, or even have a
> seperate chroot directory? Should we be handling things things that
> are not in base? 

Both slowcgi(8) and httpd(8) chroot to /var/www and are set to the www
user. The idea was to have /var/www/tmp created by default, but with
www:www ownership. This would eliminate multiple ports from creating the
directory and allow daily to clean the dir.

To Theo's point, how was /var/tmp used in the past that it caused
problems? I'm struggling to find any info in past mailing lists.

> 
> > I also choose to make the directory 1777, similar to a normal /tmp,
> > since both multiple slowcgi or php-fpm pools can run simultaneously
> > under different users.
> > 
> > The cleanup functions don't reflect the current /tmp cleanup style, but
> > we can move the existing find statements to -delete in a separate patch.
> > 
> > I already had some positive feedback during u2k20 on the concept.
> > OK?
> > 
> > martijn@
> > 
> > Index: etc//daily
> > ===
> > RCS file: /cvs/src/etc/daily,v
> > retrieving revision 1.93
> > diff -u -p -r1.93 daily
> > --- etc//daily  9 Sep 2019 20:02:26 -   1.93
> > +++ etc//daily  7 Apr 2020 14:37:15 -
> > @@ -55,6 +55,11 @@ if [ -d /tmp -a ! -L /tmp ]; then
> > ! -path ./.ICE-unix ! -name . \
> > -execdir rmdir -- {} \; >/dev/null 2>&1; }
> >  fi
> > +if [ -d /var/www/tmp -a ! -L /var/www/tmp ]; then
> > +   cd /var/www/tmp && {
> > +   find -x . -type f -atime +7 -delete 2>/dev/null
> > +   find -x . -type d -empty -delete 2>/dev/null
> > +fi
> >  
> >  # Additional junk directory cleanup would go like this:
> >  #if [ -d /scratch -a ! -L /scratch ]; then
> > Index: etc//rc
> > ===
> > RCS file: /cvs/src/etc/rc,v
> > retrieving revision 1.543
> > diff -u -p -r1.543 rc
> > --- etc//rc 24 Jan 2020 06:17:37 -  1.543
> > +++ etc//rc 7 Apr 2020 14:37:15 -
> > @@ -532,7 +532,7 @@ if [[ -f /etc/ptmp ]]; then
> > 'password file may be incorrect -- /etc/ptmp exists'
> >  fi
> >  
> > -echo clearing /tmp
> > +echo clearing temporary directories
> >  
> >  # Prune quickly with one rm, then use find to clean up /tmp/[lqv]*
> >  # (not needed with mfs /tmp, but doesn't hurt there...).
> > @@ -540,6 +540,7 @@ echo clearing /tmp
> >  (cd /tmp &&
> >  find . -maxdepth 1 ! -name . ! -name lost+found ! -name quota.user \
> > ! -name quota.group ! -name vi.recover -execdir rm -rf -- {} \;)
> > +(cd /var/www/tmp && find . -x -delete)
> >  
> >  # Create Unix sockets directories for X if needed and make sure they have
> >  # correct permissions.
> > Index: etc//mtree/4.4BSD.dist
> > ===
> > RCS file: /cvs/src/etc/mtree/4.4BSD.dist,v
> > retrieving revision 1.314
> > diff -u -p -r1.314 4.4BSD.dist
> > --- etc//mtree/4.4BSD.dist  29 Nov 2019 03:28:20 -  1.314
> > +++ etc//mtree/4.4BSD.dist  7 Apr 2020 14:37:15 -
> > @@ -749,6 +749,7 @@ var
> >  ..
> >  runtype=dir uname=root gname=daemon 
> > mode=755
> >  ..
> > +tmptype=dir uname=root gname=wheel 
> > mode=01777
> >  ..
> >  
> >  # ./var/audit
> > 
> > 

-- 

Tracey Emery



in httpd, use the correct configured server config

2020-01-14 Thread Tracey Emery
Hello,

In the server_response function of httpd, the if comparison to
srv_conf->maxrequests is using the wrong value. The value is derived from the
first server configuration in httpd.conf, since we still don't know which server
name the client is requesting.

This small diff moves srv_conf->maxrequests usage in server_response to
where we finally know which configured server config to actually use.
This ensures we are not using the first configured server config in the
queue.

Thanks,

Tracey

-- 

Tracey Emery

diff e80014c68b2561493718bbcef6e7fcb172d7f885 /usr/src
blob - 326daa6a687ff7159adc744f66b38e6ea9e266eb
file + usr.sbin/httpd/server_http.c
--- usr.sbin/httpd/server_http.c
+++ usr.sbin/httpd/server_http.c
@@ -1232,13 +1232,6 @@ server_response(struct httpd *httpd, struct client *cl
clt->clt_persist = 0;
}
 
-   if (clt->clt_persist >= srv_conf->maxrequests)
-   clt->clt_persist = 0;
-
-   /* pipelining should end after the first "idempotent" method */
-   if (clt->clt_pipelining && clt->clt_toread > 0)
-   clt->clt_persist = 0;
-
/*
 * Do we have a Host header and matching configuration?
 * XXX the Host can also appear in the URL path.
@@ -1291,6 +1284,13 @@ server_response(struct httpd *httpd, struct client *cl
goto fail;
srv_conf = clt->clt_srv_conf;
}
+
+   if (clt->clt_persist >= srv_conf->maxrequests)
+   clt->clt_persist = 0;
+
+   /* pipelining should end after the first "idempotent" method */
+   if (clt->clt_pipelining && clt->clt_toread > 0)
+   clt->clt_persist = 0;
 
if ((desc->http_host = strdup(hostname)) == NULL)
goto fail;



Re: iwm: support new umac scan API

2019-11-05 Thread Tracey Emery
On Mon, Nov 04, 2019 at 05:11:07PM +0100, Stefan Sperling wrote:
> Great, thank you! Please keep running it and let me know if you come
> across anything wonky :-)

Everything has been stable since yesterday. No wonkiness observed! :D

-- 

Tracey Emery



Re: iwm: support new umac scan API

2019-11-04 Thread Tracey Emery
On Mon, Nov 04, 2019 at 04:56:14PM +0100, Stefan Sperling wrote:
> If you want to test -34 you can copy the -34 firmware file on top of
> the -22 file. (Keep a backup!)
> 
> Alternatively, you could change the filename the driver will look for.
> The lines in if_iwm.c which would need to be changed contain the
> expected firmware file name, for instance:
> 
>   sc->sc_fwname = "iwm-8265-22";
> 
> So just replace -22 with -34 and rebuild the kernel.

Yup, definitely missed something obvious. Running stable on -34 as well.

-- 

Tracey Emery



Re: iwm: support new umac scan API

2019-11-04 Thread Tracey Emery
uint32_t suspend_time;
> + uint32_t scan_priority;
> + struct iwm_scan_umac_chan_param channel;
> + uint8_t data[];
> + } v1; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
> + struct {
> + uint8_t extended_dwell;
> + uint8_t active_dwell;
> + uint8_t passive_dwell;
> + uint8_t fragmented_dwell;
> + uint32_t max_out_time[2];
> + uint32_t suspend_time[2];
> + uint32_t scan_priority;
> + struct iwm_scan_umac_chan_param channel;
> + uint8_t data[];
> + } v6; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_6 */
> + struct {
> + uint8_t active_dwell;
> + uint8_t passive_dwell;
> + uint8_t fragmented_dwell;
> +     uint8_t adwell_default_n_aps;
> + uint8_t adwell_default_n_aps_social;
> + uint8_t reserved3;
> + uint16_t adwell_max_budget;
> + uint32_t max_out_time[2];
> + uint32_t suspend_time[2];
> + uint32_t scan_priority;
> + struct iwm_scan_umac_chan_param channel;
> + uint8_t data[];
> + } v7; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_7 */
> + struct {
> + uint8_t active_dwell[2];
> + uint8_t reserved2;
> + uint8_t adwell_default_n_aps;
> + uint8_t adwell_default_n_aps_social;
> + uint8_t general_flags2;
> + uint16_t adwell_max_budget;
> + uint32_t max_out_time[2];
> + uint32_t suspend_time[2];
> + uint32_t scan_priority;
> + uint8_t passive_dwell[2];
> + uint8_t num_of_fragments[2];
> + struct iwm_scan_umac_chan_param channel;
> + uint8_t data[];
> + } v8; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_8 */
> + struct {
> + uint8_t active_dwell[2];
> + uint8_t adwell_default_hb_n_aps;
> + uint8_t adwell_default_lb_n_aps;
> + uint8_t adwell_default_n_aps_social;
> + uint8_t general_flags2;
> + uint16_t adwell_max_budget;
> + uint32_t max_out_time[2];
> + uint32_t suspend_time[2];
> + uint32_t scan_priority;
> + uint8_t passive_dwell[2];
> + uint8_t num_of_fragments[2];
> + struct iwm_scan_umac_chan_param channel;
> + uint8_t data[];
> + } v9; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_9 */
> + };
> +} __packed;
> +
> +#define IWM_SCAN_REQ_UMAC_SIZE_V8 sizeof(struct iwm_scan_req_umac)
> +#define IWM_SCAN_REQ_UMAC_SIZE_V7 48
> +#define IWM_SCAN_REQ_UMAC_SIZE_V6 44
> +#define IWM_SCAN_REQ_UMAC_SIZE_V1 36
>  
>  /**
>   * struct iwm_umac_scan_abort

-- 

Tracey Emery



Re: acpivout: try to consistently adjust brightness by 5%

2019-10-14 Thread Tracey Emery
Patch works well on a T470s. Stepping is better in the larger
increments. No ill effects from the patch here.

Thanks,

Tracey

On Sun, Oct 13, 2019 at 09:28:26PM -0500, joshua stein wrote:
> When responding to hardware keys to increment or decrement screen 
> brightness, don't just adjust by 1 BCL level as there may be 100 
> levels.  Find the next brightness level that is at least 5% up or 
> down, and use that.
> 
> 
> Index: dev/acpi/acpivout.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/acpivout.c,v
> retrieving revision 1.13
> diff -u -p -u -p -r1.13 acpivout.c
> --- dev/acpi/acpivout.c   13 Oct 2019 10:56:31 -  1.13
> +++ dev/acpi/acpivout.c   14 Oct 2019 02:26:12 -
> @@ -47,6 +47,8 @@ int acpivout_notify(struct aml_node *, i
>  #define NOTIFY_BRIGHTNESS_ZERO   0x88
>  #define NOTIFY_DISPLAY_OFF   0x89
>  
> +#define BRIGHTNESS_STEP  5
> +
>  struct acpivout_softc {
>   struct device   sc_dev;
>  
> @@ -61,8 +63,7 @@ struct acpivout_softc {
>  };
>  
>  void acpivout_brightness_cycle(struct acpivout_softc *);
> -void acpivout_brightness_up(struct acpivout_softc *);
> -void acpivout_brightness_down(struct acpivout_softc *);
> +void acpivout_brightness_step(struct acpivout_softc *, int);
>  void acpivout_brightness_zero(struct acpivout_softc *);
>  int  acpivout_get_brightness(struct acpivout_softc *);
>  int  acpivout_find_brightness(struct acpivout_softc *, int);
> @@ -128,10 +129,10 @@ acpivout_notify(struct aml_node *node, i
>   acpivout_brightness_cycle(sc);
>   break;
>   case NOTIFY_BRIGHTNESS_UP:
> - acpivout_brightness_up(sc);
> + acpivout_brightness_step(sc, 1);
>   break;
>   case NOTIFY_BRIGHTNESS_DOWN:
> - acpivout_brightness_down(sc);
> + acpivout_brightness_step(sc, -1);
>   break;
>   case NOTIFY_BRIGHTNESS_ZERO:
>   acpivout_brightness_zero(sc);
> @@ -158,45 +159,31 @@ acpivout_brightness_cycle(struct acpivou
>   if (cur_level == sc->sc_bcl[sc->sc_bcl_len - 1])
>   acpivout_brightness_zero(sc);
>   else
> - acpivout_brightness_up(sc);
> -}
> -
> -void
> -acpivout_brightness_up(struct acpivout_softc *sc)
> -{
> - int i, cur_level;
> -
> - if (sc->sc_bcl_len == 0)
> - return;
> - cur_level = acpivout_get_brightness(sc);
> - if (cur_level == -1)
> - return;
> -
> - /* check for max brightness level */
> - if (cur_level == sc->sc_bcl[sc->sc_bcl_len - 1])
> - return;
> -
> - for (i = 0; i < sc->sc_bcl_len && cur_level != sc->sc_bcl[i]; i++);
> - acpivout_set_brightness(sc, sc->sc_bcl[i + 1]);
> + acpivout_brightness_step(sc, 1);
>  }
>  
>  void
> -acpivout_brightness_down(struct acpivout_softc *sc)
> +acpivout_brightness_step(struct acpivout_softc *sc, int dir)
>  {
> - int i, cur_level;
> + int level, nlevel;
>  
>   if (sc->sc_bcl_len == 0)
>   return;
> - cur_level = acpivout_get_brightness(sc);
> - if (cur_level == -1)
> + level = acpivout_get_brightness(sc);
> + if (level == -1)
>   return;
>  
> - /* check for min brightness level */
> - if (cur_level == sc->sc_bcl[0])
> + nlevel = acpivout_find_brightness(sc, level + (dir * BRIGHTNESS_STEP));
> + if (nlevel == level) {
> + if (dir == 1 && (nlevel + 1 < sc->sc_bcl_len))
> + nlevel++;
> + else if (dir == -1 && (nlevel - 1 >= 0))
> + nlevel--;
> + }
> + if (nlevel == level)
>   return;
>  
> - for (i = 0; i < sc->sc_bcl_len && cur_level != sc->sc_bcl[i]; i++);
> - acpivout_set_brightness(sc, sc->sc_bcl[i - 1]);
> + acpivout_set_brightness(sc, nlevel);
>  }
>  
>  void

-- 

Tracey Emery



Re: acpithinkpad: don't take over ws_[gs]et_param on version 2 devices

2019-10-14 Thread Tracey Emery
Patch works great on a T470s. Stepping is smooth now. No ill effects.

Thanks,

Tracey

On Sun, Oct 13, 2019 at 09:37:53PM -0500, joshua stein wrote:
> Newer ThinkPads have ACPI goo to allow acpivout to control screen 
> backlight, so don't take over ws_[gs]et_param from it.  This allows 
> for 100 levels of backlight control rather than the 10 or 15 that 
> are supported through acpithinkpad using its proprietary ACPI or 
> CMOS interfaces.
> 
> You can see the difference with and without this patch by doing:
> 
> xbacklight -set 1 -steps 100
> xbacklight -set 100 -steps 100
> 
> Apparently this will also be needed for newer AMD ThinkPads that use 
> radeondrm.
> 
> "Newer" here is being defined as anything not reporting version 1 
> (THINKPAD_HKEY_VERSION1) of the ThinkPad ACPI interface.
> 
> For responding to hardware brightness keys, you'll want to test with 
> the acpivout patch I posted since otherwise the keys will be 
> adjusting the backlight by 1% each time, and it may seem like it's 
> not doing anything.  That patch makes it properly adjust by 5% each 
> time (but you still get fine-grained changes through wsconsctl or 
> xbacklight).
> 
> 
> Index: sys/dev/acpi/acpithinkpad.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v
> retrieving revision 1.66
> diff -u -p -u -p -r1.66 acpithinkpad.c
> --- sys/dev/acpi/acpithinkpad.c   13 Oct 2019 10:56:31 -  1.66
> +++ sys/dev/acpi/acpithinkpad.c   14 Oct 2019 02:28:57 -
> @@ -320,8 +320,10 @@ thinkpad_attach(struct device *parent, s
>   wskbd_set_backlight = thinkpad_set_kbd_backlight;
>   }
>  
> - if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "PBLG",
> - 0, NULL, &sc->sc_brightness) == 0) {
> + /* On version 2 and newer, let *drm or acpivout control brightness */
> + if (sc->sc_hkey_version == THINKPAD_HKEY_VERSION1 &&
> + (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "PBLG",
> + 0, NULL, &sc->sc_brightness) == 0)) {
>   ws_get_param = thinkpad_get_param;
>   ws_set_param = thinkpad_set_param;
>   }

-- 

Tracey Emery



Re: [Patch] Driver for Keyspan USA-19HS

2019-06-04 Thread Tracey Emery
On Mon, Jun 03, 2019 at 11:44:37PM -0400, Cody Cutler wrote:
> Hi jcs and tech, the following is a patch which implements jcs's feedback and
> adds a man page.
> 
> Note that one must execute `make -C sys/dev/usb' after applying to build.
> 
> Thanks!
> 
> diff --git share/man/man4/Makefile share/man/man4/Makefile
> index 7d470b6ca47..999621c7889 100644
> --- share/man/man4/Makefile
> +++ share/man/man4/Makefile
> @@ -71,7 +71,7 @@ MAN=aac.4 abcrtc.4 ac97.4 acphy.4 acrtc.4 \
>   tlphy.4 thmc.4 tpm.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 tun.4 tap.4 \
>   twe.4 \
>   txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
> - ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 uslhcom.4 \
> + ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
>   udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
>   uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uipaq.4 \
>   uk.4 ukbd.4 \
> diff --git share/man/man4/ucom.4 share/man/man4/ucom.4
> index e14df75675b..bde53a2c5e1 100644
> --- share/man/man4/ucom.4
> +++ share/man/man4/ucom.4
> @@ -42,6 +42,7 @@
>  .Cd "ucom* at ucycom?"   # Cypress
>  .Cd "ucom* at uftdi?"# FTDI
>  .Cd "ucom* at uipaq?"# iPAQ
> +.Cd "ucom* at ukspan?"   # Keyspan
>  .Cd "ucom* at umcs?" # MosChip Semiconductor multiport
>  .Cd "ucom* at umct?" # MCT
>  .Cd "ucom* at umodem?"   # Standardized umodem
> diff --git share/man/man4/ukspan.4 share/man/man4/ukspan.4
> new file mode 100644
> index 000..2b98f1efcb5
> --- /dev/null
> +++ share/man/man4/ukspan.4
> @@ -0,0 +1,39 @@
> +.\" Copyright (c) 2019 Cody Cutler 
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate$
> +.Dt UKSPAN 4
> +.Os
> +.Sh NAME
> +.Nm ukspan
> +.Nd Keyspan USB serial adapter
> +.Sh SYNOPSIS
> +.Cd "ukspan* at uhub?"
> +.Cd "ucom*   at ukspan?"
> +.Sh DESCRIPTION
> +The
> +.Nm
> +driver supports the TrippLite Keyspan USA-19HS serial adapter, which is made
> +accessible through
> +.Xr ucom 4 .
> +.Sh SEE ALSO
> +.Xr tty 4 ,
> +.Xr ucom 4 ,
> +.Xr uhub 4 ,
> +.Xr usb 4
> +.Sh AUTHORS
> +The
> +.Nm
> +driver was written by
> +.An Cody Cutler Aq Mt ccut...@csail.mit.edu .
> diff --git share/man/man4/usb.4 share/man/man4/usb.4
> index 520d513f5b1..81a4abd8c70 100644
> --- share/man/man4/usb.4
> +++ share/man/man4/usb.4
> @@ -188,6 +188,8 @@ FTDI USB serial adapter
>  iPAQ USB units
>  .It Xr ulpt 4
>  USB printer support
> +.It Xr ukspan 4
> +Keyspan serial adapter
>  .It Xr umcs 4
>  MosChip Semiconductor based USB multiport serial adapter
>  .It Xr umct 4
> diff --git sys/arch/amd64/conf/GENERIC sys/arch/amd64/conf/GENERIC
> index ad192f4ea1d..5b5d37c24e2 100644
> --- sys/arch/amd64/conf/GENERIC
> +++ sys/arch/amd64/conf/GENERIC
> @@ -224,6 +224,8 @@ uvscom*   at uhub?# SUNTAC Slipper U 
> VS-10U serial
>  ucom*at uvscom?
>  ubsa*at uhub?# Belkin serial adapter
>  ucom*at ubsa?
> +ukspan* at uhub? # Keyspan USA19HS serial adapter
> +ucom*at ukspan?
>  uftdi*   at uhub?# FTDI FT8U100AX serial adapter
>  ucom*at uftdi?
>  uplcom* at uhub? # I/O DATA USB-RSAQ2 serial adapter
> diff --git sys/dev/usb/files.usb sys/dev/usb/files.usb
> index 1036cf36232..29bc1205540 100644
> --- sys/dev/usb/files.usb
> +++ sys/dev/usb/files.usb
> @@ -317,6 +317,11 @@ device   ubsa: ucombus
>  attach   ubsa at uhub
>  file dev/usb/ubsa.c  ubsa
>  
> +# Keyspan USA19HS serial
> +device   ukspan: ucombus
> +attach   ukspan at uhub
> +file dev/usb/ukspan.cukspan
> +
>  # Silicon Laboratories CP210x serial
>  device   uslcom: ucombus
>  attach   uslcom at uhub
> diff --git sys/dev/usb/ukspan.c sys/dev/usb/ukspan.c
> new file mode 100644
> index 000..5f5e9583641
> --- /dev/null
> +++ sys/dev/usb/ukspan.c
> @@ -0,0 +1,594 @@
> +/*
> + * Copyright (c) 2019 Cody Cutler 
> + *
> + * Permission to use, copy, modify, and distribute this software for any
> + * purpose with or without fee is hereby granted, provided that the above
> + * copyright notice and this permission notice appear in all copies.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRAN

Re: [Patch] Driver for Keyspan USA-19HS

2019-05-29 Thread Tracey Emery
> 
> The routine for adding USB devices is to just add them to 
> /usr/src/sys/dev/usb/usbdevs, then run 'make' in 
> /usr/src/sys/dev/usb/.  That will automatically regenerate usbdevs.h 
> and usbdevs_data.h.

I'm happy to test when the new diff is submitted. I have a USA19HS
sitting in my desk.

Tracey



Re: cp(1) add -l hard link -s symlink options

2019-05-23 Thread Tracey Emery
On Thu, May 23, 2019 at 10:21:34PM +0100, Stuart Henderson wrote:
> On 2019/05/23 22:58, Ingo Schwarze wrote:
> > Hi Tracey,
> > 
> > Tracey Emery wrote on Thu, May 23, 2019 at 02:35:10PM -0600:
> > 
> > > Attached is a proposed diff for cp(1). It adds the -l (hard link)
> > > and -s (symlink) options.
> > 
> > I don't like that.  That's exactly what can be done with ln(1) in a
> > standard way.  There is no value in making every tool do everything -
> > quite to that contrary, that only causes gratuitous complication and
> > confusion.
> 
> It can be done, but I think the main point of this cp(1) option is that
> it works with -r. You can also do that with a combination of ln(1) and
> find(1), but it's more awkward, and there's potentially a lot of fork
> overhead if copying a deep tree.
> 
> > > These options are available in GNU cp, FreeBSD cp,
> > > and the -l option is at least in NetBSD and Dragonfly.
> > > 
> > > I needed the -l option to use the system cp for rsnapshots, instead of
> > > their native_cl_al function. Hopefully, this will speed up my backups.
> > 
> > If the rsnapshots uses such options, i think you should send patches
> > to the rsnapshots project instead.  Tell them to use POSIX features
> > instead of relying on pointless GNUisms.
> 
> I don't use rsnapshot but from a quick glance it appears to be a non-
> default option that they only suggest using on Linux. (Rather than
> modifying /bin/cp, an alternative would be to install coreutils and
> point it at gcp).

Ah, good idea on gcp, Stuart. Thanks. I wanted to explore the
non-native_cp_al option for speed gains. I'll test the gcp route. Hadn't
thought that far ahead!



Re: cp(1) add -l hard link -s symlink options

2019-05-23 Thread Tracey Emery
On Thu, May 23, 2019 at 10:58:15PM +0200, Ingo Schwarze wrote:
> Hi Tracey,
> 
> Tracey Emery wrote on Thu, May 23, 2019 at 02:35:10PM -0600:
> 
> > Attached is a proposed diff for cp(1). It adds the -l (hard link)
> > and -s (symlink) options.
> 
> I don't like that.  That's exactly what can be done with ln(1) in a
> standard way.  There is no value in making every tool do everything -
> quite to that contrary, that only causes gratuitous complication and
> confusion.
> 
> > These options are available in GNU cp, FreeBSD cp,
> > and the -l option is at least in NetBSD and Dragonfly.
> > 
> > I needed the -l option to use the system cp for rsnapshots, instead of
> > their native_cl_al function. Hopefully, this will speed up my backups.
> 
> If the rsnapshots uses such options, i think you should send patches
> to the rsnapshots project instead.  Tell them to use POSIX features
> instead of relying on pointless GNUisms.
> 
> Yours,
>   Ingo

Cool! Thanks.
T



Re: cp(1) add -l hard link -s symlink options

2019-05-23 Thread Tracey Emery
On Thu, May 23, 2019 at 02:35:10PM -0600, Tracey Emery wrote:
> Hello tech@,
> 
> Attached is a proposed diff for cp(1). It adds the -l (hard link) and -s
> (symlink) options. These options are available in GNU cp, FreeBSD cp,
> and the -l option is at least in NetBSD and Dragonfly.
> 
> I needed the -l option to use the system cp for rsnapshots, instead of
> their native_cl_al function. Hopefully, this will speed up my backups.
> 
> Thanks for your consideration,
> Tracey
> 
> 
> Index: bin/cp/cp.1
> ===
> RCS file: /cvs/src/bin/cp/cp.1,v
> retrieving revision 1.40
> diff -u -p -u -r1.40 cp.1
> --- bin/cp/cp.1   28 Jan 2019 18:58:42 -  1.40
> +++ bin/cp/cp.1   23 May 2019 20:28:29 -
> @@ -103,6 +103,8 @@ The
>  option overrides any previous
>  .Fl f
>  options.
> +.It Fl l
> +Create hard links to regular files in a hierarchy instead of copying.
>  .It Fl L
>  If the
>  .Fl R
> @@ -128,6 +130,8 @@ If the source file has both its set-user
>  and either the user ID or group ID cannot be preserved, neither
>  the set-user-ID nor set-group-ID bits are preserved in the copy's
>  permissions.
> +.It Fl s
> +Create symbolic links to regular files in a hirarcy instead of copying.
>  .It Fl R
>  If
>  .Ar source
> Index: bin/cp/cp.c
> ===
> RCS file: /cvs/src/bin/cp/cp.c,v
> retrieving revision 1.52
> diff -u -p -u -r1.52 cp.c
> --- bin/cp/cp.c   28 Jan 2019 18:58:42 -  1.52
> +++ bin/cp/cp.c   23 May 2019 20:28:30 -
> @@ -71,7 +71,7 @@
>  PATH_T to = { to.p_path, "" };
>  
>  uid_t myuid;
> -int Rflag, fflag, iflag, pflag, rflag, vflag;
> +int Rflag, fflag, iflag, lflag, pflag, rflag, sflag, vflag;
>  mode_t myumask;
>  
>  enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
> @@ -88,7 +88,7 @@ main(int argc, char *argv[])
>   char *target;
>  
>   Hflag = Lflag = Pflag = Rflag = 0;
> - while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1)
> + while ((ch = getopt(argc, argv, "HLPRafiprvls")) != -1)
>   switch (ch) {
>   case 'H':
>   Hflag = 1;
> @@ -119,12 +119,18 @@ main(int argc, char *argv[])
>   iflag = 1;
>   fflag = 0;
>   break;
> + case 'l':
> + lflag = 1;
> + break;
>   case 'p':
>   pflag = 1;
>   break;
>   case 'r':
>   rflag = 1;
>   break;
> + case 's':
> + sflag = 1;
> + break;
>   case 'v':
>   vflag = 1;
>   break;
> @@ -157,6 +163,8 @@ main(int argc, char *argv[])
>   fts_options &= ~FTS_PHYSICAL;
>   fts_options |= FTS_LOGICAL;
>   }
> + if (lflag && sflag)
> + errx(1, "the -l and -s options may not be specified together.");
>   if (Rflag) {
>   if (Hflag)
>   fts_options |= FTS_COMFOLLOW;
> @@ -319,7 +327,7 @@ copy(char *argv[], enum op type, int fts
>   if (type != DIR_TO_DNE) {
>   p = find_last_component(curr->fts_path);
>   base = p - curr->fts_path;
> - 
> +
>   if (!strcmp(&curr->fts_path[base],
>   ".."))
>   base += 1;
> @@ -435,7 +443,7 @@ copy(char *argv[], enum op type, int fts
>   break;
>   case S_IFBLK:
>   case S_IFCHR:
> - if (Rflag) {
> + if (Rflag && !sflag) {
>   if ((cval = copy_special(curr->fts_statp,
>   !fts_dne(curr))) == 1)
>   rval = 1;
> @@ -448,7 +456,7 @@ copy(char *argv[], enum op type, int fts
>   cval = 0;
>   break;
>   case S_IFIFO:
> - if (Rflag) {
> + if (Rflag && !sflag) {
>   if ((cval = copy_fifo(curr->fts_statp,
>   !fts_dne(curr))) == 1)
> 

cp(1) add -l hard link -s symlink options

2019-05-23 Thread Tracey Emery
Hello tech@,

Attached is a proposed diff for cp(1). It adds the -l (hard link) and -s
(symlink) options. These options are available in GNU cp, FreeBSD cp,
and the -l option is at least in NetBSD and Dragonfly.

I needed the -l option to use the system cp for rsnapshots, instead of
their native_cl_al function. Hopefully, this will speed up my backups.

Thanks for your consideration,
Tracey


Index: bin/cp/cp.1
===
RCS file: /cvs/src/bin/cp/cp.1,v
retrieving revision 1.40
diff -u -p -u -r1.40 cp.1
--- bin/cp/cp.1 28 Jan 2019 18:58:42 -  1.40
+++ bin/cp/cp.1 23 May 2019 20:28:29 -
@@ -103,6 +103,8 @@ The
 option overrides any previous
 .Fl f
 options.
+.It Fl l
+Create hard links to regular files in a hierarchy instead of copying.
 .It Fl L
 If the
 .Fl R
@@ -128,6 +130,8 @@ If the source file has both its set-user
 and either the user ID or group ID cannot be preserved, neither
 the set-user-ID nor set-group-ID bits are preserved in the copy's
 permissions.
+.It Fl s
+Create symbolic links to regular files in a hirarcy instead of copying.
 .It Fl R
 If
 .Ar source
Index: bin/cp/cp.c
===
RCS file: /cvs/src/bin/cp/cp.c,v
retrieving revision 1.52
diff -u -p -u -r1.52 cp.c
--- bin/cp/cp.c 28 Jan 2019 18:58:42 -  1.52
+++ bin/cp/cp.c 23 May 2019 20:28:30 -
@@ -71,7 +71,7 @@
 PATH_T to = { to.p_path, "" };
 
 uid_t myuid;
-int Rflag, fflag, iflag, pflag, rflag, vflag;
+int Rflag, fflag, iflag, lflag, pflag, rflag, sflag, vflag;
 mode_t myumask;
 
 enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
char *target;
 
Hflag = Lflag = Pflag = Rflag = 0;
-   while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1)
+   while ((ch = getopt(argc, argv, "HLPRafiprvls")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -119,12 +119,18 @@ main(int argc, char *argv[])
iflag = 1;
fflag = 0;
break;
+   case 'l':
+   lflag = 1;
+   break;
case 'p':
pflag = 1;
break;
case 'r':
rflag = 1;
break;
+   case 's':
+   sflag = 1;
+   break;
case 'v':
vflag = 1;
break;
@@ -157,6 +163,8 @@ main(int argc, char *argv[])
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
}
+   if (lflag && sflag)
+   errx(1, "the -l and -s options may not be specified together.");
if (Rflag) {
if (Hflag)
fts_options |= FTS_COMFOLLOW;
@@ -319,7 +327,7 @@ copy(char *argv[], enum op type, int fts
if (type != DIR_TO_DNE) {
p = find_last_component(curr->fts_path);
base = p - curr->fts_path;
-   
+
if (!strcmp(&curr->fts_path[base],
".."))
base += 1;
@@ -435,7 +443,7 @@ copy(char *argv[], enum op type, int fts
break;
case S_IFBLK:
case S_IFCHR:
-   if (Rflag) {
+   if (Rflag && !sflag) {
if ((cval = copy_special(curr->fts_statp,
!fts_dne(curr))) == 1)
rval = 1;
@@ -448,7 +456,7 @@ copy(char *argv[], enum op type, int fts
cval = 0;
break;
case S_IFIFO:
-   if (Rflag) {
+   if (Rflag && !sflag) {
if ((cval = copy_fifo(curr->fts_statp,
!fts_dne(curr))) == 1)
rval = 1;
Index: bin/cp/extern.h
===
RCS file: /cvs/src/bin/cp/extern.h,v
retrieving revision 1.15
diff -u -p -u -r1.15 extern.h
--- bin/cp/extern.h 26 Dec 2015 18:11:43 -  1.15
+++ bin/cp/extern.h 23 May 2019 20:28:30 -
@@ -40,7 +40,7 @@ typedef struct {
 
 extern PATH_T to;
 extern uid_t myuid;
-extern int fflag, iflag, pflag;
+extern int fflag, iflag, lflag, pflag, sflag;
 extern mode_t myumask;
 extern char *__progname;
 
Index: bin/cp/utils.c
===
RCS file: /cvs/src/bin/cp/utils.c,v
retrieving revision 1.47
diff -u -p -u -r1.47 utils.c
--- bin/c

Re: acpithinkpad: a fix for the x260

2019-03-07 Thread Tracey Emery
No problems here.
Tracey

On Wed, Mar 06, 2019 at 08:55:15PM -0600, joshua stein wrote:
> sthen found that the HKEY version metric failed on the x260 where it 
> reports version 1 but requires the new ACPI method of changing 
> backlight.
> 
> This diff tries to do the ACPI method on all machines and falls back 
> to the CMOS method if that fails.
> 
> Can all those that tried the previous diff (which has been 
> committed) try this one and make sure nothing broke?
> 
> This also unmasks the microphone mute event which helps mixerctl 
> stay in sync on the x260 (it has no effect on my x1c6, but probably 
> can't hurt).
> 
> 
> Index: sys/dev/acpi/acpithinkpad.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v
> retrieving revision 1.63
> diff -u -p -u -p -r1.63 acpithinkpad.c
> --- sys/dev/acpi/acpithinkpad.c   6 Mar 2019 15:36:30 -   1.63
> +++ sys/dev/acpi/acpithinkpad.c   7 Mar 2019 02:53:36 -
> @@ -124,6 +124,7 @@
>   #define THINKPAD_ADAPTIVE_MODE_HOME 1
>   #define THINKPAD_ADAPTIVE_MODE_FUNCTION 3
>   
> +#define THINKPAD_MASK_MIC_MUTE   (1 << 14)
>   #define THINKPAD_MASK_BRIGHTNESS_UP (1 << 15)
>   #define THINKPAD_MASK_BRIGHTNESS_DOWN   (1 << 16)
>   #define THINKPAD_MASK_KBD_BACKLIGHT (1 << 17)
> @@ -171,8 +172,8 @@ int   thinkpad_get_kbd_backlight(struct ws
>   int thinkpad_set_kbd_backlight(struct wskbd_backlight *);
>   extern int (*wskbd_get_backlight)(struct wskbd_backlight *);
>   extern int (*wskbd_set_backlight)(struct wskbd_backlight *);
> -void thinkpad_get_brightness(struct acpithinkpad_softc *);
> -void thinkpad_set_brightness(void *, int);
> +int  thinkpad_get_brightness(struct acpithinkpad_softc *);
> +int  thinkpad_set_brightness(void *, int);
>   int thinkpad_get_param(struct wsdisplay_param *);
>   int thinkpad_set_param(struct wsdisplay_param *);
>   extern int (*ws_get_param)(struct wsdisplay_param *);
> @@ -345,7 +346,9 @@ thinkpad_enable_events(struct acpithinkp
>   }
>   
>   /* Enable events we need to know about */
> - mask |= (THINKPAD_MASK_BRIGHTNESS_UP | THINKPAD_MASK_BRIGHTNESS_DOWN |
> + mask |= (THINKPAD_MASK_MIC_MUTE |
> + THINKPAD_MASK_BRIGHTNESS_UP |
> + THINKPAD_MASK_BRIGHTNESS_DOWN |
>   THINKPAD_MASK_KBD_BACKLIGHT);
>   
>   DPRINTF(("%s: setting event mask to 0x%llx\n", DEVNAME(sc), mask));
> @@ -555,8 +558,7 @@ thinkpad_brightness_up(struct acpithinkp
>   {
>   int b;
>   
> - if (sc->sc_hkey_version == THINKPAD_HKEY_VERSION2) {
> - thinkpad_get_brightness(sc);
> + if (thinkpad_get_brightness(sc) == 0) {
>   b = sc->sc_brightness & 0xff;
>   if (b < ((sc->sc_brightness >> 8) & 0xff)) {
>   sc->sc_brightness = b + 1;
> @@ -573,8 +575,7 @@ thinkpad_brightness_down(struct acpithin
>   {
>   int b;
>   
> - if (sc->sc_hkey_version == THINKPAD_HKEY_VERSION2) {
> - thinkpad_get_brightness(sc);
> + if (thinkpad_get_brightness(sc) == 0) {
>   b = sc->sc_brightness & 0xff;
>   if (b > 0) {
>   sc->sc_brightness = b - 1;
> @@ -701,30 +702,39 @@ thinkpad_set_kbd_backlight(struct wskbd_
>   return 0;
>   }
>   
> -void
> +int
>   thinkpad_get_brightness(struct acpithinkpad_softc *sc)
>   {
> - aml_evalinteger(sc->sc_acpi, sc->sc_devnode,
> - "PBLG", 0, NULL, &sc->sc_brightness);
> + int ret;
> +
> + ret = aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "PBLG", 0, NULL,
> + &sc->sc_brightness);
>   
>   DPRINTF(("%s: %s: 0x%llx\n", DEVNAME(sc), __func__, sc->sc_brightness));
> +
> + return ret;
>   }
>   
> -void
> +int
>   thinkpad_set_brightness(void *arg0, int arg1)
>   {
>   struct acpithinkpad_softc *sc = arg0;
>   struct aml_value arg;
> + int ret;
>   
>   DPRINTF(("%s: %s: 0x%llx\n", DEVNAME(sc), __func__, sc->sc_brightness));
>   
>   memset(&arg, 0, sizeof(arg));
>   arg.type = AML_OBJTYPE_INTEGER;
>   arg.v_integer = sc->sc_brightness & 0xff;
> - aml_evalname(sc->sc_acpi, sc->sc_devnode,
> - "PBLS", 1, &arg, NULL);
> + ret = aml_evalname(sc->sc_acpi, sc->sc_devnode, "PBLS", 1, &arg, NULL);
> +
> + if (ret)
> + return ret;
>   
>   thinkpad_get_brightness(sc);
> +
> + return 0;
>   }
>   
>   int
> @@ -765,7 +775,8 @@ thinkpad_set_param(struct wsdisplay_para
>   dp->curval = maxval;
>   sc->sc_brightness &= ~0xff;
>   sc->sc_brightness |= dp->curval;
> - acpi_addtask(sc->sc_acpi, thinkpad_set_brightness, sc, 0);
> + acpi_addtask(sc->sc_acpi, (void *)thinkpad_set_brightness, sc,
> + 0);
>   acpi_wakeup(sc->sc_acpi);
>   return 0;
>   default:



Re: acpithinkpad: fix brightness keys, keyboard backlight value

2019-03-05 Thread Tracey Emery
On Tue, Mar 05, 2019 at 02:03:13PM -0600, joshua stein wrote:
> Here we go again...
> 
> On at least the ThinkPad X1C6, the screen brightness keys (F5 and 
> F6) do not work and "wsconsctl keyboard.backlight" doesn't report 
> the correct value when the keyboard backlight is adjusted with 
> Fn+Space.
> 
> These are both caused by the default event mask not including these 
> events, so explicitly enable them.
> 
> But then acpithinkpad has to actually do something for the screen 
> brightness keys, but it tries the very old CMOS method which doesn't 
> work on these newer machines[0].  So make it use the ACPI method.
> 
> I renamed thinkpad_[gs]et_backlight to thinkpad_[gs]et_kbd_backlight 
> because it was confusing that they have nothing to do with screen 
> backlight.
> 
> 
> 0. "newer machines" being those with MHKV reporting version 2.  If 
> this diff breaks on older "newer machines", this metric will have to 
> be changed to something else.
> 
> 

This patch fixes the backlight buttons and keyboard brightness reading on the
T740s. Awesome!

Thanks,
Tracey

> Index: sys/dev/acpi/acpithinkpad.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v
> retrieving revision 1.61
> diff -u -p -u -p -r1.61 acpithinkpad.c
> --- sys/dev/acpi/acpithinkpad.c   1 Jul 2018 19:40:49 -   1.61
> +++ sys/dev/acpi/acpithinkpad.c   5 Mar 2019 20:00:23 -
> @@ -124,6 +124,10 @@
>  #define  THINKPAD_ADAPTIVE_MODE_HOME 1
>  #define  THINKPAD_ADAPTIVE_MODE_FUNCTION 3
>  
> +#define THINKPAD_MASK_BRIGHTNESS_UP  (1 << 15)
> +#define THINKPAD_MASK_BRIGHTNESS_DOWN(1 << 16)
> +#define THINKPAD_MASK_KBD_BACKLIGHT  (1 << 17)
> +
>  struct acpithinkpad_softc {
>   struct devicesc_dev;
>  
> @@ -134,6 +138,8 @@ struct acpithinkpad_softc {
>   struct ksensor   sc_sens[THINKPAD_NSENSORS];
>   struct ksensordevsc_sensdev;
>  
> + uint64_t sc_hkey_version;
> +
>   uint64_t sc_thinklight;
>   const char  *sc_thinklight_get;
>   const char  *sc_thinklight_set;
> @@ -161,8 +167,8 @@ int   thinkpad_activate(struct device *, i
>  /* wscons hook functions */
>  void thinkpad_get_thinklight(struct acpithinkpad_softc *);
>  void thinkpad_set_thinklight(void *, int);
> -int  thinkpad_get_backlight(struct wskbd_backlight *);
> -int  thinkpad_set_backlight(struct wskbd_backlight *);
> +int  thinkpad_get_kbd_backlight(struct wskbd_backlight *);
> +int  thinkpad_set_kbd_backlight(struct wskbd_backlight *);
>  extern int (*wskbd_get_backlight)(struct wskbd_backlight *);
>  extern int (*wskbd_set_backlight)(struct wskbd_backlight *);
>  void thinkpad_get_brightness(struct acpithinkpad_softc *);
> @@ -284,6 +290,10 @@ thinkpad_attach(struct device *parent, s
>  
>   printf("\n");
>  
> + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "MHKV", 0, NULL,
> + &sc->sc_hkey_version))
> + sc->sc_hkey_version = THINKPAD_HKEY_VERSION1;
> +
>  #if NAUDIO > 0 && NWSKBD > 0
>   /* Defer speaker mute */
>   if (thinkpad_get_volume_mute(sc) == 1)
> @@ -299,14 +309,14 @@ thinkpad_attach(struct device *parent, s
>   0, NULL, &sc->sc_thinklight) == 0) {
>   sc->sc_thinklight_get = "KLCG";
>   sc->sc_thinklight_set = "KLCS";
> - wskbd_get_backlight = thinkpad_get_backlight;
> - wskbd_set_backlight = thinkpad_set_backlight;
> + wskbd_get_backlight = thinkpad_get_kbd_backlight;
> + wskbd_set_backlight = thinkpad_set_kbd_backlight;
>   } else if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "MLCG",
>   0, NULL, &sc->sc_thinklight) == 0) {
>   sc->sc_thinklight_get = "MLCG";
>   sc->sc_thinklight_set = "MLCS";
> - wskbd_get_backlight = thinkpad_get_backlight;
> - wskbd_set_backlight = thinkpad_set_backlight;
> + wskbd_get_backlight = thinkpad_get_kbd_backlight;
> + wskbd_set_backlight = thinkpad_set_kbd_backlight;
>   }
>  
>   if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "PBLG",
> @@ -327,13 +337,19 @@ thinkpad_enable_events(struct acpithinkp
>   int64_t mask;
>   int i;
>  
> - /* Get the supported event mask */
> + /* Get the default event mask */
>   if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "MHKA",
>   0, NULL, &mask)) {
>   printf("%s: no MHKA\n", DEVNAME(sc));
>   return (1);
>   }
>  
> + /* Enable events we need to know about */
> + mask |= (THINKPAD_MASK_BRIGHTNESS_UP | THINKPAD_MASK_BRIGHTNESS_DOWN |
> + THINKPAD_MASK_KBD_BACKLIGHT);
> +
> + DPRINTF(("%s: setting event mask to 0x%llx\n", DEVNAME(sc), mask));
> +
>   /* Update hotkey mask */
>   bzero(args, sizeof(args));
>   args[0].type = args[1].type = AML_OBJTYPE_INTEGER;
> @@ -380,6 +396,

Re: httpd server configuration evaluation bug

2018-11-30 Thread Tracey Emery
On Fri, Nov 30, 2018 at 10:16:45AM +0100, Florian Obser wrote:
> On Fri, Oct 26, 2018 at 03:08:11PM -0600, Tracey Emery wrote:
> > On Mon, Jul 30, 2018 at 10:24:03AM -0600, Base Pr1me wrote:
> > > Sorry, this time with the correct diff.
> > > 
> > > On 7/25/18 4:15 PM, Base Pr1me wrote:
> > > > Hi,
> > > > 
> > > > I discovered that the wrong server configuration is evaluated in the
> > > > server_read_http function. Only the first server in httpd.conf is 
> > > > checked. For
> > > > example, I have five servers setup in httpd.conf and the third server 
> > > > is the
> > > > only one with connection { max request body } set, because I desire 
> > > > it to
> > > > accept larger uploads than the other servers. When the upload is 
> > > > initiated,
> > > > server one dictates the max request body size, globally.
> > > > 
> > > > The attached diff moves the queue loop out of the server_response 
> > > > function in to
> > > > its own function, as to not duplicate code.
> > > > 
> > > > I don't know if this is the only place the wrong information is 
> > > > evaluated. Also,
> > > > I'm not sure this is the best method to fix the problem, but it should 
> > > > point the
> > > > powers that be in the right direction.
> > > > 
> > > > Thanks,
> > > > 
> > > > Tracey
> > > > 
> > > 
> > 
> > Hello,
> > 
> > I reworked the last sent diff. I missed fixing up the hostname. This was 
> > causing
> > an incorrect 301 on urls not containing an ending slash. I also moved the
> > srv_conf assignment into the new function.
> > 
> > Again, this is to use the correct server config information from the queue 
> > for
> > server_read_http and remove code duplication.
> > 
> > If anyone is willing to look at this and make suggestions, that'd be great. 
> > If
> > not, that'd be great too! LOL. Have a great weekend.
> > 
> > Thanks,
> > Tracey
> 
> (moving back from bugs@)
> 
> Sorry for slacking of on this for so long and thanks for prodding
> patiently :)
> 
> The issue is that in server_read_http we haven't found the correct
> virtual server & location yet.
> clt->clt_srv_conf contains the server_config struct for the listening IP.
> 
> But there is no need to check maxrequestbody just yet, we can do it in
> server_response() where we do know the virtual host.
> 
> Tracey, can you please test this, it should solve your problem.
> 
> OK?
> 
> diff --git server_http.c server_http.c
> index e05cec56dfc..52698a66b2e 100644
> --- server_http.c
> +++ server_http.c
> @@ -198,7 +198,6 @@ void
>  server_read_http(struct bufferevent *bev, void *arg)
>  {
>   struct client   *clt = arg;
> - struct server_config*srv_conf = clt->clt_srv_conf;
>   struct http_descriptor  *desc = clt->clt_descreq;
>   struct evbuffer *src = EVBUFFER_INPUT(bev);
>   char*line = NULL, *key, *value;
> @@ -357,11 +356,6 @@ server_read_http(struct bufferevent *bev, void *arg)
>   server_abort_http(clt, 500, errstr);
>   goto abort;
>   }
> - if ((size_t)clt->clt_toread >
> - srv_conf->maxrequestbody) {
> - server_abort_http(clt, 413, NULL);
> - goto abort;
> - }
>   }
>  
>   if (strcasecmp("Transfer-Encoding", key) == 0 &&
> @@ -1334,6 +1328,12 @@ server_response(struct httpd *httpd, struct client 
> *clt)
>   srv_conf = server_getlocation(clt, desc->http_path);
>   }
>  
> + if (clt->clt_toread > 0 && (size_t)clt->clt_toread >
> + srv_conf->maxrequestbody) {
> + server_abort_http(clt, 413, NULL);
> + return (-1);
> + }
> +
>   if (srv_conf->flags & SRVFLAG_BLOCK) {
>   server_abort_http(clt, srv_conf->return_code,
>   srv_conf->return_uri);
> 
> 
> 
> -- 
> I'm not entirely sure you are real.

Thank you, sir. That does, indeed, fix the maxrequestbody issue.

As an aside, when doing verbose debugging, the log still shows the first virtual
server when doing the upload. It's not as an important issue as the request
body, but certainly something to be aware of when you have the time to look.
Naturally, I've changed domain names below! ;)

www.upload.vs 192.168.1.2 - - [30/Nov/2018:08:01:40 -0700] "GET 
/support/file_upload.php?iss_id=917 HTTP/1.1" 200 0
www.upload.vs 192.168.1.2 - - [30/Nov/2018:08:01:47 -0700] "POST 
/support/ajax/upload.php?file=dropfile HTTP/1.1" 200 0
# wrong virt serv #
server first_vs_in_httpd.conf, client 1 (1 active), 192.168.1.2:15244 -> 
10.0.0.10:443, closed
www.upload.vs 192.168.1.2 - - [30/Nov/2018:08:01:51 -0700] "POST 
/support/file_upload.php HTTP/1.1" 200 0
www.upload.v 192.168.1.2 - - [30/Nov/2018:08:01:53 -0700] "GET 
/support/view.php?id=917 HTTP/1.1" 200 0

Thanks,
Tracey



Re: httpd server configuration evaluation bug

2018-10-26 Thread Tracey Emery
On Mon, Jul 30, 2018 at 10:24:03AM -0600, Base Pr1me wrote:
> Sorry, this time with the correct diff.
> 
> On 7/25/18 4:15 PM, Base Pr1me wrote:
> > Hi,
> > 
> > I discovered that the wrong server configuration is evaluated in the
> > server_read_http function. Only the first server in httpd.conf is checked. 
> > For
> > example, I have five servers setup in httpd.conf and the third server is the
> > only one with connection { max request body } set, because I desire it 
> > to
> > accept larger uploads than the other servers. When the upload is initiated,
> > server one dictates the max request body size, globally.
> > 
> > The attached diff moves the queue loop out of the server_response function 
> > in to
> > its own function, as to not duplicate code.
> > 
> > I don't know if this is the only place the wrong information is evaluated. 
> > Also,
> > I'm not sure this is the best method to fix the problem, but it should 
> > point the
> > powers that be in the right direction.
> > 
> > Thanks,
> > 
> > Tracey
> > 
> 

Hello,

I reworked the last sent diff. I missed fixing up the hostname. This was causing
an incorrect 301 on urls not containing an ending slash. I also moved the
srv_conf assignment into the new function.

Again, this is to use the correct server config information from the queue for
server_read_http and remove code duplication.

If anyone is willing to look at this and make suggestions, that'd be great. If
not, that'd be great too! LOL. Have a great weekend.

Thanks,
Tracey

Index: src/usr.sbin/httpd/httpd.h
===
RCS file: /cvs/src/usr.sbin/httpd/httpd.h,v
retrieving revision 1.142
diff -u -p -u -r1.142 httpd.h
--- src/usr.sbin/httpd/httpd.h  11 Oct 2018 09:52:22 -  1.142
+++ src/usr.sbin/httpd/httpd.h  26 Oct 2018 20:52:26 -
@@ -691,6 +691,8 @@ const char *
 char   *server_http_parsehost(char *, char *, size_t, int *);
 ssize_t server_http_time(time_t, char *, size_t);
 int server_log_http(struct client *, unsigned int, size_t);
+int server_check_client_config(struct server_config *, struct client *,
+   struct kv *, char *);
 
 /* server_file.c */
 int server_file(struct httpd *, struct client *);
Index: src/usr.sbin/httpd/server_http.c
===
RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
retrieving revision 1.126
diff -u -p -u -r1.126 server_http.c
--- src/usr.sbin/httpd/server_http.c15 Oct 2018 08:16:17 -  1.126
+++ src/usr.sbin/httpd/server_http.c26 Oct 2018 20:52:26 -
@@ -204,7 +204,7 @@ server_read_http(struct bufferevent *bev
char*line = NULL, *key, *value;
const char  *errstr;
size_t   size, linelen;
-   struct kv   *hdr = NULL;
+   struct kv   *hdr = NULL, kv_key, *host;
 
getmonotime(&clt->clt_tv_last);
 
@@ -344,6 +344,15 @@ server_read_http(struct bufferevent *bev
goto abort;
}
 
+   kv_key.kv_key = "Host";
+   if ((host = kv_find(&desc->http_headers, &kv_key)) !=
+   NULL && host->kv_value == NULL)
+   host = NULL;
+
+   if (server_check_client_config(srv_conf, clt, host,
+   NULL))
+   goto fail;
+
/*
 * Need to read data from the client after the
 * HTTP header.
@@ -1183,10 +1192,7 @@ server_response(struct httpd *httpd, str
struct server   *srv = clt->clt_srv;
struct server_config*srv_conf = &srv->srv_conf;
struct kv   *kv, key, *host;
-   struct str_find  sm;
-   int  portval = -1, ret;
-   char*hostval, *query;
-   const char  *errstr = NULL;
+   char*query;
 
/* Decode the URL */
if (desc->http_path == NULL ||
@@ -1234,58 +1240,8 @@ server_response(struct httpd *httpd, str
if (clt->clt_pipelining && clt->clt_toread > 0)
clt->clt_persist = 0;
 
-   /*
-* Do we have a Host header and matching configuration?
-* XXX the Host can also appear in the URL path.
-*/
-   if (host != NULL) {
-   if ((hostval = server_http_parsehost(host->kv_value,
-   hostname, sizeof(hostname), &portval)) == NULL)
-   goto fail;
-
-   TAILQ_FOREACH(srv_conf, &srv->srv_hosts, entry) {
-#ifdef DEBUG
-   if ((srv_conf->flags & SRVFLAG_LOCATION) == 0) {
-   DPRINTF("%s: virtual host \"%s:%u\""
-   " host \"%s\" (\"%s\")",
-   __f