Browse code

- merged from stable (rel0_8_11): - kill_all_children (fixes 'we kill our launching script bug ') - debian updates - tm & sl destroy when not init fixes - ver no. updated

Andrei Pelinescu-Onciul authored on 30/06/2003 15:48:44
Showing 26 changed files
... ...
@@ -26,7 +26,6 @@
26 26
 #  2003-06-06  moved compiler detection before DEFS (andrei)
27 27
 #  2003-06-10  removed -m32 for gcc 3.x/sparc64  -- it will use 
28 28
 #              arch. default: -m32 on solaris, -m64 on *bsd (andrei)
29
-#  2003-06-29  added TLS support: TLS=1 (andrei)
30 29
 
31 30
 
32 31
 # check if already included/exported
... ...
@@ -41,7 +40,7 @@ export makefile_defs
41 41
 VERSION = 0
42 42
 PATCHLEVEL = 8
43 43
 SUBLEVEL =   12
44
-EXTRAVERSION = dev-tls01
44
+EXTRAVERSION = dev-t02
45 45
 
46 46
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
47 47
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
48 48
deleted file mode 100644
... ...
@@ -1,6 +0,0 @@
1
-ser for Debian
2
-
3
- - experimental version (under construction)
4
-
5
- -- Andrei Pelinescu-Onciul <pelinescu-onciul@fokus.gmd.de>, Tue, 16 Jul 2002 15:41:31 +0200
... ...
@@ -1,3 +1,12 @@
1
+ser (0.8.11-pre34) unstable; urgency=low
2
+
3
+  * minor bugfixes
4
+
5
+  * debian packaging changes (debhelper 4.0, init & postinst cleanups, added
6
+    examples, a.s.o)
7
+
8
+ -- Andrei Pelinescu-Onciul <pelinescu-onciul@fokus.fraunhofer.de>  Fri, 27 Jun 2003 15:14:52 +0200
9
+
1 10
 ser (0.8.11-pre30) unstable; urgency=low
2 11
 
3 12
   * minor bugfixes
4 13
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+4
0 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-/etc/ser/ser.cfg
2
-/etc/init.d/ser
... ...
@@ -2,14 +2,14 @@ Source: ser
2 2
 Section: net
3 3
 Priority: optional
4 4
 Maintainer: Andrei Pelinescu-Onciul <pelinescu-onciul@fokus.fraunhofer.de>
5
-Build-Depends: debhelper (>> 3.0.0), libmysqlclient-dev, libexpat1-dev, zlib1g-dev, libradius1-dev
5
+Build-Depends: debhelper (>= 4), libmysqlclient-dev, libexpat1-dev, zlib1g-dev, libradius1-dev
6 6
 Standards-Version: 3.5.2
7 7
 
8 8
 Package: ser
9 9
 Architecture: any
10
-Depends: ${shlibs:Depends}
10
+Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
11 11
 Suggests: ser-mysql-module, ser-jabber-module
12
-Conflicts: ser-mysql-module (< ${Source-Version}), ser-jabber-module (< ${Source-Version}), ser-radius-modules (< ${Source-Version})
12
+Conflicts: ser-mysql-module (<< ${Source-Version}), ser-jabber-module (<< ${Source-Version}), ser-radius-modules (<< ${Source-Version})
13 13
 Description: Sip Express Router, very fast and configurable SIP proxy
14 14
  ser or SIP Express Router is a very fast and flexible SIP (RFC3621)
15 15
  proxy server. Written entirely in C, ser can handle thousands calls
... ...
@@ -1,13 +1,18 @@
1
-This package was debianized by Andrei Pelinescu-Onciul <pelinescu-onciul@fokus.gmd.de> on
2
-Tue, 16 Jul 2002 15:41:31 +0200.
1
+This package was debianized by Andrei Pelinescu-Onciul
2
+<pelinescu-onciul@fokus.fraunhofer.de> on Tue, 16 Jul 2002 15:41:31 +0200.
3 3
 
4 4
 It was downloaded from http://iptel.org/ser.
5 5
 
6
-Upstream Authors: Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.gmd.de>, Bogdan Iancu <iancu@fokus.gmd.de>, Daniel-Constantin Mierla, Jan Janak <J.Janak@sh.cvut.cz>, Jiri Kuthan <jiri@iptel.org>, Nils Ohlmeier, Ricardo Baratto, Stelios Sidiroglou-Douskos 
6
+Upstream Authors: Andrei Pelinescu-Onciul
7
+<pelinescu-onciul@fokus.fraunhofer.de>, Bogdan Iancu
8
+<iancu@fokus.fraunhofer.de>, Daniel-Constantin Mierla, Jan Janak
9
+<J.Janak@sh.cvut.cz>, Jiri Kuthan <jiri@iptel.org>, Nils Ohlmeier, Ricardo
10
+Baratto, Stelios Sidiroglou-Douskos  (see AUTHORS file for details)
7 11
 
8 12
 This software is copyright (c) 2002-2003 by Fhg Fokus
9 13
 
10 14
 You are free to distribute this software under the terms of
11 15
 the GNU General Public License.
16
+
12 17
 On Debian systems, the complete text of the GNU General Public
13
-License can be found in the file `/usr/share/common-licenses/GPL�.
18
+License can be found in the file `/usr/share/common-licenses/GPL.
14 19
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-usr/bin
2
-usr/sbin
3 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-README
2
-TODO
3 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-ser_0.8.7.16_i386.deb net optional
2
-ser-mysql-module_0.8.7.16_i386.deb net optional
3 1
deleted file mode 100644
... ...
@@ -1,74 +0,0 @@
1
-#! /bin/sh
2
-#
3
-# skeleton	example file to build /etc/init.d/ scripts.
4
-#		This file should be used to construct scripts for /etc/init.d.
5
-#
6
-#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
7
-#		Modified for Debian GNU/Linux
8
-#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
9
-#
10
-# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
11
-#
12
-#  adapted for ser by Andrei Pelinescu-Onciul <pelinescu-onciul@fokus.gmd.de>
13
-# $Id$
14
-
15
-
16
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
17
-DAEMON=/usr/sbin/ser
18
-NAME=ser
19
-DESC=ser
20
-PIDFILE=/var/run/$NAME/$NAME.pid
21
-PARAMS="-P $PIDFILE -u ser -g ser"
22
-
23
-test -f $DAEMON || exit 0
24
-
25
-set -e
26
-
27
-case "$1" in
28
-  start)
29
-	echo -n "Starting $DESC: $NAME"
30
-	start-stop-daemon --start --quiet --pidfile $PIDFILE \
31
-		--exec $DAEMON -- $PARAMS
32
-	echo "."
33
-	;;
34
-  stop)
35
-	echo -n "Stopping $DESC: $NAME"
36
-	start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
37
-		--exec $DAEMON
38
-	echo "."
39
-	;;
40
-  #reload)
41
-	#
42
-	#	If the daemon can reload its config files on the fly
43
-	#	for example by sending it SIGHUP, do it here.
44
-	#
45
-	#	If the daemon responds to changes in its config file
46
-	#	directly anyway, make this a do-nothing entry.
47
-	#
48
-	# echo "Reloading $DESC configuration files."
49
-	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
50
-	#	$PIDFILE --exec $DAEMON
51
-  #;;
52
-  restart|force-reload)
53
-	#
54
-	#	If the "reload" option is implemented, move the "force-reload"
55
-	#	option to the "reload" entry above. If not, "force-reload" is
56
-	#	just the same as "restart".
57
-	#
58
-	echo -n "Restarting $DESC: $NAME"
59
-	start-stop-daemon --stop --quiet --pidfile \
60
-		$PIDFILE --exec $DAEMON
61
-	sleep 1
62
-	start-stop-daemon --start --quiet --pidfile \
63
-		$PIDFILE --exec $DAEMON  -- $PARAMS
64
-	echo "."
65
-	;;
66
-  *)
67
-	N=/etc/init.d/$NAME
68
-	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
69
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
70
-	exit 1
71
-	;;
72
-esac
73
-
74
-exit 0
... ...
@@ -26,7 +26,9 @@ set -e
26 26
 
27 27
 case "$1" in
28 28
     configure)
29
-        adduser --system --group --home /var/run/ser ser
29
+        adduser --quiet --system --group --disabled-password \
30
+                --shell /bin/false --gecos "SIP Express Router" \
31
+                --home /var/run/ser ser || true
30 32
 
31 33
     ;;
32 34
 
... ...
@@ -42,12 +44,33 @@ esac
42 42
 
43 43
 # # dh_installdeb will replace this with shell code automatically
44 44
 # # generated by other debhelper scripts.
45
+# deb_helper is not used here to avoid automatically starting ser after
46
+# the installation (dh_installinit 4.0 , from woody does not support
47
+# --nostart, if you're using a newer version is safe to comment out the 
48
+# rest of the code and add again deb_helper)
45 49
 
46
-# #DEBHELPER#
47
-echo ""
48
-echo "Next install any additional ser modules and then (re)start ser"
49
-echo "by executing command '/etc/init.d/ser start|restart'."
50
-
50
+# this will be added automatically by dh_installdocs if deb_helper is 
51
+# "enabled"
52
+if [ "$1" = "configure" ]; then
53
+	if [ -d /usr/doc -a ! -e /usr/doc/ser -a -d /usr/share/doc/ser ]; then
54
+		ln -sf ../share/doc/ser /usr/doc/ser
55
+	fi
56
+fi
57
+# end dh_installdocs section
58
+# this will be automativally added by dh_installinit if deb_helper is
59
+# "enabled
60
+if [ -x "/etc/init.d/ser" ]; then
61
+	 update-rc.d ser defaults 23 >/dev/null
62
+	 if ! invoke-rc.d ser restart ; then
63
+		echo ""
64
+		echo "ser failed to (re)start. Perhaps your configuration requires "
65
+		echo "additional modules (e.g. ser-mysql-module, ser-jabber-module "
66
+		echo "or ser-radius-modules). Next try to install any additional ser"
67
+		echo "modules you might need and then (re)start ser by executing "
68
+		echo "the command '/etc/init.d/ser start|restart'."
69
+	fi
70
+fi
71
+# end dh_installinit section
51 72
 
52 73
 exit 0
53 74
 
... ...
@@ -29,9 +29,17 @@ case "$1" in
29 29
 
30 30
 esac
31 31
 
32
+
32 33
 # dh_installdeb will replace this with shell code automatically
33 34
 # generated by other debhelper scripts.
34 35
 
35 36
 #DEBHELPER#
36 37
 
38
+if [ "$1" = "purge" ] ; then
39
+# remove user/group on purge
40
+	deluser --quiet --remove-home ser &>/dev/null || true
41
+# remove /etc/ser if empty
42
+	rmdir /etc/ser || true
43
+fi
44
+
37 45
 exit 0
... ...
@@ -8,13 +8,18 @@
8 8
 # --------
9 9
 #  2003-05-30  updated for the 0.8.11 release, changed modules list and
10 10
 #              some ser make options (andrei)
11
+#  2003-06-27  changed to DH_COMPAT 4 (debian/compat) + other filenames
12
+#              & small fixes (andrei)
11 13
 
12 14
 
13 15
 # Uncomment this to turn on verbose mode.
14 16
 #export DH_VERBOSE=1
15 17
 
16 18
 # This is the debhelper compatibility version to use.
17
-export DH_COMPAT=3
19
+# export DH_COMPAT=4
20
+#  -- already set in compat
21
+#  force no striping (always include debug symbols for now)
22
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
18 23
 
19 24
 # modules not in the "main" package or unstable 
20 25
 EXCLUDED_MODULES=	mysql jabber auth_radius group_radius uri_radius \
... ...
@@ -126,7 +131,7 @@ binary-common:
126 126
 #	dh_installemacsen
127 127
 #	dh_installpam
128 128
 #	dh_installmime
129
-	dh_installinit --init-script=ser -- defaults 23
129
+	dh_installinit  -- defaults 23
130 130
 	dh_installcron
131 131
 	dh_installman
132 132
 	dh_installinfo
... ...
@@ -134,7 +139,7 @@ binary-common:
134 134
 	dh_installchangelogs 
135 135
 	dh_link
136 136
 	dh_strip
137
-	dh_compress
137
+	dh_compress 
138 138
 	dh_fixperms
139 139
 #	dh_makeshlibs
140 140
 	dh_installdeb
141 141
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-usr/lib/ser/modules
2 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-usr/lib/ser/modules/mysql.so
2 1
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+examples/acc.cfg
1
+examples/ccdiversion.cfg
2
+examples/ctd.sh
3
+examples/exec.cfg
4
+examples/logging.cfg
5
+examples/msilo.cfg
6
+examples/onr.cfg
7
+examples/pstn.cfg
8
+examples/redirect.cfg
9
+examples/replicate.cfg
10
+examples/serial_183.cfg
11
+examples/uas.cfg
12
+examples/welcome.cfg
0 13
new file mode 100644
... ...
@@ -0,0 +1,74 @@
0
+#! /bin/sh
1
+#
2
+# skeleton	example file to build /etc/init.d/ scripts.
3
+#		This file should be used to construct scripts for /etc/init.d.
4
+#
5
+#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
6
+#		Modified for Debian GNU/Linux
7
+#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
8
+#
9
+# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
10
+#
11
+#  adapted for ser by Andrei Pelinescu-Onciul <pelinescu-onciul@fokus.gmd.de>
12
+# $Id$
13
+
14
+
15
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
16
+DAEMON=/usr/sbin/ser
17
+NAME=ser
18
+DESC=ser
19
+PIDFILE=/var/run/$NAME/$NAME.pid
20
+PARAMS="-P $PIDFILE -u ser -g ser"
21
+
22
+test -f $DAEMON || exit 0
23
+
24
+set -e
25
+
26
+case "$1" in
27
+  start)
28
+	echo -n "Starting $DESC: $NAME"
29
+	start-stop-daemon --start --quiet --pidfile $PIDFILE \
30
+		--exec $DAEMON -- $PARAMS
31
+	echo "."
32
+	;;
33
+  stop)
34
+	echo -n "Stopping $DESC: $NAME"
35
+	start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
36
+		--exec $DAEMON
37
+	echo "."
38
+	;;
39
+  #reload)
40
+	#
41
+	#	If the daemon can reload its config files on the fly
42
+	#	for example by sending it SIGHUP, do it here.
43
+	#
44
+	#	If the daemon responds to changes in its config file
45
+	#	directly anyway, make this a do-nothing entry.
46
+	#
47
+	# echo "Reloading $DESC configuration files."
48
+	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
49
+	#	$PIDFILE --exec $DAEMON
50
+  #;;
51
+  restart|force-reload)
52
+	#
53
+	#	If the "reload" option is implemented, move the "force-reload"
54
+	#	option to the "reload" entry above. If not, "force-reload" is
55
+	#	just the same as "restart".
56
+	#
57
+	echo -n "Restarting $DESC: $NAME"
58
+	start-stop-daemon --oknodo --stop --quiet --pidfile \
59
+		$PIDFILE --exec $DAEMON
60
+	sleep 1
61
+	start-stop-daemon --start --quiet --pidfile \
62
+		$PIDFILE --exec $DAEMON  -- $PARAMS
63
+	echo "."
64
+	;;
65
+  *)
66
+	N=/etc/init.d/$NAME
67
+	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
68
+	echo "Usage: $N {start|stop|restart|force-reload}" >&2
69
+	exit 1
70
+	;;
71
+esac
72
+
73
+exit 0
0 74
deleted file mode 100644
... ...
@@ -1,7 +0,0 @@
1
-# Automatically added by dh_installdocs
2
-if [ "$1" = "configure" ]; then
3
-	if [ -d /usr/doc -a ! -e /usr/doc/ser -a -d /usr/share/doc/ser ]; then
4
-		ln -sf ../share/doc/ser /usr/doc/ser
5
-	fi
6
-fi
7
-# End automatically added section
8 1
deleted file mode 100644
... ...
@@ -1,5 +0,0 @@
1
-# Automatically added by dh_installdocs
2
-if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/ser ]; then
3
-	rm -f /usr/doc/ser
4
-fi
5
-# End automatically added section
6 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-shlibs:Depends=libc6 (>= 2.2.5-13)
... ...
@@ -40,8 +40,9 @@
40 40
  *               after daemonize (so that we won't catch anymore our own
41 41
  *               SIGCHLD generated when becoming session leader) (andrei)
42 42
  *              changed is_main default value to 1 (andrei)
43
- *  2003-06-29  preliminary tls support (andrei)
44
- *              replaced port_no_str snprintf w/ int2str (andrei)
43
+ *  2003-06-28  kill_all_children is now used instead of kill(0, sig)
44
+ *                see comment above it for explanations. (andrei)
45
+ *  2003-06-29  replaced port_no_str snprintf w/ int2str (andrei)
45 46
  *
46 47
  */
47 48
 
... ...
@@ -267,6 +268,8 @@ void receive_stdin_loop()
267 267
 
268 268
 /* global vars */
269 269
 
270
+int own_pgid = 0; /* whether or not we have our own pgid (and it's ok
271
+					 to use kill(0, sig) */
270 272
 char* cfg_file = 0;
271 273
 unsigned int maxbuffer = MAX_RECV_BUFFER_SIZE; /* maximum buffer size we do
272 274
 												  not want to exceed durig the
... ...
@@ -460,6 +463,8 @@ int daemonize(char*  name)
460 460
 	/* become session leader to drop the ctrl. terminal */
461 461
 	if (setsid()<0){
462 462
 		LOG(L_WARN, "setsid failed: %s\n",strerror(errno));
463
+	}else{
464
+		own_pgid=1; /* we have our own process group */
463 465
 	}
464 466
 	/* fork again to drop group  leadership */
465 467
 	if ((pid=fork())<0){
... ...
@@ -535,6 +540,29 @@ error:
535 535
 
536 536
 
537 537
 
538
+/* tries to send a signal to all our processes
539
+ * if daemonized  is ok to send the signal to all the process group,
540
+ * however if not daemonized we might end up sending the signal also
541
+ * to the shell which launched us => most signals will kill it if 
542
+ * it's not in interactive mode and we don't want this. The non-daemonized 
543
+ * case can occur when an error is encountered before daemonize is called 
544
+ * (e.g. when parsing the config file) or when ser is started in "dont-fork"
545
+ *  mode. Sending the signal to all the processes in pt[] will not work
546
+ *  for processes forked from modules (which have no correspondent entry in 
547
+ *  pt), but this can happen only in dont_fork mode (which is only for
548
+ *  debugging). So in the worst case + "dont-fork" we might leave some
549
+ *  zombies. -- andrei */
550
+static void kill_all_children(int signum)
551
+{
552
+	int r;
553
+	if (own_pgid) kill(0, signum);
554
+	else if (pt)
555
+		for (r=1; r<process_count(); r++)
556
+			if (pt[r].pid) kill(pt[r].pid, signum);
557
+}
558
+
559
+
560
+
538 561
 void handle_sigs()
539 562
 {
540 563
 	pid_t	chld;
... ...
@@ -557,7 +585,7 @@ void handle_sigs()
557 557
 				DBG("SIGTERM received, program terminates\n");
558 558
 				
559 559
 			/* first of all, kill the children also */
560
-			kill(0, SIGTERM);
560
+			kill_all_children(SIGTERM);
561 561
 
562 562
 			     /* Wait for all the children to die */
563 563
 			while(wait(0) > 0);
... ...
@@ -607,7 +635,7 @@ void handle_sigs()
607 607
 			LOG(L_INFO, "INFO: terminating due to SIGCHLD\n");
608 608
 #endif
609 609
 			/* exit */
610
-			kill(0, SIGTERM);
610
+			kill_all_children(SIGTERM);
611 611
 			while(wait(0) > 0); /* wait for all the children to terminate*/
612 612
 			cleanup(1); /* cleanup & show status*/
613 613
 			DBG("terminating due to SIGCHLD\n");
... ...
@@ -1739,14 +1767,14 @@ try_again:
1739 1739
 	
1740 1740
 	ret=main_loop();
1741 1741
 	/*kill everything*/
1742
-	kill(0, SIGTERM);
1742
+	kill_all_children(SIGTERM);
1743 1743
 	/*clean-up*/
1744 1744
 	cleanup(0);
1745 1745
 	return ret;
1746 1746
 
1747 1747
 error:
1748 1748
 	/*kill everything*/
1749
-	kill(0, SIGTERM);
1749
+	kill_all_children(SIGTERM);
1750 1750
 	/*clean-up*/
1751 1751
 	cleanup(0);
1752 1752
 	return -1;
... ...
@@ -26,6 +26,11 @@
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29
+/*
30
+ * History:
31
+ * --------
32
+ *  2003-06-27  tm_stats & friends freed on exit only if non-null (andrei)
33
+ */
29 34
 
30 35
 
31 36
 #include "defs.h"
... ...
@@ -39,7 +44,7 @@
39 39
 #include "../../fifo_server.h"
40 40
 #include "../../pt.h"
41 41
 
42
-struct t_stats *tm_stats;
42
+struct t_stats *tm_stats=0;
43 43
 
44 44
 
45 45
 /* we don't worry about locking data during reads (unlike
... ...
@@ -147,10 +152,13 @@ int init_tm_stats(void)
147 147
 
148 148
 error4:
149 149
 	shm_free(tm_stats->s_client_transactions);
150
+	tm_stats->s_client_transactions=0;
150 151
 error3:
151 152
 	shm_free(tm_stats->s_transactions);
153
+	tm_stats->s_transactions=0;
152 154
 error2:
153 155
 	shm_free(tm_stats->s_waiting);
156
+	tm_stats->s_waiting=0;
154 157
 error1:
155 158
 	shm_free(tm_stats);
156 159
 error0:
... ...
@@ -159,8 +167,13 @@ error0:
159 159
 
160 160
 void free_tm_stats()
161 161
 {
162
-	shm_free(tm_stats->s_client_transactions);
163
-	shm_free(tm_stats->s_transactions);
164
-	shm_free(tm_stats->s_waiting);
165
-	shm_free(tm_stats);
162
+	if (tm_stats!=0){
163
+		if (tm_stats->s_client_transactions) 
164
+			shm_free(tm_stats->s_client_transactions);
165
+		if (tm_stats->s_transactions)
166
+			shm_free(tm_stats->s_transactions);
167
+		if (tm_stats->s_waiting)
168
+			shm_free(tm_stats->s_waiting);
169
+		shm_free(tm_stats);
170
+	}
166 171
 }
... ...
@@ -92,6 +92,11 @@
92 92
 	a REPLY_LOCK.
93 93
 
94 94
 */
95
+/*
96
+ * History:
97
+ * --------
98
+ *  2003-06-27  timers are not unlinked if timerlist is 0 (andrei)
99
+ */
95 100
 
96 101
 #include "defs.h"
97 102
 
... ...
@@ -114,7 +119,7 @@
114 114
 #include "t_cancel.h"
115 115
 
116 116
 
117
-static struct timer_table *timertable;
117
+static struct timer_table *timertable=0;
118 118
 
119 119
 int noisy_ctimer=0;
120 120
 
... ...
@@ -463,6 +468,7 @@ void unlink_timer_lists()
463 463
 	struct timer_link  *tl, *end, *tmp;
464 464
 	enum lists i;
465 465
 
466
+	if (timertable==0) return; /* nothing to do */
466 467
 	/* remember the DELETE LIST */
467 468
 	tl = timertable->timers[DELETE_LIST].first_tl.next_tl;
468 469
 	end = & timertable->timers[DELETE_LIST].last_tl;
469 470
deleted file mode 100644
... ...
@@ -1,244 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Copyright (C) 2001-2003 Fhg Fokus
5
- *
6
- * This file is part of ser, a free SIP server.
7
- *
8
- * ser is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
- */
27
-/*
28
- * tls initialization & cleanup functions
29
- * 
30
- * History:
31
- * --------
32
- *  2003-06-29  created by andrei
33
- */
34
-#ifdef USE_TLS
35
-
36
-
37
-
38
-#include <openssl/ssl.h>
39
-#include <openssl/err.h>
40
-
41
-#include "mem/mem.h"
42
-#include "mem/shm_mem.h"
43
-#include "tcp_init.h"
44
-#include "dprint.h"
45
-
46
-
47
-
48
-#if OPENSSL_VERSION_NUMBER < 0x00906000L  /* 0.9.6*/
49
-#error "OpenSSL 0.9.6 or greater required"
50
-/* it might work ok with older versions (I think
51
- *  >= 0.9.4 should be ok), but I didn't test them
52
- *  so try them at your own risk :-) -- andrei
53
- */
54
-#endif
55
-
56
-
57
-/* global tls related data */
58
-SSL_CTX* default_ctx=0 ; /* global ssl context */
59
-
60
-int tls_log=L_INFO; /* tls log level */
61
-int tls_require_cert=0; /* require client certificate */
62
-char* tls_pkey_file=0; /* private key file name */
63
-char* tls_cert_file=0; /* certificate file name */
64
-char* tls_ca_file=0;   /* CA list file name */
65
-
66
-
67
-/* inits a sock_info structure with tls data
68
- * (calls tcp_init for the tcp part)
69
- * returns 0 on success, -1 on error */
70
-int tls_init(struct socket_info* sock_info)
71
-{
72
-	int ret;
73
-	if ((ret=tcp_init(sock_info))!=0){
74
-		LOG(L_ERR, "ERROR: tls_init: tcp_init failed on"
75
-			"%.*s:%d\n", sock_info->address_str.len,
76
-			sock_info->address_str.s, sock_info->port_no);
77
-		return ret;
78
-	}
79
-	sock_info->proto=PROTO_TLS;
80
-	/* tls specific stuff */
81
-	return 0;
82
-}
83
-
84
-
85
-/* malloc & friends functions that will be used
86
- * by libssl (we need most ssl info in shared mem.)*/
87
-
88
-void* tls_malloc(size_t size)
89
-{
90
-	return shm_malloc(size);
91
-}
92
-
93
-
94
-void tls_free(void* ptr)
95
-{
96
-	shm_free(ptr);
97
-}
98
-
99
-
100
-void* tls_realloc(void* ptr, size_t size)
101
-{
102
-	return shm_realloc(ptr, size);
103
-}
104
-
105
-
106
-/* print the ssl error stack */
107
-void tls_dump_errors(char* s)
108
-{
109
-	long err;
110
-	if ( 1 /*default_ctx */) /* only if ssl was initialized */
111
-		while((err=ERR_get_error()))
112
-			LOG(L_ERR, "%s%s\n", (s)?s:"", ERR_error_string(err,0));
113
-}
114
-
115
-
116
-
117
-/* inits ser tls support
118
- * returns 0 on success, <0 on error */
119
-int init_tls()
120
-{
121
-
122
-	
123
-	if (tls_pkey_file==0)
124
-		tls_pkey_file=TLS_PKEY_FILE;
125
-	if (tls_cert_file==0)
126
-		tls_cert_file=TLS_CERT_FILE;
127
-	if (tls_ca_file==0)
128
-		tls_ca_file=TLS_CA_FILE;
129
-	
130
-	DBG("initializing openssl...\n");
131
-	SSL_library_init();  /* don't use shm_ for SSL_library_init() */
132
-	/* init mem. alloc. for libcrypt & openssl */
133
-	CRYPTO_set_mem_functions(tls_malloc, tls_realloc,
134
-								tls_free);
135
-	
136
-	/* init the openssl library */
137
-	SSL_load_error_strings(); /* readable error messages*/
138
-	/* seed the PRNG, nothing on linux because openssl should automatically
139
-	   use /dev/urandom, see RAND_seed, RAND_add */
140
-	
141
-	/* create the ssl context */
142
-	DBG("creating the ssl context...\n");
143
-	default_ctx=SSL_CTX_new(TLSv1_method());
144
-	if (default_ctx==0){
145
-		LOG(L_ERR, "init_tls: failed to create ssl context\n");
146
-		goto error;
147
-	}
148
-	/* no passwd: */
149
-	 /* SSL_CTX_set_default_passwd_cb(ctx, callback); */
150
-	
151
-	/* set options, e.g SSL_OP_NO_SSLv2, 
152
-	 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
153
-	 */
154
-	/* SSL_CTX_set_options(ctx, options); */
155
-	
156
-	/* mode, e.g. SSL_MODE_ENABLE_PARTIAL_WRITE,
157
-	 * SSL_MODE_AUTO_RETRY */
158
-	/* SSL_CTX_set_mode(ctx, mode); */
159
-	
160
-	/* using certificates (we don't allow anonymous ciphers => at least
161
-	 * the server must have a cert)*/
162
-	/* private key */
163
-	if (SSL_CTX_use_PrivateKey_file(default_ctx, tls_pkey_file,
164
-				SSL_FILETYPE_PEM)!=1){
165
-		LOG(L_ERR, "init_tls: failed to load private key from \"%s\"\n",
166
-				tls_pkey_file);
167
-		goto error_certs;
168
-	}
169
-	if (SSL_CTX_use_certificate_chain_file(default_ctx, tls_cert_file)!=1){
170
-		/* better than *_use_certificate_file 
171
-		 * see SSL_CTX_use_certificate(3)/Notes */
172
-		LOG(L_ERR, "init_tls: failed to load certificate from \"%s\"\n",
173
-					tls_cert_file);
174
-		goto error_certs;
175
-	}
176
-	/* check if private key corresponds to the loaded ceritficate */
177
-	if (SSL_CTX_check_private_key(default_ctx)!=1){
178
-		LOG(L_CRIT, "init_tls: private key \"%s\" does not match the"
179
-				" certificate file \"%s\"\n", tls_pkey_file, tls_cert_file);
180
-		goto error_certs;
181
-	}
182
-	
183
-	/* set session id context, usefull for reusing stored sessions */
184
-	/*
185
-	if (SSL_CTX_set_session_id_context(ctx, version, version_len)!=1){
186
-		LOG(L_CRIT, "init_tls: failed to set session id\n");
187
-		goto error;
188
-	}
189
-	*/
190
-	
191
-	/* set cert. verifications options */
192
-	/* verify peer if it has a cert (to fail for no cert. add 
193
-	 *  | SSL_VERIFY_FAIL_IF_NO_PEER_CERT ); forces the server to send
194
-	 *  a client certificate request */
195
-	SSL_CTX_set_verify(default_ctx, SSL_VERIFY_PEER | ( (tls_require_cert)?
196
-			SSL_VERIFY_FAIL_IF_NO_PEER_CERT:0 ), 0);
197
-	/* SSL_CTX_set_verify_depth(ctx, 2);  -- default 9 */
198
-	/* CA locations, list */
199
-	if (tls_ca_file){
200
-		if (SSL_CTX_load_verify_locations(default_ctx, tls_ca_file, 0 )!=1){
201
-			/* we don't support ca path, we load them only from files */
202
-			LOG(L_CRIT, "init_tls: error while processing CA locations\n");
203
-			goto error_certs;
204
-		}
205
-		SSL_CTX_set_client_CA_list(default_ctx, 
206
-									SSL_load_client_CA_file(tls_ca_file));
207
-		if (SSL_CTX_get_client_CA_list(default_ctx)==0){
208
-			LOG(L_CRIT, "init_tls: error setting client CA list from <%s>\n",
209
-						tls_ca_file);
210
-			goto error_certs;
211
-		}
212
-	}
213
-	
214
-	/* DH tmp key generation -- see DSA_generate_parameters,
215
-	 * SSL_CTX_set_tmp_dh, SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE */
216
-	
217
-	/* RSA tmp key generation => we don't care, we won't accept 
218
-	 * connection to export restricted applications and tls does not
219
-	 * allow a tmp key in another sitaution */
220
-	
221
-	return 0;
222
-error_certs:
223
-	/*
224
-	SSL_CTX_free(ctx);
225
-	ctx=0;
226
-	*/
227
-error:
228
-	tls_dump_errors("tls_init:");
229
-	return -1;
230
-}
231
-
232
-
233
-
234
-void destroy_tls()
235
-{
236
-	if(default_ctx){
237
-		DBG("destroy_tls...\n");
238
-		SSL_CTX_free(default_ctx);
239
-		ERR_free_strings();
240
-		default_ctx=0; 
241
-	}
242
-}
243
-
244
-#endif
245 1
deleted file mode 100644
... ...
@@ -1,67 +0,0 @@
1
-
2
-/*
3
- * $Id$
4
- *
5
- * Copyright (C) 2001-2003 Fhg Fokus
6
- *
7
- * This file is part of ser, a free SIP server.
8
- *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
13
- *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License
25
- * along with this program; if not, write to the Free Software
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
- */
28
-/*
29
- * tls initialization & cleanup functions
30
- * 
31
- * History:
32
- * --------
33
- *  2003-06-29  created by andrei
34
- */
35
-#ifdef USE_TLS
36
-
37
-#ifndef tls_init_h
38
-#define tls_init_h
39
-
40
-#ifndef USE_TCP
41
-#error "TLS requires TCP support compiled-in, please" \
42
-        " add -DUSE_TCP to the Makefile.defs"
43
-#endif
44
-
45
-#ifndef SHM_MEM
46
-#error "shared memory support needed (add -DSHM_MEM to Makefile.defs)"
47
-#endif
48
-
49
-
50
-/* inits ser tls support
51
- * returns 0 on success, <0 on error */
52
-int init_tls();
53
-
54
-/* cleans up */
55
-void destroy_tls();
56
-
57
-/* inits a sock_info structure with tls data
58
- * (calls tcp_init for the tcp part)
59
- * returns 0 on success, -1 on error */
60
-int tls_init(struct socket_info* sock_info);
61
-
62
-/* print the ssl error stack */
63
-void tls_dump_errors(char* s);
64
-
65
-
66
-#endif /* tls_init_h*/
67
-#endif /* USE_TLS*/