🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
11 messages
11 total messages Started by D. Stussy Tue, 12 Jan 2010 10:24
INN and "ovgrouppat" - bug?
#82555
Author: D. Stussy
Date: Tue, 12 Jan 2010 10:24
41 lines
3133 bytes
I had the occasion to read the OVgroupmatch() subroutine in
storage/expire.c (about line 816), and I'm not certain that it follows the
general poisoned-wildmat rules.

I see that it defaults to false.  I see that if there's a positive match,
it is set to true, and poisoned groups abort with false.  However, are
later sub-patterns (patterns specifying groups or sub-hierarchies of
earlier-matched hierarchies) properly processed?  If a later sub-pattern is
negated with "!", I don't see how the result is turned back to false.
Also, if a poisoned group matches, the immediate return prevents subsequent
patterns from matching.  This doesn't seem to be the same result as
uwildmat processing.  It appears that the leftmost match governs while the
rightmost match governs wildmat functions, yet this function is described
as a wildmat function.  The manual page entry for inn.conf does not hint
that the behavior is different.

Specifying a pattern string like "all except ..., except",
"*,!pattern,pattern.sub ...", will return false for "pattern.sub" when it
should return true.

Remember that as "ovgrouppat" is read into the array OVpatterns, each array
element is a separate pattern - divided by the commas in the configuration
parser.  Therefore, we have to compare all of the patterns in case a later
pattern flips the result - thus resulting in a rightmost match.

If there are no positive sub-hierarchy matches (i.e. without "!" and "@")
to the right of any negative matches ("!" or "@") for that same
sub-hierarchy or its superset, then there is no problem.  Only when there
are patterns contained in other patterns is there a problem.

Code (fix?):

Instead of "return false;", should we have a "wanted = false;"?  This would
make the conditional under case "!" and before case "@" unnecessary.
Alternatively, we could loop through the patterns from high to low (right
to left) instead of low to high (left to right) and return on the first
(rightmost) match (whether true or false).

This issue appears present in INN 2.5.1.

Re: INN and "ovgrouppat" - bug?
#82561
Author: Julien ÉLIE
Date: Tue, 12 Jan 2010 19:27
53 lines
3410 bytes
Hi D. Stussy,

> I had the occasion to read the OVgroupmatch() subroutine in
> storage/expire.c (about line 816), and I'm not certain that it follows the
> general poisoned-wildmat rules.

You're right.  Thanks for having spotted that.


> Instead of "return false;", should we have a "wanted = false;"?  This would
> make the conditional under case "!" and before case "@" unnecessary.
> Alternatively, we could loop through the patterns from high to low (right
> to left) instead of low to high (left to right) and return on the first
> (rightmost) match (whether true or false).

In fact, "!" and "@" have the same meaning in that function.  There is only
a group to compare, and the notion of crosspost is irrelevant.  It looks
as though it is always a poison for the overview data:  if one of the newsgroups
an article is crossposted to matches in OVgroupmatch(), then the article
is not stored -- see OVadd() in storage/ov.c.

So maybe it is OVadd() that needs fixing to take that into account...


As for OVgroupmatch(), here is what I would see:

    for (i = 0; i < OVnumpatterns; i++) {
        switch (OVpatterns[i][0]) {
        case '!':
        case '@':
            if (uwildmat(group, &OVpatterns[i][1])) {
                wanted = false;
            }
            break;
        default:
            if (uwildmat(group, OVpatterns[i]))
                wanted = true;
        }
    }
    return wanted;


I case OVadd() is to be fixed, maybe we should send three different values
(UWILDMAT_MATCH, UWILDMAT_FAIL, and UWILDMAT_POISON).  This way, OVadd()
could properly decide whether to store the article in the overview data.

-- 
Julien ÉLIE

« Un dictionnaire est comme une montre ; il vaut mieux en avoir un
  que pas du tout, mais le meilleur n'est jamais tout à fait exact. »
  (Georges-Bernard Shaw) 
Re: INN and "ovgrouppat" - bug?
#82597
Author: Julien ÉLIE
Date: Sat, 16 Jan 2010 15:33
19 lines
2269 bytes
Responding to myself:
> In fact, "!" and "@" have the same meaning in that function.  There is only
> a group to compare, and the notion of crosspost is irrelevant.  It looks
> as though it is always a poison for the overview data:  if one of the newsgroups
> an article is crossposted to matches in OVgroupmatch(), then the article
> is not stored -- see OVadd() in storage/ov.c.

I have just added that precision to the inn.conf documentation for ovgrouppat:

Note that the use of "!" in this wildmat expression has the same meaning as
"@", that is to say it is a poisoned match and the overview data will not
be generated if one of the newsgroups an article is posted to is unwanted.

-- 
Julien ÉLIE

« Rien ni personne n'a tout à fait tort : même une horloge
  arrêtée a raison deux fois par jour. » (John Steinbeck) 
Re: INN and "ovgrouppat" - bug?
#82604
Author: D. Stussy
Date: Sun, 17 Jan 2010 04:22
44 lines
2937 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:hism7f$rn3$1@news.trigofacile.com...
> Responding to myself:
> > In fact, "!" and "@" have the same meaning in that function.  There is
only
> > a group to compare, and the notion of crosspost is irrelevant.  It
looks
> > as though it is always a poison for the overview data:  if one of the
newsgroups
> > an article is crossposted to matches in OVgroupmatch(), then the
article
> > is not stored -- see OVadd() in storage/ov.c.
>
> I have just added that precision to the inn.conf documentation for
ovgrouppat:
>
> Note that the use of "!" in this wildmat expression has the same meaning
as
> "@", that is to say it is a poisoned match and the overview data will not
> be generated if one of the newsgroups an article is posted to is
unwanted.

If we go with the above, it would be better to disallow "@" from the
string.  Only "!" should be allowed.  The way this is currently
implemented, there is no such thing as a "poison" group.  Either a group
has an overview or not, and a crossposted article will have overview data
in those groups where overview data is permitted even when it isn't for
other groups.

That is, we should clearly disclose that the group mask in this case is
"uwildmat" without poison group specifications.  Inn.conf(5) manual page:

 "ovgrouppat

"If set, restricts the overview data stored by INN to only the newsgroups
matching this comma-separated {list of} [non-poisoned u]wildmat
expression{s}. Newsgroups not matching this setting may not be readable,
and if groupbaseexpiry is set to true and the storage method for these
newsgroups does not have self-expire functionality, storing overview data
will fail. The default is unset."

[] = additions.  {}=deletions

Re: INN and "ovgrouppat" - bug?
#82603
Author: Russ Allbery
Date: Sun, 17 Jan 2010 04:34
36 lines
2840 bytes
"D. Stussy" <spam+newsgroups@bde-arc.ampr.org> writes:
> "Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote:

>> I have just added that precision to the inn.conf documentation for
>> ovgrouppat:

>> Note that the use of "!" in this wildmat expression has the same
>> meaning as "@", that is to say it is a poisoned match and the overview
>> data will not be generated if one of the newsgroups an article is
>> posted to is unwanted.

Why in this situation do we not use the more typical meaning of "!" and
"@" and keep generating overview unless every newsgroup to which it's
posted does not match or unless it matches a poisoned pattern?  The code
structure just doesn't allow for it?

> If we go with the above, it would be better to disallow "@" from the
> string.  Only "!" should be allowed.  The way this is currently
> implemented, there is no such thing as a "poison" group.  Either a group
> has an overview or not, and a crossposted article will have overview
> data in those groups where overview data is permitted even when it isn't
> for other groups.

Don't you have that backwards?  We would have to disallow "!", not "@",
since the meaning is always the same as "@" would be.

Remember, "!" and "@" are equivalent unless you're matching a crossposted
article, in which case the intended semantics is that if *any* group to
which the article is posted matches, that article matches, unless it
matches a poisoned pattern.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: INN and "ovgrouppat" - bug?
#82605
Author: D. Stussy
Date: Sun, 17 Jan 2010 07:45
54 lines
3674 bytes
"Russ Allbery" <rra@stanford.edu> wrote in message
news:87vdf1ic39.fsf@windlord.stanford.edu...
> "D. Stussy" <spam+newsgroups@bde-arc.ampr.org> writes:
> > "Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote:
> >> I have just added that precision to the inn.conf documentation for
> >> ovgrouppat:
>
> >> Note that the use of "!" in this wildmat expression has the same
> >> meaning as "@", that is to say it is a poisoned match and the overview
> >> data will not be generated if one of the newsgroups an article is
> >> posted to is unwanted.
>
> Why in this situation do we not use the more typical meaning of "!" and
> "@" and keep generating overview unless every newsgroup to which it's
> posted does not match or unless it matches a poisoned pattern?  The code
> structure just doesn't allow for it?

Because that's not what the code is actually doing.

It selects for storage overview data for ALL groups not excluded by the
string.
It skips for storage overview data for any group that matches an excluded
element.

As it tests this by stepping through the "Xref:" header one group at a
time, it can't skip all when it finds a poisoned element.  "@" is
operationally no different from "!" with the current implementation.

> > If we go with the above, it would be better to disallow "@" from the
> > string.  Only "!" should be allowed.  The way this is currently
> > implemented, there is no such thing as a "poison" group.  Either a
group
> > has an overview or not, and a crossposted article will have overview
> > data in those groups where overview data is permitted even when it
isn't
> > for other groups.
>
> Don't you have that backwards?  We would have to disallow "!", not "@",
> since the meaning is always the same as "@" would be.

No.  "@" has no meaning separate from "!" and is therefore redundant, as
implemented.

> Remember, "!" and "@" are equivalent unless you're matching a crossposted
> article, in which case the intended semantics is that if *any* group to
> which the article is posted matches, that article matches, unless it
> matches a poisoned pattern.

Such is NOT what this is doing (for "ovgrouppat").  That's the problem.
OVcheckpat() returns only true and false.  To process poisoned groups, we
need THREE return states - and we need to check every group before storing
the overview (in OVadd()) for any of them.

Re: INN and "ovgrouppat" - bug?
#82608
Author: Julien ÉLIE
Date: Sun, 17 Jan 2010 10:19
57 lines
3814 bytes
Hi D. Stussy,

>>> Note that the use of "!" in this wildmat expression has the same
>>> meaning as "@", that is to say it is a poisoned match and the overview
>>> data will not be generated if one of the newsgroups an article is
>>> posted to is unwanted.
>>
>> Why in this situation do we not use the more typical meaning of "!" and
>> "@" and keep generating overview unless every newsgroup to which it's
>> posted does not match or unless it matches a poisoned pattern?  The code
>> structure just doesn't allow for it?
>
> Because that's not what the code is actually doing.

No, the code is really using "@" for "!".


> It selects for storage overview data for ALL groups not excluded by the
> string.
> It skips for storage overview data for any group that matches an excluded
> element.
>
> As it tests this by stepping through the "Xref:" header one group at a
> time, it can't skip all when it finds a poisoned element.  "@" is
> operationally no different from "!" with the current implementation.

No.  There is no overview generation when stepping through the Xref: header.
The check of ovgrouppat is done before the overview generation.  Either
there is *no* overview data or *all* groups have overview data for the
article.

    if (innconf->ovgrouppat != NULL) {
        memcpy(patcheck, next, xreflen);
        patcheck[xreflen] = '\0';
        for (group = patcheck; group && *group; group = memchr(nextcheck, ' ', xreflen - (nextcheck - patcheck))) {
            while (isspace((int)*group))
                group++;
            if ((nextcheck = memchr(group, ':', xreflen - (patcheck - group))) == NULL)
                return OVADDFAILED;
            *nextcheck++ = '\0';
            if (!OVgroupmatch(group)) {
                if (!SMprobe(SELFEXPIRE, &token, NULL) && innconf->groupbaseexpiry)
                    /* This article will never be expired, since it does not
                       have self expiry function in stored method and
                       groupbaseexpiry is true. */
                    return OVADDFAILED;
                return OVADDGROUPNOMATCH;
            }
        }
    }

-- 
Julien ÉLIE

« La perfection est atteinte non pas lorsqu'il n'y a plus rien à ajouter,
  mais lorsqu'il n'y a plus rien à retirer. » (Saint-Exupéry) 
Re: INN and "ovgrouppat" - bug?
#82609
Author: Julien ÉLIE
Date: Sun, 17 Jan 2010 11:56
40 lines
2931 bytes
Hi Russ,

>>> I have just added that precision to the inn.conf documentation for
>>> ovgrouppat:
>
>>> Note that the use of "!" in this wildmat expression has the same
>>> meaning as "@", that is to say it is a poisoned match and the overview
>>> data will not be generated if one of the newsgroups an article is
>>> posted to is unwanted.
>
> Why in this situation do we not use the more typical meaning of "!" and
> "@" and keep generating overview unless every newsgroup to which it's
> posted does not match or unless it matches a poisoned pattern?  The code
> structure just doesn't allow for it?

Yes, you're right Russ.  I should have fixed the problem instead of
documenting the difference between usual wildmats.
Now done.

  http://inn.eyrie.org/trac/changeset/8890/trunk

    Add complete support for uwildmats in ovgrouppat: negated
    patterns "!" are now taken into account (and not considered
    as poisoned patterns "@").

    Also fix a wrong memchr length.


Yeah, that memchr was strange (group is always greater than patcheck...).
It could have led to segfaults (especially with the write of '\0' just after).

-            if ((nextcheck = memchr(group, ':', xreflen - (patcheck - group))) == NULL)
+            if ((nextcheck = memchr(group, ':', xreflen - (group - patcheck))) == NULL)

-- 
Julien ÉLIE

« -- Une amphore pleine de salade, s'il vous plaît...
  -- C'est bon ça, la salade nicæoise ? » (Astérix) 
Re: INN and "ovgrouppat" - bug?
#82613
Author: D. Stussy
Date: Mon, 18 Jan 2010 04:03
44 lines
3207 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:hiuo7h$3tq$1@news.trigofacile.com...
> >>> Note that the use of "!" in this wildmat expression has the same
> >>> meaning as "@", that is to say it is a poisoned match and the
overview
> >>> data will not be generated if one of the newsgroups an article is
> >>> posted to is unwanted.
> >>
> >> Why in this situation do we not use the more typical meaning of "!"
and
> >> "@" and keep generating overview unless every newsgroup to which it's
> >> posted does not match or unless it matches a poisoned pattern?  The
code
> >> structure just doesn't allow for it?
> >
> > Because that's not what the code is actually doing.
>
> No, the code is really using "@" for "!".
>
>
> > It selects for storage overview data for ALL groups not excluded by the
> > string.
> > It skips for storage overview data for any group that matches an
excluded
> > element.
> >
> > As it tests this by stepping through the "Xref:" header one group at a
> > time, it can't skip all when it finds a poisoned element.  "@" is
> > operationally no different from "!" with the current implementation.
>
> No.  There is no overview generation when stepping through the Xref:
header.
> The check of ovgrouppat is done before the overview generation.  Either
> there is *no* overview data or *all* groups have overview data for the
> article.

Regardless, my point is that it's not being treated as a poisoned-uwildmat
the same way that newsfeeds entries are.  One matching "!" pattern also
kills the overview.  Also, as implemented in 2.5.1, one can't have a later
matching pattern (representing a subhierarchy) that turns storage back to
permitted as parsing takes the first (leftmost) match, while wildmat
matches the rightmost matching term.

Re: INN and "ovgrouppat" - bug?
#82614
Author: D. Stussy
Date: Mon, 18 Jan 2010 05:02
115 lines
5359 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:hiutsh$etq$1@news.trigofacile.com...
> >>> I have just added that precision to the inn.conf documentation for
> >>> ovgrouppat:
> >
> >>> Note that the use of "!" in this wildmat expression has the same
> >>> meaning as "@", that is to say it is a poisoned match and the
overview
> >>> data will not be generated if one of the newsgroups an article is
> >>> posted to is unwanted.
> >
> > Why in this situation do we not use the more typical meaning of "!" and
> > "@" and keep generating overview unless every newsgroup to which it's
> > posted does not match or unless it matches a poisoned pattern?  The
code
> > structure just doesn't allow for it?
>
> Yes, you're right Russ.  I should have fixed the problem instead of
> documenting the difference between usual wildmats.
> Now done.
>
>   http://inn.eyrie.org/trac/changeset/8890/trunk
>
>     Add complete support for uwildmats in ovgrouppat: negated
>     patterns "!" are now taken into account (and not considered
>     as poisoned patterns "@").

In my opinion, the patch could be optimized.  Instead of checking from left
to right (0 to OVnumpatterns-1), we could check from right to left and
return immediately upon the first matching element:

enum uwildmat
OVgroupmatch(const char *group)
{
    int i;

    if (OVnumpatterns == 0 || group == NULL)
        return UWILDMAT_MATCH;
    for (i = OVnumpatterns - 1; i >= 0; --i) {
        switch (OVpatterns[i][0]) {
        case '!':
             if (uwildmat(group, &OVpatterns[i][1])) {
                return UWILDMAT_FAIL;
            }
            break;
       case '@':
            if (uwildmat(group, &OVpatterns[i][1])) {
                return UWILDMAT_POISON;
            }
            break;
        default:
            if (uwildmat(group, OVpatterns[i]))
                return UWILDMAT_MATCH;
        }
    }
    return UWILDMAT_FAIL;
}

However, doesn't that make the whole thing equivalent to:

enum uwildmat OVgroupmatch(const char *group)
{
    return (innconf->ovgrouppat == NULL || group == NULL)
        ? UWILDMAT_MATCH
         : uwildmat_poison(group,innconf->ovgrouppat);
}

i.e. use the existing function (except for the pre-parsing*)?  There may be
further code optimizations@.

* - looking at "match_expression()" in lib/uwildmat.c, I don't see where
the pre-parsing is an advantage.  Each pattern is still going to be scanned
for commas, so splitting it up only saves time if we aren't scanning for
them.

@ - As OVgroupmatch() is called ONLY from one place, OVadd(), from inside a
conditional that checked for innconf->ovgrouppat != NULL, and from inside a
loop that makes certain that group != NULL, the conditional inside the
function optimizes out completely - effectively:

#define OVgroupmatch(x) uwildmat_poison(x,innconf->ovgrouppat)

BTW,  switch may be cleaner than if-elseif.  (Lines 205-215 of storage/ov.c
become):

            switch(uwildmat_poison(group, innconf->ovgrouppat)){
                case UWILDMAT_FAIL:
                    if (!SMprobe(SELFEXPIRE, &token, NULL) &&
innconf->groupbaseexpiry)
                    /* this article will never be expired, since it does
not
                       have self expiry function in stored method and
                       groupbaseexpiry is true */
                        return OVADDFAILED;
                case UWILDMAT_FAIL:
                    return OVADDGROUPNOMATCH;
            }

...And now that we're using an actual wildmat call, there are no
documentation changes.  ;-)

>     Also fix a wrong memchr length.
>
> Yeah, that memchr was strange (group is always greater than patcheck...).
> It could have led to segfaults (especially with the write of '\0' just
after).
>
> -            if ((nextcheck = memchr(group, ':', xreflen - (patcheck -
group))) == NULL)
> +            if ((nextcheck = memchr(group, ':', xreflen - (group -
patcheck))) == NULL)

OK.

Re: INN and "ovgrouppat" - bug?
#82644
Author: Julien ÉLIE
Date: Fri, 22 Jan 2010 23:25
50 lines
3312 bytes
Hi D. Stussy,

> @ - As OVgroupmatch() is called ONLY from one place, OVadd(), from inside a
> conditional that checked for innconf->ovgrouppat != NULL, and from inside a
> loop that makes certain that group != NULL, the conditional inside the
> function optimizes out completely - effectively:
>
> #define OVgroupmatch(x) uwildmat_poison(x,innconf->ovgrouppat)

You're totally right.  It greatly simplifies the code (and removes the need
of OVgroupmatch, OVnumpatterns and OVpatterns).
    http://inn.eyrie.org/trac/changeset/8917/trunk



> BTW,  switch may be cleaner than if-elseif.  (Lines 205-215 of storage/ov.c
> become):
>
>            switch(uwildmat_poison(group, innconf->ovgrouppat)){
>                case UWILDMAT_FAIL:
>                    if (!SMprobe(SELFEXPIRE, &token, NULL) &&
> innconf->groupbaseexpiry)
>                    /* this article will never be expired, since it does
> not
>                       have self expiry function in stored method and
>                       groupbaseexpiry is true */
>                        return OVADDFAILED;
>                case UWILDMAT_FAIL:
>                    return OVADDGROUPNOMATCH;
>            }

The second case is for UWILDMAT_POISON.
Anyway, I kept the if-elseif.  Not a big deal, though.



> ...And now that we're using an actual wildmat call, there are no
> documentation changes.  ;-)

Only that:

-matching this comma-separated list of wildmat expressions.  Newsgroups not
+matching this comma-separated list of uwildmat(3) expressions.  Newsgroups not

-- 
Julien ÉLIE

« Boire du café empêche de dormir. Par contre, dormir empêche de boire
  du café. » (Philippe Geluck) 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads