]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk & udptl: fix port selection to work with SELinux restrictions
authorCorey Farrell <git@cfware.com>
Thu, 30 Jan 2014 20:26:52 +0000 (20:26 +0000)
committerCorey Farrell <git@cfware.com>
Thu, 30 Jan 2014 20:26:52 +0000 (20:26 +0000)
ast_bind to a port reserved for another program by SELinux causes
errno == EACCES.  This caused random failures when binding rtp or
udptl sockets.  Treat EACCES as a non-fatal error, try next port.

(closes issue ASTERISK-23134)
Reported by: Corey Farrell

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@406933 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/udptl.c
res/res_rtp_asterisk.c

index 00989b46eecc93b6e04f5ee9a90c8900b382ab5d..d874c23df95d4e70eb2cf6d70992d1c348d18352 100644 (file)
@@ -968,7 +968,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc
                if (ast_bind(udptl->fd, &udptl->us) == 0) {
                        break;
                }
-               if (errno != EADDRINUSE) {
+               if (errno != EADDRINUSE && errno != EACCES) {
                        ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno));
                        close(udptl->fd);
                        ast_free(udptl);
index b0745ddca537096da290dc4b79f5fef950e7eaa2..6c7f88c60b6db35be0383517d52ae9a2a7292ad3 100644 (file)
@@ -596,7 +596,7 @@ static int ast_rtp_new(struct ast_rtp_instance *instance,
                }
 
                /* See if we ran out of ports or if the bind actually failed because of something other than the address being in use */
-               if (x == startplace || errno != EADDRINUSE) {
+               if (x == startplace || (errno != EADDRINUSE && errno != EACCES)) {
                        ast_log(LOG_ERROR, "Oh dear... we couldn't allocate a port for RTP instance '%p'\n", instance);
                        close(rtp->s);
                        ast_free(rtp);