login always password

This commit is contained in:
Mario Fetka
2026-05-22 12:38:36 +02:00
parent acac4892a0
commit 3b8664cb77

17
login.c
View File

@@ -103,7 +103,6 @@ static int get_raw_str(uint8 *s, int maxlen, int doecho)
static void getstr(char *what, char *str, int rsize, int doecho)
{
fprintf(stdout, "%s: ", what);
fflush(stdout);
get_raw_str(str, rsize, doecho);
fprintf(stdout, "\n");
}
@@ -122,6 +121,7 @@ int func_login(int argc, char *argv[], int mode)
uint8 uname[200];
uint8 upasswd[200];
SEARCH_VECTOR save_drives;
int password_given = 0;
if (argc > 1) {
if (argv[1][0] == '-') {
@@ -135,23 +135,26 @@ int func_login(int argc, char *argv[], int mode)
remove_nwpathes();
if (argc > 1) strmaxcpy(uname, argv[1], sizeof(uname) -1);
else uname[0]='\0';
if (argc > 2) strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1);
else upasswd[0]='\0';
if (argc > 2) {
strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1);
password_given = 1;
} else upasswd[0]='\0';
while (result) {
if (!uname[0]) getstr("Login", uname, sizeof(uname)-1, 1);
if (uname[0]) {
upstr(uname);
upstr(upasswd);
if ((result = do_object_login(uname, 0x1, upasswd, option)) < 0 && !*upasswd) {
if (!password_given) {
getstr("Password", upasswd, sizeof(upasswd)-1, 0);
upstr(upasswd);
result = do_object_login(uname, 0x1, upasswd, option);
}
password_given = 1;
} else upstr(upasswd);
result = do_object_login(uname, 0x1, upasswd, option);
if (result < 0) {
fprintf(stdout, "Login incorrect\n\n");
uname[0] = '\0';
upasswd[0] = '\0';
password_given = 0;
}
} else break;
}