nologin.c revision 126512
1232950Stheraven/*- 2232950Stheraven * This program is in the public domain. I couldn't bring myself to 3232950Stheraven * declare Copyright on a variant of Hello World. 4232950Stheraven */ 5232950Stheraven 6232950Stheraven#include <sys/cdefs.h> 7232950Stheraven__FBSDID("$FreeBSD: head/usr.sbin/nologin/nologin.c 126117 2004-02-22 10:03:24Z cperciva $"); 8232950Stheraven 9232950Stheraven#include <sys/types.h> 10232950Stheraven#include <sys/uio.h> 11232950Stheraven#include <syslog.h> 12232950Stheraven#include <unistd.h> 13232950Stheraven 14232950Stheraven#define MESSAGE "This account is currently not available.\n" 15232950Stheraven 16232950Stheravenint 17232950Stheravenmain(int argc, char *argv[]) 18232950Stheraven{ 19232950Stheraven#ifndef NO_NOLOGIN_LOG 20232950Stheraven char *user, *tt; 21232950Stheraven 22232950Stheraven if ((tt = ttyname(0)) == NULL) 23232950Stheraven tt = "UNKNOWN"; 24232950Stheraven if ((user = getlogin()) == NULL) 25232950Stheraven user = "UNKNOWN"; 26232950Stheraven 27227825Stheraven openlog("nologin", LOG_CONS, LOG_AUTH); 28227825Stheraven syslog(LOG_CRIT, "Attempted login by %s on %s", user, tt); 29227825Stheraven closelog(); 30227825Stheraven#endif /* NO_NOLOGIN_LOG */ 31227825Stheraven 32227825Stheraven write(STDOUT_FILENO, MESSAGE, sizeof(MESSAGE) - 1); 33227825Stheraven _exit(1); 34227825Stheraven} 35227825Stheraven