Bug 588651

Summary: guestfish 'strings-e' cmd does not give proper error message or hint
Product: [Community] Virtualization Tools Reporter: Pengzhen Cao <pcao>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-14 19:10:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Pengzhen Cao 2010-05-04 08:29:45 UTC
Description of problem:
when using wrong options in guestfish 'strings-e' cmd, it does not give proper error message or hint

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. run guestfish, add a image, run , mount it
2. run strings-e xx /your_file, whre xx is an invalid option

Actual results:
><fs> strings-e h /elf/bash
strings_e "h" "/elf/bash"
libguestfs: error: strings_e: /elf/bash: Usage: strings [option(s)] [file(s)]
 Display printable strings in [file(s)] (stdin by default)
 The options are:
  -a - --all                Scan the entire file, not just the data section
  -f --print-file-name      Print the name of the file

Expected results:
should give some error message say "invalid option" or a list of valid options

Additional info:
valid options in the corresponding bash cmd:
valid encodings: “s = single-7-bit-byte characters (ASCII, ISO 8859, etc., default), S = single-8-bit-byte characters, b = 16-bit bigendian, l = 16-bit littleendian, B = 32-bit bigendian, L = 32-bit littleendian.  Useful for finding wide character strings. (l and b apply to, for example, Unicode UTF-16/UCS-2 encodings).

Comment 1 Richard W.M. Jones 2010-05-12 15:58:16 UTC
I made a change upstream which improves error messages
and the associated documentation:

><fs> strings-e l /etc/fstab 
><fs> strings-e s /etc/fstab 
/dev/sda1 / ext2 defaults 1 2
><fs> strings-e ss /etc/fstab 
libguestfs: error: strings_e: ss: invalid encoding
><fs> strings-e x /etc/fstab 
libguestfs: error: strings_e: x: invalid encoding
><fs> strings-e '' /etc/fstab 
libguestfs: error: strings_e: : invalid encoding

$ ./fish/guestfish -h strings-e
    strings-e - print the printable strings in a file

     strings-e encoding path

    This is like the "strings" command, but allows you to specify the
    encoding of strings that are looked for in the source file "path".

    Allowed encodings are:

    s   Single 7-bit-byte characters like ASCII and the ASCII-compatible
        parts of ISO-8859-X (this is what "strings" uses).

    S   Single 8-bit-byte characters.

    b   16-bit big endian strings such as those encoded in UTF-16BE or

    l (lower case letter L)
        16-bit little endian such as UTF-16LE and UCS-2LE. This is useful
        for examining binaries in Windows guests.

    B   32-bit big endian such as UCS-4BE.

    L   32-bit little endian such as UCS-4LE.

    The returned strings are transcoded to UTF-8.

    Because of the message protocol, there is a transfer limit of somewhere
    between 2MB and 4MB. See "PROTOCOL LIMITS" in guestfs(3).

Patch posted upstream:

Comment 2 Fedora Update System 2010-05-14 19:12:41 UTC
libguestfs-1.2.6-1.fc13 has been submitted as an update for Fedora 13.

Comment 3 Fedora Update System 2010-05-17 12:27:51 UTC
libguestfs-1.2.7-1.fc12 has been submitted as an update for Fedora 12.

Comment 4 Fedora Update System 2010-05-17 12:47:41 UTC
libguestfs-1.2.7-1.el5 has been submitted as an update for Fedora EPEL 5.

Comment 5 Fedora Update System 2010-05-17 13:00:12 UTC
libguestfs-1.2.7-2.fc13 has been submitted as an update for Fedora 13.

Comment 6 Fedora Update System 2010-05-21 11:33:24 UTC
libguestfs-1.2.7-2.fc13.1 has been submitted as an update for Fedora 13.