commit 0f65d8ad2eda79b763fbc6bd6055e5793354e67c
parent 6572693ae7605700d0bd87be9f614d610cbe0738
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Wed, 29 Sep 2021 22:06:13 +0200
Remove debug printf
Diffstat:
3 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/attack.c b/attack.c
@@ -14,14 +14,10 @@ isattack(char *constat)
NULL,
};
- printf("isattack: %s\n", constat);
- for (char **p = attack; *p; ++p) {
- printf("%s\n", *p);
- if (strstr(constat, *p)) {
- printf("isattack: found\n");
+ for (char **p = attack; *p; ++p)
+ if (strstr(constat, *p))
return 1;
- }
- }
+
return 0;
}
@@ -33,12 +29,11 @@ islogin(char *constat)
"Accepted keyboard-interactive/pam for",
NULL,
};
- printf("islogin: %s\n", constat);
+
for (char **p = login; *p; ++p)
- if (strstr(constat, *p)) {
- printf("islogin: found\n");
+ if (strstr(constat, *p))
return 1;
- }
+
return 0;
}
diff --git a/main.c b/main.c
@@ -17,7 +17,6 @@ SLIST_HEAD(lhead, attacker) head = SLIST_HEAD_INITIALIZER(head);
void
ban(struct attacker *a)
{
- printf("ban\n");
a->nban++;
if (a->nban > 8)
blacklist(a);
@@ -42,12 +41,9 @@ unban(struct attacker *a, struct lhead *headp)
void
init(struct attacker *a)
{
- printf("attacker: %p\n", a);
strcpy(a->ip, ip);
a->nban = -1;
a->last = time(NULL);
- printf("init: %s %d %ld\n",
- a->ip, a->nban, a->last);
}
int
@@ -80,18 +76,13 @@ main(int argc, char **argv)
a = 0;
found = 0;
if (isattack(statmsg)) {
- printf("isattack\n");
- SLIST_FOREACH(a, &head, attackers) {
- printf("slist_foreach 1\n");
- printf("a: %p\n", a);
+ SLIST_FOREACH(a, &head, attackers)
if (!strcmp(a->ip, ip)) {
- printf("if 1\n");
++found;
break;
}
- }
+
if (!found) {
- printf("attacker not found\n");
a = malloc(sizeof(struct attacker));
init(a);
SLIST_INSERT_HEAD(&head, a, attackers);
@@ -99,14 +90,12 @@ main(int argc, char **argv)
ban(a);
}
- if (islogin(statmsg)) {
- printf("login detected\n");
+ if (islogin(statmsg))
SLIST_FOREACH(a, &head, attackers)
if (!strcmp(a->ip, ip)) {
printf("attacker deleted\n");
SLIST_REMOVE(&head, a, attacker, attackers);
}
- }
unban(NULL, &head);
diff --git a/range.c b/range.c
@@ -12,9 +12,7 @@ range(char *s, int min, int max)
return -1;
errno = 0;
- printf("range str: %s\n", s);
t = atoi(s);
- printf("range t: %d\n", t);
if (errno) {
fprintf(stderr, "atoi failed: %s\n", strerror(errno));
return -1;