mirror of git://git.suckless.org/ubase
Add nologin(8)
Signed-off-by: Mattias Andrée <maandree@kth.se>
This commit is contained in:
parent
e0dc3f9546
commit
6e7386edb3
2
Makefile
2
Makefile
|
@ -64,6 +64,7 @@ BIN = \
|
||||||
mkswap \
|
mkswap \
|
||||||
mount \
|
mount \
|
||||||
mountpoint \
|
mountpoint \
|
||||||
|
nologin \
|
||||||
pagesize \
|
pagesize \
|
||||||
passwd \
|
passwd \
|
||||||
pidof \
|
pidof \
|
||||||
|
@ -129,6 +130,7 @@ MAN8 = \
|
||||||
lsusb.8 \
|
lsusb.8 \
|
||||||
mkswap.8 \
|
mkswap.8 \
|
||||||
mount.8 \
|
mount.8 \
|
||||||
|
nologin.8 \
|
||||||
pivot_root.8 \
|
pivot_root.8 \
|
||||||
readahead.8 \
|
readahead.8 \
|
||||||
rmmod.8 \
|
rmmod.8 \
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
.Dd March 26, 2016
|
||||||
|
.Dt NOLOGIN 8
|
||||||
|
.Os ubase
|
||||||
|
.Sh NAME
|
||||||
|
.Nm nologin
|
||||||
|
.Nd refuse login
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
.Nm
|
||||||
|
prints a message informing the user that she
|
||||||
|
is not allowed to log in. If /etc/nologin.txt
|
||||||
|
exists, its content is printed instead of
|
||||||
|
the default message.
|
||||||
|
.Pp
|
||||||
|
.Nm
|
||||||
|
is intended to be specified as the user's
|
||||||
|
default shell.
|
||||||
|
.Sh EXIT STATUS
|
||||||
|
.Nm
|
||||||
|
returns a status code indicating failure.
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
ssize_t n;
|
||||||
|
|
||||||
|
fd = open("/etc/nologin.txt", O_RDONLY);
|
||||||
|
if (fd >= 0) {
|
||||||
|
while ((n = read(fd, buf, sizeof(buf))) > 0)
|
||||||
|
write(STDOUT_FILENO, buf, n);
|
||||||
|
close(fd);
|
||||||
|
} else {
|
||||||
|
printf("The account is currently unavailable.\n");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
Loading…
Reference in New Issue