-
Notifications
You must be signed in to change notification settings - Fork 164
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
Do not start getty on tty0 to avoid screen corruption #4517
Merged
+105
−4
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.*\.dts | ||
.*\.md | ||
^.codespellignorelines | ||
pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/sh | ||
|
||
infinite_loop() { | ||
while true; do | ||
$@ | ||
done | ||
} | ||
|
||
# run getty on all known consoles | ||
start_getty() { | ||
tty=${1%,*} | ||
speed=${1#*,} | ||
securetty="$2" | ||
line= | ||
term="linux" | ||
[ "$speed" = "$1" ] && speed=115200 | ||
|
||
# if console=tty0 is specified on the kernel command line, we should not start a getty on tty0 | ||
# but instead start it on the first available tty. tty0 points to the current console, so if | ||
# we start a getty from pillar of debug.enable.console=true we may start it on current tty | ||
# which may be occupied by TUI monitor application and tty will be taken away by getty. | ||
# replacing tty0 with tty1 should be ok because this is the user's intention | ||
if [ "$tty" = "tty0" ]; then | ||
tty="tty1" | ||
fi | ||
|
||
# did we already process this tty? | ||
if $(echo "${PROCESSEDTTY}" | grep -q -w "$tty"); then | ||
echo "getty: already processed tty for $tty, not starting twice" | tee /dev/tty | ||
return | ||
fi | ||
# now indicate that we are processing it | ||
PROCESSEDTTY="${PROCESSEDTTY} ${tty}" | ||
|
||
# does the device even exist? | ||
if [ ! -c /dev/$tty ]; then | ||
echo "getty: cmdline has console=$tty but /dev/$tty is not a character device; not starting getty for $tty" | tee /dev/tty | ||
return | ||
fi | ||
|
||
case "$tty" in | ||
ttyS*|ttyAMA*|ttyUSB*|ttyMFD*) | ||
line="-L" | ||
term="vt100" | ||
;; | ||
tty?) | ||
line="" | ||
speed="38400" | ||
term="" | ||
;; | ||
esac | ||
|
||
# are we secure or insecure? | ||
loginargs= | ||
if [ "$INSECURE" == "true" ]; then | ||
loginargs="-a root" | ||
fi | ||
|
||
if ! grep -q -w "$tty" "$securetty"; then | ||
# we could not find the tty in securetty, so start a getty but warn that root login will not work | ||
echo "getty: cmdline has console=$tty but does not exist in $securetty; will not be able to log in as root on this tty $tty." | tee /dev/$tty | ||
fi | ||
# respawn forever | ||
echo "getty: starting getty for $tty" | tee /dev/$tty | ||
infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term & | ||
} | ||
|
||
|
||
# check if we are namespaced, and, if so, indicate in the PS1 | ||
if [ -z "$INITGETTY" ]; then | ||
cat >/etc/profile.d/namespace.sh <<"EOF" | ||
export PS1="(ns: getty) $PS1" | ||
EOF | ||
fi | ||
|
||
PROCESSEDTTY= | ||
|
||
# check if we have /etc/getty.shadow | ||
ROOTSHADOW=/hostroot/etc/getty.shadow | ||
if [ -f $ROOTSHADOW ]; then | ||
cp $ROOTSHADOW /etc/shadow | ||
# just in case someone forgot a newline | ||
echo >> /etc/shadow | ||
fi | ||
|
||
for opt in $(cat /proc/cmdline); do | ||
case "$opt" in | ||
console=*) | ||
start_getty ${opt#console=} /etc/securetty | ||
esac | ||
done | ||
|
||
# if we are in a container (not in root init) wait for all our child process to exit; tini will handle subreaping, if necessary | ||
[ -n "$INITGETTY" ] || wait |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why do you want to ignore blank tabs?
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.
As far as I understand, because it's not our code originally )