From: Omar Polo Subject: Re: fix gotd authentication timeout To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Thu, 29 Dec 2022 17:53:04 +0100 On 2022/12/29 17:39:40 +0100, Stefan Sperling wrote: > While running tests with a gotd auth process that was crashing due > to a missing pledge promise, I found that the timeout upon authentication > process failure was much longer than intended. > > The authentication timeout was accidentally overriden by the request timeout. > Fix this and set both timeouts in the same place for clarity. sure, ok op@ > diff 5e25db14db9eb20ee11b68048b45b3e0f54d50eb 33223026dc355d2180b79d22cbd06044ee342411 > commit - 5e25db14db9eb20ee11b68048b45b3e0f54d50eb > commit + 33223026dc355d2180b79d22cbd06044ee342411 > blob - 2ae681053c360d76a04ee62d816fbcb536e57c4b > blob + 4e693a39b4414ee735aa6d7f2649143c79ce3a88 > --- gotd/gotd.c > +++ gotd/gotd.c > @@ -94,6 +94,7 @@ static struct gotd gotd; > static SIPHASH_KEY clients_hash_key; > volatile int client_cnt; > static struct timeval timeout = { 3600, 0 }; > +static struct timeval auth_timeout = { 5, 0 }; > static struct gotd gotd; > > void gotd_sighdlr(int sig, short event, void *arg); > @@ -1200,7 +1201,10 @@ gotd_request(int fd, short events, void *arg) > disconnect_on_error(client, err); > } else { > gotd_imsg_event_add(&client->iev); > - evtimer_add(&client->tmo, &timeout); > + if (client->state == GOTD_STATE_EXPECT_LIST_REFS) > + evtimer_add(&client->tmo, &auth_timeout); > + else > + evtimer_add(&client->tmo, &timeout); > } > } > > @@ -2306,7 +2310,6 @@ start_auth_child(struct gotd_client *client, int requi > { > struct gotd_child_proc *proc; > struct gotd_imsg_auth iauth; > - struct timeval auth_timeout = { 5, 0 }; > > memset(&iauth, 0, sizeof(iauth)); > > @@ -2348,7 +2351,6 @@ start_auth_child(struct gotd_client *client, int requi > > client->auth = proc; > client->required_auth = required_auth; > - evtimer_add(&client->tmo, &auth_timeout); > return NULL; > } >