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