nologin.c revision 126512
1/*- 2 * This program is in the public domain. I couldn't bring myself to 3 * declare Copyright on a variant of Hello World. 4 */ 5 6#include <sys/cdefs.h> 7__FBSDID("$FreeBSD: head/usr.sbin/nologin/nologin.c 126117 2004-02-22 10:03:24Z cperciva $"); 8 9#include <sys/types.h> 10#include <sys/uio.h> 11#include <syslog.h> 12#include <unistd.h> 13 14#define MESSAGE "This account is currently not available.\n" 15 16int 17main(int argc, char *argv[]) 18{ 19#ifndef NO_NOLOGIN_LOG 20 char *user, *tt; 21 22 if ((tt = ttyname(0)) == NULL) 23 tt = "UNKNOWN"; 24 if ((user = getlogin()) == NULL) 25 user = "UNKNOWN"; 26 27 openlog("nologin", LOG_CONS, LOG_AUTH); 28 syslog(LOG_CRIT, "Attempted login by %s on %s", user, tt); 29 closelog(); 30#endif /* NO_NOLOGIN_LOG */ 31 32 write(STDOUT_FILENO, MESSAGE, sizeof(MESSAGE) - 1); 33 _exit(1); 34} 35