-
Notifications
You must be signed in to change notification settings - Fork 10
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
[RFC] Move the target /etc/resolv.conf to /run #114
Changes from 1 commit
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 |
---|---|---|
|
@@ -1682,14 +1682,16 @@ def MountPartitions(root_device_current) | |
Yast2::FsSnapshotStore.save("update", snapshot.number) | ||
end | ||
Update.clean_backup | ||
pre_inject_files | ||
create_backup | ||
inject_intsys_files | ||
end | ||
|
||
success | ||
end | ||
|
||
RESOLV_CONF = "/etc/resolv.conf".freeze | ||
RESOLV_CONF = "/run/netconfig/resolv.conf".freeze | ||
OLD_RESOLV_CONF = "/etc/resolv.conf".freeze | ||
|
||
# known configuration files that are changed during update, so we need to | ||
# backup them to restore if something goes wrong (bnc#882039) | ||
|
@@ -1714,6 +1716,16 @@ def create_backup | |
end | ||
end | ||
|
||
def pre_inject_files | ||
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. Term "inject" means adding from outside. In this case we are just moving the files inside 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. It are a set of checks of steps needed before injecting the resolv conf, so for me looked reasonable, but as it is resolv.conf specific I will try to use something more meaningful. |
||
old_dest = File.join(Installation.destdir, OLD_RESOLV_CONF) | ||
dest = File.join(Installation.destdir, RESOLV_CONF) | ||
if File.file?(old_dest) && !File.exist?(dest) | ||
::FileUtils.mkdir_p(File.dirname(dest)) | ||
::FileUtils.mv(old_dest, dest) | ||
::FileUtils.ln_s(dest, old_dest) | ||
end | ||
end | ||
|
||
# inject the required files from the inst-sys to the chroot so | ||
# the network connection works for the chrooted scripts | ||
def inject_intsys_files | ||
|
@@ -1723,7 +1735,9 @@ def inject_intsys_files | |
# resolver like systemd-resolver and some configuration of network manager. So we not modify | ||
# symlink target and instead just replace symlink with our file that can resolve and from | ||
# backup we later restore original symlink. | ||
::FileUtils.copy_entry(RESOLV_CONF, target, false, false, true) if File.exist?(RESOLV_CONF) | ||
if File.symlink?(old_target) | ||
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. Note: |
||
::FileUtils.copy_entry(RESOLV_CONF, target, false, false, true) if File.exist?(RESOLV_CONF) | ||
end | ||
rescue Errno::EPERM => e | ||
# just log a warning when rewriting the file is not permitted, | ||
# e.g. it has the immutable flag set (bsc#1096142) | ||
|
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.
Hm, writing to
/run
might make troubles. In Leap 15.0 the/run
is on a tmpfs file system (RAM disk), but there is no/etc/fstab
entry for it so during upgrade/mnt/run
is actually on the disk.There is some extra cleanup done in the end (yast/yast-installation#725), but I think this should be mentioned in a comment as this behavior is not obvious from the code.