fix: adjust login password handling

This commit is contained in:
Mario Fetka
2026-05-22 12:29:32 +02:00
parent 82b0f918dd
commit dd5e4e9a3b

24
login.c
View File

@@ -121,6 +121,7 @@ int func_login(int argc, char *argv[], int mode)
uint8 uname[200]; uint8 uname[200];
uint8 upasswd[200]; uint8 upasswd[200];
SEARCH_VECTOR save_drives; SEARCH_VECTOR save_drives;
int password_given = 0;
if (argc > 1) { if (argc > 1) {
if (argv[1][0] == '-') { if (argv[1][0] == '-') {
@@ -134,23 +135,26 @@ int func_login(int argc, char *argv[], int mode)
remove_nwpathes(); remove_nwpathes();
if (argc > 1) strmaxcpy(uname, argv[1], sizeof(uname) -1); if (argc > 1) strmaxcpy(uname, argv[1], sizeof(uname) -1);
else uname[0]='\0'; else uname[0]='\0';
if (argc > 2) strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1); if (argc > 2) {
else upasswd[0]='\0'; strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1);
password_given = 1;
} else upasswd[0]='\0';
while (result) { while (result) {
if (!uname[0]) getstr("Login", uname, sizeof(uname)-1, 1); if (!uname[0]) getstr("Login", uname, sizeof(uname)-1, 1);
if (uname[0]) { if (uname[0]) {
upstr(uname); upstr(uname);
upstr(upasswd); if (!password_given) {
if ((result = do_object_login(uname, 0x1, upasswd, option)) < 0 && !*upasswd) {
getstr("Password", upasswd, sizeof(upasswd)-1, 0); getstr("Password", upasswd, sizeof(upasswd)-1, 0);
upstr(upasswd); 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) { if (result < 0) {
fprintf(stdout, "Login incorrect\n\n"); fprintf(stdout, "Login incorrect\n\n");
uname[0] = '\0'; uname[0] = '\0';
upasswd[0] = '\0'; upasswd[0] = '\0';
password_given = 0;
} }
} else break; } else break;
} }
@@ -391,17 +395,9 @@ int func_exec(int argc, char *argv[], int mode)
xfree(buff); xfree(buff);
if (nargv != NULL) { if (nargv != NULL) {
if (!mode) if (!mode)
#ifdef __WATCOMC__
spawnvp(P_WAIT, buf, (const char * const *)nargv);
#else
spawnvp(P_WAIT, buf, nargv); spawnvp(P_WAIT, buf, nargv);
#endif
else else
#ifdef __WATCOMC__
execvp(buf, (const char * const *)nargv);
#else
execvp(buf, nargv); execvp(buf, nargv);
#endif
} }
xfree(buf); xfree(buf);
} }