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

[RFC] Move the target /etc/resolv.conf to /run #114

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/modules/RootPart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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.

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)
Expand All @@ -1714,6 +1716,16 @@ def create_backup
end
end

def pre_inject_files
Copy link
Member

@lslezak lslezak Oct 26, 2018

Choose a reason for hiding this comment

The 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 /mnt. E.g. the inject_intsys_files method really copies from inst-sys (/) into /mnt. So I'd prefer a different method name here for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: old_target variable does not exist here. Probably a reference to target.

::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)
Expand Down