Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > ebe084c140192657f9094e135a84202c > files > 84

libvirt-0.8.2-29.el5.src.rpm

From d0a67fa69f24d91e382a118c47fc3f1b0a8bf338 Mon Sep 17 00:00:00 2001
Message-Id: <d0a67fa69f24d91e382a118c47fc3f1b0a8bf338.1284409900.git.jdenemar@redhat.com>
From: Eric Blake <eblake@redhat.com>
Date: Tue, 27 Jul 2010 12:05:27 -0600
Subject: [PATCH] libvirt-guests: detect invalid arguments

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=630621

Reject extra arguments.
Return the correct status for unknown arguments, as mandated by
https://fedoraproject.org/wiki/Packaging/SysVInitScript
Add --help, as a permitted extension.

* daemon/libvirt-guests.init.in (usage): New function.  Use it in
more places, and return correct value.
(cherry picked from commit 592277bcff7a012e8c10f9e0951245dc93b08630)
---
 daemon/libvirt-guests.init.in |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/daemon/libvirt-guests.init.in b/daemon/libvirt-guests.init.in
index f57b2a4..36b987d 100644
--- a/daemon/libvirt-guests.init.in
+++ b/daemon/libvirt-guests.init.in
@@ -287,8 +287,21 @@ gueststatus() {
     done
 }
 
+# usage [val]
+# Display usage string, then exit with VAL (defaults to 2).
+usage() {
+    echo $"Usage: $0 {start|stop|restart|force-reload|gueststatus|shutdown}"
+    exit ${1-2}
+}
+
 # See how we were called.
+if test $# != 1; then
+    usage
+fi
 case "$1" in
+    --help)
+        usage 0
+        ;;
     start|stop|gueststatus)
         $1
         ;;
@@ -309,8 +322,7 @@ case "$1" in
         stop
         ;;
     *)
-        echo $"Usage: $0 {start|stop|restart|force-reload|gueststatus|shutdown}"
-        exit 3
+        usage
         ;;
 esac
 exit $RETVAL
-- 
1.7.2.2