]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
script: Set alarm() for the script being run only if alarm=<secs> parameter is given.
authorTimo Sirainen <tss@iki.fi>
Fri, 20 Jan 2012 16:09:41 +0000 (18:09 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 20 Jan 2012 16:09:41 +0000 (18:09 +0200)
src/util/script.c

index 53c6c60f880eb292dbd5acbafef1636f0bee8ffb..0c545e7be39cf492b426d2dae3554ec2ebb43d79 100644 (file)
@@ -78,6 +78,7 @@ static bool client_exec_script(struct master_service_connection *conn)
        /* Input contains:
 
           VERSION .. <lf>
+          [timeout=<timeout>]
           <noreply> | "-" <lf>
 
           arg 1 <lf>
@@ -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);