aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/vlock/vlock-2.2.3/vlock-no_tally.patch
blob: 6e8a6a9fdcdfc8a09460754b00cdecea7a664ff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Upstream-Status: Pending

written by: Jeff Polk <jeff.polk@windriver.com>
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>

--- a/Makefile
+++ b/Makefile
@@ -126,6 +126,10 @@ ifeq ($(AUTH_METHOD),shadow)
 vlock-main : override LDLIBS += $(CRYPT_LIB)
 endif
 
+ifneq ($(ENABLE_FAIL_COUNT),yes)
+vlock-main.o : override CFLAGS += -DNO_FAIL_COUNT
+endif
+
 ifeq ($(ENABLE_PLUGINS),yes)
 vlock-main: plugins.o plugin.o module.o process.o script.o tsort.o list.o
 # -rdynamic is needed so that the all plugin can access the symbols from console_switch.o
--- a/configure
+++ b/configure
@@ -44,6 +44,7 @@ Optional Features:
   --enable-shadow         enable shadow authentication [disabled]
   --enable-root-password  enable unlogging with root password [enabled]
   --enable-debug          enable debugging
+  --enable-fail-count     enable failed login attempt summary [enabled]
 
 Additional configuration:
   --with-scripts=SCRIPTS  enable the named scripts []
@@ -78,6 +79,9 @@ enable_feature() {
     root-password)
       ENABLE_ROOT_PASSWORD="$2"
     ;;
+    fail-count)
+      ENABLE_FAIL_COUNT="$2"
+    ;;
     pam|shadow)
       if [ "$2" = "yes" ] ; then
         if [ -n "$auth_method" ] && [ "$auth_method" != "$1" ] ; then
@@ -232,6 +232,7 @@ set_defaults() {
   AUTH_METHOD="pam"
   ENABLE_ROOT_PASSWORD="yes"
   ENABLE_PLUGINS="yes"
+  ENABLE_FAIL_COUNT="yes"
   SCRIPTS=""
 
   VLOCK_GROUP="vlock"
@@ -356,10 +356,14 @@ ENABLE_PLUGINS = ${ENABLE_PLUGINS}
 # which plugins should be build
 MODULES = ${MODULES}
 # which scripts should be installed
 SCRIPTS = ${SCRIPTS}
 
+# display a summary of failed authentication attempts after successfully
+# unlocking?
+ENABLE_FAIL_COUNT = ${ENABLE_FAIL_COUNT}
+
 # root's group
 ROOT_GROUP = ${ROOT_GROUP}
 
 # group for privileged plugins
 VLOCK_GROUP = ${VLOCK_GROUP}
--- a/src/vlock-main.c
+++ b/src/vlock-main.c
@@ -111,7 +111,9 @@ static void restore_terminal(void)
   (void) tcsetattr(STDIN_FILENO, TCSANOW, &term);
 }
 
+#ifdef ENABLE_FAIL_COUNT
 static int auth_tries;
+#endif /* ENABLE_FAIL_COUNT */
 
 static void auth_loop(const char *username)
 {
@@ -181,7 +183,9 @@ static void auth_loop(const char *userna
     }
 #endif
 
+#ifdef ENABLE_FAIL_COUNT
     auth_tries++;
+#endif /* ENABLE_FAIL_COUNT */
   }
 
   /* Free timeouts memory. */
@@ -189,11 +193,13 @@ static void auth_loop(const char *userna
   free(prompt_timeout);
 }
 
+#ifdef ENABLE_FAIL_COUNT
 void display_auth_tries(void)
 {
   if (auth_tries > 0)
     fprintf(stderr, "%d failed authentication %s.\n", auth_tries, auth_tries > 1 ? "tries" : "try");
 }
+#endif /* ENABLE_FAIL_COUNT */
 
 #ifdef USE_PLUGINS
 static void call_end_hook(void)
@@ -216,7 +222,9 @@ int main(int argc, char *const argv[])
   if (username == NULL)
     fatal_perror("vlock: could not get username");
 
+#ifdef ENABLE_FAIL_COUNT
   ensure_atexit(display_auth_tries);
+#endif /* ENABLE_FAIL_COUNT */
 
 #ifdef USE_PLUGINS
   for (int i = 1; i < argc; i++)