remove dependency on asprintf
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14589 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
19
lib/des/ui.c
19
lib/des/ui.c
@@ -53,7 +53,8 @@ intr(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_string(const char *prompt, char *buf, size_t len, int echo)
|
read_string(const char *preprompt, const char *prompt,
|
||||||
|
char *buf, size_t len, int echo)
|
||||||
{
|
{
|
||||||
struct sigaction sigs[47];
|
struct sigaction sigs[47];
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@@ -76,7 +77,7 @@ read_string(const char *prompt, char *buf, size_t len, int echo)
|
|||||||
if((tty = fopen("/dev/tty", "r")) == NULL)
|
if((tty = fopen("/dev/tty", "r")) == NULL)
|
||||||
tty = stdin;
|
tty = stdin;
|
||||||
|
|
||||||
fprintf(stderr, "%s", prompt);
|
fprintf(stderr, "%s%s", preprompt, prompt);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
if(echo == 0){
|
if(echo == 0){
|
||||||
@@ -127,24 +128,20 @@ read_string(const char *prompt, char *buf, size_t len, int echo)
|
|||||||
int
|
int
|
||||||
UI_UTIL_read_pw_string(char *buf, int length, char *prompt, int verify)
|
UI_UTIL_read_pw_string(char *buf, int length, char *prompt, int verify)
|
||||||
{
|
{
|
||||||
|
size_t plen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = read_string(prompt, buf, length, 0);
|
ret = read_string("", prompt, buf, length, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
char *prompt2, *buf2;
|
char *buf2;
|
||||||
buf2 = malloc(length);
|
buf2 = malloc(length);
|
||||||
if (buf2 == NULL)
|
if (buf2 == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
asprintf(&prompt2, "Verify password - %s", prompt2);
|
|
||||||
if (prompt2 == NULL) {
|
ret = read_string("Verify password - ", prompt, buf2, length, 0);
|
||||||
free(buf2);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ret = read_string(prompt2, buf2, length, 0);
|
|
||||||
free(prompt2);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
free(buf2);
|
free(buf2);
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user