Skip to content

Commit f3005d0

Browse files
committed
Tunnel: don't trigger FortiGate password blocking on wrong password.
1 parent 1493a80 commit f3005d0

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const struct vpn_config invalid_cfg = {
6464
.use_syslog = -1,
6565
.half_internet_routes = -1,
6666
.persistent = -1,
67+
.backoff_sleep = UINT_MAX,
6768
#if HAVE_USR_SBIN_PPPD
6869
.pppd_log = NULL,
6970
.pppd_plugin = NULL,

src/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ struct vpn_config {
112112
int half_internet_routes;
113113

114114
unsigned int persistent;
115+
/* Used to store sleep time between attempts (as tunnel struct is cleaned). */
116+
unsigned int backoff_sleep;
117+
115118

116119
#if HAVE_USR_SBIN_PPPD
117120
char *pppd_log;

src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ int main(int argc, char *argv[])
242242
.use_syslog = 0,
243243
.half_internet_routes = 0,
244244
.persistent = 0,
245+
.backoff_sleep = 0,
245246
#if HAVE_RESOLVCONF
246247
.use_resolvconf = USE_RESOLVCONF,
247248
#endif

src/tunnel.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,11 +1381,22 @@ int run_tunnel(struct vpn_config *config)
13811381
if (ret != 1) {
13821382
log_error("Could not authenticate to gateway. Please check the password, client certificate, etc.\n");
13831383
log_debug("%s (%d)\n", err_http_str(ret), ret);
1384+
/* We should do a back off attempt here no ? */
1385+
/* As FortiGate kick us after 3 attempts just increase quickly the */
1386+
/* tries. */
1387+
/* Maybe we should force the exit or reask for password ? */
1388+
if (tunnel.config->persistent != 0) {
1389+
if (tunnel.config->backoff_sleep <= 3600)
1390+
tunnel.config->backoff_sleep += 60;
1391+
sleep(tunnel.config->backoff_sleep);
1392+
}
13841393
ret = 1;
13851394
goto err_tunnel;
13861395
}
13871396
log_info("Authenticated.\n");
13881397
log_debug("Cookie: %s\n", tunnel.cookie);
1398+
/* Reset backoff timing */
1399+
tunnel.config->backoff_sleep = 0;
13891400

13901401
ret = auth_request_vpn_allocation(&tunnel);
13911402
if (ret != 1) {

0 commit comments

Comments
 (0)