Looking for a restricted shell.

mike.stefanik mike at bria.UUCP
Sun May 26 04:13:38 AEST 1991


In an article, pineault at sarcelle.DMI.USherb.CA (Christian Pineault) writes:
>I'm looking for a shell on SunOS 4.1.1 that would prevent users from
>using any [h]armful commands.

Here is the source to a shell that you might find useful:

#include <stdio.h>
#include <string.h>
#include <signal.h>

main(argc,argv)
int argc;
char *argv[];
{
char *image, buf[1024];
char *tok;

	signal(SIGINT,SIG_IGN);
	signal(SIGQUIT,SIG_IGN);

	image = strrchr(argv[0],'/');
	image++;

	printf("$ ");
	while ( fgets(buf,1024,stdin) != NULL ) {
		tok = strtok(buf," \t\n");
		if ( ! strcmp(tok,"exit") )
			break;
		if ( tok && strlen(tok) > 0 )
			fprintf(stderr,"%s: %s: permission denied\n",
				image, tok);
		printf("$ ");
		}

	return 0;
}
-- 
Michael Stefanik, MGI Inc, Los Angeles | Opinions stated are never realistic
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
If MS-DOS didn't exist, who would UNIX programmers have to make fun of?



More information about the Comp.unix.questions mailing list