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
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs (Show other bugs)
(Show other bugs)
Version: 6.0
Hardware: All Linux
low
low
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Keywords:
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)
Story Points: ---
Clone Of: 617436
Environment:
Last Closed: 2011-05-19 11:45:27 UTC
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 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.