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