Skip to content

comment match not working #4

Closed
Closed

Description

@freddy36

Extracting comments always results in an empty string.
Tested with commit 9d63c85

To reproduce the issue see the follwoing example.
A workaround is also included.

import iptc

# example code to demonstrate comment extraction failure
# All comments of all chains in the filter table should be printed
# 
# iptables -A INPUT -m comment --comment "example comment"

chains = iptc.TABLE_FILTER.chains

for chain in chains:
  print "Chain: %s" % (chain.name)
  for rule in chain.rules:
    for match in rule.matches:
      if match.name == "comment":
        print "comment1: %s" % match.comment # match.comment is always an empty string

        # manually extract comment from the buffer
        # tested on kernel 2.6.32 (amd64)
        comment = "".join(map(chr, match.match_buf[32:]))
        print "comment2: %s" % comment # works

Activity

  1. added a commit that references this issue on May 4, 2012
  2. ldx commented on May 4, 2012

    @ldx
    Owner

    Good catch. Can you try 1dcf732?

  3. freddy36 commented on May 7, 2012

    @freddy36
    ContributorAuthor

    Thanks, working great.

  4. added a commit that references this issue on May 12, 2012
  5. added a commit that references this issue on May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions