Bug 617440 - guestfish: fails to tilde expand '~' when the $HOME env is unset
guestfish: fails to tilde expand '~' when the $HOME env is unset
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs (Show other bugs)
6.0
All Linux
low Severity low
: rc
: ---
Assigned To: Richard W.M. Jones
Virtualization Bugs
:
Depends On: 617436
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-22 23:19 EDT by Jinxin Zheng
Modified: 2015-09-27 22:11 EDT (History)
5 users (show)

See Also:
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)
Story Points: ---
Clone Of: 617436
Environment:
Last Closed: 2011-05-19 07:45:27 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0586 normal SHIPPED_LIVE Low: libguestfs security, bug fix, and enhancement update 2011-05-19 07:44:03 EDT

  None (edit)
Description Jinxin Zheng 2010-07-22 23:19:05 EDT
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 11:46:13 EST
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-14 21:47:33 EST
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-18 21:06:12 EDT
    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 03:37:07 EDT
Fixed.
Comment 8 Richard W.M. Jones 2011-04-19 03:37:07 EDT
    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 07:45:27 EDT
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 09:10:23 EDT
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.