faillock.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * faillock.h - authentication failure data file record structure
  37. *
  38. * Each record in the file represents an instance of login failure of
  39. * the user at the recorded time.
  40. */
  41. #ifndef _FAILLOCK_H
  42. #define _FAILLOCK_H
  43. #include <stdint.h>
  44. #include <sys/types.h>
  45. #define TALLY_STATUS_VALID 0x1 /* the tally file entry is valid */
  46. #define TALLY_STATUS_RHOST 0x2 /* the source is rhost */
  47. #define TALLY_STATUS_TTY 0x4 /* the source is tty */
  48. /* If neither TALLY_FLAG_RHOST nor TALLY_FLAG_TTY are set the source is service. */
  49. struct tally {
  50. char source[52]; /* rhost or tty of the login failure */
  51. /* (not necessarily NULL terminated) */
  52. uint16_t reserved; /* reserved for future use */
  53. uint16_t status; /* record status */
  54. uint64_t time; /* time of the login failure */
  55. };
  56. /* 64 bytes per entry */
  57. struct tally_data {
  58. struct tally *records; /* array of tallies */
  59. unsigned int count; /* number of records */
  60. };
  61. #define FAILLOCK_DEFAULT_TALLYDIR "/var/run/faillock"
  62. #define FAILLOCK_DEFAULT_CONF "/etc/security/faillock.conf"
  63. int open_tally(const char *dir, const char *user, uid_t uid, int create);
  64. int read_tally(int fd, struct tally_data *tallies);
  65. int update_tally(int fd, struct tally_data *tallies);
  66. #endif