nologin.c - ubase - suckless linux base utils
 (HTM) git clone git://git.suckless.org/ubase
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       nologin.c (405B)
       ---
            1 /* See LICENSE file for copyright and license details. */
            2 #include <fcntl.h>
            3 #include <stdio.h>
            4 #include <unistd.h>
            5 
            6 int
            7 main(void)
            8 {
            9         int fd;
           10         char buf[BUFSIZ];
           11         ssize_t n;
           12 
           13         fd = open("/etc/nologin.txt", O_RDONLY);
           14         if (fd >= 0) {
           15                 while ((n = read(fd, buf, sizeof(buf))) > 0)
           16                         write(STDOUT_FILENO, buf, n);
           17                 close(fd);
           18         } else {
           19                 printf("The account is currently unavailable.\n");
           20         }
           21         return 1;
           22 }