Bug 1988413 - rear overwrites the ifcfg-XXX files's MAC address with another MAC address
Summary: rear overwrites the ifcfg-XXX files's MAC address with another MAC address
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: rear
Version: 8.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Pavel Cahyna
QA Contact: Jakub Haruda
Šárka Jana
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-07-30 13:54 UTC by Renaud Métrich
Modified: 2023-08-15 12:37 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Renaud Métrich 2021-07-30 13:54:12 UTC
Description of problem:

Even when restoring on exact same system, it may happen that ReaR overwrites the HWADDR field in ifcfg-XXX files with the HWADDR of another network interface present on the system.

This is due to having /usr/share/rear/finalize/GNU/Linux/300_create_mac_mapping.sh script rely on the ifcfg-XXX file name instead of actual content (see reproducer below):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
 14 for file in "${PATCH_FILES[@]}"; do
 15         grep -q HWADDR $file || continue
 16         dev=$(echo $file | cut -d- -f3)
 17         old_mac=$(grep HWADDR $file | cut -d= -f2)
 18         new_mac=$(cat /sys/class/net/$dev/address)
 :
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Here above on line 16, the "dev" is computed as the first part of ifcfg-XXX file name, as shown in the examples below:

- /etc/sysconfig/network-scripts/ifcfg-FOO --> device is supposed to be FOO
- /etc/sysconfig/network-scripts/ifcfg-FOO-BAR --> device is supposed to be FOO as well

This code is unreliable, the device name should be collected by checking the DEVICE field in the file instead.


Version-Release number of selected component (if applicable):

rear-2.4+ and Upstream (but didn't test)


How reproducible:

Always

Steps to Reproduce:
1. Add another network interface to a VM

  e.g. there was "enp1s0" and you add an interface that becomes "enp7s0"

2. Create file ifcfg-enp1s0-enp7s0 as a modified copy of ifcfg-enp1s0 with corresponding HWADDR for enp7s0

  e.g. /etc/sysconfig/network-scripts/ifcfg-enp1s0
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp1s0"
UUID="40412d75-5e23-4d6b-8a42-0f2b2995b1d7"
ONBOOT="yes"
HWADDR=52:54:00:20:7d:fb
DEVICE="enp1s0"
NAME="enp1s0"
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

  and /etc/sysconfig/network-scripts/ifcfg-enp1s0-enp7s0
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp1s0"
UUID="5aa1ebf2-d4d4-4dc3-9f68-6d32ab457867"
ONBOOT="yes"
HWADDR=52:54:00:e5:bc:d1
DEVICE="enp7s0"
NAME="enp7s0"
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

3. Create a REAR backup and restore it on same system


Actual results:

HWADDR in /mnt/local/etc/sysconfig/network-scripts/ifcfg-enp1s0-enp7s0 becomes the one for enp1s0:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
HWADDR=52:54:00:20:7d:fb
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Expected results:

Correct MAC for enp7s0 even though the ifcfg file name is weird


Additional info:

You may think the root cause is the weird file name, but in fact it's not really the case, in normal situations, such kind of weirdness in names happens with slaves of bonding interfaces created using NetworkManager.

Comment 1 Pavel Cahyna 2021-09-21 16:56:48 UTC
Thank you for the report and analysis, I will try to implement some more reliable method.


Note You need to log in before you can comment on or make changes to this bug.