[Concept,09/13] scripts: ubuntu: Use command.run() in hash_password()

Message ID 20260507221507.505998-10-sjg@u-boot.org
State New
Headers
Series bootstd: bls: Scan every partition; Ubuntu autoinstall via BLS |

Commit Message

Simon Glass May 7, 2026, 10:14 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The rest of the script funnels every external invocation through
u_boot_pylib's command.run(), so its CommandExc carries the captured
output on failure and the -v/-quiet wiring keeps subprocess chatter out
of the default run. hash_password() is the lone holdout, going straight
to subprocess.run() to feed the plaintext password through stdin.

command.run() takes the same data via stdin_data= and returns the
captured stdout as a string when capture=True, so the conversion keeps
the no-arg-on-the-command-line property of the password input and lets
us drop the subprocess import altogether.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/ubuntu-iso-to-uboot.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
  

Patch

diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py
index 68ba4cd3d97..d43308676e3 100755
--- a/scripts/ubuntu-iso-to-uboot.py
+++ b/scripts/ubuntu-iso-to-uboot.py
@@ -66,7 +66,6 @@  import argparse
 import os
 import re
 import shutil
-import subprocess
 import sys
 import tempfile
 from pathlib import Path
@@ -339,11 +338,10 @@  def hash_password(password: str) -> str:
     password. Shelling out to openssl keeps the script's dependency list
     unchanged (Python's crypt module is gone in 3.13).
     """
-    out = subprocess.run(
-        ['openssl', 'passwd', '-6', '-stdin'],
-        input=password, capture_output=True, text=True, check=True,
-    )
-    return out.stdout.strip()
+    return command.run(
+        'openssl', 'passwd', '-6', '-stdin',
+        capture=True, stdin_data=password,
+    ).strip()
 
 
 def autoinstall_yaml(