static char sccsid
[] = "@(#)nsh.c 4.3 (Berkeley) %G%";
nsh -c "comand to be executed"
This pseudo-shell is executed over the network
as the login shell of an acount "network", no passwd.
It will only execute certain allowed commands.
EX_USAGE = wrong # arguments to nsh
9 = command you execute may not take arguments
EX_UNAVAILABLE= could not find full path name for the command
count is the # of arguments (= argc) allowed.
a count of 0 turns off the command
/* I assume these are the same for RAND */
"mmail", 20, "/usr/net/bin/mmail", "/usr/net/bin/mmail",
"mwrite", 20, "/usr/net/bin/mwrite", "/usr/net/bin/mwrite",
"prmail", 20, "/usr/net/bin/prmail", "/usr/net/bin/prmail",
"finger", 20, "/usr/ucb/finger", "/usr/bin/finger",
"lpq", 20, "/usr/ucb/lpq", "/usr/bin/lpq",
"lpr", 20, "/usr/ucb/lpr", "/usr/bin/lpr",
"netlog", 20, "/usr/bin/netlog", "/usr/ucb/netlog",
"netq", 20, "/usr/bin/netq", "/usr/ucb/netq",
"ps", 20, "/bin/ps", "/usr/bin/ps",
"pstat", 20, "/etc/pstat", "/usr/bin/pstat",
"vpq", 20, "/usr/ucb/vpq", "/usr/bin/vpq",
"w", 20, "/usr/ucb/w", "/usr/bin/w",
"wc", 20, "/usr/bin/wc", "/bin/wc",
"who", 20, "/bin/who", "/usr/bin/who",
"whom", 20, "/usr/ucb/whom", "/usr/bin/whom",
"yank", 20, "/usr/ucb/yank", "/usr/bin/yank",
fprintf(stderr
,"Wrong number of arguments to nsh.\n");
fprintf(stderr
, "Illegal shell metacharacter in command.\n");
while(*s
&& *s
!= ' ')s
++;
if((i
= mlookup(argv
[2])) < 0){
"Command '%s' is not allowed if logged in as 'network'.\n",
"The command '%s' is not allowed to have arguments.\n",argv
[2]);
if(stat(st
[i
].full
,buf
) >= 0)
else strcpy(buf
,st
[i
].full1
);
if(flg
&& st
[i
].count
> 1){ /* some cmds don't allow parms */
fprintf(stderr,"%s\n",buf);
execl(Bsh
,"sh","-c",buf
,0);
fprintf(stderr
,"Execute of shell failed.\n");
for(i
= 0; st
[i
].app
; i
++)
if(strcmp(st
[i
].app
,s
) == 0 || strcmp(st
[i
].full
,s
) == 0
|| strcmp(st
[i
].full1
,s
) == 0)return(i
);