Author: mcslee
Date: Mon Oct 27 15:45:26 2008
New Revision: 708364
URL: http://svn.apache.org/viewvc?rev=708364&view=rev
Log:
THRIFT-183 let non-root issues run fb303 status commands
Reviewed By: mcslee
Modified:
incubator/thrift/trunk/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py
Modified:
incubator/thrift/trunk/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py?rev=708364&r1=708363&r2=708364&view=diff
==============================================================================
--- incubator/thrift/trunk/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py
(original)
+++ incubator/thrift/trunk/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py
Mon Oct 27 15:45:26 2008
@@ -34,11 +34,6 @@
TBinaryProtocolFactory
"""
- # Only root should be able to run these scripts, although we could relax
this for some of the operations.
- if os.getuid() != 0:
- print "requires root."
- return 4
-
if command in ["status"]:
try:
status = fb303_wrapper('status', port, trans_factory, prot_factory)
@@ -57,15 +52,6 @@
print "Failed to get status"
return 3
- # async commands
- if command in ["stop","reload"]:
- try:
- fb303_wrapper(command, port, trans_factory, prot_factory)
- return 0
- except:
- print "failed to tell the service to ", command
- return 3
-
# scalar commands
if command in ["version","alive","name"]:
try:
@@ -87,6 +73,31 @@
print "failed to get counters"
return 3
+
+ # Only root should be able to run the following commands
+ if os.getuid() == 0:
+ # async commands
+ if command in ["stop","reload"] :
+ try:
+ fb303_wrapper(command, port, trans_factory, prot_factory)
+ return 0
+ except:
+ print "failed to tell the service to ", command
+ return 3
+ else:
+ if command in ["stop","reload"]:
+ print "root privileges are required to stop or reload the service."
+ return 4
+
+ print "The following commands are available:"
+ for command in ["counters","name","version","alive","status"]:
+ print "\t%s" % command
+ print "The following commands are available for users with root
privileges:"
+ for command in ["stop","reload"]:
+ print "\t%s" % command
+
+
+
return 0;