/*
 * notsh.c -- NOT Shell
 *
 * Designed to simply inform the user they do not have shell access.  Compile
 * with -DCUSTOM_MESG if you want your custom message to be displayed.
 *
 * This and other hacks can be found at: http://oddgeek.info/
 *
 * Copyright (c) 2005 Jason A. Dour
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the
 * use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 *     1. The origin of this software must not be misrepresented; you must not
 *     claim that you wrote the original software. If you use this software in
 *     a product, an acknowledgment in the product documentation would be
 *     appreciated but is not required.
 *
 *     2. Altered source versions must be plainly marked as such, and must not
 *     be misrepresented as being the original software.
 *
 *     3. This notice may not be removed or altered from any source
 *     distribution.
 *
 */

/*
 * Version Information
 *
 * 1.0	2005.05.25
 * 
 * 	First public release.  Nothing really changed other than comments and
 * 	adding one include to ensure a -Wall returns no warnings.
 *
 * primordial ooze
 *
 * 	Used for years privately to lock down accounts on personal and work
 * 	servers.  Given to a few others privately when they had need of it.
 * 	Never distributed widely.
 *
 */

/*
 * Necessary includes.
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

/*
 * Change CUSTOM_MESG to whatever string you want to display to the user, and
 * make certain to include a newline at the end.
 */
#define CUSTOM_MESG "Please contact the system administrator for more information.\n"

/*
 * MAIN
 */
int main (int argc, char **argv) {
	/* Notify the user they have no shell access. */
	printf("You do not have shell access to this machine.\n");

	/* If the person compiles with a custom message... */
#ifdef CUSTOM_MESG
	/* If the stdin/stdout are tty... */
	if ( isatty( fileno(stdin) ) && isatty( fileno(stdout) ) ) {
		/* Output the custom message to the user. */
		printf(CUSTOM_MESG);
	}
#endif

	/* We're done. */
	exit(0);
}
