dosutils: remove hard-coded MARS fallbacks

Do not fall back to the literal server name "MARS" in LOGIN or WHOAMI.

LOGIN now uses a neutral usage example and tries to resolve the current
file server through the active connection/NCP server info. If no server
name can be determined, it reports the Novell-style error:

  No known file server.

WHOAMI likewise no longer invents a default server name. If the current
server name cannot be resolved, it reports the Novell-style failure:

  Unable to get server name. (%x)

This keeps the tools usable on servers with arbitrary names instead of
silently producing MARS-specific output.
This commit is contained in:
Mario Fetka
2026-05-27 20:30:56 +02:00
parent 4ad455c6df
commit 0fa4a6f700
2 changed files with 49 additions and 7 deletions

42
login.c
View File

@@ -28,6 +28,32 @@ static char **build_argv(char *buf, int bufsize, char *str);
extern int read_command_file(char *fstr);
extern int get_fs_name(int connid, char *name);
static int login_ncp23_server_info(char *server)
{
struct {
uint16 len;
uint8 func;
} req;
struct {
uint16 len;
uint8 data[128];
} repl;
req.len = 1;
req.func = 17;
repl.len = sizeof(repl.data);
neterrno = Net_Call(0xE300, &req, &repl);
if (neterrno) {
if (server) server[0] = '\0';
return(-1);
}
if (server)
strmaxcpy(server, repl.data, 47);
return(0);
}
static uint8 login_video_attr = 0x07;
@@ -109,7 +135,7 @@ static int login_help(void)
fprintf(stdout, "\n");
fprintf(stdout, " Examples:\n");
fprintf(stdout, " LOGIN SUPERVISOR\n");
fprintf(stdout, " LOGIN MARS/SUPERVISOR\n");
fprintf(stdout, " LOGIN SERVER/SUPERVISOR\n");
fprintf(stdout, "\n");
return(0);
}
@@ -833,8 +859,18 @@ int func_login(int argc, char *argv[], int mode)
if (result > -1) {
strmaxcpy(script_login_name, uname, sizeof(script_login_name) - 1);
if (get_fs_name(1, script_file_server))
strcpy(script_file_server, "MARS");
script_file_server[0] = '\0';
if (get_fs_name(1, script_file_server) || !script_file_server[0])
login_ncp23_server_info(script_file_server);
if (!script_file_server[0]) {
fprintf(stdout, "No known file server.\n");
#ifdef MAINTAINER_BUILD
memset(hidden_passwd, 0, sizeof(hidden_passwd));
#endif
memset(upasswd, 0, sizeof(upasswd));
return(1);
}
if (interactive_login)
fprintf(stdout, "You are attached to server %s.\n", script_file_server);

View File

@@ -331,11 +331,17 @@ int func_whoami(int argc, char *argv[], int mode)
if (get_fs_name(connid, server))
server[0] = '\0';
if (!server[0])
who_ncp23_server_info(server);
if (!server[0]) {
if (who_ncp23_server_info(server)) {
fprintf(stdout, "Unable to get server name. (%x)\a\n", neterrno);
return(1);
}
}
if (!server[0])
strcpy(server, "MARS");
if (!server[0]) {
fprintf(stdout, "Unable to get server name. (%x)\a\n", neterrno);
return(1);
}
if (server_arg) {
char s1[52];