summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nologin/nologin.c
blob: ad2c2fe3c9c1401ba65a43c862a8f81bb5cd1c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*-
 * This program is in the public domain.  I couldn't bring myself to
 * declare Copyright on a variant of Hello World.
 */

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <sys/types.h>
#include <sys/uio.h>
#include <syslog.h>
#include <unistd.h>

#define	MESSAGE	"This account is currently not available.\n"

int
main(int argc, char *argv[])
{
#ifndef NO_NOLOGIN_LOG
	char *user, *tt;

	if ((tt = ttyname(0)) == NULL)
		tt = "UNKNOWN";
	if ((user = getlogin()) == NULL)
		user = "UNKNOWN";

	openlog("nologin", LOG_CONS, LOG_AUTH);
	syslog(LOG_CRIT, "Attempted login by %s on %s", user, tt);
	closelog();
#endif /* NO_NOLOGIN_LOG */

	write(STDOUT_FILENO, MESSAGE, sizeof(MESSAGE) - 1);
	_exit(1);
}
OpenPOWER on IntegriCloud