forked from paren2/Python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWho.py
More file actions
52 lines (40 loc) · 1.3 KB
/
Copy pathWho.py
File metadata and controls
52 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import getpass
import os
import sys
class Who:
"""
Este Metodo detecta quien eres en el sesion actual,
Si detecta el user ROOT se detiene.
"""
user = getpass.getuser()
localhost = os.popen('hostname', 'r')
localhost = localhost.read()
sistema_operativo = os.name
def identificar(self, user, local_host):
if user == 'root':
print ''
print 'Usuario ' + user.upper() + ' detectado!'
print ''
print 'Este programa no requiere de privilegios elevados'
print 'Cambia el usuario y reinicia'
print ''
sys.exit(0)
else:
print 'No estas usando root'
print ''
print 'User: ' + user
print 'Host: ' + local_host
#Metodo para detectar el OS, en caso de windows se detiene.
#No hay soporte.
def sistema(self, SistemaOperativo):
if SistemaOperativo == 'nt':
print 'Sistema Windows'
print 'Sistema Operativo no soportado!'
print ''
sys.exit(0)
elif SistemaOperativo == 'posix':
print 'Linux o variante Unix'
elif SistemaOperativo == 'mac':
print 'Mac'
else:
print 'Sistema operativo no validado'