2021-09-13 17:37:37 +05:30
|
|
|
|
|
|
|
set sysctl ${topdir}sysctl
|
|
|
|
|
|
|
|
set test "sysctl write from command line"
|
|
|
|
spawn $sysctl --dry-run kernel.hostname=procps-test
|
2022-04-09 09:48:28 +05:30
|
|
|
expect_pass "$test" "kernel.hostname = procps-test"
|
|
|
|
|
|
|
|
set test "sysctl write from command line using slash"
|
|
|
|
spawn $sysctl --dry-run kernel/hostname=procps-test
|
|
|
|
expect_pass "$test" "kernel.hostname = procps-test"
|
2021-09-13 17:37:37 +05:30
|
|
|
|
|
|
|
set test "sysctl write from configuration file"
|
|
|
|
spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_glob_test.conf
|
2022-04-09 09:48:28 +05:30
|
|
|
expect_pass "$test" "fs.protected_fifos = 2\\s+fs.protected_symlinks = 2\\s+fs.protected_hardlinks = 1"
|
|
|
|
|
|
|
|
set test "sysctl write from file with slashes"
|
|
|
|
spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_slash_test.conf
|
|
|
|
expect_pass "$test" "kernel.hostname = procps-test"
|
2021-09-13 17:37:37 +05:30
|
|
|
|
|
|
|
set hostname_file "/proc/sys/kernel/hostname"
|
|
|
|
if {[file exists ${hostname_file}]} {
|
|
|
|
if {[file writable ${hostname_file}]} {
|
|
|
|
unsupported "sysctl write: hostname file is writable"
|
|
|
|
} else {
|
|
|
|
set test "sysctl write unwritable file"
|
|
|
|
spawn $sysctl -q kernel.hostname=procpstest
|
|
|
|
expect_pass "$test" "sysctl: permission denied on key \"kernel.hostname\"\\s*$"
|
|
|
|
expect_spawn_retval "$test" 1
|
|
|
|
|
|
|
|
set test "sysctl write unwritable file ignored"
|
|
|
|
spawn $sysctl -q -- -kernel.hostname=procpstest
|
|
|
|
expect_pass "$test" "sysctl: permission denied on key \"kernel.hostname\", ignoring\\s*$"
|
|
|
|
expect_spawn_retval "$test" 0
|
|
|
|
}
|
|
|
|
} else {
|
2022-04-09 09:48:28 +05:30
|
|
|
unsupported "sysctl write: hostname file does not exist"
|
2021-09-13 17:37:37 +05:30
|
|
|
}
|