mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
Check user's oom_score_adj write permission for oom-score-adj test (#13111)
`CONFIG SET oom-score-adj handles configuration failures` test failed in some CI jobs today. Failed CI: https://github.com/redis/redis/actions/runs/8152519326 Not sure why the github action's docker image perssions have changed, but the issue is similar to #12887, where we can't assume the range of oom_score_adj that a user can change. ## Solution: Modify the way of determining whether the current user has no privileges or not, instead of relying on whether the user id is 0 or not.
This commit is contained in:
parent
28976a9003
commit
9738ba9841
@ -1,5 +1,4 @@
|
|||||||
set system_name [string tolower [exec uname -s]]
|
set system_name [string tolower [exec uname -s]]
|
||||||
set user_id [exec id -u]
|
|
||||||
|
|
||||||
if {$system_name eq {linux}} {
|
if {$system_name eq {linux}} {
|
||||||
start_server {tags {"oom-score-adj external:skip"}} {
|
start_server {tags {"oom-score-adj external:skip"}} {
|
||||||
@ -56,8 +55,15 @@ if {$system_name eq {linux}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Determine whether the current user is unprivileged
|
||||||
|
set original_value [exec cat /proc/self/oom_score_adj]
|
||||||
|
catch {
|
||||||
|
set fd [open "/proc/self/oom_score_adj" "w"]
|
||||||
|
puts $fd -1000
|
||||||
|
close $fd
|
||||||
|
} e
|
||||||
# Failed oom-score-adj tests can only run unprivileged
|
# Failed oom-score-adj tests can only run unprivileged
|
||||||
if {$user_id != 0} {
|
if {[string match "*permission denied*" $e]} {
|
||||||
test {CONFIG SET oom-score-adj handles configuration failures} {
|
test {CONFIG SET oom-score-adj handles configuration failures} {
|
||||||
# Bad config
|
# Bad config
|
||||||
r config set oom-score-adj no
|
r config set oom-score-adj no
|
||||||
@ -81,6 +87,11 @@ if {$system_name eq {linux}} {
|
|||||||
# Make sure previous values remain
|
# Make sure previous values remain
|
||||||
assert {[r config get oom-score-adj-values] == {oom-score-adj-values {0 100 100}}}
|
assert {[r config get oom-score-adj-values] == {oom-score-adj-values {0 100 100}}}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
# Restore the original oom_score_adj value
|
||||||
|
set fd [open "/proc/self/oom_score_adj" "w"]
|
||||||
|
puts $fd $original_value
|
||||||
|
close $fd
|
||||||
}
|
}
|
||||||
|
|
||||||
test {CONFIG SET oom-score-adj-values doesn't touch proc when disabled} {
|
test {CONFIG SET oom-score-adj-values doesn't touch proc when disabled} {
|
||||||
|
Loading…
Reference in New Issue
Block a user