eval_password code is now in cmd_connect so that it can be changed
without clearing it. eval_password errors are also now ignored, along with pclosing the popened eval_password.
This commit is contained in:
@@ -130,7 +130,20 @@ cmd_connect(gchar **args, struct cmd_help_t help)
|
||||
ProfAccount *account = accounts_get_account(lower);
|
||||
if (account != NULL) {
|
||||
jid = account_create_full_jid(account);
|
||||
if (account->password == NULL && account->eval_password == NULL) {
|
||||
if(account->eval_password){
|
||||
// Evaluate as shell command to retrieve password
|
||||
GString *cmd = g_string_append(g_string_new(account->eval_password), " 2>/dev/null");
|
||||
FILE *stream = popen(cmd->str, "r");
|
||||
if(stream){
|
||||
// Limit to READ_BUF_SIZE bytes to prevent overflows in the case of a poorly chosen command
|
||||
account->password = g_malloc(READ_BUF_SIZE);
|
||||
fgets(account->password, READ_BUF_SIZE, stream);
|
||||
pclose(stream);
|
||||
} else {
|
||||
log_error("popen failed when running eval_password.");
|
||||
}
|
||||
g_string_free(cmd, TRUE);
|
||||
} else if (!account->password) {
|
||||
account->password = ui_ask_password();
|
||||
}
|
||||
cons_show("Connecting with account %s as %s", account->name, jid);
|
||||
|
||||
Reference in New Issue
Block a user