Re: utmps: database cursor position and pututxline(3)

From: Xavier Stonestreet <xstonestreet_at_gmail.com>
Date: Mon, 12 Apr 2021 03:12:05 +0200

On Sun, Apr 11, 2021 at 2:31 PM Laurent Bercot <ska-skaware_at_skarnet.org> wrote:
>
> Fixed in git, please try it and tell me if it works for you.
> (I simply made the getutx*() functions stay on the current record on
> success, instead of pointing to the next record.)
>

Thanks for the quick changes.

So the good news is that putuxline() following getuxid() or
getuxline() correctly overwrites the matched record.
The bad news is that getutxent() is suffering from a self-inflicted DoS :)

setutxent(); while (getutxent());

will give you an infinite loop (reading the first record over and over again).

I'd suggest another approach that should work better, at least on
paper: instead of doing onestepback() at the end of each do_getutx*(),
revert those changes and do onestepback() in do_putline() before
entering the idmatch() loop - taking care to ignore the failure
(EINVAL) of onestepback() if we're at the start of database.

There may be scenarios where this may not be correct. I haven't
thought it through properly.

Unless you have other ideas you'd rather try, I'll experiment with
this approach a bit and let you know the results. In the meantime you
may want to back out your commit because it's pretty broken right now
unfortunately.
Received on Mon Apr 12 2021 - 01:12:05 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC