procsyskernel

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package procsyskernel reads Linux kernel information from /proc/sys/kernel/.

This package is in builtins/internal/ and is therefore exempt from the builtinAllowedSymbols allowlist check. It may use OS-specific APIs freely.

Sandbox bypass

ReadFile intentionally bypasses the AllowedPaths sandbox (callCtx.OpenFile) and calls os.OpenFile directly. This is safe because procPath is always a kernel-managed pseudo-filesystem root (/proc by default) that is hardcoded by the caller — it is never derived from user-supplied input and cannot be redirected by a shell script. The caller is responsible for ensuring that procPath remains a safe, non-user-controlled path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(procPath, name string) (string, error)

ReadFile reads a single-line value from a /proc/sys/kernel/ pseudo-file. name is the filename (e.g. "ostype", "hostname"). procPath is the base proc path (e.g. "/proc" or "/host/proc").

The file is opened with O_NONBLOCK to prevent blocking on FIFOs, then validated via fstat to reject non-regular files. Reads are bounded to 4 KiB. The returned value is trimmed of trailing whitespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL