Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: add missing VNC_PASS generation in draksetup init #970

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion drakrun/drakrun/draksetup/init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import configparser
import logging
import secrets
import string
import sysconfig
from pathlib import Path
from typing import List, Optional
Expand Down Expand Up @@ -38,6 +40,14 @@ def create_configuration_file(config_file_name, target_dir=None):
return target_path


def set_template_vnc_password(template_path):
template_data = template_path.read_text()
passwd_characters = string.ascii_letters + string.digits
vnc_passwd = "".join(secrets.choice(passwd_characters) for _ in range(20))
template_data = template_data.replace("{{ VNC_PASS }}", vnc_passwd)
template_path.write_text(template_data)


def apply_local_minio_service_config(config: DrakrunConfig):
parser = configparser.ConfigParser(strict=False, allow_no_value=True)
minio_env = "[DEFAULT]\n" + MINIO_ENV_CONFIG_FILE.read_text()
Expand Down Expand Up @@ -226,7 +236,10 @@ def is_component_to_init(component_name):
create_configuration_file("hooks.txt")
create_configuration_file("[email protected]", target_dir=SYSTEMD_SERVICE_PATH)
fix_exec_start("[email protected]")
create_configuration_file("cfg.template", target_dir=ETC_SCRIPTS_DIR)
template_path = create_configuration_file(
"cfg.template", target_dir=ETC_SCRIPTS_DIR
)
set_template_vnc_password(template_path)

if is_component_to_init("system"):
create_configuration_file(
Expand Down
Loading