Skip to main content

set_sysctl

Function set_sysctl 

Source
pub fn set_sysctl(key: &str, value: &str) -> Result<(), NetlinkError>
Expand description

Set a sysctl via the /proc/sys/... filesystem.

key uses dotted form like net.ipv4.ip_forward; dots are translated to path separators so the effective path is /proc/sys/net/ipv4/ip_forward. Writes the string form of value to the file.

Replaces the shell-outs: sysctl -w <key>=<value>

Writing to /proc/sys/... is the kernel-standard way of setting sysctls and works under any confinement that still allows write access to /proc/sys (which the overlay manager needs anyway for its other operations).

§Errors

Returns NetlinkError::Io if the write fails (e.g. permission denied, file missing because the sysctl doesn’t exist on this kernel, etc.).