* lib/mu-util: add mu_util_read_password
This commit is contained in:
@ -494,3 +494,27 @@ mu_util_printerr_encoded (const char *frm, ...)
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
mu_util_read_password (const char *prompt)
|
||||
{
|
||||
char *pass, *tmp;
|
||||
|
||||
g_return_val_if_fail (prompt, NULL);
|
||||
|
||||
/* note: getpass is obsolete; replace with something better */
|
||||
|
||||
tmp = getpass (prompt);
|
||||
if (!tmp) {
|
||||
if (errno)
|
||||
g_warning ("error: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
/* make sure we can free with g_free(), not free() */
|
||||
|
||||
pass = g_strdup (tmp);
|
||||
free (tmp);
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user