1 diff -Nur openswan-2.4.5rc5/programs/loggerfix openswan-2.4.5rc5.patched/programs/loggerfix
2 --- openswan-2.4.5rc5/programs/loggerfix 1970-01-01 01:00:00.000000000 +0100
3 +++ openswan-2.4.5rc5.patched/programs/loggerfix 2006-03-29 01:20:44.000000000 +0200
6 +# use filename instead of /dev/null to log, but dont log to flash or ram
7 +# pref. log to nfs mount
8 +echo "$*" >> /dev/null
10 diff -Nur openswan-2.4.5rc5/programs/look/look.in openswan-2.4.5rc5.patched/programs/look/look.in
11 --- openswan-2.4.5rc5/programs/look/look.in 2005-08-18 16:10:09.000000000 +0200
12 +++ openswan-2.4.5rc5.patched/programs/look/look.in 2006-03-29 01:20:44.000000000 +0200
15 pat="$pat|$defaultroutephys\$|$defaultroutevirt\$"
17 - for i in `echo "$IPSECinterfaces" | sed 's/=/ /'`
18 + for i in `echo "$IPSECinterfaces" | tr '=' ' '`
22 diff -Nur openswan-2.4.5rc5/programs/manual/manual.in openswan-2.4.5rc5.patched/programs/manual/manual.in
23 --- openswan-2.4.5rc5/programs/manual/manual.in 2005-11-18 06:18:33.000000000 +0100
24 +++ openswan-2.4.5rc5.patched/programs/manual/manual.in 2006-03-29 01:20:44.000000000 +0200
29 - }' | sed ':a;N;$!ba;s/\n/ /g'`"
34 diff -Nur openswan-2.4.5rc5/programs/_plutorun/_plutorun.in openswan-2.4.5rc5.patched/programs/_plutorun/_plutorun.in
35 --- openswan-2.4.5rc5/programs/_plutorun/_plutorun.in 2006-01-06 00:45:00.000000000 +0100
36 +++ openswan-2.4.5rc5.patched/programs/_plutorun/_plutorun.in 2006-03-29 01:20:44.000000000 +0200
41 - if test ! -w "`dirname $stderrlog`"
42 + if test ! -w "`echo $stderrlog | sed -r 's/(^.*\/)(.*$)/\1/'`"
44 echo Cannot write to directory to create \"$stderrlog\".
46 diff -Nur openswan-2.4.5rc5/programs/_realsetup/_realsetup.in openswan-2.4.5rc5.patched/programs/_realsetup/_realsetup.in
47 --- openswan-2.4.5rc5/programs/_realsetup/_realsetup.in 2005-07-28 02:23:48.000000000 +0200
48 +++ openswan-2.4.5rc5.patched/programs/_realsetup/_realsetup.in 2006-03-29 01:20:44.000000000 +0200
51 # misc pre-Pluto setup
53 - perform test -d `dirname $subsyslock` "&&" touch $subsyslock
54 + perform test -d `echo $subsyslock | sed -r 's/(^.*\/)(.*$)/\1/'` "&&" touch $subsyslock
56 if test " $IPSECforwardcontrol" = " yes"
59 lsmod 2>&1 | grep "^xfrm_user" > /dev/null && rmmod -s xfrm_user
62 - perform test -d `dirname $subsyslock` "&&" rm -f $subsyslock
63 + perform test -d `echo $subsyslock | sed -r 's/(^.*\/)(.*$)/\1/'` "&&" touch $subsyslock "&&" rm -f $subsyslock
65 perform rm -f $info $lock $plutopid
66 perform echo "...Openswan IPsec stopped" "|" $LOGONLY
67 diff -Nur openswan-2.4.5rc5/programs/send-pr/send-pr.in openswan-2.4.5rc5.patched/programs/send-pr/send-pr.in
68 --- openswan-2.4.5rc5/programs/send-pr/send-pr.in 2005-04-18 01:04:46.000000000 +0200
69 +++ openswan-2.4.5rc5.patched/programs/send-pr/send-pr.in 2006-03-29 01:20:44.000000000 +0200
72 if [ "$fieldname" != "Category" ]
74 - values=`${BINDIR}/query-pr --valid-values $fieldname | sed ':a;N;$!ba;s/\n/ /g' | sed 's/ *$//g;s/ / | /g;s/^/[ /;s/$/ ]/;'`
75 + values=`${BINDIR}/query-pr --valid-values $fieldname | tr '\n' ' ' | sed 's/ *$//g;s/ / | /g;s/^/[ /;s/$/ ]/;'`
76 valslen=`echo "$values" | wc -c`
78 values="choose from a category listed above"
81 desc="<${values} (one line)>";
83 - dpat=`echo "$desc" | sed 's/[][*+^$|\()&/]/./g'`
84 + dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`
85 echo "/^>${fieldname}:/ s/${dpat}//" >> $FIXFIL
87 echo "${fmtname}${desc}" >> $file
91 desc=" <`${BINDIR}/query-pr --field-description $fieldname` (multiple lines)>";
92 - dpat=`echo "$desc" | sed 's/[][*+^$|\()&/]/./g'`
93 + dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`
94 echo "s/^${dpat}//" >> $FIXFIL
96 echo "${fmtname}" >> $file;
100 desc="<`${BINDIR}/query-pr --field-description $fieldname` (one line)>"
101 - dpat=`echo "$desc" | sed 's/[][*+^$|\()&/]/./g'`
102 + dpat=`echo "$desc" | tr '\]\[*+^$|\()&/' '............'`
103 echo "/^>${fieldname}:/ s/${dpat}//" >> $FIXFIL
105 echo "${fmtname}${desc}" >> $file
106 diff -Nur openswan-2.4.5rc5/programs/setup/setup.in openswan-2.4.5rc5.patched/programs/setup/setup.in
107 --- openswan-2.4.5rc5/programs/setup/setup.in 2005-07-25 21:17:03.000000000 +0200
108 +++ openswan-2.4.5rc5.patched/programs/setup/setup.in 2006-03-29 01:20:44.000000000 +0200
109 @@ -117,12 +117,22 @@
112 start|--start|stop|--stop|_autostop|_autostart)
113 - if test " `id -u`" != " 0"
114 + if [ "x${USER}" != "xroot" ]
116 echo "permission denied (must be superuser)" |
117 logger -s -p $IPSECsyslog -t ipsec_setup 2>&1
121 + # make sure all required directories exist
122 + if [ ! -d /var/run/pluto ]
124 + mkdir -p /var/run/pluto
126 + if [ ! -d /var/lock/subsys ]
128 + mkdir -p /var/lock/subsys
130 tmp=/var/run/pluto/ipsec_setup.st
131 outtmp=/var/run/pluto/ipsec_setup.out
133 diff -Nur openswan-2.4.5rc5/programs/showhostkey/showhostkey.in openswan-2.4.5rc5.patched/programs/showhostkey/showhostkey.in
134 --- openswan-2.4.5rc5/programs/showhostkey/showhostkey.in 2004-11-14 14:40:41.000000000 +0100
135 +++ openswan-2.4.5rc5.patched/programs/showhostkey/showhostkey.in 2006-03-29 01:20:44.000000000 +0200
140 -host="`hostname --fqdn`"
141 +host="`cat /proc/sys/kernel/hostname`"
145 diff -Nur openswan-2.4.5rc5/programs/_startklips/_startklips.in openswan-2.4.5rc5.patched/programs/_startklips/_startklips.in
146 --- openswan-2.4.5rc5/programs/_startklips/_startklips.in 2005-11-25 00:08:05.000000000 +0100
147 +++ openswan-2.4.5rc5.patched/programs/_startklips/_startklips.in 2006-03-29 01:23:54.000000000 +0200
148 @@ -262,15 +262,15 @@
149 echo "FATAL ERROR: Both KLIPS and NETKEY IPsec code is present in kernel"
152 -if test ! -f $ipsecversion && test ! -f $netkey && modprobe -qn ipsec
153 +if test ! -f $ipsecversion && test ! -f $netkey && insmod ipsec
155 # statically compiled KLIPS/NETKEY not found; try to load the module
160 if test ! -f $ipsecversion && test ! -f $netkey
167 @@ -278,21 +278,21 @@
173 - modprobe -qv ipcomp
177 # xfrm4_tunnel is needed by ipip and ipcomp
178 - modprobe -qv xfrm4_tunnel
179 + insmod -qv xfrm4_tunnel
180 # xfrm_user contains netlink support for IPsec
181 - modprobe -qv xfrm_user
182 - modprobe -qv hw_random
183 + insmod -qv xfrm_user
184 + insmod -qv hw_random
185 # padlock must load before aes module
186 - modprobe -qv padlock
188 # load the most common ciphers/algo's
200 @@ -308,10 +308,10 @@
202 unset MODPATH MODULECONF # no user overrides!
203 depmod -a >/dev/null 2>&1
204 - modprobe -qv hw_random
205 + insmod -qv hw_random
206 # padlock must load before aes module
207 - modprobe -qv padlock
212 if test ! -f $ipsecversion
214 diff -Nur openswan-2.4.5rc5/programs/_startklips/_startklips.in.orig openswan-2.4.5rc5.patched/programs/_startklips/_startklips.in.orig
215 --- openswan-2.4.5rc5/programs/_startklips/_startklips.in.orig 1970-01-01 01:00:00.000000000 +0100
216 +++ openswan-2.4.5rc5.patched/programs/_startklips/_startklips.in.orig 2005-11-25 00:08:05.000000000 +0100
219 +# KLIPS startup script
220 +# Copyright (C) 1998, 1999, 2001, 2002 Henry Spencer.
222 +# This program is free software; you can redistribute it and/or modify it
223 +# under the terms of the GNU General Public License as published by the
224 +# Free Software Foundation; either version 2 of the License, or (at your
225 +# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
227 +# This program is distributed in the hope that it will be useful, but
228 +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
229 +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
234 +me='ipsec _startklips' # for messages
236 +# KLIPS-related paths
237 +sysflags=/proc/sys/net/ipsec
238 +modules=/proc/modules
239 +# full rp_filter path is $rpfilter1/interface/$rpfilter2
240 +rpfilter1=/proc/sys/net/ipv4/conf
242 +# %unchanged or setting (0, 1, or 2)
244 +ipsecversion=/proc/net/ipsec_version
245 +moduleplace=/lib/modules/`uname -r`/kernel/net/ipsec
246 +bareversion=`uname -r | sed -e 's/\.nptl//' | sed -e 's/^\(2\.[0-9]\.[1-9][0-9]*-[1-9][0-9]*\(\.[0-9][0-9]*\)*\(\.x\)*\).*$/\1/'`
247 +moduleinstplace=/lib/modules/$bareversion/kernel/net/ipsec
248 +case $bareversion in
250 + modulename=ipsec.ko
258 +netkey=/proc/net/pfkey
265 + --log) log="$2" ; shift ;;
266 + --info) info="$2" ; shift ;;
267 + --debug) debug="$2" ; shift ;;
268 + --omtu) omtu="$2" ; shift ;;
269 + --fragicmp) fragicmp="$2" ; shift ;;
270 + --hidetos) hidetos="$2" ; shift ;;
271 + --rpfilter) rpfiltercontrol="$2" ; shift ;;
272 + --) shift ; break ;;
273 + -*) echo "$me: unknown option \`$1'" >&2 ; exit 2 ;;
281 +# some shell functions, to clarify the actual code
283 +# set up a system flag based on a variable
284 +# sysflag value shortname default flagname
290 + if test ! -f $sysflags/$4
292 + if test " $v" != " $3"
294 + echo "cannot do $2=$v, $sysflags/$4 does not exist"
297 + return # can't set, but it's the default anyway
302 + *) echo "unknown (not yes/no) $2 value \`$1'"
307 + yes) echo 1 >$sysflags/$4 ;;
308 + no) echo 0 >$sysflags/$4 ;;
312 +# set up a Klips interface
314 + # pull apart the interface spec
315 + virt=`expr $1 : '\([^=]*\)=.*'`
316 + phys=`expr $1 : '[^=]*=\(.*\)'`
319 + *) echo "invalid interface \`$virt' in \`$1'" ; exit 1 ;;
322 + # figure out ifconfig for interface
324 + eval `ifconfig $phys |
325 + awk '$1 == "inet" && $2 ~ /^addr:/ && $NF ~ /^Mask:/ {
330 + print "type=broadcast"
331 + else if ($4 == "P-t-P")
332 + print "type=pointopoint"
333 + else if (NF == 5) {
337 + print "type=unknown"
338 + print "otheraddr=" other
341 + if test " $addr" = " "
343 + echo "unable to determine address of \`$phys'"
346 + if test " $type" = " unknown"
348 + echo "\`$phys' is of an unknown type"
351 + if test " $omtu" != " "
357 + echo "KLIPS $virt on $phys $addr/$mask $type $otheraddr $mtu" | logonly
361 + # attach the interface and bring it up
362 + ipsec tncfg --attach --virtual $virt --physical $phys
363 + ifconfig $virt inet $addr $type $otheraddr netmask $mask $mtu
366 + # if %defaultroute, note the facts
367 + if test " $2" != " "
370 + echo "defaultroutephys=$phys"
371 + echo "defaultroutevirt=$virt"
372 + echo "defaultrouteaddr=$addr"
373 + if test " $2" != " 0.0.0.0"
375 + echo "defaultroutenexthop=$2"
379 + echo '#dr: no default route' >>$info
382 + # check for rp_filter trouble
383 + checkif $phys # thought to be a problem only on phys
386 +# check an interface for problems
389 + rpf=$rpfilter1/$1/$rpfilter2
393 + if test " $r" != " 0"
395 + case "$r-$rpfiltercontrol" in
396 + 0-%unchanged|0-0|1-1|2-2)
400 + echo "WARNING: $1 has route filtering turned on; KLIPS may not work ($rpf is $r)"
403 + echo "WARNING: changing route filtering on $1 (changing $rpf from $r to $rpfiltercontrol)"
404 + echo "$rpfiltercontrol" >$rpf
407 + echo "ERROR: unknown rpfilter setting: $rpfiltercontrol"
410 + echo "ERROR: unknown $rpf value $r"
417 +# interfaces=%defaultroute: put ipsec0 on top of default route's interface
418 +defaultinterface() {
419 + phys=`netstat -nr |
420 + awk '$1 == "0.0.0.0" && $3 == "0.0.0.0" { print $NF }'`
421 + if test " $phys" = " "
423 + echo "no default route, %defaultroute cannot cope!!!"
426 + if test `echo " $phys" | wc -l` -gt 1
428 + echo "multiple default routes, %defaultroute cannot cope!!!"
431 + next=`netstat -nr |
432 + awk '$1 == "0.0.0.0" && $3 == "0.0.0.0" { print $2 }'`
433 + klipsinterface "ipsec0=$phys" $next
436 +# log only to syslog, not to stdout/stderr
438 + logger -p $log -t ipsec_setup
441 +# sort out which module is appropriate, changing it if necessary
443 + if [ -e /proc/kallsyms ]
445 + kernelsymbols="/proc/kallsyms";
446 + echo "calcgoo: warning: 2.6 kernel with kallsyms not supported yet"
448 + kernelsymbols="/proc/ksyms";
450 + wantgoo="`ipsec calcgoo $kernelsymbols`"
451 + module=$moduleplace/$modulename
454 + goo="`nm -ao $module | ipsec calcgoo`"
455 + if test " $wantgoo" = " $goo"
457 + return # looks right
460 + if test -f $moduleinstplace/$wantgoo
462 + echo "modprobe failed, but found matching template module $wantgoo."
463 + echo "Copying $moduleinstplace/$wantgoo to $module."
465 + mkdir -p $moduleplace
466 + cp -p $moduleinstplace/$wantgoo $module
467 + # "depmod -a" gets done by caller
475 +# load module if possible
476 +if test -f $ipsecversion && test -f $netkey
478 + # both KLIPS and NETKEY code detected, bail out
479 + echo "FATAL ERROR: Both KLIPS and NETKEY IPsec code is present in kernel"
482 +if test ! -f $ipsecversion && test ! -f $netkey && modprobe -qn ipsec
484 + # statically compiled KLIPS/NETKEY not found; try to load the module
488 +if test ! -f $ipsecversion && test ! -f $netkey
496 + if test -f $modules
500 + modprobe -qv ipcomp
501 + # xfrm4_tunnel is needed by ipip and ipcomp
502 + modprobe -qv xfrm4_tunnel
503 + # xfrm_user contains netlink support for IPsec
504 + modprobe -qv xfrm_user
505 + modprobe -qv hw_random
506 + # padlock must load before aes module
507 + modprobe -qv padlock
508 + # load the most common ciphers/algo's
516 +if test ! -f $ipsecversion && $klips
518 + if test -r $modules # kernel does have modules
520 + if [ ! -e /proc/ksyms -a ! -e /proc/kallsyms ]
522 + echo "Broken 2.6 kernel without kallsyms, skipping calcgoo (Fedora rpm?)"
526 + unset MODPATH MODULECONF # no user overrides!
527 + depmod -a >/dev/null 2>&1
528 + modprobe -qv hw_random
529 + # padlock must load before aes module
530 + modprobe -qv padlock
533 + if test ! -f $ipsecversion
535 + echo "kernel appears to lack IPsec support (neither CONFIG_KLIPS or CONFIG_NET_KEY are set)"
540 +# figure out debugging flags
544 +if test -r /proc/net/ipsec_klipsdebug
546 + echo "KLIPS debug \`$debug'" | logonly
548 + none) ipsec klipsdebug --none ;;
549 + all) ipsec klipsdebug --all ;;
550 + *) ipsec klipsdebug --none
553 + ipsec klipsdebug --set $d
559 + if test " $debug" != " none"
561 + echo "klipsdebug=\`$debug' ignored, KLIPS lacks debug facilities"
565 +# figure out misc. kernel config
566 +if test -d $sysflags
568 + sysflag "$fragicmp" "fragicmp" yes icmp
569 + echo 1 >$sysflags/inbound_policy_check # no debate
570 + sysflag no "no_eroute_pass" no no_eroute_pass # obsolete parm
571 + sysflag no "opportunistic" no opportunistic # obsolete parm
572 + sysflag "$hidetos" "hidetos" yes tos
575 + echo "WARNING: cannot adjust KLIPS flags, no $sysflags directory!"
581 + # clear tables out in case dregs have been left over
582 + ipsec eroute --clear
586 + if ip xfrm state > /dev/null 2>&1
588 + ip xfrm state flush
589 + ip xfrm policy flush
590 + elif type setkey > /dev/null 2>&1
592 + # Check that the setkey command is available.
594 + PATH=$PATH:/usr/local/sbin
595 + for dir in `echo $PATH | tr ':' ' '`
597 + if test -f $dir/setkey -a -x $dir/setkey
599 + setkeycmd=$dir/setkey
600 + break # NOTE BREAK OUT
607 + echo "WARNING: cannot flush state/policy database -- \`$1'. Install a newer version of iproute/iproute2 or install the ipsec-tools package to obtain the setkey command." |
608 + logger -s -p daemon.error -t ipsec_setup
612 +# figure out interfaces
616 + ipsec*=?*) klipsinterface "$i" ;;
617 + %defaultroute) defaultinterface ;;
618 + *) echo "interface \`$i' not understood"