Skip to content
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

state: set_stdio: chdir back to / in case of failure #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Rondom
Copy link

@Rondom Rondom commented Apr 15, 2024

This has been previously posted to the mailinglist


set_stdio chdirs to /dev/ to facilitate easy freopen of the console device name given by the tty parameter. Make sure to chdir back to / in all cases, even in the error path. This keeps the function free from unintended side effects.

Before this commit, in case of an error, the working directory would remain /dev/ which would break sysupgrade because the rest of the code would rely on the current working directory to be unchanged, which is not an unreasonable expectation to make.

Fixing this fixes an issue where sysupgrade would fail, when /dev/console does not exist or cannot be opened, which can happen for example when setting console= on kernel cmdline.

Closes: openwrt/openwrt#6005
Fixes: 91da63d ("properly handle return codes")

set_stdio chdirs to /dev/ to facilitate easy freopen of the console
device name given by the tty parameter. Make sure to chdir back to / in
all cases, even in the error path. This keeps the function free from
unintended side effects.

Before this commit, in case of an error, the working directory would
remain /dev/ which would break sysupgrade because the rest of the code
would rely on the current working directory to be unchanged, which is
not an unreasonable expectation to make.

Fixing this fixes an issue where sysupgrade would fail, when
/dev/console does not exist or cannot be opened, which can happen for
example when setting console= on kernel cmdline.

Closes: openwrt/openwrt#6005
Fixes: 91da63d ("properly handle return codes")
Signed-off-by: Andreas Gnau <andreas.gnau@iopsys.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FS#1071 - Sysupgrade fails when kernel console is disabled
1 participant