Skip to content

Commit a0d760b

Browse files
committed
guestagent: start iptables audit watcher when auditing already enabled
Fixes a logic gap where, if auditing was already enabled at startup, the code only set worthCheckingIPTables=true and did not launch setWorthCheckingIPTablesRoutine. Without the routine the flag never changes (never set false after idle, never toggled by NETFILTER_CFG events), so the cached a.latestIPTables path is never used and behavior differs from the “auditing just enabled” case. Change: - After confirming auditing is (or becomes) enabled, always set worthCheckingIPTables=true for the initial scan and always start setWorthCheckingIPTablesRoutine. - Leave the non‑auditing fallback path unchanged. This makes flag state transitions consistent regardless of initial auditStatus.Enabled. Signed-off-by: ashwat287 <[email protected]>
1 parent 1bf475c commit a0d760b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/guestagent/guestagent_linux.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ func New(ctx context.Context, newTicker func() (<-chan time.Time, func()), iptab
6767
return nil, err
6868
}
6969
}
70-
71-
go a.setWorthCheckingIPTablesRoutine(auditClient, iptablesIdle)
72-
} else {
73-
a.worthCheckingIPTables = true
7470
}
71+
72+
a.worthCheckingIPTables = true // allow initial iptables scan
73+
go a.setWorthCheckingIPTablesRoutine(auditClient, iptablesIdle)
74+
7575
logrus.Infof("Auditing enabled (%d)", auditStatus.Enabled)
7676
return startGuestAgentRoutines(ctx, a, true), nil
7777
}
@@ -111,7 +111,8 @@ type agent struct {
111111
// when no NETFILTER_CFG audit message was received for the iptablesIdle time.
112112
func (a *agent) setWorthCheckingIPTablesRoutine(auditClient *libaudit.AuditClient, iptablesIdle time.Duration) {
113113
logrus.Info("setWorthCheckingIPTablesRoutine(): monitoring netfilter audit events")
114-
var latestTrue time.Time
114+
// Initialize to now so the first sleeper loop does not immediately mark it false.
115+
latestTrue := time.Now()
115116
go func() {
116117
for {
117118
time.Sleep(iptablesIdle)

0 commit comments

Comments
 (0)