-
Notifications
You must be signed in to change notification settings - Fork 397
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
fix(network-manager): disable tty output if the console is not usable #1611
Conversation
Hmm this seems somewhat backwards. |
4ad0834
to
7e5d828
Compare
Good point, there should be no output on console unless the command line contains
I'm not sure about this; having two units means that every change must be duplicated in both files and it's easy to get them out of sync by mistake. How about changing only the needed options through a drop-in file instead? |
if [ -n "$DRACUT_SYSTEMD" ]; then | ||
# enable tty output if an usable console is found | ||
# shellcheck disable=SC2217 | ||
if [ -w /dev/console ] && (echo < /dev/console) > /dev/null 2> /dev/null; then |
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 assume echo < /dev/console
is a test and will fail if the console doesn't work? It seems weird to me to send anything to stdin of echo
since it doesn't do anything with it. cat
does.
Also:
if [ -w /dev/console ] && (echo < /dev/console) > /dev/null 2> /dev/null; then | |
if [ -w /dev/console ] && (echo < /dev/console) &> /dev/null; then |
I think this is equivalent with less characters.
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 assume echo < /dev/console is a test and will fail if the console doesn't work? It seems weird to me to send anything to stdin of echo since it doesn't do anything with it. cat does.
I copied this code from https://github.com/dracutdevs/dracut/blob/055/modules.d/99shutdown/shutdown.sh#L15
The idea is to try to open the console via shell redirection, but don't actually read or write anything from/to it. If /dev/console
can't be opened, the command returns a non-zero value which is interpreted as false
.
I think this is equivalent with less characters.
The interpreter of this script is /bin/sh
, so it must be POSIX compatible.
&>
is a bashism and is not POSIX.
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.
Thanks for the reply/explanation.
[Service] | ||
StandardOutput=tty | ||
EOF | ||
systemctl --no-block daemon-reload |
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.
any implications of running this daemon-reload here? If we ran this as part of a systemd generator would we need to do the daemon-reload?
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'm not aware of any side effect of calling daemon-reload here.
A generator would be an alternative and wouldn't require a daemon-reload; I think it requires to ship new service and a script. I like how the current code is self-contained, but I have no objections in turning it into a generator if that's the general consensus.
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.
@lucab - any thoughts here on the tradeoffs?
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.
Yes, reloading in the middle of a boot isn't the nicest, a generator would be advisable.
I don't think it directly breaks anything so not strictly a problem, but may trigger some unexpected second-order effects.
For reference, I see there are some dracut modules already shipping a generator in this repository, like modules.d/95nbd/
.
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.
Agree a generator would be slightly cleaner and would make a good follow-up, but if this is already tested IMO it's not worth the respin.
The module should show the output on console only when initrd debugging is enabled.
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.
seems fine to me
The network-manager module also writes logs to the console, so that it's easier to debug network-related boot issues. If systemd can't open the console, the service fails and network doesn't get configured. Add a check to disable tty output when the console is not present or not usable. coreos/fedora-coreos-tracker#943
@johannbg - can we merge this? |
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.
LGTM
@dustymabe I've ack this but it needs second review from @haraldh before it can be merged. |
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.
This is so ugly... but if you insist...
can you elaborate? obviously we're interested in an expert's opinion on best way to achieve something. |
All output of services is normally logged to the systemd journal anyway. There exist kernel command line options to display the output of the journal like You can even get a systemd driven shell with If |
Thanks for the explanation. |
The network-manager module also writes logs to the console, so that it's easier to debug network-related boot issues. If systemd can't open the console, the service fails and network doesn't get configured.
Add a check to disable tty output when the console is not present or not usable.
coreos/fedora-coreos-tracker#943
Checklist