Skip to content

Commit 6b4ddd4

Browse files
FedeDPpoiana
authored andcommitted
chore(pkg/driver): restored uek kernel check.
Signed-off-by: Federico Di Pierro <[email protected]>
1 parent ae5a30b commit 6b4ddd4

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

pkg/driver/distro/distro_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,28 @@ func TestDiscoverDistro(t *testing.T) {
167167
distroExpected: &bottlerocket{},
168168
errExpected: false,
169169
},
170+
{
171+
// os-release ID "ol" maps to oracle
172+
krInput: "5.10.0-2047.510.5.5.el7uek.x86_64",
173+
preFn: func() error {
174+
type brCfg struct {
175+
OsID string `ini:"ID"`
176+
}
177+
f := ini.Empty()
178+
err := f.ReflectFrom(&brCfg{
179+
OsID: "ol",
180+
})
181+
if err != nil {
182+
return err
183+
}
184+
return f.SaveTo(osReleaseFile)
185+
},
186+
postFn: func() {
187+
_ = os.Remove(osReleaseFile)
188+
},
189+
distroExpected: &ol{},
190+
errExpected: false,
191+
},
170192
{
171193
// No os-release but "centos-release" file present maps to centos
172194
krInput: "5.10.0",

pkg/driver/distro/oracle.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright (C) 2024 The Falco Authors
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
package driverdistro
17+
18+
import (
19+
"strings"
20+
21+
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
22+
23+
drivertype "github.com/falcosecurity/falcoctl/pkg/driver/type"
24+
)
25+
26+
func init() {
27+
distros["ol"] = &ol{generic: &generic{}}
28+
}
29+
30+
type ol struct {
31+
*generic
32+
}
33+
34+
//nolint:gocritic // the method shall not be able to modify kr
35+
func (o *ol) PreferredDriver(kr kernelrelease.KernelRelease, allowedDriverTypes []drivertype.DriverType) drivertype.DriverType {
36+
for _, allowedDrvType := range allowedDriverTypes {
37+
// Skip dkms on UEK hosts because it will always fail
38+
if allowedDrvType.String() == drivertype.TypeKmod && strings.Contains(kr.String(), "uek") {
39+
continue
40+
}
41+
if allowedDrvType.Supported(kr) {
42+
return allowedDrvType
43+
}
44+
}
45+
return nil
46+
}

0 commit comments

Comments
 (0)