summaryrefslogtreecommitdiff
path: root/i3lock.c
diff options
context:
space:
mode:
authorkoebi <koebischnell@googlemail.com>2014-07-24 22:32:07 +0200
committerMichael Stapelberg <michael@stapelberg.de>2014-08-24 23:27:00 +0200
commit0cbf483cb4a1597343df90642ac475b288ae9e80 (patch)
tree66dadbe94de7d2d2066d50f1a19f4b94e6b7e483 /i3lock.c
parent7f450a52f60ac543540a8ef50fd6d440bf0d4c8a (diff)
implemented logging the number of failed attempts
This closes #1243
Diffstat (limited to 'i3lock.c')
-rw-r--r--i3lock.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/i3lock.c b/i3lock.c
index b2dbd6b..64e4600 100644
--- a/i3lock.c
+++ b/i3lock.c
@@ -64,6 +64,8 @@ static struct ev_timer *dpms_timeout;
static struct ev_timer *discard_passwd_timeout;
extern unlock_state_t unlock_state;
extern pam_state_t pam_state;
+int failed_attempts = 0;
+bool show_failed_attempts = false;
static struct xkb_state *xkb_state;
static struct xkb_context *xkb_context;
@@ -239,6 +241,7 @@ static void input_done(void) {
fprintf(stderr, "Authentication failure\n");
pam_state = STATE_PAM_WRONG;
+ failed_attempts += 1;
clear_input();
redraw_screen();
@@ -674,13 +677,14 @@ int main(int argc, char *argv[]) {
{"tiling", no_argument, NULL, 't'},
{"ignore-empty-password", no_argument, NULL, 'e'},
{"inactivity-timeout", required_argument, NULL, 'I'},
+ {"show-failed-attempts", no_argument, NULL, 'f'},
{NULL, no_argument, NULL, 0}
};
if ((username = getenv("USER")) == NULL)
errx(EXIT_FAILURE, "USER environment variable not set, please set it.\n");
- char *optstring = "hvnbdc:p:ui:teI:";
+ char *optstring = "hvnbdc:p:ui:teI:f";
while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
switch (o) {
case 'v':
@@ -738,9 +742,12 @@ int main(int argc, char *argv[]) {
if (strcmp(longopts[optind].name, "debug") == 0)
debug_mode = true;
break;
+ case 'f':
+ show_failed_attempts = true;
+ break;
default:
errx(EXIT_FAILURE, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
- " [-i image.png] [-t] [-e] [-I]"
+ " [-i image.png] [-t] [-e] [-I] [-f]"
);
}
}