[libvirt] [PATCH 2/2] maint: prohibit access(,X_OK)

Eric Blake eblake at redhat.com
Fri Mar 25 21:15:05 UTC 2011


On 03/24/2011 03:22 PM, Eric Blake wrote:
>> Here you (rightly) removed the examination of sb. That means that the
>> only result of the call to stat() (just out of view of the diff) used is
>> the return value. Maybe that could be changed to virFileExists(), or
>> even just simplify the code and print the same message for "doesn't
>> exist" and "isn't executable".
> 
> The message was only a debug level, so I consolidated things to skip it
> altogether.
> 

> -    if (stat(path, &sb) < 0) {
> +    if (!virFileIsExecutable(path)) {
>          ret = 0;
> -        VIR_DEBUG("No hook script %s", path);
> +        VIR_WARN("Missing or non-executable hook script %s", path);
>      } else {
> -        if (!virFileIsExecutable(path)) {
> -            ret = 0;
> -            VIR_WARN("Non executable hook script %s", path);

Aargh,  I didn't do it right.  It was debug on missing but warn on
non-executable; now it's always warn (which means missing is noisier
than it used to be).

I'm applying this as an obvious followup to fix that minor regression.

From fd79f2d51e0de224a5389ddfa8c24c6cc0d3ab4d Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake at redhat.com>
Date: Fri, 25 Mar 2011 15:14:27 -0600
Subject: [PATCH] hooks: fix regression in previous patch

* src/util/hooks.c (virHookCheck): Missing hooks should just be
debug, not warn.
---
 src/util/hooks.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/util/hooks.c b/src/util/hooks.c
index 99dddc4..41598a6 100644
--- a/src/util/hooks.c
+++ b/src/util/hooks.c
@@ -110,9 +110,12 @@ virHookCheck(int no, const char *driver) {
         return -1;
     }

-    if (!virFileIsExecutable(path)) {
+    if (!virFileExists(path)) {
         ret = 0;
-        VIR_WARN("Missing or non-executable hook script %s", path);
+        VIR_DEBUG("No hook script %s", path);
+    } else if (!virFileIsExecutable(path)) {
+        ret = 0;
+        VIR_WARN("Non-executable hook script %s", path);
     } else {
         ret = 1;
         VIR_DEBUG("Found hook script %s", path);
-- 
1.7.4



-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110325/32c210cb/attachment-0001.sig>


More information about the libvir-list mailing list