/*
From jeff@cns.nyu.edu Thu Aug 30 12:33:12 1990
Return-Path: <jeff@cns.nyu.edu>
Received: from wotan.cns.nyu.edu by erda.cns.nyu.edu (4.1/SMI-4.1)
	id AA15081; Thu, 30 Aug 90 12:33:10 EDT
Received: from parsifal.cns.nyu.edu by wotan.cns.nyu.edu (4.0/SMI-4.0)
	id AA21644; Thu, 30 Aug 90 12:19:52 EDT
Date: Thu, 30 Aug 90 12:19:52 EDT
From: jeff@cns.nyu.edu (Jeff Fookson)
Message-Id: <9008301619.AA21644@wotan.cns.nyu.edu>
To: roman@cns.nyu.edu
Subject: .asr
Status: ORr

Here it is -- edit it to use your user id (get from password file) and 
make it as instructed
*/

#include <stdio.h>

/*		  compile with 'cc -o file file.c'
 		  then 'chown root file; chmod u+s file'	*/

main(argc, argv)
int argc;
char **argv;
{
	int mynum = 1118;	/* real (login) user id from /etc/passwd */
	extern char *gets();
	int retcode;
	char string[260];

	if(getuid() != mynum) {

		printf("sorry\n");
		exit(0);
	}
	setuid(geteuid());
	if(argc > 1) {

		execvp(argv[1], &argv[1]);
		fprintf(stderr,
		"%s: execution of '%s' failed: ",argv[0], argv[1]);
		perror("");
		exit(1);
	}
	else {

		printf("Enter string to be executed: ");
		fflush(stdout);
		retcode=system(gets(string));
		if(retcode != 0)
			fprintf(stderr,
			"%s: the command '%s' exited with status %d\n",
			argv[0], string, retcode);
		exit(retcode);
	}
}

