vlock-no_tally.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. From 17e5c8d32abc214aea408f0837be41e88bce7eb2 Mon Sep 17 00:00:00 2001
  2. From: Jackie Huang <jackie.huang@windriver.com>
  3. Date: Wed, 16 Aug 2017 13:37:40 +0800
  4. Subject: [PATCH] vlock: add new recipe
  5. Upstream-Status: Pending
  6. written by: Jeff Polk <jeff.polk@windriver.com>
  7. Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
  8. ---
  9. Makefile | 4 ++++
  10. configure | 9 +++++++++
  11. src/vlock-main.c | 8 ++++++++
  12. 3 files changed, 21 insertions(+)
  13. diff --git a/Makefile b/Makefile
  14. index 4eeb42a..834cd2c 100644
  15. --- a/Makefile
  16. +++ b/Makefile
  17. @@ -126,6 +126,10 @@ ifeq ($(AUTH_METHOD),shadow)
  18. vlock-main : override LDLIBS += $(CRYPT_LIB)
  19. endif
  20. +ifneq ($(ENABLE_FAIL_COUNT),yes)
  21. +vlock-main.o : override CFLAGS += -DNO_FAIL_COUNT
  22. +endif
  23. +
  24. ifeq ($(ENABLE_PLUGINS),yes)
  25. vlock-main: plugins.o plugin.o module.o process.o script.o tsort.o list.o
  26. # -rdynamic is needed so that the all plugin can access the symbols from console_switch.o
  27. diff --git a/configure b/configure
  28. index d5d84d6..1303598 100755
  29. --- a/configure
  30. +++ b/configure
  31. @@ -44,6 +44,7 @@ Optional Features:
  32. --enable-shadow enable shadow authentication [disabled]
  33. --enable-root-password enable unlogging with root password [enabled]
  34. --enable-debug enable debugging
  35. + --enable-fail-count enable failed login attempt summary [enabled]
  36. Additional configuration:
  37. --with-scripts=SCRIPTS enable the named scripts []
  38. @@ -78,6 +79,9 @@ enable_feature() {
  39. root-password)
  40. ENABLE_ROOT_PASSWORD="$2"
  41. ;;
  42. + fail-count)
  43. + ENABLE_FAIL_COUNT="$2"
  44. + ;;
  45. pam|shadow)
  46. if [ "$2" = "yes" ] ; then
  47. if [ -n "$auth_method" ] && [ "$auth_method" != "$1" ] ; then
  48. @@ -228,6 +232,7 @@ set_defaults() {
  49. AUTH_METHOD="pam"
  50. ENABLE_ROOT_PASSWORD="yes"
  51. ENABLE_PLUGINS="yes"
  52. + ENABLE_FAIL_COUNT="yes"
  53. SCRIPTS=""
  54. VLOCK_GROUP="vlock"
  55. @@ -353,6 +358,10 @@ MODULES = ${MODULES}
  56. # which scripts should be installed
  57. SCRIPTS = ${SCRIPTS}
  58. +# display a summary of failed authentication attempts after successfully
  59. +# unlocking?
  60. +ENABLE_FAIL_COUNT = ${ENABLE_FAIL_COUNT}
  61. +
  62. # root's group
  63. ROOT_GROUP = ${ROOT_GROUP}
  64. diff --git a/src/vlock-main.c b/src/vlock-main.c
  65. index 008f6f0..108ce8b 100644
  66. --- a/src/vlock-main.c
  67. +++ b/src/vlock-main.c
  68. @@ -112,7 +112,9 @@ static void restore_terminal(void)
  69. (void) tcsetattr(STDIN_FILENO, TCSANOW, &old_term);
  70. }
  71. +#ifdef ENABLE_FAIL_COUNT
  72. static int auth_tries;
  73. +#endif /* ENABLE_FAIL_COUNT */
  74. static void auth_loop(const char *username)
  75. {
  76. @@ -182,7 +184,9 @@ static void auth_loop(const char *username)
  77. }
  78. #endif
  79. +#ifdef ENABLE_FAIL_COUNT
  80. auth_tries++;
  81. +#endif /* ENABLE_FAIL_COUNT */
  82. }
  83. /* Free timeouts memory. */
  84. @@ -190,11 +194,13 @@ static void auth_loop(const char *username)
  85. free(prompt_timeout);
  86. }
  87. +#ifdef ENABLE_FAIL_COUNT
  88. void display_auth_tries(void)
  89. {
  90. if (auth_tries > 0)
  91. fprintf(stderr, "%d failed authentication %s.\n", auth_tries, auth_tries > 1 ? "tries" : "try");
  92. }
  93. +#endif /* ENABLE_FAIL_COUNT */
  94. #ifdef USE_PLUGINS
  95. static void call_end_hook(void)
  96. @@ -217,7 +223,9 @@ int main(int argc, char *const argv[])
  97. if (username == NULL)
  98. fatal_perror("vlock: could not get username");
  99. +#ifdef ENABLE_FAIL_COUNT
  100. ensure_atexit(display_auth_tries);
  101. +#endif /* ENABLE_FAIL_COUNT */
  102. #ifdef USE_PLUGINS
  103. for (int i = 1; i < argc; i++)