cdown / rpms / util-linux

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