Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: KeyError when handling CoA packet for 0.0.0.0 host #197

Open
mmakaay opened this issue May 31, 2024 · 1 comment
Open

Bug: KeyError when handling CoA packet for 0.0.0.0 host #197

mmakaay opened this issue May 31, 2024 · 1 comment
Assignees
Labels

Comments

@mmakaay
Copy link

mmakaay commented May 31, 2024

When defining a client host 0.0.0.0 for a CoA radius Server, then a KeyError will occur when handling a CoA packet.

        File ".../pyrad/server.py", line 250, in _HandleCoaPacket
            pkt.secret = self.hosts[pkt.source[0]].secret
                         ~~~~~~~~~~^^^^^^^^^^^^^^^
        KeyError: '172.16.0.100'

The reason seems to be that _AddSecret(...) was added at some point to support using 0.0.0.0 as a host, but the pkt.secret = ... assignment that it ought to replace was not removed.

I provided a fix in PR: #196

Work-around while this fix is not available in the released pyrad packge

For now, I fixed the issue by overriding _AddSecret(...) to dynamically add a host when 0.0.0.0 was matched.

    def _AddSecret(self, pkt):
        if pkt.source[0] in self.hosts:
            pkt.secret = self.hosts[pkt.source[0]].secret
        elif '0.0.0.0' in self.hosts:
            pkt.secret = self.hosts['0.0.0.0'].secret
            # The fix: dynamically add the actual host to the server's hosts list.
            self.hosts[pkt.source[0]] = self.hosts['0.0.0.0']
        else:
            raise server.ServerPacketError('Received packet from unknown host')
@GIC-de GIC-de self-assigned this Jul 24, 2024
@GIC-de GIC-de added the fixed label Jul 24, 2024
@mmakaay
Copy link
Author

mmakaay commented Aug 16, 2024

The PR got merged, and will be part of the next release.
Since no release is done yet with the fix in it, I will keep this issue open until the release is done.
Till then, the work-around will have to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants