File: sysctl-get-local.patch

package info (click to toggle)
goss 0.4.9-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,692 kB
  • sloc: sh: 984; makefile: 139
file content (30 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Description: Manually get sysctl key to avoid go-sysctl dependency.
Author: Lena Voytek <lena.voytek@canonical.com>
Last-Update: 2024-04-10
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/system/kernel_param.go
+++ b/system/kernel_param.go
@@ -2,8 +2,10 @@
 
 import (
 	"context"
+	"errors"
+	"io/ioutil"
+	"strings"
 
-	"github.com/achanda/go-sysctl"
 	"github.com/goss-org/goss/util"
 )
 
@@ -40,5 +42,9 @@
 }
 
 func (k *DefKernelParam) Value() (string, error) {
-	return sysctl.Get(k.key)
+	keyData, err := ioutil.ReadFile("/proc/sys/" + strings.Replace(k.key, ".", "/", -1))
+	if err != nil {
+		return "", errors.New("could not find the given key")
+	}
+	return strings.TrimSpace(string(keyData)), nil
 }