RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 617440 - guestfish: fails to tilde expand '~' when the $HOME env is unset
Summary: guestfish: fails to tilde expand '~' when the $HOME env is unset
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs
Version: 6.0
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 617436
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-07-23 03:19 UTC by Jinxin Zheng
Modified: 2015-09-28 02:11 UTC (History)
5 users (show)

Fixed In Version: libguestfs-1.7.17-8.el6
Doc Type: Bug Fix
Doc Text:
If the $HOME variable was not set, guestfish did not expand a path containing "~" (tilde) into a path to the user's home directory. Guestfish now examines the current user's passwd file for the location of the user's home directory so that a path containing "~" can be expanded correctly. Additionally, an off-by-one error was discovered in the same path-expansion algorithm. This error could potentially cause a crash. The off-by-one error has been corrected so that a crash is no longer possible. (BZ#617440)
Clone Of: 617436
Environment:
Last Closed: 2011-05-19 11:45:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0586 0 normal SHIPPED_LIVE Low: libguestfs security, bug fix, and enhancement update 2011-05-19 11:44:03 UTC

Description Jinxin Zheng 2010-07-23 03:19:05 UTC
Cloning from upstream. As this is not a very severe issue, requesting it to get fixed in 6.1.

+++ This bug was initially created as a clone of Bug #617436 +++

Description of problem:
When the environment variable $HOME is unset, bash can still expand ~ to current user's home path. But guestfish cannot.

Version-Release number of selected component (if applicable):
guestfish-1.2.7-1.18.el6.x86_64

How reproducible:
Always

Steps to Reproduce:

$ unset HOME

$ echo ~
/root

$ guestfish <<EOF
echo ~
EOF
~


Actual results:
~

Expected results:
/root

Additional info:
It would be nice to try expanding ~ from the host's passwd file when HOME is unset.

Comment 1 Richard W.M. Jones 2011-01-04 16:46:13 UTC
Upstream fix:
http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=7ce627fce02eae8c7db36b4090fa0ce1bf69bf44

Note that while I was fixing this I discovered an off-by-one
bug in related code which should also be backported:
http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=a9802509184341e731de5c9af363184a9964a8a7

Comment 3 Yufang Zhang 2011-02-15 02:47:33 UTC
QA verified this bug with libguestfs-1.7.17-12.el6.x86_64 and
guestfish-1.7.17-12.el6.x86_64:

# unset HOME

# echo ~
/root

# guestfish

><fs> echo ~
/root

So change this bug to VERIFIED.

Comment 6 Laura Bailey 2011-04-19 01:06:12 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
If the $HOME variable was not set, guestfish did not expand a path containing "~" (tilde) into a path to the user's home directory (/home/username by default). Guestfish now examines the current user's passwd file for the location of the user's home directory so that a path containing "~" can be expanded correctly.

Additionally, an off-by-one error was discovered in the same path-expansion algorithm. This error could potentially cause a crash if the following command were attempted:

echo 'echo ~root/foo' | guestfish

The off-by-one error has been corrected so that a crash is no longer possible. (BZ#617440)

Comment 7 Richard W.M. Jones 2011-04-19 07:37:07 UTC
Fixed.

Comment 8 Richard W.M. Jones 2011-04-19 07:37:07 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,7 +1,3 @@
-If the $HOME variable was not set, guestfish did not expand a path containing "~" (tilde) into a path to the user's home directory (/home/username by default). Guestfish now examines the current user's passwd file for the location of the user's home directory so that a path containing "~" can be expanded correctly.
+If the $HOME variable was not set, guestfish did not expand a path containing "~" (tilde) into a path to the user's home directory. Guestfish now examines the current user's passwd file for the location of the user's home directory so that a path containing "~" can be expanded correctly.
 
-Additionally, an off-by-one error was discovered in the same path-expansion algorithm. This error could potentially cause a crash if the following command were attempted:
+Additionally, an off-by-one error was discovered in the same path-expansion algorithm. This error could potentially cause a crash.  The off-by-one error has been corrected so that a crash is no longer possible. (BZ#617440)-
-echo 'echo ~root/foo' | guestfish
-
-The off-by-one error has been corrected so that a crash is no longer possible. (BZ#617440)

Comment 10 errata-xmlrpc 2011-05-19 11:45:27 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0586.html

Comment 11 errata-xmlrpc 2011-05-19 13:10:23 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0586.html


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