1*15f9f824SAaron LI /*-
2*15f9f824SAaron LI * Copyright (c) 2004 The FreeBSD Project.
3*15f9f824SAaron LI * All rights reserved.
4234030c7SMatthias Schmidt *
5234030c7SMatthias Schmidt * Redistribution and use in source and binary forms, with or without
6234030c7SMatthias Schmidt * modification, are permitted provided that the following conditions
7234030c7SMatthias Schmidt * are met:
8234030c7SMatthias Schmidt * 1. Redistributions of source code must retain the above copyright
9234030c7SMatthias Schmidt * notice, this list of conditions and the following disclaimer.
10234030c7SMatthias Schmidt * 2. Redistributions in binary form must reproduce the above copyright
11*15f9f824SAaron LI * notice, this list of conditions and the following disclaimer in the
12*15f9f824SAaron LI * documentation and/or other materials provided with the distribution.
13234030c7SMatthias Schmidt *
14*15f9f824SAaron LI * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*15f9f824SAaron LI * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*15f9f824SAaron LI * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*15f9f824SAaron LI * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*15f9f824SAaron LI * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*15f9f824SAaron LI * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*15f9f824SAaron LI * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*15f9f824SAaron LI * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*15f9f824SAaron LI * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*15f9f824SAaron LI * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24234030c7SMatthias Schmidt * SUCH DAMAGE.
25234030c7SMatthias Schmidt *
26*15f9f824SAaron LI * $FreeBSD: head/usr.sbin/nologin/nologin.c 139685 2005-01-04 20:07:12Z delphij $
27234030c7SMatthias Schmidt */
28234030c7SMatthias Schmidt
29234030c7SMatthias Schmidt #include <stdio.h>
30*15f9f824SAaron LI #include <syslog.h>
31234030c7SMatthias Schmidt #include <unistd.h>
32234030c7SMatthias Schmidt
33*15f9f824SAaron LI #define MESSAGE "This account is currently not available.\n"
34*15f9f824SAaron LI
35234030c7SMatthias Schmidt int
main(__unused int argc,__unused char * argv[])36*15f9f824SAaron LI main(__unused int argc, __unused char *argv[])
37234030c7SMatthias Schmidt {
38*15f9f824SAaron LI const char *user, *tt;
39*15f9f824SAaron LI
40*15f9f824SAaron LI if ((tt = ttyname(0)) == NULL)
41*15f9f824SAaron LI tt = "UNKNOWN";
42*15f9f824SAaron LI if ((user = getlogin()) == NULL)
43*15f9f824SAaron LI user = "UNKNOWN";
44*15f9f824SAaron LI openlog("nologin", LOG_CONS, LOG_AUTH);
45*15f9f824SAaron LI syslog(LOG_CRIT, "Attempted login by %s on %s", user, tt);
46*15f9f824SAaron LI closelog();
47*15f9f824SAaron LI
48*15f9f824SAaron LI printf("%s", MESSAGE);
49*15f9f824SAaron LI return 1;
50234030c7SMatthias Schmidt }
51