b0b08526d45989d47cd916368a41558be2fadd1a
[packages.git] / ipv6 / tspc / patches / 001-debian_patches.patch
1 --- a/conf/Makefile
2 +++ b/conf/Makefile
3 @@ -34,15 +34,15 @@ tspc.conf.sample:
4         fi
5         @if [ -z "$(configdir)" ]; then \
6          if [ -z "$(installdir)" ]; then \
7 -          sed -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+`cd ..;pwd`+"  tspc.conf.in>$(BIN)/tspc.conf.sample; \
8 +          $(SED) -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+`cd ..;pwd`+"  tspc.conf.in>$(BIN)/tspc.conf.sample; \
9          else \
10 -          sed -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(installdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
11 +          $(SED) -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(installdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
12          fi \
13         else \
14 -        sed -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(configdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
15 +        $(SED) -e "s+@ifname_tun@+$(ifname_tun)+" -e "s+@ifname@+$(ifname)+" -e "s+@target@+$(target)+" -e "s+@tsp_dir@+$(configdir)+" tspc.conf.in >$(BIN)/tspc.conf.sample; \
16         fi
17  
18 -       chmod 700 $(BIN)/tspc.conf.sample
19 +       chmod 600 $(BIN)/tspc.conf.sample
20         
21  
22  clean:
23 --- a/conf/tspc.conf.in
24 +++ b/conf/tspc.conf.in
25 @@ -18,13 +18,6 @@
26  # to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
27  # MA 02111-1307 USA
28  #------------------------------------------------------------------------------
29 -#
30 -#
31 -# tsp directory:
32 -#  the only use is for the OS scripts which will be taken 
33 -#  from $tsp_dir/template
34 -#
35 -tsp_dir=@tsp_dir@
36  
37  #
38  # authentication method:
39 @@ -66,28 +59,19 @@ passwd=
40  
41  #
42  # Name of the script:
43 -# template=checktunnel|freebsd|netbsd|linux|windows|darwin|cisco|
44 -#   solaris|openbsd
45 +# template=checktunnel|setup
46  #
47  # the value is the file name of the script in the tsp_dir/template directory
48  # The script will be executed after the TSP session is completed. The script
49  #  is configuring the tunnel interface and routes.
50  # checktunnel is only printing information and does not configure any tunnel
51 -# freebsd is for FreeBSD 4.X and above
52 -# netbsd is for NetBSD 1.6 and above
53 -# linux is for Linux (most distributions)
54 -# windows is for WindowsXP
55 -# darwin is for MacOS X 10.2 and above
56 -# cisco is for Cisco IOS. This script prints the cisco configuration while
57 -#  not configuring the cisco itself.
58 -# solaris is for Solaris 8 and above.
59 -# openbsd is for OpenBSD 3.X and above
60 +# setup will do the actual work
61  # you could customize your own script, name it and put the filename in 
62  #  the template variable.
63  # on unix, '.sh' is added to the name of the script. 
64  # on windows, '.bat' is added to the name of the script.
65  # 
66 -template=@target@
67 +template=setup
68  
69  #
70  # 'server' is the tunnel broker identifier
71 --- a/platform/linux/tsp_local.c
72 +++ b/platform/linux/tsp_local.c
73 @@ -59,13 +59,13 @@
74  
75  /* these globals are defined by US used by alot of things in  */
76  
77 -char *FileName  = "tspc.conf";
78 -char *LogFile   = "tspc.log";
79 +char *FileName  = "/etc/tsp/tspc.conf";
80 +char *LogFile   = "/var/log/tspc.log";
81  char *LogFileName = NULL;
82 -char *ScriptInterpretor = "/bin/sh";
83 +char *ScriptInterpretor = "";
84  char *ScriptExtension = "sh";
85  char *ScriptDir = NULL;
86 -char *TspHomeDir = "/usr/local/etc/tsp";
87 +char *TspHomeDir = "/etc/tsp";
88  char DirSeparator = '/';
89  
90  int Verbose = 0;
91 @@ -143,7 +143,7 @@ int tspStartLocal(SOCKET socket, tConf *
92         {
93                   int tunfd;
94  
95 -                 Display(0, ELInfo, "tspStartLocal", "Going daemon, check %s for tunnel creation status", LogFile);
96 +                 Display(1, ELInfo, "tspStartLocal", "Going daemon, check %s for tunnel creation status", LogFile);
97  
98                   if (daemon(0,0) == -1) {
99                           Display(1, ELError, "tspStartLocal", "Unable to fork.");
100 --- a/src/lib/config.c
101 +++ b/src/lib/config.c
102 @@ -474,14 +474,17 @@ int tspVerifyConfig(tConf *Conf)
103    if(IsPresent(Conf->dns_server)) {
104       char *Server;
105       char *dns = strdup(Conf->dns_server);
106 +     struct addrinfo *contact;
107       if (eq(Conf->host_type, "host")) {
108         Display(1,ELError, "tspVerifyConfig", "DNS delegation is not supported for host_type=host");
109         status = 1;
110       }
111       for(Server = strtok(dns, ":");Server; Server = strtok(NULL, ":")) {
112 -        if(gethostbyname(Server) == NULL) {
113 +        if(getaddrinfo(Server, "domain", 0, &contact)!=0) {
114             Display(1,ELError, "tspVerifyConfig", "DNS server name %s is not resolving.", Server);
115             status = 1;
116 +        } else {
117 +           freeaddrinfo(contact);
118          }
119       }
120       free(dns);
121 --- a/src/tsp/tsp_client.c
122 +++ b/src/tsp/tsp_client.c
123 @@ -275,7 +275,7 @@ int tspSetupTunnel(tConf *conf, net_tool
124  
125  start_show:
126  
127 -       Display(0, ELInfo, "tspSetupTunnel", "Got tunnel parameters from server, setting up local tunnel");
128 +       Display(1, ELInfo, "tspSetupTunnel", "Got tunnel parameters from server, setting up local tunnel");
129  
130         /* and start the show */
131         ret = tspStartLocal(socket, conf, &t, nt[conf->transport]);
132 @@ -337,8 +337,8 @@ int tspMain(int argc, char *argv[]) 
133         LogInit("tspc", LogFile);
134  
135         Display( 1, ELInfo, "tspMain", "----- TSP Client Version %s Initializing -------------------------", TSP_CLIENT_VERSION);
136 -       Display( 0, ELInfo, "tspMain", IDENTIFICATION);
137 -       Display( 0, ELInfo, "tspMain", "Initializing (use -h for help)\n");
138 +       Display( 1, ELInfo, "tspMain", IDENTIFICATION);
139 +       Display( 1, ELInfo, "tspMain", "Initializing (use -h for help)\n");
140  
141         if((status = tspInitialize(argc, argv, &c)) != 0) {     // *** we have no uninitialize
142                 if (status == -1) {
143 @@ -361,12 +361,12 @@ int tspMain(int argc, char *argv[]) 
144  
145         /* first try with RUDP */
146         c.transport = NET_TOOLS_T_RUDP;
147 -       Display( 0, ELInfo, "tspMain", "\nConnecting to server with reliable udp");
148 +       Display( 1, ELInfo, "tspMain", "\nConnecting to server with reliable udp");
149  
150  try_server:
151  
152         if (c.transport == NET_TOOLS_T_TCP)
153 -               Display( 0, ELInfo, "tspMain", "\nConnecting to server with tcp");
154 +               Display( 1, ELInfo, "tspMain", "\nConnecting to server with tcp");
155  
156         Display( 1, ELInfo, "tspMain", "Using TSP protocol version %s",
157                 TspProtocolVersionStrings[version_index]); 
158 --- a/template/linux.sh
159 +++ b/template/linux.sh
160 @@ -135,9 +135,7 @@ if [ X"${TSP_HOST_TYPE}" = X"host" ] || 
161     # 
162     # Default route  
163     Display 1 "Adding default route"
164 -   ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
165     ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null  # delete old gw route
166 -   Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
167     Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
168  fi
169  
170 @@ -147,9 +145,10 @@ if [ X"${TSP_HOST_TYPE}" = X"router" ]; 
171     Display 1 "Kernel setup"
172     if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
173        #Better way on linux to avoid loop with the remaining /48?
174 -      $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE 2>/dev/null
175 +      ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE 2>/dev/null
176 +      Exec $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE
177     fi
178 -   Exec $sysctl -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
179 +   Exec $sysctl -q -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
180     Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
181     OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
182     if [ ! -z $OLDADDR ]; then
183 @@ -157,28 +156,28 @@ if [ X"${TSP_HOST_TYPE}" = X"router" ]; 
184        Exec $ifconfig $TSP_HOME_INTERFACE inet6 del $OLDADDR
185     fi
186     Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
187 -   # Router advertisement configuration 
188 -   Display 1 "Create new $rtadvdconfigfile"
189 -   echo "##### rtadvd.conf made by TSP ####" > "$rtadvdconfigfile"
190 -   echo "interface $TSP_HOME_INTERFACE" >> "$rtadvdconfigfile"
191 -   echo "{" >> "$rtadvdconfigfile"
192 -   echo " AdvSendAdvert on;" >> "$rtadvdconfigfile"
193 -   echo " prefix $TSP_PREFIX::/64" >> "$rtadvdconfigfile"
194 -   echo " {" >> "$rtadvdconfigfile"
195 -   echo " AdvOnLink on;" >> "$rtadvdconfigfile"
196 -   echo " AdvAutonomous on;" >> "$rtadvdconfigfile"
197 -   echo " };" >> "$rtadvdconfigfile"
198 -   echo "};" >> "$rtadvdconfigfile"
199 -   echo "" >> "$rtadvdconfigfile"
200 -   /etc/init.d/radvd stop
201 -   if [ -f $rtadvdconfigfile ]; then
202 -      KillProcess $rtadvdconfigfile
203 -      Exec $rtadvd -u radvd -C $rtadvdconfigfile
204 -      Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
205 -   else
206 -      echo "Error : file $rtadvdconfigfile not found"
207 -      exit 1
208 -   fi
209 +#   # Router advertisement configuration 
210 +#   Display 1 "Create new $rtadvdconfigfile"
211 +#   echo "##### rtadvd.conf made by TSP ####" > "$rtadvdconfigfile"
212 +#   echo "interface $TSP_HOME_INTERFACE" >> "$rtadvdconfigfile"
213 +#   echo "{" >> "$rtadvdconfigfile"
214 +#   echo " AdvSendAdvert on;" >> "$rtadvdconfigfile"
215 +#   echo " prefix $TSP_PREFIX::/64" >> "$rtadvdconfigfile"
216 +#   echo " {" >> "$rtadvdconfigfile"
217 +#   echo " AdvOnLink on;" >> "$rtadvdconfigfile"
218 +#   echo " AdvAutonomous on;" >> "$rtadvdconfigfile"
219 +#   echo " };" >> "$rtadvdconfigfile"
220 +#   echo "};" >> "$rtadvdconfigfile"
221 +#   echo "" >> "$rtadvdconfigfile"
222 +#   /etc/init.d/radvd stop
223 +#   if [ -f $rtadvdconfigfile ]; then
224 +#      KillProcess $rtadvdconfigfile
225 +#      Exec $rtadvd -u radvd -C $rtadvdconfigfile
226 +#      Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
227 +#   else
228 +#      echo "Error : file $rtadvdconfigfile not found"
229 +#      exit 1
230 +#   fi
231  fi
232  
233  Display 1 "--- End of configuration script. ---"