mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-12-01 19:06:45 +00:00
fix: add more debug for subprocess.check_output
This commit is contained in:
parent
74b3046e5d
commit
b9ee8fad91
|
@ -53,17 +53,22 @@ class KanidmAdminToken:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_and_save_token(kanidm_admin_password: str) -> str:
|
def create_and_save_token(kanidm_admin_password: str) -> str:
|
||||||
with temporary_env_var(key="KANIDM_PASSWORD", value=kanidm_admin_password):
|
with temporary_env_var(key="KANIDM_PASSWORD", value=kanidm_admin_password):
|
||||||
kanidm_admin_token = subprocess.check_output(
|
try:
|
||||||
[
|
kanidm_admin_token = subprocess.check_output(
|
||||||
"kanidm",
|
[
|
||||||
"service-account",
|
"kanidmd",
|
||||||
"api-token",
|
"recover-account",
|
||||||
"generate",
|
"-c",
|
||||||
"--rw",
|
"/etc/kanidm/server.toml",
|
||||||
"selfprivacy",
|
"idm_admin",
|
||||||
"token2",
|
"-o",
|
||||||
]
|
"json",
|
||||||
)
|
],
|
||||||
|
text=True,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
redis.set("kanidm:token", kanidm_admin_token)
|
redis.set("kanidm:token", kanidm_admin_token)
|
||||||
return kanidm_admin_token
|
return kanidm_admin_token
|
||||||
|
@ -80,14 +85,15 @@ class KanidmAdminToken:
|
||||||
"-o",
|
"-o",
|
||||||
"json",
|
"json",
|
||||||
],
|
],
|
||||||
|
text=True,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
).decode("utf-8")
|
)
|
||||||
|
|
||||||
new_kanidm_admin_password = re.search(r'{"password":"([^"]+)"}', output).group(
|
new_kanidm_admin_password = re.search(r'{"password":"([^"]+)"}', output).group(
|
||||||
1
|
1
|
||||||
)
|
) # we have many not json strings in output
|
||||||
redis.set("kanidm:password", new_kanidm_admin_password)
|
|
||||||
|
|
||||||
|
redis.set("kanidm:password", new_kanidm_admin_password)
|
||||||
return new_kanidm_admin_password
|
return new_kanidm_admin_password
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue