ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | 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 }