Bug 580016 - aug-ls in guestfish does not take augeas variable as argument
aug-ls in guestfish does not take augeas variable as argument
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-07 06:03 EDT by Jinxin Zheng
Modified: 2010-04-30 19:46 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-04-09 04:44:14 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)

  None (edit)
Description Jinxin Zheng 2010-04-07 06:03:30 EDT
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 06:53:26 EDT
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 04:44:14 EDT
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 03:43:22 EDT
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 19:46:33 EDT
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.

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