OBS User unknown 2008-12-01 17:07:56 +00:00 committed by Git OBS Bridge
parent d055136c76
commit fa26ca1d2b
3 changed files with 103 additions and 2 deletions

63
pmap_set.c Normal file
View File

@ -0,0 +1,63 @@
/*
* pmap_set - set portmapper table from data produced by pmap_dump
*
* Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
* Computing Science, Eindhoven University of Technology, The Netherlands.
*/
#include <stdio.h>
#include <sys/types.h>
#ifdef SYSV40
#include <netinet/in.h>
#endif
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
static int
parse_line(char *buf, u_long *prog, u_long *vers,
int *prot, unsigned *port);
int
main(int argc, char **argv)
{
char buf[BUFSIZ];
u_long prog;
u_long vers;
int prot;
unsigned port;
while (fgets(buf, sizeof(buf), stdin)) {
if (parse_line(buf, &prog, &vers, &prot, &port) == 0) {
fprintf(stderr, "%s: malformed line: %s", argv[0], buf);
return (1);
}
if (pmap_set(prog, vers, prot, (unsigned short) port) == 0)
fprintf(stderr, "not registered: %s", buf);
}
return (0);
}
/* parse_line - convert line to numbers */
static int
parse_line(char *buf, u_long *prog, u_long *vers,
int *prot, unsigned *port)
{
char proto_name[256];
if (sscanf(buf, "%lu %lu %255s %u", prog, vers, proto_name, port) != 4) {
return (0);
}
if (strcmp(proto_name, "tcp") == 0) {
*prot = IPPROTO_TCP;
return (1);
}
if (strcmp(proto_name, "udp") == 0) {
*prot = IPPROTO_UDP;
return (1);
}
if (sscanf(proto_name, "%d", prot) == 1) {
return (1);
}
return (0);
}

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon Dec 1 12:29:50 CET 2008 - mkoenig@suse.de
- if upgrading from portmap:
* we need to stop portmap and start rpcbind in %post since the
restart on upgrade mechanism does not work here
* dump portmap tables and set them again in rpcbind [bnc#446388]
- add pmap_set.c which is needed to set the old portmap tables
in rpcbind
-------------------------------------------------------------------
Wed Nov 26 14:18:06 CET 2008 - mkoenig@suse.de

View File

@ -24,17 +24,19 @@ License: BSD 3-Clause
Group: Productivity/Networking/System
AutoReqProv: on
Version: 0.1.6+git20080930
Release: 3
Release: 4
Summary: Transport independent RPC portmapper
Url: http://nfsv4.bullopensource.org/doc/tirpc_rpcbind.php
Source: %{name}-%{version}.tar.bz2
Source1: rpcbind.init
Source2: sysconfig.rpcbind
Source3: rpcbind.xml
Source4: pmap_set.c
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Provides: portmap = 6.0+git20070716
Obsoletes: portmap <= 6.0+git20070716
PreReq: %insserv_prereq %fillup_prereq
%define statefile /var/lib/portmap.state
%description
Rpcbind is a replacement for portmap. Whereas portmap supports only UDP
@ -52,6 +54,7 @@ Authors:
%prep
%setup
cp %{SOURCE4} .
%build
autoreconf -fi
@ -66,6 +69,7 @@ autoreconf -fi
CFLAGS="$RPM_OPT_FLAGS -fpie" \
LDFLAGS="-pie"
make
gcc -o pmap_set $RPM_OPT_FLAGS pmap_set.c
%install
make install DESTDIR=$RPM_BUILD_ROOT
@ -80,12 +84,20 @@ mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/var/adm/fillup-templates/
mkdir -p $RPM_BUILD_ROOT%_datadir/omc/svcinfo.d
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%_datadir/omc/svcinfo.d/
#
install -m 755 pmap_set $RPM_BUILD_ROOT/sbin/pmap_set
%clean
rm -rf $RPM_BUILD_ROOT
%pre
# upgrade case from portmap
# 1. if portmap is running, dump portmap tables
if checkproc /sbin/portmap; then
rm -f %statefile
test -x /sbin/pmap_dump && /sbin/pmap_dump > %statefile
fi
# 2. disable portmap service to be able to enable rpcbind
if test -x /sbin/portmap && chkconfig -c portmap 3; then
/sbin/insserv -f -r portmap
fi
@ -95,6 +107,14 @@ fi
%post
%fillup_and_insserv -y rpcbind
# if portmap is running, we need to stop portmap *now*,
# start rpcbind and restore the old tables
if test -r %statefile; then
/etc/init.d/portmap stop > /dev/null || :
/etc/init.d/rpcbind start > /dev/null || :
/sbin/pmap_set < %statefile
rm -f %statefile
fi
%postun
%restart_on_update rpcbind
@ -103,6 +123,7 @@ fi
%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README
/sbin/pmap_set
/sbin/rpcbind
/sbin/rpcinfo
%doc %{_mandir}/*/*
@ -113,6 +134,13 @@ fi
%{_datadir}/omc/svcinfo.d/rpcbind.xml
%changelog
* Mon Dec 01 2008 mkoenig@suse.de
- if upgrading from portmap:
* we need to stop portmap and start rpcbind in %%post since the
restart on upgrade mechanism does not work here
* dump portmap tables and set them again in rpcbind [bnc#446388]
- add pmap_set.c which is needed to set the old portmap tables
in rpcbind
* Wed Nov 26 2008 mkoenig@suse.de
- specify runlevel in chkconfig check [bnc#444663]
* Wed Nov 05 2008 mkoenig@suse.de