1/* See LICENSE file for copyright and license details. */
2
3
4#include <fcntl.h>
5#include <stdio.h>
6#include <unistd.h>
7
8// ?man nologin: politely refuse login
9// ?man politely refuse a login attempt by exiting with status 1
10int
11main(void)
12{
13 int fd;
14 char buf[BUFSIZ];
15 ssize_t n;
16
17 fd = open("/etc/nologin.txt", O_RDONLY);
18 if (fd >= 0) {
19 while ((n = read(fd, buf, sizeof(buf))) > 0)
20 write(STDOUT_FILENO, buf, n);
21 close(fd);
22 } else {
23 printf("The account is currently unavailable.\n");
24 }
25 return 1;
26}