opensips/opensips.patch

Tue, 28 Aug 2012 18:31:35 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 28 Aug 2012 18:31:35 +0200
changeset 547
1c75a8bb0fec
parent 416
0bc1d0d1fe3a
permissions
-rw-r--r--

Update to new version, correct new flaky menuconfig implementation, modernize
packaging, and only conditionally implement strsep(3) on SVR4 missing it.

     1 Index: main.c
     2 diff -Nau main.c.orig main.c
     3 --- main.c.orig	2012-03-21.orig 10:29:31.458420799 +0100
     4 +++ main.c	2012-03-21 10:30:52.034994020 +0100
     5 @@ -1029,6 +1029,10 @@
     6  	ret=-1;
     7  	my_argc=argc; my_argv=argv;
     9 +	/* if (!log_stderr), that's not usable yet! '/
    10 +	/* ...so unconditionally log to syslog for now */
    11 +	openlog(argv[0], LOG_PID|LOG_CONS, log_facility);
    12 +
    13  	/* process pkg mem size from command line */
    14  	opterr=0;
    15  	options="f:cCm:M:b:l:n:N:rRvdDETSVhw:t:u:g:P:G:W:o:";
    16 @@ -1387,6 +1391,11 @@
    18  	/* init_daemon? */
    19  	if (!dont_fork){
    20 +		/* shortly after main() we called openlog(3) to log */
    21 +		/* the initialization, but since daemonize() has its */
    22 +		/* own syslog(3) handling, we need to close the log first */
    23 +		closelog(); /* close the initialization logging logic */
    24 +
    25  		if ( daemonize((log_name==0)?argv[0]:log_name, &own_pgid) <0 )
    26  			goto error;
    27  	}
    28 Index: Makefile.defs
    29 diff -Nau Makefile.defs.orig Makefile.defs
    30 --- Makefile.defs.orig	2012-03-21.orig 10:29:31.252995930 +0100
    31 +++ Makefile.defs	2012-03-21 10:30:52.038327356 +0100
    32 @@ -220,7 +220,7 @@
    33  else
    34  	doc-dir = doc/$(MAIN_NAME)/
    35  	man-dir = man/
    36 -	data-dir = $(MAIN_NAME)/
    37 +	data-dir = share/$(MAIN_NAME)/
    38  	LOCALBASE ?= $(SYSBASE)/local
    39  endif
    40  endif
    41 @@ -1411,6 +1411,10 @@
    42  LIBS+= -lsctp
    43  endif
    45 +#conditionally add libfsl
    46 +LDFLAGS += -L$(prefix)/lib
    47 +LIBS    += -lfsl
    48 +
    49  ifneq ($(found_lock_method), yes)
    50  $(warning	No locking method found so far, trying SYS V sems)
    51  		DEFS+= -DUSE_SYSV_SEM  # try sys v sems
    52 Index: scripts/opensipsctl.8
    53 diff -Nau scripts/opensipsctl.8.orig scripts/opensipsctl.8
    54 --- scripts/opensipsctl.8.orig	2012-03-21.orig 10:29:31.357825870 +0100
    55 +++ scripts/opensipsctl.8	2012-03-21 10:30:52.039349015 +0100
    56 @@ -20,8 +20,6 @@
    58  .SH FILES
    59  .PD 0
    60 -.I /etc/opensips/.opensipsctlrc
    61 -.br
    62  .I /usr/local/etc/opensips/.opensipsctlrc
    63  .br
    64  .I ~/.opensipsctlrc
    65 Index: scripts/osipsconsole
    66 diff -Nau scripts/osipsconsole.orig scripts/osipsconsole
    67 --- scripts/osipsconsole.orig	2012-03-21.orig 10:29:31.335460757 +0100
    68 +++ scripts/osipsconsole	2012-03-21 10:30:52.050666821 +0100
    69 @@ -30,7 +30,6 @@
    70  use Term::ReadLine;
    71  use DBI;
    72  use POSIX;
    73 -use Frontier::RPC2;
    74  use IO::Socket;
    75  use Socket;
    76  #use Net::IP;
    77 @@ -376,6 +375,12 @@
    78  			}		
    79  		}
    81 +		if ( $MD5 eq "" ) {
    82 +			if ( $arr[0] =~ /^\s*MD5/ ) {
    83 +			 	$MD5 = $arr[1]; 
    84 +			}		
    85 +		}
    86 +
    87  		if ( $AWK eq "" ) {
    88  			if ( $arr[0] =~ /^\s*AWK/ ) {
    89  			 	$AWK = $arr[1]; 
    90 Index: modules/permissions/parse_config.c
    91 diff -Nau modules/permissions/parse_config.c.orig modules/permissions/parse_config.c
    92 --- modules/permissions/parse_config.c.orig	2012-03-21.orig 10:29:32.047580003 +0100
    93 +++ modules/permissions/parse_config.c	2012-03-21 10:30:52.052696686 +0100
    94 @@ -114,8 +114,11 @@
    95  	except = strstr(str, " EXCEPT ");
    96  	if (except) {
    97  		/* exception found */
    98 -		strncpy(str2, str, except-str);
    99 -		str2[except-str] = '\0';
   100 +		int l = except - str;
   101 +		if (l > sizeof(str2) - 1)
   102 +			l = sizeof(str2) - 1;
   103 +		strncpy(str2, str, l);
   104 +		str2[l] = '\0';
   105  		/* except+8 points to the exception */
   106  		if (parse_expression_list(except+8, e_exceptions)) {
   107  			/* error */
   108 @@ -124,7 +127,8 @@
   109  		}
   110  	} else {
   111  		/* no exception */
   112 -		strcpy(str2, str);
   113 +		strncpy(str2, str, sizeof(str2)-1);
   114 +		str2[sizeof(str2)-1] = '\0';
   115  		*e_exceptions = NULL;
   116  	}
   118 Index: parser/sdp/sdp_helpr_funcs.c
   119 diff -Nau parser/sdp/sdp_helpr_funcs.c.orig parser/sdp/sdp_helpr_funcs.c
   120 --- parser/sdp/sdp_helpr_funcs.c.orig	2012-03-21.orig 10:29:31.444187545 +0100
   121 +++ parser/sdp/sdp_helpr_funcs.c	2012-03-21 10:30:52.057616045 +0100
   122 @@ -396,7 +396,7 @@
   124  	cp1 = NULL;
   125  	for (cp = body->s; (len = body->s + body->len - cp) > 0;) {
   126 -		cp1 = (char*)ser_memmem(cp, line, len, 2);
   127 +		cp1 = (char*)ser_memmem(cp, line, len, strlen(line));
   128  		if (cp1 == NULL || cp1[-1] == '\n' || cp1[-1] == '\r')
   129  			break;
   130  		cp = cp1 + 2;
   131 Index: modules/nathelper/nathelper.c
   132 diff -Nau modules/nathelper/nathelper.c.orig modules/nathelper/nathelper.c
   133 --- modules/nathelper/nathelper.c.orig	2012-03-21.orig 10:29:31.795178267 +0100
   134 +++ modules/nathelper/nathelper.c	2012-03-21 10:30:52.055610362 +0100
   135 @@ -289,6 +289,9 @@
   136  	return 0;
   137  }
   139 +/* MSvB macros */
   140 +#define OPENSIPS_NOOP ((void)0)
   141 +
   145 @@ -813,6 +816,7 @@
   146  #define	FIX_MEDIP	0x02
   147  #define	ADD_ANORTPPROXY	0x04
   148  #define	FIX_ORGIP	0x08
   149 +#define	FIX_RTCPIP	0x10
   151  #define	ADIRECTION	"a=direction:active"
   152  #define	ADIRECTION_LEN	(sizeof(ADIRECTION) - 1)
   153 @@ -829,7 +833,9 @@
   154  {
   155  	char *buf;
   156  	int offset;
   157 +	int binlump;
   158  	struct lump* anchor;
   159 +	struct lump* templump;
   160  	str omip, nip, oip;
   162  	/* check that updating mediaip is really necessary */
   163 @@ -860,7 +866,19 @@
   164  		memcpy(buf, CRLF, CRLF_LEN);
   165  		memcpy(buf + CRLF_LEN, omip.s, omip.len);
   166  		memcpy(buf + CRLF_LEN + omip.len, oldip->s, oldip->len);
   167 -		if (insert_new_lump_after(anchor, buf,
   168 +
   169 +		/* if the oldmediaip string is already */
   170 +		/* in the body then don't add it again */
   171 +		binlump = 0;
   172 +		for (templump = msg->body_lumps; templump; templump = templump->next)
   173 +			if (templump->op == LUMP_ADD && strstr(templump->u.value, buf))
   174 +				binlump = 1;
   175 +		for (templump = msg->add_rm; templump; templump = templump->next)
   176 +			if (templump->op == LUMP_ADD && strstr(templump->u.value, buf))
   177 +				binlump = 1;
   178 +		if (strstr(body->s, buf) || binlump)
   179 +			pkg_free(buf);
   180 +		else if (insert_new_lump_after(anchor, buf,
   181  		    omip.len + oldip->len + CRLF_LEN, 0) == NULL) {
   182  			LM_ERR("insert_new_lump_after failed\n");
   183  			pkg_free(buf);
   184 @@ -1046,6 +1064,12 @@
   185  		p= p->next;
   186  	}
   188 +	if (level & FIX_RTCPIP) {
   189 +		/* Iterate all a=rtcp: and replace ips in them. */
   190 +		if (replace_sdp_ip(msg, &body, "a=rtcp:", str2?&ip:0)==-1)
   191 +			return -1;
   192 +	}
   193 +
   194  	return 1;
   195  }
   197 Index: tls/tls_init.c
   198 diff -Nau tls/tls_init.c.orig tls/tls_init.c
   199 --- tls/tls_init.c.orig	2012-01-17 13:16:02.000000000 +0100
   200 +++ tls/tls_init.c	2012-03-30 18:34:08.540354386 +0200
   201 @@ -617,7 +617,7 @@
   202  			d->cert_file = tls_cert_file;
   203  		}
   204  		if (load_certificate(d->ctx, d->cert_file) < 0)
   205 -			return -1;
   206 +			LM_WARN("tls[%s:%d] proceeding with no certificate at all!\n", ip_addr2a(&d->addr), d->port);
   208  		/*
   209  		* load ca 
   210 @@ -629,7 +629,7 @@
   211  			d->ca_file = tls_ca_file;
   212  		}
   213  		if (d->ca_file && load_ca(d->ctx, d->ca_file) < 0)
   214 -			return -1;
   215 +			LM_WARN("tls[%s:%d] proceeding with no CA at all!\n", ip_addr2a(&d->addr), d->port);
   216  		d = d->next;
   217  	}
   219 @@ -644,7 +644,7 @@
   220  			d->pkey_file = tls_pkey_file;
   221  		}
   222  		if (load_private_key(d->ctx, d->pkey_file) < 0)
   223 -			return -1;
   224 +			LM_WARN("tls[%s:%d] proceeding with no key at all!\n", ip_addr2a(&d->addr), d->port);
   225  		d = d->next;
   226  	}
   227  	return 0;
   228 Index: menuconfig/Makefile
   229 diff -Nau menuconfig/Makefile.orig menuconfig/Makefile
   230 --- menuconfig/Makefile.orig	2012-03-26 12:11:03.000000000 +0200
   231 +++ menuconfig/Makefile	2012-08-21 21:44:18.781092313 +0200
   232 @@ -5,10 +5,10 @@
   233  CFLAGS=-g -Wall -DMENUCONFIG_CFG_PATH=\"$(MENUCONFIG_CFG_PATH)\" \
   234  			-DMENUCONFIG_GEN_PATH=\"$(MENUCONFIG_GEN_PATH)\" \
   235  			-DMENUCONFIG_HAVE_SOURCES=$(MENUCONFIG_HAVE_SOURCES)
   236 -MY_LDFLAGS=-lcurses
   237 +MY_LDFLAGS=-lncurses
   238  EXEC_NAME=configure
   239  all: $(MENUCONFIG_FILES)
   240 -	$(CC) -o $(EXEC_NAME) $(CFLAGS) $^ $(MY_LDFLAGS)
   241 +	$(CC) -o $(EXEC_NAME) $(CFLAGS) $(CPPFLAGS) $^ $(LDFLAGS) $(LIBS)
   243  proper:
   244  	rm -f $(EXEC_NAME)
   245 Index: menuconfig/Makefile
   246 diff -Nau menuconfig/Makefile.orig menuconfig/Makefile
   247 --- menuconfig/curses.c.orig	2012-03-23 11:47:37.000000000 +0100
   248 +++ menuconfig/curses.c	2012-08-21 21:49:29.506561887 +0200
   249 @@ -28,6 +28,7 @@
   250  #include<string.h>
   252  #include<sys/ioctl.h> 
   253 +#include<sys/termio.h>
   254  #include<errno.h>
   256  #include "curses.h"

mercurial