fix(samba): compatibility with Samba 4.22+ and add CanarySMB alias#481
Open
pippocom wants to merge 1 commit into
Open
fix(samba): compatibility with Samba 4.22+ and add CanarySMB alias#481pippocom wants to merge 1 commit into
pippocom wants to merge 1 commit into
Conversation
The SMB module had two issues that prevented it from working on modern Samba installations: 1. Regex fix: the original anchored regex (^.*smbd_audit) failed when syslog prepends a timestamp before the smbd_audit token, as seen with rsyslog on Debian 12+ and Samba 4.x. Changed to use re.search() with unanchored pattern to match anywhere in the line. 2. Field parsing: Samba 4.22+ with vfs_full_audit prefix '%U|%I|%S' produces only 6 pipe-separated fields instead of the 13+ expected by the original code, causing IndexError. Added format detection to handle both the short format (Samba 4.22+) and the legacy long format transparently. 3. CanarySMB alias: opencanary.tac imports CanarySMB but the module only defines CanarySamba, causing ImportError on startup. Added CanarySMB = CanarySamba alias for backward compatibility. Tested on: Debian 13 Trixie, Samba 4.22.8, Python 3.13 Reported-by: Marco Iannacone <ianna@pippo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR fixes two bugs in the SMB module that prevent it from working with Samba 4.22+ and modern Linux distributions, and adds a missing class alias that causes an ImportError on startup.
No related issue exists yet — this was discovered while deploying OpenCanary on Debian 13 Trixie with Samba 4.22.8.
Types of changes
Bugfix (non-breaking change which fixes an issue)
Checklist
Lint and unit tests pass locally with my changes (if applicable)
Further comments
Three issues fixed in a single PR as they are all related to the SMB module failing silently on modern systems:
Tested on: Debian 13 Trixie, Samba 4.22.8, Python 3.13, Raspberry Pi Zero W.
Reported-by: Marco Iannacone ianna@pippo.com