Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv3518/res

Modified Files:
      Tag: v1-0
        res_agi.c 
Log Message:
unmask SIGHUP before exec'ing AGI scripts (bug #4854)


Index: res_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v
retrieving revision 1.10.2.7
retrieving revision 1.10.2.8
diff -u -d -r1.10.2.7 -r1.10.2.8
--- res_agi.c   14 Jun 2005 20:24:38 -0000      1.10.2.7
+++ res_agi.c   4 Aug 2005 22:52:15 -0000       1.10.2.8
@@ -203,6 +203,7 @@
        int audio[2];
        int x;
        int res;
+       sigset_t signal_set;
        
        if (!strncasecmp(script, "agi://", 6))
                return launch_netscript(script, argv, fds, efd, opid);
@@ -258,9 +259,17 @@
                } else {
                        close(STDERR_FILENO + 1);
                }
+               
+               /* unblock important signal handlers */
+               if (sigfillset(&signal_set) || pthread_sigmask(SIG_UNBLOCK, 
&signal_set, NULL)) {
+                       ast_log(LOG_WARNING, "unable to unblock signals for AGI 
script: %s\n", strerror(errno));
+                       exit(1);
+               }
+
                /* Close everything but stdin/out/error */
                for (x=STDERR_FILENO + 2;x<1024;x++) 
                        close(x);
+
                /* Execute script */
                execv(script, argv);
                /* Can't use ast_log since FD's are closed */
@@ -433,7 +442,7 @@
                return RESULT_SHOWUSAGE;
        
        fs = ast_openstream(chan, argv[2], chan->language);
-       if(!fs){
+       if (!fs){
                fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, 
sample_offset);
                return RESULT_SUCCESS;
        }
@@ -1542,8 +1551,10 @@
                }
        }
        /* Notify process */
-       if (pid > -1)
-               kill(pid, SIGHUP);
+       if (pid > -1) {
+               if (kill(pid, SIGHUP))
+                       ast_log(LOG_WARNING, "unable to send SIGHUP to AGI 
process %d: %s\n", pid, strerror(errno));
+       }
        fclose(readf);
        return returnstatus;
 }

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to