Bug 580016

Summary: aug-ls in guestfish does not take augeas variable as argument
Product: [Community] Virtualization Tools Reporter: Jinxin Zheng <jzheng>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: unspecifiedCC: jzheng, mbooth, qwan, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-04-09 08:44:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jinxin Zheng 2010-04-07 10:03:30 UTC
Description of problem:
if we aug-defvar a variable and use it with aug-ls, the aug-ls returns with an error saying that it does not recognize the argument.

Version-Release number of selected component (if applicable):
1.0.89, on a Fedora 12 x86_64 box.

How reproducible:
Always

Steps to Reproduce:
1. prepare a linux guest image (which has a /etc/passwd file in it), say test.img
2. run the following guestfish commands in sequence:
$ guestfish -a test.img <<EOF
run
mount /dev/vda1 /
aug-init / 0
aug-defvar var /files/etc/passwd/root
aug-ls $var
EOF

Actual results:
libguestfs: error: aug_ls: do_aug_ls: path must start with a / character

Expected results:
we are supposed to get same output as aug-ls /files/etc/passwd/root

Additional info:
It seems that same problem does not apply to aug-get and aug-match.
I tried augtool from my host, the ls command recognizes variables perfectly.

Comment 1 Jinxin Zheng 2010-04-07 10:53:26 UTC
Sorry, I forgot about the shell expansion, the reproducing step 2 should be
$ guestfish -a test.img <<\EOF
run
mount /dev/vda1 /
aug-init / 0
aug-defvar var /files/etc/passwd/root
aug-ls $var
EOF

(adding backslash before EOF prevents the $var from being expanded by the shell).

and here's comparison among output of aug-get, aug-match and aug-ls,
...
><fs> aug-defvar var /files/etc/passwd/root
><fs> aug-get $var/home
/root
><fs> aug-match $var/*
/files/etc/passwd/root/password
/files/etc/passwd/root/uid
/files/etc/passwd/root/gid
/files/etc/passwd/root/name
/files/etc/passwd/root/home
/files/etc/passwd/root/shell
><fs> aug-ls $var
libguestfs: error: aug_ls: do_aug_ls: path must start with a / character

Comment 2 Richard W.M. Jones 2010-04-09 08:44:14 UTC
Upstream:
http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=d1dd00606d0b5b1430598e5092b017aa15d9ee11

><fs> aug-defvar var /files/etc/passwd
1
><fs> aug-ls $var
/files/etc/passwd/adm
/files/etc/passwd/apache
/files/etc/passwd/avahi
/files/etc/passwd/avahi-autoipd

The downside to this change is that aug-ls has no way
to tell if the path is not correct, eg:

><fs> aug-ls foobar
><fs>

Comment 3 Fedora Update System 2010-04-13 07:43:22 UTC
libguestfs-1.2.2-1.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/libguestfs-1.2.2-1.fc13

Comment 4 Fedora Update System 2010-04-30 23:46:33 UTC
libguestfs-1.2.2-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.