|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
#-*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
# Copyright 2012 Calculate Ltd. http://www.calculate-linux.org
|
|
|
|
|
# Copyright 2012-2013 Calculate Ltd. http://www.calculate-linux.org
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
@ -463,63 +463,3 @@ def get_password_from_daemon(server_host, server_port, wait_thread):
|
|
|
|
|
else:
|
|
|
|
|
password = resp if resp else None
|
|
|
|
|
return password
|
|
|
|
|
|
|
|
|
|
#def get_password_from_daemon(server_host, server_port, set_pass = False):
|
|
|
|
|
# host = '' # ip
|
|
|
|
|
# port = 5501 # порт
|
|
|
|
|
# size = 1024 # размер данных
|
|
|
|
|
# find_proc = False
|
|
|
|
|
# username = pwd.getpwuid(os.getuid()).pw_name
|
|
|
|
|
# for run_commands in filter(lambda x:'s.py' in x[0],getRunProc()):
|
|
|
|
|
# if 'python' in run_commands[0]:
|
|
|
|
|
# if username == owner(run_commands[1]):
|
|
|
|
|
# #print 'YES'
|
|
|
|
|
# find_proc = True
|
|
|
|
|
#
|
|
|
|
|
# home_path = pwd.getpwuid(os.getuid()).pw_dir
|
|
|
|
|
# file_path = os.path.join(home_path, '.calculate', 'passwd_daemon')
|
|
|
|
|
# if not find_proc:
|
|
|
|
|
# os.unlink(file_path)
|
|
|
|
|
#
|
|
|
|
|
# cmd = ['/var/calculate/s.py']
|
|
|
|
|
# #print cmd
|
|
|
|
|
# subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
|
|
|
|
|
# stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
#
|
|
|
|
|
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
|
# s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
|
|
|
# while True:
|
|
|
|
|
# try:
|
|
|
|
|
# s.bind((host,port)) # ассоциировать адрес с сокетом
|
|
|
|
|
# break
|
|
|
|
|
# except socket.error:
|
|
|
|
|
# port += 1
|
|
|
|
|
# connect_error = 0
|
|
|
|
|
# while connect_error < 16:
|
|
|
|
|
# try:
|
|
|
|
|
# while connect_error < 10:
|
|
|
|
|
# if os.path.isfile(file_path):
|
|
|
|
|
# serv_port, hash_val = open(file_path, 'r').read().split()
|
|
|
|
|
# break
|
|
|
|
|
# else:
|
|
|
|
|
# connect_error += 1
|
|
|
|
|
# time.sleep(0.3)
|
|
|
|
|
# s.connect(('localhost', int(serv_port)))
|
|
|
|
|
# break
|
|
|
|
|
# except socket.error:
|
|
|
|
|
# time.sleep(0.3)
|
|
|
|
|
# #print s.recv(1024)
|
|
|
|
|
# req = '%s,%s,%s,%s' %(server_host, str(server_port), username, hash_val)
|
|
|
|
|
# s.send(req)
|
|
|
|
|
# resp = s.recv(size)
|
|
|
|
|
# if resp.startswith('Error'):
|
|
|
|
|
# password = getpass()
|
|
|
|
|
# msg = '%s,%s' %(req,password)
|
|
|
|
|
# s.send(msg)
|
|
|
|
|
# resp = s.recv(size)
|
|
|
|
|
# if resp.startswith('Error'):
|
|
|
|
|
# print resp
|
|
|
|
|
# else:
|
|
|
|
|
# password = resp if resp else None
|
|
|
|
|
# return password
|
|
|
|
|
######################### End get password
|
|
|
|
|