Red Hat Bugzilla – Bug 617440
guestfish: fails to tilde expand '~' when the $HOME env is unset
Last modified: 2015-09-27 22:11:28 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.
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
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.
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)
Fixed.
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)
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