[FIX] iot: Generate new password at launch

Generate a new password at launch for security reasons

3696215

closes odoo/odoo#150776

X-original-commit: 5e985abdd2a10f359438b5d4f276778e17559f24
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Yaroslav Soroko (yaso) <yaso@odoo.com>
This commit is contained in:
vifo
2024-01-24 15:56:29 +00:00
parent 6cda7c2411
commit 9beebd4141
2 changed files with 26 additions and 27 deletions
+2 -1
View File
@@ -89,8 +89,9 @@ class Manager(Thread):
"""
helpers.start_nginx_server()
if platform.system() == 'Linux':
if platform.system() == 'Linux' and helpers.get_odoo_server_url():
helpers.check_git_branch()
helpers.generate_password()
is_certificate_ok, certificate_details = helpers.get_certificate_status()
if not is_certificate_ok:
_logger.warning("An error happened when trying to get the HTTPS certificate: %s",
+24 -26
View File
@@ -130,37 +130,35 @@ def check_git_branch():
checkout to match it if needed.
"""
server = get_odoo_server_url()
if server:
urllib3.disable_warnings()
http = urllib3.PoolManager(cert_reqs='CERT_NONE')
try:
response = http.request(
'POST',
server + "/web/webclient/version_info",
body = '{}',
headers = {'Content-type': 'application/json'}
)
urllib3.disable_warnings()
http = urllib3.PoolManager(cert_reqs='CERT_NONE')
try:
response = http.request('POST',
server + "/web/webclient/version_info",
body='{}',
headers={'Content-type': 'application/json'}
)
if response.status == 200:
git = ['git', '--work-tree=/home/pi/odoo/', '--git-dir=/home/pi/odoo/.git']
if response.status == 200:
git = ['git', '--work-tree=/home/pi/odoo/', '--git-dir=/home/pi/odoo/.git']
db_branch = json.loads(response.data)['result']['server_serie'].replace('~', '-')
if not subprocess.check_output(git + ['ls-remote', 'origin', db_branch]):
db_branch = 'master'
db_branch = json.loads(response.data)['result']['server_serie'].replace('~', '-')
if not subprocess.check_output(git + ['ls-remote', 'origin', db_branch]):
db_branch = 'master'
local_branch = subprocess.check_output(git + ['symbolic-ref', '-q', '--short', 'HEAD']).decode('utf-8').rstrip()
local_branch = subprocess.check_output(git + ['symbolic-ref', '-q', '--short', 'HEAD']).decode('utf-8').rstrip()
if db_branch != local_branch:
with writable():
subprocess.check_call(["rm", "-rf", "/home/pi/odoo/addons/hw_drivers/iot_handlers/drivers/*"])
subprocess.check_call(["rm", "-rf", "/home/pi/odoo/addons/hw_drivers/iot_handlers/interfaces/*"])
subprocess.check_call(git + ['branch', '-m', db_branch])
subprocess.check_call(git + ['remote', 'set-branches', 'origin', db_branch])
os.system('/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/posbox_update.sh')
if db_branch != local_branch:
with writable():
subprocess.check_call(["rm", "-rf", "/home/pi/odoo/addons/hw_drivers/iot_handlers/drivers/*"])
subprocess.check_call(["rm", "-rf", "/home/pi/odoo/addons/hw_drivers/iot_handlers/interfaces/*"])
subprocess.check_call(git + ['branch', '-m', db_branch])
subprocess.check_call(git + ['remote', 'set-branches', 'origin', db_branch])
os.system('/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/posbox_update.sh')
except Exception as e:
_logger.error('Could not reach configured server')
_logger.error('A error encountered : %s ' % e)
except Exception as e:
_logger.error('Could not reach configured server')
_logger.error('A error encountered : %s ', e)
def check_image():
"""