From: Timo Sirainen Date: Fri, 20 Jan 2012 16:09:41 +0000 (+0200) Subject: script: Set alarm() for the script being run only if alarm= parameter is given. X-Git-Tag: 2.1.rc4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8656ae1d89e3576902376658cd8657d30748414f;p=thirdparty%2Fdovecot%2Fcore.git script: Set alarm() for the script being run only if alarm= parameter is given. --- diff --git a/src/util/script.c b/src/util/script.c index 53c6c60f88..0c545e7be3 100644 --- a/src/util/script.c +++ b/src/util/script.c @@ -78,6 +78,7 @@ static bool client_exec_script(struct master_service_connection *conn) /* Input contains: VERSION .. + [timeout=] | "-" arg 1 @@ -130,6 +131,7 @@ static bool client_exec_script(struct master_service_connection *conn) } buffer_set_used_size(input, scanpos); } + alarm(0); /* drop the last LF */ buffer_set_used_size(input, scanpos-1); @@ -137,6 +139,10 @@ static bool client_exec_script(struct master_service_connection *conn) args = t_strsplit(str_c(input), "\n"); script_verify_version(*args); args++; if (*args != NULL) { + if (strncmp(*args, "alarm=", 6) == 0) { + alarm(atoi(*args + 6)); + args++; + } if (strcmp(*args, "noreply") == 0) { /* no need to fork and check exit status */ exec_child(conn, args + 1);