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