1 /*
2 * Copyright (c) 2010 Tomas Mraz <tmraz@redhat.com>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, and the entire permission notice in its entirety,
9 * including the disclaimer of warranties.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior
15 * written permission.
16 *
17 * ALTERNATIVELY, this product may be distributed under the terms of
18 * the GNU Public License, in which case the provisions of the GPL are
19 * required INSTEAD OF the above restrictions. (This clause is
20 * necessary due to a potential bad interaction between the GPL and
21 * the restrictions contained in a BSD-style copyright.)
22 *
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33 * OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /*
37 * faillock.h - authentication failure data file record structure
38 *
39 * Each record in the file represents an instance of login failure of
40 * the user at the recorded time.
41 */
42
43
44 #ifndef _FAILLOCK_H
45 #define _FAILLOCK_H
46
47 #include <stdint.h>
48 #include <sys/types.h>
49
50 #define TALLY_STATUS_VALID 0x1 /* the tally file entry is valid */
51 #define TALLY_STATUS_RHOST 0x2 /* the source is rhost */
52 #define TALLY_STATUS_TTY 0x4 /* the source is tty */
53 /* If neither TALLY_FLAG_RHOST nor TALLY_FLAG_TTY are set the source is service. */
54
55 struct tally {
56 char source[52]; /* rhost or tty of the login failure */
57 /* (not necessarily NULL terminated) */
58 uint16_t reserved; /* reserved for future use */
59 uint16_t status; /* record status */
60 uint64_t time; /* time of the login failure */
61 };
62 /* 64 bytes per entry */
63
64 struct tally_data {
65 struct tally *records; /* array of tallies */
66 unsigned int count; /* number of records */
67 };
68
69 #define FAILLOCK_DEFAULT_TALLYDIR "/var/run/faillock"
70
71 int open_tally(const char *dir, const char *user, uid_t uid, int create);
72 int read_tally(int fd, struct tally_data *tallies);
73 int update_tally(int fd, struct tally_data *tallies);
74 #endif