#1184 PR closed: Fixed problem of truncating network prefix from IPADDR if NETMASK not…

Labels: bug, won't fix / can't fix / obsolete

petr-gansel opened issue at 2017-01-27 20:47:

… specified in ifcfg-* file

jsmeix commented at 2017-01-30 09:46:

From plain looking at the code it seems the second change

-  for network_file in $TARGET_FS_ROOT/etc/sysconfig/*/ifcfg-*${device}* $TARGET_FS_ROOT/etc/sysconfig/network ; do
+  for network_file in $TARGET_FS_ROOT/etc/sysconfig/*/ifcfg-*${device}* $TARGET_FS_ROOT/etc/sysconfig/network/routes ; do

could be a backward incompatible change because now
$TARGET_FS_ROOT/etc/sysconfig/network
is no longer used - but perhaps that is needed on older systems,
cf. "Maintain backward compatibility" in
https://github.com/rear/rear/wiki/Coding-Style

petr-gansel commented at 2017-02-02 08:47:

Sorry for inconvenience.
The second change is wrong, I know. It was just my misunderstandig.
The goal was to get rid of error message while updating routes since during restore SLES11/12 where $TARGET_FS_ROOT/etc/sysconfig/network is not a file but directory.
Now I see that /etc/sysconfig/network is really a file in other distros like centos.

I've udpated the code, but didn't have time to check my code so far, so no commit yet...

diff --git a/usr/share/rear/finalize/GNU/Linux/42_migrate_network_configuration_files.sh b/usr/share/rear/finalize/GNU/Linux/42_migrate_network_configuration_files.sh
index d14a957..d1506c7 100644


a/usr/share/rear/finalize/GNU/Linux/42_migrate_network_configuration_files.sh
+++ b/usr/share/rear/finalize/GNU/Linux/42_migrate_network_configuration_files.sh
@@ -89,11 +89,19 @@ if test -s $TMP_DIR/mappings/routes ; then
while read destination gateway device junk ; do
# echo "$destination $gateway - $device" >> $TARGET_FS_ROOT/etc/sysconfig/network/routes
if [[ "$destination" = "default" ]]; then

  • for network_file in $TARGET_FS_ROOT/etc/sysconfig//ifcfg-${device}* $TARGET_FS_ROOT/etc/sysconfig/network/routes ; do

  • SED_SCRIPT="s#^GATEWAY=.#GATEWAY='$gateway'#g;s#^GATEWAYDEV=.#GATEWAYDEV='$device'#g"

  • Log "SED_SCRIPT: '$SED_SCRIPT'"

  • sed -i -e "$SED_SCRIPT" "$network_file"

  • LogPrintIfError "WARNING! There was an error patching the network configuration files!"

  • for network_file in $TARGET_FS_ROOT/etc/sysconfig//ifcfg-${device}* $TARGET_FS_ROOT/etc/sysconfig/network $TARGET_FS_ROOT/etc/sysconfig/network/routes; do

  • [[ -d $network_file ]] && continue

  • if [[ "$network_file" = "routes" ]];then

  • SED_SCRIPT="s#^default=.*#default $gateway - $device#"

  • Log "SED_SCRIPT: '$SED_SCRIPT'"

  • sed -i -e "$SED_SCRIPT" "$network_file"

  • LogPrintIfError "WARNING! There was an error patching the network configuration files!"

  • else

  • SED_SCRIPT="s#^GATEWAY=.#GATEWAY='$gateway'#g;s#^GATEWAYDEV=.#GATEWAYDEV='$device'#g"

  • Log "SED_SCRIPT: '$SED_SCRIPT'"

  • sed -i -e "$SED_SCRIPT" "$network_file"

  • LogPrintIfError "WARNING! There was an error patching the network configuration files!"

  • fi done else # static-routes or route- settings?

On 2 Feb 2017, at 09:16, gdha notifications@github.com wrote:

@gdha requested changes on this pull request.

In usr/share/rear/finalize/GNU/Linux/42_migrate_network_configuration_files.sh https://github.com/rear/rear/pull/1184#pullrequestreview-19044200:

@@ -68,7 +68,11 @@ if test -s $TMP_DIR/mappings/ip_addresses ; then
nmask=""
nip="$new_ip" # keep ipaddress/cidr
else

  • nip="${new_ip%%/*}" # only keep ipaddress
  • if grep -qE '^NETMASK=' $network_file;then

Can you give an example so I understand this better what you would like to achieve?

In usr/share/rear/finalize/GNU/Linux/42_migrate_network_configuration_files.sh https://github.com/rear/rear/pull/1184#pullrequestreview-19044200:

@@ -85,7 +89,7 @@ if test -s $TMP_DIR/mappings/routes ; then
while read destination gateway device junk ; do
# echo "$destination $gateway - $device" >> $TARGET_FS_ROOT/etc/sysconfig/network/routes
if [[ "$destination" = "default" ]]; then

  • for network_file in $TARGET_FS_ROOT/etc/sysconfig//ifcfg-${device}* $TARGET_FS_ROOT/etc/sysconfig/network ; do
  • for network_file in $TARGET_FS_ROOT/etc/sysconfig//ifcfg-${device}* $TARGET_FS_ROOT/etc/sysconfig/network/routes ; do

RedHat related Linuxes require $TARGET_FS_ROOT/etc/sysconfig/network. I assume that for SLES the routes are defined in $TARGET_FS_ROOT/etc/sysconfig/network/routes? If that is the case please add it and do not remove the previous network file.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/rear/rear/pull/1184#pullrequestreview-19044200, or mute the thread https://github.com/notifications/unsubscribe-auth/AYNxpgCKCyZu-kxWfL9_ijsHVlAJJPGgks5rYZD7gaJpZM4LwMs8.

gdha commented at 2017-02-17 08:19:

@petr-gansel any update on your tests?

gdha commented at 2017-02-24 09:48:

@petr-gansel kind reminder - do not let this pull request die :-/

gdha commented at 2017-03-30 13:24:

@petr-gansel Any progress??

jsmeix commented at 2017-05-22 07:25:

Because of possible backward incompatible changes
I post-pone it for a later release after 2.1 (for now for 2.2).


[Export of Github issue for rear/rear.]