Ver Fonte

- big makefile changes
- debian fixes (works like a charm now)
- ipaddr2he bug fix
- changes rpm specs
- modified the tar makefile target
- new make vars: basedir, cfg-target, modules-target
- cfg. file modified on the fly (module-path=modules-target)
- ser default cfg. file=cfg-target
- etc.

Andrei Pelinescu-Onciul há 23 anos atrás
pai
commit
054cb6cff5
19 ficheiros alterados com 182 adições e 75 exclusões
  1. 27 13
      Makefile
  2. 49 21
      Makefile.defs
  3. 2 1
      Makefile.rules
  4. 3 1
      Makefile.sources
  5. 4 0
      cfg.lex
  6. 9 1
      cfg.y
  7. 1 1
      config.h
  8. 5 0
      debian/changelog
  9. 1 0
      debian/conffiles
  10. 1 1
      debian/control
  11. 11 7
      debian/init.d
  12. 2 0
      debian/postinst
  13. 1 2
      debian/postrm
  14. 12 9
      debian/rules
  15. 2 0
      globals.h
  16. 1 1
      ip_addr.h
  17. 37 13
      main.c
  18. 7 2
      rpm/ser.spec
  19. 7 2
      rpm/ser.spec.SuSE

+ 27 - 13
Makefile

@@ -10,7 +10,8 @@ auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
 #include  source related defs
 #include  source related defs
 include Makefile.sources
 include Makefile.sources
 
 
-exclude_modules=CVS cpl cpl-c ext radius_acc radius_auth snmp mysql 
+override exclude_modules:=CVS cpl cpl-c ext radius_acc radius_auth snmp mysql \
+	$(exclude_modules)
 static_modules=
 static_modules=
 static_modules_path=$(addprefix modules/, $(static_modules))
 static_modules_path=$(addprefix modules/, $(static_modules))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
@@ -49,7 +50,7 @@ $(NAME): static_modules
 lex.yy.c: cfg.lex $(ALLDEP)
 lex.yy.c: cfg.lex $(ALLDEP)
 	$(LEX) $<
 	$(LEX) $<
 
 
-cfg.tab.c: cfg.y $(ALLDEP)
+cfg.tab.c: cfg.y  $(ALLDEP)
 	$(YACC) $(YACC_FLAGS) $<
 	$(YACC) $(YACC_FLAGS) $<
 
 
 .PHONY: all
 .PHONY: all
@@ -85,27 +86,32 @@ dbg: ser
 
 
 .PHONY: tar
 .PHONY: tar
 tar: mantainer-clean 
 tar: mantainer-clean 
-	$(TAR) -C .. -zcf ../$(NAME)-$(RELEASE)_src.tar.gz  $(notdir $(CURDIR)) 
+	$(TAR) -C .. \
+		--exclude=$(notdir $(CURDIR))/test \
+		--exclude=$(notdir $(CURDIR))/tmp \
+		--exclude=$(notdir $(CURDIR))/debian/ser \
+		--exclude=$(notdir $(CURDIR))/debian/ser-mysql-module \
+		 -zcf ../$(NAME)-$(RELEASE)_src.tar.gz  $(notdir $(CURDIR)) 
 
 
 # binary dist. tar.gz
 # binary dist. tar.gz
 .PHONY: bin
 .PHONY: bin
 bin:
 bin:
 	mkdir -p tmp/ser/usr/local
 	mkdir -p tmp/ser/usr/local
-	$(MAKE) install prefix=tmp/ser/usr/local
+	$(MAKE) install basedir=tmp/ser prefix=/usr/local 
 	$(TAR) -C tmp/ser/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
 	$(TAR) -C tmp/ser/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
 	rm -rf tmp/ser
 	rm -rf tmp/ser
 
 
 .PHONY: deb
 .PHONY: deb
 deb:
 deb:
-	dpkg-buildpackage -rfakeroot -pgpg -sgpg
+	dpkg-buildpackage -rfakeroot -tc
 
 
 .PHONY: sunpkg
 .PHONY: sunpkg
 sunpkg:
 sunpkg:
 	mkdir -p tmp/ser
 	mkdir -p tmp/ser
 	mkdir -p tmp/ser_sun_pkg
 	mkdir -p tmp/ser_sun_pkg
-	$(MAKE) install prefix=tmp/ser
+	$(MAKE) install basedir=tmp/ser prefix=/usr/local
 	(cd solaris; \
 	(cd solaris; \
-	pkgmk -r ../tmp/ser/ -o -d ../tmp/ser_sun_pkg/ -v "$(RELEASE)" ; \
+	pkgmk -r ../tmp/ser/usr/local -o -d ../tmp/ser_sun_pkg/ -v "$(RELEASE)" ;\
 	cd ..)
 	cd ..)
 	cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
 	cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
 	pkgtrans -s tmp/ser_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
 	pkgtrans -s tmp/ser_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
@@ -147,14 +153,22 @@ $(man-prefix)/$(man-dir)/man8:
 $(man-prefix)/$(man-dir)/man5:
 $(man-prefix)/$(man-dir)/man5:
 		mkdir -p $(man-prefix)/$(man-dir)/man5
 		mkdir -p $(man-prefix)/$(man-dir)/man5
 
 
-install-cfg:
-		$(INSTALL-CFG) etc/ser.cfg $(cfg-prefix)/$(cfg-dir)
+install-cfg: $(cfg-prefix)/$(cfg-dir)
+		sed -e "s#/usr/lib/ser/modules/#$(modules-target)#g" \
+			< etc/ser.cfg > $(cfg-prefix)/$(cfg-dir)ser.cfg
+		chmod 644 $(cfg-prefix)/$(cfg-dir)ser.cfg
+#		$(INSTALL-CFG) etc/ser.cfg $(cfg-prefix)/$(cfg-dir)
 
 
-install-bin:
+install-bin: $(bin-prefix)/$(bin-dir) utils/gen_ha1/gen_ha1
 		$(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
 		$(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
+		$(INSTALL-BIN) scripts/sc $(bin-prefix)/$(bin-dir)/serctl
+		$(INSTALL-BIN) scripts/ser_mysql.sh  $(bin-prefix)/$(bin-dir)
+		$(INSTALL-BIN) utils/gen_ha1/gen_ha1 $(bin-prefix)/$(bin-dir)
 
 
+utils/gen_ha1/gen_ha1:
+		cd utils/gen_ha1; $(MAKE) all
 
 
-install-modules:
+install-modules: modules $(modules-prefix)/$(modules-dir)
 	-@for r in $(modules_full_path) "" ; do \
 	-@for r in $(modules_full_path) "" ; do \
 		if [ -n "$$r" ]; then \
 		if [ -n "$$r" ]; then \
 			$(INSTALL-MODULES)  $$r  $(modules-prefix)/$(modules-dir) ; \
 			$(INSTALL-MODULES)  $$r  $(modules-prefix)/$(modules-dir) ; \
@@ -162,10 +176,10 @@ install-modules:
 	done 
 	done 
 
 
 
 
-install-doc:
+install-doc: $(doc-prefix)/$(doc-dir)
 	$(INSTALL-DOC) README $(doc-prefix)/$(doc-dir)
 	$(INSTALL-DOC) README $(doc-prefix)/$(doc-dir)
 
 
-install-man:
+install-man: $(man-prefix)/$(man-dir)/man8 $(man-prefix)/$(man-dir)/man5
 	$(INSTALL-MAN)  ser.8 $(man-prefix)/$(man-dir)/man8
 	$(INSTALL-MAN)  ser.8 $(man-prefix)/$(man-dir)/man8
 	$(INSTALL-MAN)  ser.cfg.5 $(man-prefix)/$(man-dir)/man5
 	$(INSTALL-MAN)  ser.cfg.5 $(man-prefix)/$(man-dir)/man5
 
 

+ 49 - 21
Makefile.defs

@@ -8,18 +8,28 @@
 VERSION = 0
 VERSION = 0
 PATCHLEVEL = 8
 PATCHLEVEL = 8
 SUBLEVEL = 7
 SUBLEVEL = 7
-EXTRAVERSION = -16
+EXTRAVERSION = -99
 
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
 
 
-prefix = /usr/local
-cfg-prefix = $(prefix)
-bin-prefix = $(prefix)
-modules-prefix= $(prefix)
-doc-prefix = $(prefix)
-man-prefix = $(prefix)
+ # install location
+PREFIX = /usr/local
+prefix = $(PREFIX)
+# install path is $(basedir) $(prefix) 
+# example:
+#  creating a bin. archive in /tmp, which unpacks in /usr/local
+#  basedir=/tmp
+#  prefix=/usr/local
+basedir = 
+# install prefixes for various stuff
+cfg-prefix = $(basedir)$(prefix)
+bin-prefix = $(basedir)$(prefix)
+modules-prefix = $(basedir)$(prefix)
+doc-prefix = $(basedir)$(prefix)
+man-prefix = $(basedir)$(prefix)
+ut-prefix = $(basedir)$(prefix)
 
 
 # dirs
 # dirs
 cfg-dir = etc/ser/
 cfg-dir = etc/ser/
@@ -27,6 +37,10 @@ bin-dir = sbin/
 modules-dir = lib/ser/modules/
 modules-dir = lib/ser/modules/
 doc-dir = share/doc/ser/
 doc-dir = share/doc/ser/
 man-dir = share/man/
 man-dir = share/man/
+ut-prefix = bin/
+# target dirs for various stuff
+cfg-target = $(prefix)/$(cfg-dir)
+modules-target = $(prefix)/$(modules-dir)
 
 
 
 
 ifeq ($(OS), solaris)
 ifeq ($(OS), solaris)
@@ -37,12 +51,20 @@ else
 INSTALL = install 
 INSTALL = install 
 TAR= tar
 TAR= tar
 endif
 endif
-INSTALL-CFG = $(INSTALL) -m 644
+
+# INSTALL-CFG = $(INSTALL) -m 644
 INSTALL-BIN = $(INSTALL) -m 755
 INSTALL-BIN = $(INSTALL) -m 755
 INSTALL-MODULES = $(INSTALL) -m 755
 INSTALL-MODULES = $(INSTALL) -m 755
 INSTALL-DOC = $(INSTALL) -m 644
 INSTALL-DOC = $(INSTALL) -m 644
 INSTALL-MAN = $(INSTALL) -m 644
 INSTALL-MAN = $(INSTALL) -m 644
 
 
+#set some vars from the environment (and not make builtins)
+CC   := $(shell echo "$${CC}")
+LEX  := $(shell echo "$${LEX}")
+YACC := $(shell echo "$${YACC}")
+
+
+
 
 
 # compile-time options
 # compile-time options
 #
 #
@@ -103,16 +125,15 @@ INSTALL-MAN = $(INSTALL) -m 644
 #  		if enabled, allows forking of the snmp agent just before child
 #  		if enabled, allows forking of the snmp agent just before child
 #  		forking (done at the top of main_loop). Needed if you want
 #  		forking (done at the top of main_loop). Needed if you want
 #  		to use the snmp module.
 #  		to use the snmp module.
-
-DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
-	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
+DEFS= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
+	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' \
+	 -DCFG_DIR='"$(cfg-target)"'\
 	 -DPKG_MALLOC \
 	 -DPKG_MALLOC \
 	 -DSHM_MEM  -DSHM_MMAP \
 	 -DSHM_MEM  -DSHM_MMAP \
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
 	 -DDNS_IP_HACK \
 	 -DDNS_IP_HACK \
 	 -DUSE_IPV6 \
 	 -DUSE_IPV6 \
 	 -DF_MALLOC \
 	 -DF_MALLOC \
-	 -DEXTRA_DEBUG \
 	 #-DDBG_QM_MALLOC \
 	 #-DDBG_QM_MALLOC \
 	 #-DVQ_MALLOC  
 	 #-DVQ_MALLOC  
 	 #-DCONTACT_BUG
 	 #-DCONTACT_BUG
@@ -127,13 +148,17 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 
 
 #PROFILE=  -pg #set this if you want profiling
 #PROFILE=  -pg #set this if you want profiling
 #mode = debug
 #mode = debug
-mode = release
+ifeq ($(mode),)
+	mode = release
+endif
 
 
 # platform dependent settings
 # platform dependent settings
 
 
 
 
 #common
 #common
-CC=gcc
+ifeq ($(CC),)
+	CC=gcc
+endif
 LD= $(CC)
 LD= $(CC)
 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
 						$(CC) -v 2>&1 ;\
 						$(CC) -v 2>&1 ;\
@@ -228,8 +253,7 @@ ifeq ($(ARCH), armv4l)
 	DEFS+= -DFAST_LOCK
 	DEFS+= -DFAST_LOCK
 endif
 endif
 
 
-
-
+CFLAGS=
 # setting CFLAGS
 # setting CFLAGS
 ifeq ($(mode), release)
 ifeq ($(mode), release)
 	#if i386
 	#if i386
@@ -354,7 +378,7 @@ endif	#ARCH, i386
 
 
 	
 	
 
 
-
+LDFLAGS=
 # setting LDFLAGS
 # setting LDFLAGS
 ifeq	($(CC_NAME), gcc)
 ifeq	($(CC_NAME), gcc)
 ifeq		($(ARCH), sparc64)
 ifeq		($(ARCH), sparc64)
@@ -426,8 +450,12 @@ ifeq	($(CC_NAME), suncc)
 MOD_CFLAGS=-Kpic  $(CFLAGS)
 MOD_CFLAGS=-Kpic  $(CFLAGS)
 endif
 endif
 
 
-LEX=flex
-YACC=bison
+ifeq ($(LEX),)
+	LEX=flex
+endif
+ifeq ($(YACC),)
+	YACC=bison
+endif
 YACC_FLAGS=-d -b cfg
 YACC_FLAGS=-d -b cfg
 # on linux and freebsd keep it empty (e.g. LIBS= )
 # on linux and freebsd keep it empty (e.g. LIBS= )
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
@@ -452,9 +480,9 @@ ifeq  ($(OS), solaris)
 	YACC=yacc
 	YACC=yacc
 
 
 ifeq ($(CC_NAME), suncc)
 ifeq ($(CC_NAME), suncc)
-	LIBS=-lfast -lresolv
+	LIBS+= -lfast 
 endif
 endif
-	LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lxnet -lrt -lnsl
+	LIBS+= -L/usr/local/lib -L/usr/lib/mysql -lxnet -lrt -lnsl
 	# -lrt needed for sched_yield
 	# -lrt needed for sched_yield
 endif
 endif
 
 

+ 2 - 1
Makefile.rules

@@ -38,7 +38,7 @@ dep: $(depends)
 static: $(objs)
 static: $(objs)
 
 
 .PHONY: clean
 .PHONY: clean
-clean:
+clean: 
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
 	-@for r in $(modules) $(static_modules_path) "" ; do \
 	-@for r in $(modules) $(static_modules_path) "" ; do \
 		if [ -n "$$r" ]; then \
 		if [ -n "$$r" ]; then \
@@ -46,6 +46,7 @@ clean:
 			$(MAKE) -C $$r clean ; \
 			$(MAKE) -C $$r clean ; \
 		fi ; \
 		fi ; \
 	done
 	done
+	@if [ -n "$(modules)" ]; then cd utils/gen_ha1; $(MAKE) clean; fi
 
 
 .PHONY: proper
 .PHONY: proper
 .PHONY: distclean
 .PHONY: distclean

+ 3 - 1
Makefile.sources

@@ -11,7 +11,9 @@
 # defines: sources, objs, depends
 # defines: sources, objs, depends
 #
 #
 
 
-sources=$(filter-out $(auto_gen), $(wildcard *.c) $(wildcard mem/*.c) $(wildcard parser/*.c) $(wildcard parser/digest/*.c) $(wildcard parser/contact/*.c) $(wildcard db/*.c) ) $(auto_gen)
+sources=$(filter-out $(auto_gen), $(wildcard *.c) $(wildcard mem/*.c) \
+		$(wildcard parser/*.c) $(wildcard parser/digest/*.c) \
+		$(wildcard parser/contact/*.c) $(wildcard db/*.c) ) $(auto_gen)
 objs=$(sources:.c=.o)
 objs=$(sources:.c=.o)
 extra_objs=
 extra_objs=
 depends=$(sources:.c=.d)
 depends=$(sources:.c=.d)

+ 4 - 0
cfg.lex

@@ -106,6 +106,8 @@ FIFO fifo
 FIFO_MODE fifo_mode
 FIFO_MODE fifo_mode
 SERVER_SIGNATURE server_signature
 SERVER_SIGNATURE server_signature
 REPLY_TO_VIA reply_to_via
 REPLY_TO_VIA reply_to_via
+USER		"user"|"uid"
+GROUP		"group"|"gid"
 
 
 LOADMODULE	loadmodule
 LOADMODULE	loadmodule
 MODPARAM        modparam
 MODPARAM        modparam
@@ -200,6 +202,8 @@ EAT_ABLE	[\ \t\b\r]
 <INITIAL>{SYN_BRANCH}	{ count(); yylval.strval=yytext; return SYN_BRANCH; }
 <INITIAL>{SYN_BRANCH}	{ count(); yylval.strval=yytext; return SYN_BRANCH; }
 <INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
 <INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
 <INITIAL>{SIP_WARNING}	{ count(); yylval.strval=yytext; return SIP_WARNING; }
 <INITIAL>{SIP_WARNING}	{ count(); yylval.strval=yytext; return SIP_WARNING; }
+<INITIAL>{USER}		{ count(); yylval.strval=yytext; return USER; }
+<INITIAL>{GROUP}	{ count(); yylval.strval=yytext; return GROUP; }
 <INITIAL>{FIFO}	{ count(); yylval.strval=yytext; return FIFO; }
 <INITIAL>{FIFO}	{ count(); yylval.strval=yytext; return FIFO; }
 <INITIAL>{FIFO_MODE}	{ count(); yylval.strval=yytext; return FIFO_MODE; }
 <INITIAL>{FIFO_MODE}	{ count(); yylval.strval=yytext; return FIFO_MODE; }
 <INITIAL>{SERVER_SIGNATURE}	{ count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
 <INITIAL>{SERVER_SIGNATURE}	{ count(); yylval.strval=yytext; return SERVER_SIGNATURE; }

+ 9 - 1
cfg.y

@@ -114,6 +114,8 @@ struct id_list* lst_tmp;
 %token LOADMODULE
 %token LOADMODULE
 %token MODPARAM
 %token MODPARAM
 %token MAXBUFFER
 %token MAXBUFFER
+%token USER
+%token GROUP
 
 
 
 
 
 
@@ -273,7 +275,13 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
 		| FIFO EQUAL STRING { fifo=$3; }
 		| FIFO EQUAL STRING { fifo=$3; }
 		| FIFO EQUAL error { yyerror("string value expected"); }
 		| FIFO EQUAL error { yyerror("string value expected"); }
 		| FIFO_MODE EQUAL NUMBER { fifo_mode=$3; }
 		| FIFO_MODE EQUAL NUMBER { fifo_mode=$3; }
-		| FIFO_MODE EQUAL NUMBER { yyerror("int value expected"); }
+		| FIFO_MODE EQUAL error { yyerror("int value expected"); }
+		| USER EQUAL STRING     { user=$3; }
+		| USER EQUAL ID         { user=$3; }
+		| USER EQUAL error      { yyerror("string value expected"); }
+		| GROUP EQUAL STRING     { group=$3; }
+		| GROUP EQUAL ID         { group=$3; }
+		| GROUP EQUAL error      { yyerror("string value expected"); }
 		| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
 		| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
 		| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
 		| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
 		| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
 		| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }

+ 1 - 1
config.h

@@ -36,7 +36,7 @@
 /* default sip port if none specified */
 /* default sip port if none specified */
 #define SIP_PORT 5060
 #define SIP_PORT 5060
 
 
-#define CFG_FILE "/etc/ser/ser.cfg"
+#define CFG_FILE CFG_DIR "ser.cfg"
 
 
 
 
 /* maximum number of addresses on which we will listen */
 /* maximum number of addresses on which we will listen */

+ 5 - 0
debian/changelog

@@ -3,6 +3,11 @@ ser (0.8.7.16) unstable; urgency=low
   * First Public Release.
   * First Public Release.
 
 
  -- Andrei Pelinescu-Onciul <[email protected]>  Tue, 24 Sep 2002 21:33:39 +0200
  -- Andrei Pelinescu-Onciul <[email protected]>  Tue, 24 Sep 2002 21:33:39 +0200
+ser (0.8.7.16) unstable; urgency=low
+
+  * First Public Release.
+
+ -- Andrei Pelinescu-Onciul <[email protected]>  Tue, 24 Sep 2002 21:33:39 +0200
 
 
 ser (0.8.7.6-1) unstable; urgency=low
 ser (0.8.7.6-1) unstable; urgency=low
 
 

+ 1 - 0
debian/conffiles

@@ -1 +1,2 @@
 /etc/ser/ser.cfg
 /etc/ser/ser.cfg
+/etc/init.d/ser

+ 1 - 1
debian/control

@@ -2,7 +2,7 @@ Source: ser
 Section: net
 Section: net
 Priority: optional
 Priority: optional
 Maintainer: Andrei Pelinescu-Onciul <[email protected]>
 Maintainer: Andrei Pelinescu-Onciul <[email protected]>
-Build-Depends: debhelper (>> 3.0.0), libmysqlclient-dev
+Build-Depends: debhelper (>> 3.0.0), libmysqlclient-dev, fakeroot
 Standards-Version: 3.5.2
 Standards-Version: 3.5.2
 
 
 Package: ser
 Package: ser

+ 11 - 7
debian/init.d.ex → debian/init.d

@@ -9,12 +9,16 @@
 #
 #
 # Version:	@(#)skeleton  1.8  03-Mar-1998  [email protected]
 # Version:	@(#)skeleton  1.8  03-Mar-1998  [email protected]
 #
 #
-# This file was automatically customized by dh-make on Tue, 16 Jul 2002 15:41:31 +0200
+#  adapted for ser by Andrei Pelinescu-Onciul <[email protected]>
+# $Id$
+
 
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/sbin/ser
 DAEMON=/usr/sbin/ser
 NAME=ser
 NAME=ser
 DESC=ser
 DESC=ser
+PIDFILE=/var/run/$NAME/$NAME.pid
+PARAMS="-P $PIDFILE -u ser -g ser"
 
 
 test -f $DAEMON || exit 0
 test -f $DAEMON || exit 0
 
 
@@ -23,13 +27,13 @@ set -e
 case "$1" in
 case "$1" in
   start)
   start)
 	echo -n "Starting $DESC: $NAME"
 	echo -n "Starting $DESC: $NAME"
-	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-		--exec $DAEMON
+	start-stop-daemon --start --quiet --pidfile $PIDFILE \
+		--exec $DAEMON -- $PARAMS
 	echo "."
 	echo "."
 	;;
 	;;
   stop)
   stop)
 	echo -n "Stopping $DESC: $NAME"
 	echo -n "Stopping $DESC: $NAME"
-	start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
+	start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
 		--exec $DAEMON
 		--exec $DAEMON
 	echo "."
 	echo "."
 	;;
 	;;
@@ -43,7 +47,7 @@ case "$1" in
 	#
 	#
 	# echo "Reloading $DESC configuration files."
 	# echo "Reloading $DESC configuration files."
 	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
 	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
-	#	/var/run/$NAME.pid --exec $DAEMON
+	#	$PIDFILE --exec $DAEMON
   #;;
   #;;
   restart|force-reload)
   restart|force-reload)
 	#
 	#
@@ -53,10 +57,10 @@ case "$1" in
 	#
 	#
 	echo -n "Restarting $DESC: $NAME"
 	echo -n "Restarting $DESC: $NAME"
 	start-stop-daemon --stop --quiet --pidfile \
 	start-stop-daemon --stop --quiet --pidfile \
-		/var/run/$NAME.pid --exec $DAEMON
+		$PIDFILE --exec $DAEMON
 	sleep 1
 	sleep 1
 	start-stop-daemon --start --quiet --pidfile \
 	start-stop-daemon --start --quiet --pidfile \
-		/var/run/$NAME.pid --exec $DAEMON
+		$PIDFILE --exec $DAEMON  -- $PARAMS
 	echo "."
 	echo "."
 	;;
 	;;
   *)
   *)

+ 2 - 0
debian/postinst.ex → debian/postinst

@@ -1,4 +1,5 @@
 #! /bin/sh
 #! /bin/sh
+# $Id$
 # postinst script for ser-0.8.7
 # postinst script for ser-0.8.7
 #
 #
 # see: dh_installdeb(1)
 # see: dh_installdeb(1)
@@ -25,6 +26,7 @@ set -e
 
 
 case "$1" in
 case "$1" in
     configure)
     configure)
+        adduser --system --group --home /var/run/ser ser
 
 
     ;;
     ;;
 
 

+ 1 - 2
debian/postrm.ex → debian/postrm

@@ -1,4 +1,5 @@
 #! /bin/sh
 #! /bin/sh
+# $Id$
 # postrm script for ser-0.8.7
 # postrm script for ser-0.8.7
 #
 #
 # see: dh_installdeb(1)
 # see: dh_installdeb(1)
@@ -20,8 +21,6 @@ set -e
 
 
 case "$1" in
 case "$1" in
        purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-
-
         ;;
         ;;
 
 
     *)
     *)

+ 12 - 9
debian/rules

@@ -34,8 +34,8 @@ build-stamp: configure-stamp
 	dh_testdir
 	dh_testdir
 
 
 	# Add here commands to compile the package.
 	# Add here commands to compile the package.
-	$(MAKE) all 
-	$(MAKE) modules modules=modules/mysql
+	$(MAKE) all  exclude_modules=mysql cfg-target=/etc/ser/
+	$(MAKE) modules modules=modules/mysql cfg-target=/etc/ser/
 	#/usr/bin/docbook-to-man debian/ser.sgml > ser.1
 	#/usr/bin/docbook-to-man debian/ser.sgml > ser.1
 
 
 	touch build-stamp
 	touch build-stamp
@@ -57,14 +57,17 @@ install: build
 	dh_installdirs
 	dh_installdirs
 
 
 	# Add here commands to install the package into debian/ser
 	# Add here commands to install the package into debian/ser
-	$(MAKE) install  \
-		prefix=$(CURDIR)/debian/ser/usr \
-		cfg-prefix=$(CURDIR)/debian/ser 
-	
+	$(MAKE) install  exclude_modules=mysql \
+		basedir=$(CURDIR)/debian/ser \
+		prefix=/usr \
+		cfg-prefix=$(CURDIR)/debian/ser \
+		cfg-target=/etc/ser/
 	# install only the mysql module
 	# install only the mysql module
 	$(MAKE) install-modules modules=modules/mysql  \
 	$(MAKE) install-modules modules=modules/mysql  \
-		prefix=$(CURDIR)/debian/ser-mysql-module/usr \
-		cfg-prefix=$(CURDIR)/debian/ser-mysql-module 
+		basedir=$(CURDIR)/debian/ser-mysql-module \
+		prefix=/usr \
+		cfg-prefix=$(CURDIR)/debian/ser-mysql-module \
+		cfg-target=/etc/ser/
 	#dh_movefiles
 	#dh_movefiles
 
 
 
 
@@ -84,7 +87,7 @@ binary-common:
 #	dh_installemacsen
 #	dh_installemacsen
 #	dh_installpam
 #	dh_installpam
 #	dh_installmime
 #	dh_installmime
-#	dh_installinit
+	dh_installinit
 	dh_installcron
 	dh_installcron
 	dh_installman
 	dh_installman
 	dh_installinfo
 	dh_installinfo

+ 2 - 0
globals.h

@@ -74,6 +74,8 @@ extern int syn_branch;
 /* extern int process_no; */
 /* extern int process_no; */
 extern int sip_warning;
 extern int sip_warning;
 extern int server_signature;
 extern int server_signature;
+extern char* user;
+extern char* group;
 /*
 /*
  * debug & log_stderr moved to dprint.h*/
  * debug & log_stderr moved to dprint.h*/
 
 

+ 1 - 1
ip_addr.h

@@ -418,7 +418,7 @@ static inline struct hostent* ip_addr2he(char* name, int len,
 	p_aliases[0]=0; /* no aliases*/
 	p_aliases[0]=0; /* no aliases*/
 	p_addr[1]=0; /* only one address*/
 	p_addr[1]=0; /* only one address*/
 	p_addr[0]=address;
 	p_addr[0]=address;
-	strncpy(hostname, name, (len<256)?len:256);
+	strncpy(hostname, name, (len<256)?len+1:256);
 	if (ip->len>16) return 0;
 	if (ip->len>16) return 0;
 	memcpy(address, ip->u.addr, ip->len);
 	memcpy(address, ip->u.addr, ip->len);
 	
 	

+ 37 - 13
main.c

@@ -42,6 +42,8 @@
 #include <sys/fcntl.h>
 #include <sys/fcntl.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/wait.h>
+#include <pwd.h>
+#include <grp.h>
 #include <signal.h>
 #include <signal.h>
 
 
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
@@ -247,6 +249,8 @@ int server_signature=1;
 int received_dns = 0;      
 int received_dns = 0;      
 char* working_dir = 0;
 char* working_dir = 0;
 char* chroot_dir = 0;
 char* chroot_dir = 0;
+char* user=0;
+char* group=0;
 int uid = 0;
 int uid = 0;
 int gid = 0;
 int gid = 0;
 /* a hint to reply modules whether they should send reply
 /* a hint to reply modules whether they should send reply
@@ -869,6 +873,8 @@ int main(int argc, char** argv)
 	char port_no_str[MAX_PORT_LEN];
 	char port_no_str[MAX_PORT_LEN];
 	int port_no_str_len;
 	int port_no_str_len;
 	int ret;
 	int ret;
+	struct passwd *pw_entry;
+	struct group  *gr_entry;
 
 
 	/*init*/
 	/*init*/
 	port_no_str_len=0;
 	port_no_str_len=0;
@@ -1027,19 +1033,10 @@ int main(int argc, char** argv)
 					chroot_dir=optarg;
 					chroot_dir=optarg;
 					break;
 					break;
 			case 'u':
 			case 'u':
-					uid=strtol(optarg, &tmp, 10);
-					if ((tmp==0) ||(*tmp)){
-						fprintf(stderr, "bad uid number: -u %s\n", optarg);
-						goto error;
-					}
-					/* test if string?*/
+					user=optarg;
 					break;
 					break;
 			case 'g':
 			case 'g':
-					gid=strtol(optarg, &tmp, 10);
-					if ((tmp==0) ||(*tmp)){
-						fprintf(stderr, "bad gid number: -g %s\n", optarg);
-						goto error;
-					}
+					group=optarg;
 					break;
 					break;
 			case 'P':
 			case 'P':
 					pid_file=optarg;
 					pid_file=optarg;
@@ -1130,6 +1127,33 @@ int main(int argc, char** argv)
 #endif
 #endif
 	
 	
 	if (working_dir==0) working_dir="/";
 	if (working_dir==0) working_dir="/";
+	
+	/* get uid/gid */
+	if (user){
+		uid=strtol(user, &tmp, 10);
+		if ((tmp==0) ||(*tmp)){
+			/* maybe it's a string */
+			pw_entry=getpwnam(user);
+			if (pw_entry==0){
+				fprintf(stderr, "bad user name/uid number: -u %s\n", user);
+				goto error;
+			}
+			uid=pw_entry->pw_uid;
+			gid=pw_entry->pw_gid;
+		}
+	}
+	if (group){
+		gid=strtol(user, &tmp, 10);
+		if ((tmp==0) ||(*tmp)){
+			/* maybe it's a string */
+			gr_entry=getgrnam(group);
+			if (gr_entry==0){
+				fprintf(stderr, "bad group name/gid number: -u %s\n", group);
+				goto error;
+			}
+			gid=gr_entry->gr_gid;
+		}
+	}
 
 
 	if (sock_no==0) {
 	if (sock_no==0) {
 		/* try to get all listening ipv4 interfaces */
 		/* try to get all listening ipv4 interfaces */
@@ -1196,7 +1220,6 @@ int main(int argc, char** argv)
 			if (add_alias(*h, strlen(*h))<0){
 			if (add_alias(*h, strlen(*h))<0){
 				LOG(L_ERR, "ERROR: main: add_alias failed\n");
 				LOG(L_ERR, "ERROR: main: add_alias failed\n");
 			}
 			}
-		
 		hostent2ip_addr(&sock_info[r].address, he, 0); /*convert to ip_addr 
 		hostent2ip_addr(&sock_info[r].address, he, 0); /*convert to ip_addr 
 														 format*/
 														 format*/
 		if ((tmp=ip_addr2a(&sock_info[r].address))==0) goto error;
 		if ((tmp=ip_addr2a(&sock_info[r].address))==0) goto error;
@@ -1235,7 +1258,8 @@ int main(int argc, char** argv)
 		sock_info[r].port_no_str.len=strlen(port_no_str);
 		sock_info[r].port_no_str.len=strlen(port_no_str);
 		
 		
 #ifdef EXTRA_DEBUG
 #ifdef EXTRA_DEBUG
-		printf("              %s [%s]:%s\n",sock_info[r].name.s,
+		printf("              %.*s [%s]:%s\n", sock_info[r].name.len, 
+				sock_info[r].name.s,
 				sock_info[r].address_str.s, sock_info[r].port_no_str.s);
 				sock_info[r].address_str.s, sock_info[r].port_no_str.s);
 #endif
 #endif
 	}
 	}

+ 7 - 2
rpm/ser.spec

@@ -10,7 +10,7 @@ Release:      %rel
 Packager:     Jan Janak <[email protected]>
 Packager:     Jan Janak <[email protected]>
 Copyright:    GPL
 Copyright:    GPL
 Group:        System Environment/Daemons
 Group:        System Environment/Daemons
-Source:       http://iptel.org/ser/stable/%{name}-%{ver}.tar.gz
+Source:       http://iptel.org/ser/stable/%{name}-%{ver}_src.tar.gz
 Source2:      ser.init
 Source2:      ser.init
 URL:          http://iptel.org/ser
 URL:          http://iptel.org/ser
 Vendor:       FhG Fokus
 Vendor:       FhG Fokus
@@ -43,7 +43,7 @@ entries.
 %setup
 %setup
 
 
 %build
 %build
-make all exclude_modules="%exclude"
+make all exclude_modules="%exclude" cfg-target=/%{_sysconfdir}/ser/
 cd utils/gen_ha1
 cd utils/gen_ha1
 make
 make
 
 
@@ -61,6 +61,8 @@ make install cfg-prefix=$RPM_BUILD_ROOT/%{_sysconfdir} \
 	     doc-dir=ser/ \
 	     doc-dir=ser/ \
 	     man-prefix=$RPM_BUILD_ROOT/%{_mandir} \
 	     man-prefix=$RPM_BUILD_ROOT/%{_mandir} \
 	     man-dir="" \
 	     man-dir="" \
+		 cfg-target=/%{_sysconfdir}/ser/ \
+		 modules-target=/%{_libdir}/ser/modules/ \
 	     exclude_modules="%exclude"
 	     exclude_modules="%exclude"
 
 
 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
@@ -138,6 +140,9 @@ fi
 
 
 
 
 %changelog
 %changelog
+* Wed Sep 25 2002 Andrei Pelinescu - Onciul  <[email protected]>
+- modified make install & make: added cfg-target & modules-target
+
 * Sun Sep 08 2002 Jan Janak <[email protected]>
 * Sun Sep 08 2002 Jan Janak <[email protected]>
 - Created subpackage containing mysql connectivity support.
 - Created subpackage containing mysql connectivity support.
 
 

+ 7 - 2
rpm/ser.spec.SuSE

@@ -10,7 +10,7 @@ Release:      %rel
 Packager:     Nils Ohlmeier <[email protected]>
 Packager:     Nils Ohlmeier <[email protected]>
 Copyright:    GPL
 Copyright:    GPL
 Group:        System Environment/Daemons
 Group:        System Environment/Daemons
-Source:       http://iptel.org/ser/stable/%{name}-%{ver}.tar.gz
+Source:       http://iptel.org/ser/stable/%{name}-%{ver}_src.tar.gz
 Source2:      ser.init.SuSE
 Source2:      ser.init.SuSE
 URL:          http://iptel.org/ser
 URL:          http://iptel.org/ser
 Vendor:       FhG Fokus
 Vendor:       FhG Fokus
@@ -43,7 +43,7 @@ entries.
 %setup
 %setup
 
 
 %build
 %build
-make all exclude_modules="%exclude"
+make all cfg-target=/%{_sysconfdir}/ser/ exclude_modules="%exclude"
 cd utils/gen_ha1
 cd utils/gen_ha1
 make
 make
 
 
@@ -61,6 +61,8 @@ make install cfg-prefix=$RPM_BUILD_ROOT/%{_sysconfdir} \
 	     doc-dir=ser/ \
 	     doc-dir=ser/ \
 	     man-prefix=$RPM_BUILD_ROOT/%{_mandir} \
 	     man-prefix=$RPM_BUILD_ROOT/%{_mandir} \
 	     man-dir="" \
 	     man-dir="" \
+		 cfg-target=/%{_sysconfdir}/ser/ \
+		 modules-target=/%{_libdir}/ser/modules/ \
 	     exclude_modules="%exclude"
 	     exclude_modules="%exclude"
 
 
 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init.d
 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init.d
@@ -139,6 +141,9 @@ sbin/insserv etc/init.d/
 
 
 
 
 %changelog
 %changelog
+* Wed Sep 25 2002 Andrei Pelinescu - Onciul  <[email protected]>
+- modified make install & make: added cfg-target & modules-target
+
 * Wen Sep 25 2002 Nils Ohlmeier <[email protected]>
 * Wen Sep 25 2002 Nils Ohlmeier <[email protected]>
 - Copyed mysql connectivity subpackage from orig rpm.spec.
 - Copyed mysql connectivity subpackage from orig rpm.spec.