mirror of https://github.com/eLvErDe/hwraid.git
megaclisas-status: Handle Windows when checking permissions
This commit is contained in:
parent
1af2d222f9
commit
a87f5a9d18
|
@ -9,6 +9,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import pdb
|
import pdb
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
import ctypes
|
||||||
|
|
||||||
def_megaclipath = "/opt/MegaRAID/MegaCli/MegaCli64"
|
def_megaclipath = "/opt/MegaRAID/MegaCli/MegaCli64"
|
||||||
|
|
||||||
|
@ -39,10 +41,12 @@ def print_usage():
|
||||||
|
|
||||||
# We need root access to query
|
# We need root access to query
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
myuid = os.geteuid()
|
try:
|
||||||
if myuid != 0:
|
root_or_admin = os.geteuid() == 0
|
||||||
print '# This script requires Administrator privs (Current EUID: '+str(myuid)+'! e.g :\r'
|
except AttributeError:
|
||||||
print 'sudo '+str(sys.argv[0])+'\r'
|
root_or_admin = ctypes.windll.shell32.IsUserAnAdmin() !=0
|
||||||
|
if not root_or_admin:
|
||||||
|
print '# This script requires Administrator privileges'
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
# Check command line arguments to enable nagios or not
|
# Check command line arguments to enable nagios or not
|
||||||
|
|
Loading…
Reference in New Issue