-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: add missing VNC_PASS generation in draksetup init (#970)
- Loading branch information
Showing
1 changed file
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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() | ||
|
@@ -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( | ||
|