Skip to content

Commit 7dcdf6a

Browse files
authored
Merge pull request #4059 from ashwat287/FixWorthCheckingIPTablesLogic
guestagent: start iptables audit watcher when auditing already enabled
2 parents e5b9acc + a0d760b commit 7dcdf6a

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
@@ -68,11 +68,11 @@ func New(ctx context.Context, ticker ticker.Ticker, iptablesIdle time.Duration)
6868
return nil, err
6969
}
7070
}
71-
72-
go a.setWorthCheckingIPTablesRoutine(auditClient, iptablesIdle)
73-
} else {
74-
a.worthCheckingIPTables = true
7571
}
72+
73+
a.worthCheckingIPTables = true // allow initial iptables scan
74+
go a.setWorthCheckingIPTablesRoutine(auditClient, iptablesIdle)
75+
7676
logrus.Infof("Auditing enabled (%d)", auditStatus.Enabled)
7777
return startGuestAgentRoutines(ctx, a, true), nil
7878
}
@@ -112,7 +112,8 @@ type agent struct {
112112
// when no NETFILTER_CFG audit message was received for the iptablesIdle time.
113113
func (a *agent) setWorthCheckingIPTablesRoutine(auditClient *libaudit.AuditClient, iptablesIdle time.Duration) {
114114
logrus.Info("setWorthCheckingIPTablesRoutine(): monitoring netfilter audit events")
115-
var latestTrue time.Time
115+
// Initialize to now so the first sleeper loop does not immediately mark it false.
116+
latestTrue := time.Now()
116117
go func() {
117118
for {
118119
time.Sleep(iptablesIdle)

0 commit comments

Comments
 (0)