]> 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:28:40 +0000 (20:28 +0000)
committerCorey Farrell <git@cfware.com>
Thu, 30 Jan 2014 20:28:40 +0000 (20:28 +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
........

Merged revisions 406933 from http://svn.asterisk.org/svn/asterisk/branches/1.8

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

main/udptl.c
res/res_rtp_asterisk.c

index 772da03ee5f23999477f692eb3d663f50eb4dea6..b5d13943450af8747d4497317103ea5f4407c27f 100644 (file)
@@ -1009,7 +1009,7 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, s
                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 3d195d846f333a51157216cf4c785f8fcbf6f506..5dde2ba55db8b61ec2ad17f9d2bc705908d57137 100644 (file)
@@ -1823,7 +1823,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);