[libvirt] [PATCH] tools: make virt-pki-validate work with acls and xattrs

Philipp Hahn hahn at univention.de
Thu May 31 11:57:16 UTC 2012


Hello,

I find parsing the output of "ls -l" very suspect and fragile, since its 
output heaviely depends on the environment: SELinux, ACLs, locale.
Perhaps using /usr/bin/stat would be better, but I don't know how 
available /usr/bin/stat" is on non-Linux-platforms (on my Debian system it's 
in coreutils).

On Thursday 31 May 2012 11:02:51 Martin Kletzander wrote:
> diff --git a/tools/virt-pki-validate.in b/tools/virt-pki-validate.in
> index 01825d1..4164758 100755
> --- a/tools/virt-pki-validate.in
> +++ b/tools/virt-pki-validate.in
>              OWN=`ls -l "$LIBVIRTP/clientkey.pem" | awk '{ print $3 }'`
OWN=`stat -c %U "$LIBVIRTP/clientkey.pem"`

> -            MOD=`ls -l "$LIBVIRTP/clientkey.pem" | awk '{ print $1 }'`
> +            # The substr($1, 1, 10) gets rid of acl and xattr markers
> +            MOD=`ls -l "$LIBVIRTP/clientkey.pem" | awk '{ print substr($1, 
1, 10) }'`
MOD=`stat -c %s "$LIBVIRTP/clientkey.pem"`

Sincerely
Philipp
-- 
Philipp Hahn           Open Source Software Engineer      hahn at univention.de
Univention GmbH        be open.                       fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120531/fc391f49/attachment-0001.sig>


More information about the libvir-list mailing list