fd7089e
/*	$OpenBSD: nologin.c,v 1.2 1997/04/04 16:51:37 millert Exp $	*/
fd7089e
fd7089e
/*
fd7089e
 * Copyright (c) 1997, Jason Downs.  All rights reserved.
fd7089e
 *
fd7089e
 * Redistribution and use in source and binary forms, with or without
fd7089e
 * modification, are permitted provided that the following conditions
fd7089e
 * are met:
fd7089e
 * 1. Redistributions of source code must retain the above copyright
fd7089e
 *    notice, this list of conditions and the following disclaimer.
fd7089e
 * 2. Redistributions in binary form must reproduce the above copyright
fd7089e
 *    notice, this list of conditions and the following disclaimer in the
fd7089e
 *    documentation and/or other materials provided with the distribution.
fd7089e
 *
fd7089e
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
fd7089e
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
fd7089e
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
fd7089e
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
fd7089e
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
fd7089e
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
fd7089e
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
fd7089e
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
fd7089e
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
fd7089e
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
fd7089e
 * SUCH DAMAGE.
fd7089e
 */
fd7089e
fd7089e
#include <sys/types.h>
fd7089e
#include <fcntl.h>
fd7089e
#include <string.h>
fd7089e
#include <unistd.h>
fd7089e
#include <stdlib.h>
fd7089e
fd7089e
/* Distinctly different from _PATH_NOLOGIN. */
fd7089e
#define _PATH_NOLOGIN_TXT	"/etc/nologin.txt"
fd7089e
fd7089e
#define DEFAULT_MESG	"This account is currently not available.\n"
fd7089e
fd7089e
/*ARGSUSED*/
fd7089e
int main(argc, argv)
fd7089e
	int argc;
fd7089e
	char *argv[];
fd7089e
{
fd7089e
	int nfd, nrd;
fd7089e
	char nbuf[128];
fd7089e
fd7089e
	nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY);
fd7089e
	if (nfd < 0) {
fd7089e
		write(STDOUT_FILENO, DEFAULT_MESG, strlen(DEFAULT_MESG));
fd7089e
		exit (1);
fd7089e
	}
fd7089e
fd7089e
	while ((nrd = read(nfd, nbuf, sizeof(nbuf))) > 0)
fd7089e
		write(STDOUT_FILENO, nbuf, nrd);
fd7089e
	close (nfd);
fd7089e
fd7089e
	exit (1);
fd7089e
}