Flavio Leitner cd82131
From 691e47554dd03dd6492e00bab5bd6d215f5cbd4f Mon Sep 17 00:00:00 2001
Flavio Leitner cd82131
From: Flavio Leitner <fbl@redhat.com>
Flavio Leitner cd82131
Date: Thu, 27 Feb 2014 09:16:34 -0300
Flavio Leitner cd82131
Subject: [PATCH] ovs-lib: allow non-root users to check service status
Flavio Leitner cd82131
Flavio Leitner cd82131
It tries to log the status operation, so although non-root
Flavio Leitner cd82131
users can see the current status, the lack of permission
Flavio Leitner cd82131
to write to the log results in an error message.
Flavio Leitner cd82131
Flavio Leitner cd82131
This changes to log only if the user has the permission to
Flavio Leitner cd82131
write to the log file.
Flavio Leitner cd82131
Flavio Leitner cd82131
Signed-off-by: Flavio Leitner <fbl@redhat.com>
Flavio Leitner cd82131
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Flavio Leitner cd82131
---
Flavio Leitner cd82131
 utilities/ovs-lib.in | 6 +++++-
Flavio Leitner cd82131
 1 file changed, 5 insertions(+), 1 deletion(-)
Flavio Leitner cd82131
Flavio Leitner cd82131
diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
Flavio Leitner cd82131
index 029ed3b..48d0c36 100644
Flavio Leitner cd82131
--- a/utilities/ovs-lib.in
Flavio Leitner cd82131
+++ b/utilities/ovs-lib.in
Flavio Leitner cd82131
@@ -54,7 +54,11 @@ ovs_ctl () {
Flavio Leitner cd82131
             # of ovs-ctl. It is also useful to document the o/p in ovs-ctl.log.
Flavio Leitner cd82131
             display=`"${datadir}/scripts/ovs-ctl" "$@" 2>&1`
Flavio Leitner cd82131
             rc=$?
Flavio Leitner cd82131
-            echo "${display}" | tee -a "${logdir}/ovs-ctl.log"
Flavio Leitner cd82131
+            if test -w "${logdir}/ovs-ctl.log"; then
Flavio Leitner cd82131
+                 echo "${display}" | tee -a "${logdir}/ovs-ctl.log"
Flavio Leitner cd82131
+            else
Flavio Leitner cd82131
+                 echo "${display}"
Flavio Leitner cd82131
+            fi
Flavio Leitner cd82131
             return ${rc}
Flavio Leitner cd82131
         ;;
Flavio Leitner cd82131
         *)
Flavio Leitner cd82131
-- 
Flavio Leitner cd82131
1.8.5.3
Flavio Leitner cd82131