Bug 2097437

Summary: [ReaR] vi command in rear recover environment hungs
Product: Red Hat Enterprise Linux 9 Reporter: Pradeep Jagtap <prjagtap>
Component: rearAssignee: Pavel Cahyna <pcahyna>
Status: CLOSED ERRATA QA Contact: David Jež <djez>
Severity: medium Docs Contact: Šárka Jana <sjanderk>
Priority: unspecified    
Version: 9.0CC: djez, eric.p.hagen.ctr, pcahyna, sjanderk
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rear-2.6-12.el9 Doc Type: Bug Fix
Doc Text:
.The `vi` command in ReaR no longer results in an infinite loop Previously, the ReaR rescue system did not contain the `vi` executable, only the `/bin/vi` script. As a consequence, the `/bin/vi` script caused an infinite loop when invoked. With this update, the ReaR rescue system contains the actual `vi` executable `/usr/libexec/vi`, and running the `vi` command no longer leads to an endless loop.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:42:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pradeep Jagtap 2022-06-15 16:56:27 UTC
Description of problem:
=========================
/bin/vi hung in rear recover environment only was to exit is pressing Ctrl+C

The /bin/vi script on the rear iso checks for the existence of vim incorrectly which causes an infinite loop


Version-Release number of selected component (if applicable):
============================================================
rear-2.6-11.el9.x86_64

How reproducible:
=================

Steps to Reproduce:
1. Boot system with rear rescue ISO
2. Use vi editor to edit the file 

Actual results:
=================
vi hungs in rear rescue 

Expected results:
==================
Should be able to use vi editor

Comment 3 Pavel Cahyna 2022-06-16 10:04:47 UTC
The problem is in usr/share/rear/build/GNU/Linux/005_create_symlinks.sh :

ln -sf $v vi $ROOTFS_DIR/bin/vim >&2

I think this line should be removed and vim added to PROGS.

Comment 4 Pavel Cahyna 2022-06-16 10:59:29 UTC
> ln -sf $v vi $ROOTFS_DIR/bin/vim >&2
> 
> I think this line should be removed and vim added to PROGS.

This solution indeed works.

Steps to reproduce (almost) automatically:

# echo 'PROGS+=( timeout )' >> /etc/rear/local.conf
# rear -d mkrescue
...
Testing that the recovery system in /var/tmp/rear.sewWahfi7dNgMlf/rootfs contains a usable system
...
# chroot /var/tmp/rear.sewWahfi7dNgMlf/rootfs timeout 10 vi +q
# echo $?
# 124

Comment 5 Pavel Cahyna 2022-06-16 11:24:37 UTC
If I only remove the /usr/bin/vim symlink and try to run vi, I get

/usr/sbin/vi: line 23: /usr/libexec/vi: No such file or directory

So checking for symlink is not enough, there is nothing to run if we don't want to execute the symlink.

In addition to the proposed fix, I would also add /usr/libexec/vi to PROGS (in case vim is not there, for example).

Comment 6 eric_hagen 2022-06-20 19:40:16 UTC
Original RH ticket assigned to this report.
Tested above with the same results.
Currently vi is listed in the /usr/share/rear/conf/GNU/Linux.conf file under:
# progs to take along
vim is not defined anywhere.

Comment 16 errata-xmlrpc 2022-11-15 10:42:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (rear bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8246