mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-08-02 22:36:22 +00:00
fix: restore TTY access for eval_password commands
Replace g_spawn_command_line_sync with g_spawn_sync with the
G_SPAWN_CHILD_INHERITS_STDIN flag.
This is actually needed to so that interactive commands can access the
terminal.
Otherwise they cannot ask the user for the passphrase.
Ref: f5787fb31f
Fixes: https://github.com/profanity-im/profanity/issues/2143
Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
@@ -385,6 +385,7 @@ cmd_connect(ProfWin* window, const char* const command, gchar** args)
|
|||||||
// use eval_password if set
|
// use eval_password if set
|
||||||
} else if (account->eval_password) {
|
} else if (account->eval_password) {
|
||||||
gboolean res = account_eval_password(account);
|
gboolean res = account_eval_password(account);
|
||||||
|
ui_resize();
|
||||||
if (res) {
|
if (res) {
|
||||||
conn_status = cl_ev_connect_account(account);
|
conn_status = cl_ev_connect_account(account);
|
||||||
free(account->password);
|
free(account->password);
|
||||||
|
|||||||
@@ -138,13 +138,23 @@ account_eval_password(ProfAccount* account)
|
|||||||
gchar* stdout_buf = NULL;
|
gchar* stdout_buf = NULL;
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
gint exit_status = 0;
|
gint exit_status = 0;
|
||||||
|
gchar** argv = NULL;
|
||||||
|
|
||||||
if (!g_spawn_command_line_sync(account->eval_password, &stdout_buf, NULL, &exit_status, &error)) {
|
if (!g_shell_parse_argv(account->eval_password, NULL, &argv, &error)) {
|
||||||
log_error("Failed to execute `eval_password` command: %s", error->message);
|
log_error("Failed to parse `eval_password` command: %s", error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_CHILD_INHERITS_STDIN, NULL, NULL, &stdout_buf, NULL, &exit_status, &error)) {
|
||||||
|
log_error("Failed to execute `eval_password` command: %s", error->message);
|
||||||
|
g_strfreev(argv);
|
||||||
|
g_error_free(error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strfreev(argv);
|
||||||
|
|
||||||
if (WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == 0) {
|
if (WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == 0) {
|
||||||
account->password = stdout_buf;
|
account->password = stdout_buf;
|
||||||
g_strstrip(account->password);
|
g_strstrip(account->password);
|
||||||
|
|||||||
Reference in New Issue
Block a user