Skip to content

Commit 1685a83

Browse files
committed
added root_warning
1 parent fd7703a commit 1685a83

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
911 Bytes
Binary file not shown.

start_page.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
import pwinput
2-
2+
import msvcrt
33

44
def account_message():
55
ip = input("Введите IP адрес сервера: ").strip()
66
login = input("Введите логин: ").strip()
7+
if login != "root":
8+
is_root = root_warning()
9+
if is_root:
10+
login = "root"
711
password = pwinput.pwinput("Введите пароль: ", mask='*')
812
server = Server(ip, login, password)
913
return server
10-
14+
1115
class Server:
1216
def __init__(self, ip, login, password):
1317
self.login = login
1418
self.ip = ip
15-
self.password = password
19+
self.password = password
20+
21+
def root_warning():
22+
print("Вы собираетесь войти не под пользователем root, для корректной работы скрипта необходимы права администратора, они есть у текущего пользователя?")
23+
print("""1. Нет, войти под root
24+
2. Да, я подтверждаю, что заблаговременно повысил права пользователю""")
25+
char = msvcrt.getch().decode('utf-8')
26+
if char == '1':
27+
return True
28+
if char == '2':
29+
return False

0 commit comments

Comments
 (0)