Skip to content

Commit

Permalink
us os.walk instead of subprocess to get the list of .pub files
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Sep 12, 2023
1 parent e18eed3 commit efd4307
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions update-server/otupdate/common/ssh_key_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import contextlib
import functools
import hashlib
import subprocess
import ipaddress
import logging
import os
Expand Down Expand Up @@ -248,12 +247,12 @@ async def add_from_local(request: web.Request) -> web.Response:
"""

LOG.info("Searching for public keys in /media")
pub_keys = (
subprocess.check_output(["find", "/media", "-type", "f", "-name", "*.pub"])
.decode()
.strip()
.split()
)
pub_keys = [
Path(root, file)
for root, _, files in os.walk("/media")
for file in files
if file.endswith(".pub")
]
if not pub_keys:
LOG.warning("No keys found")
return key_error("no-key", "No valid keys found", 404)
Expand Down

0 comments on commit efd4307

Please sign in to comment.