-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect whether we are running in containers and act responsively. #2063
base: master
Are you sure you want to change the base?
Changes from all commits
d41f484
1ca79e8
520c7f7
5810a19
f9cc651
08a766d
06ebe2f
6328778
dd26bd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,43 @@ undotrap() { | |
settrap "$TRAP" | ||
} | ||
|
||
# Check if we are able to mknod. | ||
capmknod() { | ||
local tmp=`mktemp -d --tmpdir=/tmp 'crouton-mknod.XXX'` | ||
local ret=0 | ||
if ! mknod "$tmp/test-mknod" c 0 0 2>/dev/null; then | ||
ret=1 | ||
fi | ||
rm -rf "$tmp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You leave the directory |
||
return $ret | ||
} | ||
|
||
# Check whether $1 is mounted with options $2. | ||
# We check the options of a mount point by inspecting /proc/mounts. | ||
# For options dev, suid and exec, since they will not show up in /proc/mounts, | ||
# we check whether their opposite options (nodev, nosuid, noexec) exists. | ||
checkmountopt() { | ||
local opt | ||
local opts="$2," | ||
while [ -n "$opts" ]; do | ||
opt=${opts%%,*} | ||
opts=${opts#*,} | ||
case $opt in | ||
dev|suid|exec) | ||
if ! awk -v dir="$1" -v opt="no$opt(,|$)" \ | ||
'$2 == dir && $4 ~ opt { exit 1 }' "/proc/mounts"; then | ||
return 1 | ||
fi;; | ||
*) | ||
if ! awk -v dir="$1" -v opt="$opt(,|$)" \ | ||
'$2 == dir && $4 !~ opt { exit 1 }' "/proc/mounts"; then | ||
return 1 | ||
fi;; | ||
esac | ||
done | ||
return 0 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# Works mostly like built-in getopts but silently coalesces positional arguments. | ||
# Does not take parameters. Set getopts_string prior to calling. | ||
# Sets getopts_var and getopts_arg. | ||
|
@@ -156,7 +193,9 @@ release() { | |
# sure the kernel does not panic (this is the default configuration of a vanilla | ||
# kernel). See crbug.com/260955 for details. | ||
disablehungtask() { | ||
echo 0 > /proc/sys/kernel/hung_task_panic | ||
# Don't fail since we do not have permission to write /proc/sys/* if we are | ||
# in container. | ||
echo 0 2>/dev/null > /proc/sys/kernel/hung_task_panic || true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this, but it didn't work on my machine. It still printed out the error messages, and I'm not sure if it's the same on ChromeBook.
and the error occurs (at first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah that makes sense... Thanks. |
||
} | ||
|
||
# Run an awk program, without buffering its output. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a kernel bug. I'll try to reproduce on recent kernels and ask on LKML...