summarylogtreecommitdiffstats
path: root/cvs-2013.patch
blob: e9469f752211df59a6a396b90e6688cff04f5566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
diff -purN vtun-3.0.3/auth.c vtun/auth.c
--- vtun-3.0.3/auth.c	2009-05-15 11:23:39.000000000 +0400
+++ vtun/auth.c	2013-07-07 23:54:20.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: auth.c,v 1.9.2.4 2009/04/24 09:15:33 mtbishop Exp $
+ * $Id: auth.c,v 1.9.2.5 2013/07/07 19:54:20 mtbishop Exp $
  */ 
 
 /*
@@ -62,12 +62,12 @@
 #include <openssl/blowfish.h>
 #include <openssl/rand.h>
 
-void gen_chal(char *buf)
+static void gen_chal(char *buf)
 {
    RAND_bytes(buf, VTUN_CHAL_SIZE);
 }
 
-void encrypt_chal(char *chal, char *pwd)
+static void encrypt_chal(char *chal, char *pwd)
 { 
    register int i;
    BF_KEY key;
@@ -78,7 +78,7 @@ void encrypt_chal(char *chal, char *pwd)
       BF_ecb_encrypt(chal + i,  chal + i, &key, BF_ENCRYPT);
 }
 
-void decrypt_chal(char *chal, char *pwd)
+static void decrypt_chal(char *chal, char *pwd)
 { 
    register int i;
    BF_KEY key;
@@ -91,7 +91,7 @@ void decrypt_chal(char *chal, char *pwd)
 
 #else /* HAVE_SSL */
 
-void encrypt_chal(char *chal, char *pwd)
+static void encrypt_chal(char *chal, char *pwd)
 { 
    char * xor_msk = pwd;
    register int i, xor_len = strlen(xor_msk);
@@ -100,13 +100,13 @@ void encrypt_chal(char *chal, char *pwd)
       chal[i] ^= xor_msk[i%xor_len];
 }
 
-void inline decrypt_chal(char *chal, char *pwd)
+static void inline decrypt_chal(char *chal, char *pwd)
 { 
    encrypt_chal(chal, pwd);
 }
 
 /* Generate PSEUDO random challenge key. */
-void gen_chal(char *buf)
+static void gen_chal(char *buf)
 {
    register int i;
  
@@ -123,7 +123,7 @@ void gen_chal(char *buf)
  * C - compression, S - speed for shaper and so on.
  */ 
 
-char *bf2cf(struct vtun_host *host)
+static char *bf2cf(struct vtun_host *host)
 {
      static char str[20], *ptr = str;
 
@@ -187,7 +187,7 @@ char *bf2cf(struct vtun_host *host)
    FLAGS: <TuE1>
 */
 
-int cf2bf(char *str, struct vtun_host *host)
+static int cf2bf(char *str, struct vtun_host *host)
 {
      char *ptr, *p;
      int s;
@@ -277,7 +277,7 @@ int cf2bf(char *str, struct vtun_host *h
  * string format:  <char_data> 
  */ 
 
-char *cl2cs(char *chal)
+static char *cl2cs(char *chal)
 {
      static char str[VTUN_CHAL_SIZE*2+3], *chr="abcdefghijklmnop";
      register char *ptr = str;
@@ -295,7 +295,7 @@ char *cl2cs(char *chal)
      return str;
 }
 
-int cs2cl(char *str, char *chal)
+static int cs2cl(char *str, char *chal)
 {
      register char *ptr = str;
      register int i;
diff -purN vtun-3.0.3/cfg_file.y vtun/cfg_file.y
--- vtun-3.0.3/cfg_file.y	2012-07-09 05:01:08.000000000 +0400
+++ vtun/cfg_file.y	2013-07-08 00:36:33.000000000 +0400
@@ -18,7 +18,7 @@
  */
 
 /*
- * $Id: cfg_file.y,v 1.8.2.6 2012/07/09 01:01:08 mtbishop Exp $
+ * $Id: cfg_file.y,v 1.8.2.7 2013/07/07 20:36:33 mtbishop Exp $
  */ 
 
 #include "config.h"
@@ -107,6 +107,7 @@ statement: '\n'
 	  	  memcpy(parse_host, &default_host, sizeof(struct vtun_host));
 		  parse_host->host = strdup($1);
 		  parse_host->passwd = NULL;
+		  parse_host->sopt.host = strdup($1);
 
 		  /* Copy local address */
 		  copy_addr(parse_host, &default_host);
diff -purN vtun-3.0.3/ChangeLog vtun/ChangeLog
--- vtun-3.0.3/ChangeLog	2012-07-09 05:10:17.000000000 +0400
+++ vtun/ChangeLog	2013-07-08 00:24:07.000000000 +0400
@@ -1,3 +1,10 @@
+
+-.-.-
+	bug53 - Race condition in socket() vs syslog (AH)
+	patch23 - check for fork and work around lack (AM)
+	patch22 - static declarations where possible (AM)
+	patch21 - fix up configure.in for newer autoheader (AM)
+	
 3.0.3:
 	rfe2636157 - Delayed UDP connection (dv)
 	rfe2149137 - makefile ignores LDFLAGS (sbk)
diff -purN vtun-3.0.3/configure.in vtun/configure.in
--- vtun-3.0.3/configure.in	2009-03-29 14:08:51.000000000 +0400
+++ vtun/configure.in	2013-07-07 23:54:28.000000000 +0400
@@ -2,12 +2,12 @@ dnl
 dnl VTun - Virtual Tunnel over TCP/IP network.
 dnl Copyright (C) 1998-2006  Maxim Krasnyansky <max_mk@yahoo.com>
 dnl
-dnl $Id: configure.in,v 1.19.2.2 2009/03/29 10:08:51 mtbishop Exp $
+dnl $Id: configure.in,v 1.19.2.3 2013/07/07 19:54:28 mtbishop Exp $
 dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl
 
-AC_INIT(lib.c)
+AC_INIT(vtun, 3) dnl this needs to change via variables as in the tail
 AC_CONFIG_HEADER(config.h)
 
 dnl Shapper support
@@ -110,10 +110,13 @@ dnl Check for librt
 AC_SEARCH_LIBS(nanosleep, rt posix4)
 
 dnl Check for setproctitle in libutil
-AC_SEARCH_LIBS(setproctitle, util bsd, AC_DEFINE(HAVE_SETPROC_TITLE) )
+AC_SEARCH_LIBS(setproctitle, util bsd, AC_DEFINE(HAVE_SETPROC_TITLE, [1], [Define to 1 if you have setproctitle() function]) )
+
+dnl Check for fork() (fallback to vfork() on non-MMU systems)
+AC_FUNC_FORK
 
 if test "$SHAPER" = "yes"; then
-   AC_DEFINE(HAVE_SHAPER)
+   AC_DEFINE(HAVE_SHAPER, [1], [Define to 1 if you want to enable shaper module])
 fi
 
 if test "$ZLIB" = "yes"; then
@@ -121,7 +124,7 @@ if test "$ZLIB" = "yes"; then
    AC_CHECKING( for ZLIB Library and Header files ... )
    AC_CHECK_LIB(z, deflate,
 	LIBS="$LIBS -lz"
-	AC_DEFINE(HAVE_ZLIB),
+	AC_DEFINE(HAVE_ZLIB, [1], [Define to 1 if you have zlib]),
 	AC_MSG_ERROR( Zlib library not found.)
    )
 fi
@@ -148,7 +151,7 @@ if test "$LZO" = "yes"; then
 	    AC_CHECK_LIB($I, lzo1x_decompress,
 	    [
 	          LIBS="$LIBS -l"$I
-	       AC_DEFINE(HAVE_LZO)
+	       AC_DEFINE(HAVE_LZO, [1], [Define to 1 if you have lzo])
 	          havelzo=1
 	      ]
 	    )
@@ -180,8 +183,8 @@ if test "$SSL" = "yes"; then
 	AC_CHECK_LIB(crypto, BF_set_key,
 	    [
 	       LIBS="$LIBS -lcrypto"
-	       AC_DEFINE(HAVE_SSL)
-	       AC_DEFINE(HAVE_SSL_BLOWFISH)
+	       AC_DEFINE(HAVE_SSL, [1], [Define to 1 if you have openssl])
+	       AC_DEFINE(HAVE_SSL_BLOWFISH, [1], [Define to 1 if you have blowfish in openssl])
 	    ],
 	    AC_MSG_ERROR( SSL library not found. )
 	),
@@ -196,7 +199,7 @@ if test "$SSL" = "yes"; then
     $SSL_HDR_DIR /usr/include/ssl /usr/include/openssl /usr/include /usr/local/include /usr/local/ssl/include  /usr/include/crypto,
 	AC_CHECK_LIB(crypto, AES_set_encrypt_key,
 	    [
-	       AC_DEFINE(HAVE_SSL_AES)
+	       AC_DEFINE(HAVE_SSL_AES, [1], [Define to 1 if you have AES in openssl])
 	    ],
 	    AC_MSG_ERROR( AES library not found. )
 	),
@@ -211,7 +214,7 @@ if test "$SSL" = "yes"; then
     $SSL_HDR_DIR /usr/include/ssl /usr/include/openssl /usr/include /usr/local/include /usr/local/ssl/include  /usr/include/crypto,
 	AC_CHECK_LIB(crypto, EVP_EncryptInit,
 	    [
-	       AC_DEFINE(HAVE_SSL_EVP)
+	       AC_DEFINE(HAVE_SSL_EVP, [1], [Define to 1 if you have EVP in openssl])
 	    ],
 	    AC_MSG_ERROR( EVP library not found. )
 	),
@@ -220,7 +223,7 @@ if test "$SSL" = "yes"; then
 fi
 
 if test "$NATHACK" = "yes"; then
-   AC_DEFINE(ENABLE_NAT_HACK)
+   AC_DEFINE(ENABLE_NAT_HACK, [1], [Define to 1 if you want to enable Nat Hack code])
 fi
 
 if test "$SOCKS" = "yes"; then
@@ -274,6 +277,6 @@ changequote(<,>)
 REL=`echo 'BRANCH-3_X' | tr -d '$: \-' | sed 's/^[A-Za-z]*//' | sed 's/\_/\./'`
 changequote([,])
 
-AC_DEFINE_UNQUOTED(VTUN_VER, "$REL `date '+%m/%d/%Y'`")
+AC_DEFINE_UNQUOTED(VTUN_VER, "$REL `date '+%m/%d/%Y'`", [Vtun version])
 
 AC_OUTPUT(Makefile)
diff -purN vtun-3.0.3/Credits vtun/Credits
--- vtun-3.0.3/Credits	2012-07-08 09:32:07.000000000 +0400
+++ vtun/Credits	2013-07-08 00:24:11.000000000 +0400
@@ -159,3 +159,11 @@ Eugene Berdnikov
 
 Sean MacLennan
 	Reduce connection chatter 
+
+Andrey Mazo <ahippo@sf>
+	Clean up Configure.in for autoheader
+	Static declarations where sensible
+	Check/handle no fork() for no-MMU client systems (eg blackfin)
+
+Alfred Heisner <aheisner@sf>
+	Race condition between syslog socket and vtun (bug53)
diff -purN vtun-3.0.3/driver.h vtun/driver.h
--- vtun-3.0.3/driver.h	2008-01-08 01:35:30.000000000 +0300
+++ vtun/driver.h	2013-07-08 00:36:37.000000000 +0400
@@ -17,14 +17,14 @@
  */
 
 /*
- * $Id: driver.h,v 1.4.2.2 2008/01/07 22:35:30 mtbishop Exp $
+ * $Id: driver.h,v 1.4.2.3 2013/07/07 20:36:37 mtbishop Exp $
  */ 
 #ifndef _DRIVER_H
 #define _DRIVER_H
 
 /* Definitions for device and protocol drivers 
  * Interface will be completely rewritten in 
- * version 3.0
+ * future versions.
  */
 
 extern int (*dev_write)(int fd, char *buf, int len);
diff -purN vtun-3.0.3/lfd_encrypt.c vtun/lfd_encrypt.c
--- vtun-3.0.3/lfd_encrypt.c	2008-01-08 01:35:32.000000000 +0300
+++ vtun/lfd_encrypt.c	2013-07-07 23:54:35.000000000 +0400
@@ -64,16 +64,16 @@
 #define ENC_BUF_SIZE VTUN_FRAME_SIZE + 128 
 #define ENC_KEY_SIZE 16
 
-BF_KEY key;
-char * enc_buf;
-char * dec_buf;
+static BF_KEY key;
+static char * enc_buf;
+static char * dec_buf;
 
 #define CIPHER_INIT		0
 #define CIPHER_CODE		1	
 #define CIPHER_SEQUENCE 	2
 #define CIPHER_REQ_INIT 	3
 
-struct vtun_host *phost;
+static struct vtun_host *phost;
 
 extern int send_a_packet;
 
@@ -81,27 +81,32 @@ extern int send_a_packet;
 #define MAX_GIBBERISH	10
 #define MIN_GIBBERISH   1
 #define MAX_GIBBERISH_TIME   2
-int gibberish;
-time_t gib_time_start;
+static int gibberish;
+static time_t gib_time_start;
 
-int cipher_enc_state;
-int cipher_dec_state;
-int cipher;
-int blocksize;
-int keysize;
-int enc_init_first_time;
-int dec_init_first_time;
-unsigned long sequence_num;
-char * pkey;
-char * iv_buf;
+static int cipher_enc_state;
+static int cipher_dec_state;
+static int cipher;
+static int blocksize;
+static int keysize;
+static int enc_init_first_time;
+static int dec_init_first_time;
+static unsigned long sequence_num;
+static char * pkey;
+static char * iv_buf;
+
+static EVP_CIPHER_CTX ctx_enc;	/* encrypt */
+static EVP_CIPHER_CTX ctx_dec;	/* decrypt */
+
+static EVP_CIPHER_CTX ctx_enc_ecb;	/* sideband ecb encrypt */
+static EVP_CIPHER_CTX ctx_dec_ecb;	/* sideband ecb decrypt */
+
+static int send_msg(int len, char *in, char **out);
+static int recv_msg(int len, char *in, char **out);
+static int send_ib_mesg(int *len, char **in);
+static int recv_ib_mesg(int *len, char **in);
 
-EVP_CIPHER_CTX ctx_enc;	/* encrypt */
-EVP_CIPHER_CTX ctx_dec;	/* decrypt */
-
-EVP_CIPHER_CTX ctx_enc_ecb;	/* sideband ecb encrypt */
-EVP_CIPHER_CTX ctx_dec_ecb;	/* sideband ecb decrypt */
-
-int prep_key(char **key, int size, struct vtun_host *host)
+static int prep_key(char **key, int size, struct vtun_host *host)
 {
    int tmplen, halflen;
    char *hashkey;
@@ -136,12 +141,12 @@ int prep_key(char **key, int size, struc
    return 0;
 }
 
-void free_key (char *key)
+static void free_key (char *key)
 {
    free(key);
 }
 
-int alloc_encrypt(struct vtun_host *host)
+static int alloc_encrypt(struct vtun_host *host)
 {
    int sb_init = 0;
    int var_key = 0;
@@ -282,7 +287,7 @@ int alloc_encrypt(struct vtun_host *host
    return 0;
 }
 
-int free_encrypt()
+static int free_encrypt()
 {
    free_key(pkey); pkey = NULL;
 
@@ -297,7 +302,7 @@ int free_encrypt()
    return 0;
 }
 
-int encrypt_buf(int len, char *in, char **out)
+static int encrypt_buf(int len, char *in, char **out)
 { 
    register int pad, p, msg_len;
    int outlen;
@@ -326,7 +331,7 @@ int encrypt_buf(int len, char *in, char
    return outlen+msg_len;
 }
 
-int decrypt_buf(int len, char *in, char **out)
+static int decrypt_buf(int len, char *in, char **out)
 {
    register int pad;
    char *tmp_ptr, *in_ptr, *out_ptr = dec_buf;
@@ -351,7 +356,7 @@ int decrypt_buf(int len, char *in, char
    return outlen - pad;
 }
 
-int cipher_enc_init(char * iv)
+static int cipher_enc_init(char * iv)
 {
    int var_key = 0;
    const EVP_CIPHER *cipher_type;
@@ -442,7 +447,7 @@ int cipher_enc_init(char * iv)
    return 0;
 }
 
-int cipher_dec_init(char * iv)
+static int cipher_dec_init(char * iv)
 {
    int var_key = 0;
    const EVP_CIPHER *cipher_type;
@@ -532,7 +537,7 @@ int cipher_dec_init(char * iv)
    return 0;
 }
 
-int send_msg(int len, char *in, char **out)
+static int send_msg(int len, char *in, char **out)
 {
    char * iv; char * in_ptr;
    int outlen;
@@ -570,7 +575,7 @@ int send_msg(int len, char *in, char **o
    return len;
 }
 
-int recv_msg(int len, char *in, char **out)
+static int recv_msg(int len, char *in, char **out)
 {
    char * iv; char * in_ptr;
    int outlen;
@@ -645,7 +650,7 @@ int recv_msg(int len, char *in, char **o
 }
 
 /* Send In-Band Message */
-int send_ib_mesg(int *len, char **in)
+static int send_ib_mesg(int *len, char **in)
 {
    char *in_ptr = *in;
 
@@ -684,7 +689,7 @@ int send_ib_mesg(int *len, char **in)
 }
 
 /* Receive In-Band Message */
-int recv_ib_mesg(int *len, char **in)
+static int recv_ib_mesg(int *len, char **in)
 {
    char *in_ptr = *in;
 
@@ -747,7 +752,7 @@ struct lfd_mod lfd_encrypt = {
 
 #else  /* HAVE_SSL */
 
-int no_encrypt(struct vtun_host *host)
+static int no_encrypt(struct vtun_host *host)
 {
      vtun_syslog(LOG_INFO, "Encryption is not supported");
      return -1;
diff -purN vtun-3.0.3/lfd_legacy_encrypt.c vtun/lfd_legacy_encrypt.c
--- vtun-3.0.3/lfd_legacy_encrypt.c	2008-01-08 01:35:33.000000000 +0300
+++ vtun/lfd_legacy_encrypt.c	2013-07-07 23:54:41.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: lfd_legacy_encrypt.c,v 1.1.4.2 2008/01/07 22:35:33 mtbishop Exp $
+ * $Id: lfd_legacy_encrypt.c,v 1.1.4.3 2013/07/07 19:54:41 mtbishop Exp $
  * Code added wholesale temporarily from lfd_encrypt 1.2.2.8
  */ 
 
@@ -61,10 +61,10 @@
 #define ENC_BUF_SIZE VTUN_FRAME_SIZE + 16 
 #define ENC_KEY_SIZE 16
 
-BF_KEY key;
-char * enc_buf;
+static BF_KEY key;
+static char * enc_buf;
 
-int alloc_legacy_encrypt(struct vtun_host *host)
+static int alloc_legacy_encrypt(struct vtun_host *host)
 {
    if( !(enc_buf = lfd_alloc(ENC_BUF_SIZE)) ){
       vtun_syslog(LOG_ERR,"Can't allocate buffer for legacy encryptor");
@@ -77,13 +77,13 @@ int alloc_legacy_encrypt(struct vtun_hos
    return 0;
 }
 
-int free_legacy_encrypt()
+static int free_legacy_encrypt()
 {
    lfd_free(enc_buf); enc_buf = NULL;
    return 0;
 }
 
-int legacy_encrypt_buf(int len, char *in, char **out)
+static int legacy_encrypt_buf(int len, char *in, char **out)
 { 
    register int pad, p;
    register char *in_ptr = in, *out_ptr = enc_buf;
@@ -105,7 +105,7 @@ int legacy_encrypt_buf(int len, char *in
    return len + 8;
 }
 
-int legacy_decrypt_buf(int len, char *in, char **out)
+static int legacy_decrypt_buf(int len, char *in, char **out)
 {
    register int p;
 
@@ -140,7 +140,7 @@ struct lfd_mod lfd_legacy_encrypt = {
 
 #else  /* HAVE_SSL */
 
-int no_legacy_encrypt(struct vtun_host *host)
+static int no_legacy_encrypt(struct vtun_host *host)
 {
      vtun_syslog(LOG_INFO, "Encryption is not supported");
      return -1;
diff -purN vtun-3.0.3/lfd_lzo.c vtun/lfd_lzo.c
--- vtun-3.0.3/lfd_lzo.c	2012-07-09 05:01:08.000000000 +0400
+++ vtun/lfd_lzo.c	2013-07-07 23:54:44.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: lfd_lzo.c,v 1.5.2.5 2012/07/09 01:01:08 mtbishop Exp $
+ * $Id: lfd_lzo.c,v 1.5.2.6 2013/07/07 19:54:44 mtbishop Exp $
  */ 
 
 /* LZO compression module */
@@ -44,7 +44,7 @@ static lzo_voidp wmem;
 static int zbuf_size = VTUN_FRAME_SIZE * VTUN_FRAME_SIZE / 64 + 16 + 3;
 
 /* Pointer to compress function */
-int (*lzo1x_compress)(const lzo_byte *src, lzo_uint  src_len,
+static int (*lzo1x_compress)(const lzo_byte *src, lzo_uint  src_len,
 		   	    lzo_byte *dst, lzo_uint *dst_len,
 		   	    lzo_voidp wrkmem);
 /* 
@@ -52,7 +52,7 @@ int (*lzo1x_compress)(const lzo_byte *sr
  * Allocate the buffers.
  */  
 
-int alloc_lzo(struct vtun_host *host)
+static int alloc_lzo(struct vtun_host *host)
 {
      int zlevel = host->zlevel ? host->zlevel : 1;
      lzo_uint mem;
@@ -91,7 +91,7 @@ int alloc_lzo(struct vtun_host *host)
  * Free the buffer.
  */  
 
-int free_lzo()
+static int free_lzo()
 {
      lfd_free(zbuf); zbuf = NULL;
      lzo_free(wmem); wmem = NULL;
@@ -102,7 +102,7 @@ int free_lzo()
  * This functions _MUST_ consume all incoming bytes in one pass,
  * that's why we expand buffer dynamicly.
  */  
-int comp_lzo(int len, char *in, char **out)
+static int comp_lzo(int len, char *in, char **out)
 { 
      lzo_uint zlen = 0;    
      int err;
@@ -116,7 +116,7 @@ int comp_lzo(int len, char *in, char **o
      return zlen;
 }
 
-int decomp_lzo(int len, char *in, char **out)
+static int decomp_lzo(int len, char *in, char **out)
 {
      lzo_uint zlen = 0;
      int err;
@@ -144,7 +144,7 @@ struct lfd_mod lfd_lzo = {
 
 #else  /* HAVE_LZO */
 
-int no_lzo(struct vtun_host *host)
+static int no_lzo(struct vtun_host *host)
 {
      vtun_syslog(LOG_INFO, "LZO compression is not supported");
      return -1;
diff -purN vtun-3.0.3/lfd_shaper.c vtun/lfd_shaper.c
--- vtun-3.0.3/lfd_shaper.c	2008-01-08 01:35:36.000000000 +0300
+++ vtun/lfd_shaper.c	2013-07-07 23:54:48.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: lfd_shaper.c,v 1.7.2.2 2008/01/07 22:35:36 mtbishop Exp $
+ * $Id: lfd_shaper.c,v 1.7.2.3 2013/07/07 19:54:48 mtbishop Exp $
  */
 
 #include "config.h"
@@ -38,13 +38,13 @@
 
 #ifdef HAVE_SHAPER 
 
-unsigned long bytes, max_speed;
-struct timeval curr_time, last_time;
+static unsigned long bytes, max_speed;
+static struct timeval curr_time, last_time;
 
 /* 
  * Initialization function.
  */
-int shaper_init(struct vtun_host *host)
+static int shaper_init(struct vtun_host *host)
 {
      /* Calculate max speed bytes/sec */
      max_speed = host->spd_out / 8 * 1024;
@@ -59,7 +59,7 @@ int shaper_init(struct vtun_host *host)
 }
 
 /* Shaper counter */
-int shaper_counter(int len, char *in, char **out)
+static int shaper_counter(int len, char *in, char **out)
 { 
      /* Just count incoming bytes */
      bytes += len;
@@ -69,7 +69,7 @@ int shaper_counter(int len, char *in, ch
 }
 
 /* Convert tv struct to milisec */
-unsigned long inline tv2ms(struct timeval tv)
+static unsigned long inline tv2ms(struct timeval tv)
 {
      register unsigned long ms = (tv.tv_sec * 1000)+(tv.tv_usec / 1000); 
      return  ms ? ms : 1;
@@ -94,7 +94,7 @@ unsigned long inline tv2ms(struct timeva
  * higher than maximal speed stop accepting input 
  * until the speed become lower or equal to maximal.
  */
-int shaper_avail(void)
+static int shaper_avail(void)
 { 
      static struct timeval tv;
      register unsigned long speed;
@@ -144,7 +144,7 @@ struct lfd_mod lfd_shaper = {
 
 #else  /* HAVE_SHAPER */
 
-int no_shaper(struct vtun_host *host)
+static int no_shaper(struct vtun_host *host)
 {
      vtun_syslog(LOG_INFO, "Traffic shaping is not supported");
      return -1;
diff -purN vtun-3.0.3/lfd_zlib.c vtun/lfd_zlib.c
--- vtun-3.0.3/lfd_zlib.c	2008-01-08 01:35:38.000000000 +0300
+++ vtun/lfd_zlib.c	2013-07-07 23:54:52.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: lfd_zlib.c,v 1.5.2.2 2008/01/07 22:35:38 mtbishop Exp $
+ * $Id: lfd_zlib.c,v 1.5.2.3 2013/07/07 19:54:52 mtbishop Exp $
  */ 
 
 /* ZLIB compression module */
@@ -45,7 +45,7 @@ static int zbuf_size = VTUN_FRAME_SIZE +
  * Initialize compressor/decompressor.
  * Allocate the buffer.
  */  
-int zlib_alloc(struct vtun_host *host)
+static int zlib_alloc(struct vtun_host *host)
 {
      int zlevel = host->zlevel ? host->zlevel : 1;
 
@@ -78,7 +78,7 @@ int zlib_alloc(struct vtun_host *host)
  * Free the buffer.
  */  
 
-int zlib_free()
+static int zlib_free()
 {
      deflateEnd(&zd);
      inflateEnd(&zi);
@@ -104,7 +104,7 @@ static int expand_zbuf(z_stream *zs, int
  * That's why we expand buffer dynamically.
  * Practice shows that buffer will not grow larger that 16K.
  */  
-int zlib_comp(int len, char *in, char **out)
+static int zlib_comp(int len, char *in, char **out)
 { 
      int oavail, olen = 0;    
      int err;
@@ -133,7 +133,7 @@ int zlib_comp(int len, char *in, char **
      return olen;
 }
 
-int zlib_decomp(int len, char *in, char **out)
+static int zlib_decomp(int len, char *in, char **out)
 {
      int oavail = 0, olen = 0;     
      int err;
@@ -175,7 +175,7 @@ struct lfd_mod lfd_zlib = {
 
 #else  /* HAVE_ZLIB */
 
-int no_zlib(struct vtun_host *host)
+static int no_zlib(struct vtun_host *host)
 {
      vtun_syslog(LOG_INFO, "ZLIB compression is not supported");
      return -1;
diff -purN vtun-3.0.3/lib.c vtun/lib.c
--- vtun-3.0.3/lib.c	2008-01-08 01:35:40.000000000 +0300
+++ vtun/lib.c	2013-07-08 00:21:20.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: lib.c,v 1.9.2.2 2008/01/07 22:35:40 mtbishop Exp $
+ * $Id: lib.c,v 1.9.2.4 2013/07/07 20:21:20 mtbishop Exp $
  */ 
 
 #include "config.h"
@@ -45,9 +45,9 @@ volatile sig_atomic_t __io_canceled = 0;
 /* Functions to manipulate with program title */
 
 extern char **environ;
-char	*title_start;	/* start of the proc title space */
-char	*title_end;     /* end of the proc title space */
-int	title_size;
+static char	*title_start;	/* start of the proc title space */
+static char	*title_end;     /* end of the proc title space */
+static int	title_size;
 
 void init_title(int argc,char *argv[], char *envp[], char *name)
 {
@@ -148,7 +148,7 @@ int readn_t(int fd, void *buf, size_t co
  * Substitutes opt in place off '%X'. 
  * Returns new string.
  */
-char * subst_opt(char *str, struct vtun_sopt *opt)
+static char * subst_opt(char *str, struct vtun_sopt *opt)
 {
     register int slen, olen, sp, np;
     register char *optr, *nstr, *tmp;
@@ -185,6 +185,9 @@ char * subst_opt(char *str, struct vtun_
 		   sprintf(buf,"%d",opt->rport);
                    optr=buf;
                    break;
+	        case 'h':
+		   optr=opt->host;
+		   break;
                 default:
                    sp++;
                    continue;
@@ -223,7 +226,7 @@ char * subst_opt(char *str, struct vtun_
  * ' ' - group arguments
  * Modifies original string. 
  */
-void split_args(char *str, char **argv)
+static void split_args(char *str, char **argv)
 {       
      register int i = 0;
      int mode = 0;
@@ -276,6 +279,7 @@ void split_args(char *str, char **argv)
      argv[i]=NULL;
 }
  
+#ifdef HAVE_WORKING_FORK
 int run_cmd(void *d, void *opt)
 {
      struct vtun_cmd *cmd = d;	
@@ -324,6 +328,7 @@ int run_cmd(void *d, void *opt)
      vtun_syslog(LOG_ERR,"Couldn't exec program %s", cmd->prog);
      exit(1);
 }
+#endif
 
 void free_sopt( struct vtun_sopt *opt )
 {
@@ -355,6 +360,7 @@ void vtun_syslog (int priority, char *fo
       va_start(ap, format);
       vsnprintf(buf, sizeof(buf)-1, format, ap);
       syslog(priority, "%s", buf);
+      closelog();
       va_end(ap);
 
       in_syslog = 0;
diff -purN vtun-3.0.3/lib.h vtun/lib.h
--- vtun-3.0.3/lib.h	2008-01-08 01:35:41.000000000 +0300
+++ vtun/lib.h	2013-07-07 23:55:00.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: lib.h,v 1.7.2.2 2008/01/07 22:35:41 mtbishop Exp $
+ * $Id: lib.h,v 1.7.2.3 2013/07/07 19:55:00 mtbishop Exp $
  */ 
 #ifndef _VTUN_LIB_H
 #define _VTUN_LIB_H
@@ -46,7 +46,9 @@
 int readn_t(int fd, void *buf, size_t count, time_t timeout);
 int print_p(int f, const char *ftm, ...);
 
+#ifdef HAVE_WORKING_FORK
 int  run_cmd(void *d, void *opt);
+#endif
 void free_sopt(struct vtun_sopt *opt);
 
 /* IO cancelation */
diff -purN vtun-3.0.3/linkfd.c vtun/linkfd.c
--- vtun-3.0.3/linkfd.c	2012-07-08 09:31:44.000000000 +0400
+++ vtun/linkfd.c	2013-07-07 23:55:06.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: linkfd.c,v 1.13.2.5 2012/07/07 07:14:17 mtbishop Exp $
+ * $Id: linkfd.c,v 1.13.2.6 2013/07/07 19:55:06 mtbishop Exp $
  */
 
 #include "config.h"
@@ -56,14 +56,14 @@ int send_a_packet = 0;
 /* Host we are working with. 
  * Used by signal handlers that's why it is global. 
  */
-struct vtun_host *lfd_host;
+static struct vtun_host *lfd_host;
 
-struct lfd_mod *lfd_mod_head = NULL, *lfd_mod_tail = NULL;
+static struct lfd_mod *lfd_mod_head = NULL, *lfd_mod_tail = NULL;
 
 /* Modules functions*/
 
 /* Add module to the end of modules list */
-void lfd_add_mod(struct lfd_mod *mod)
+static void lfd_add_mod(struct lfd_mod *mod)
 {
      if( !lfd_mod_head ){
         lfd_mod_head = lfd_mod_tail = mod;
@@ -77,7 +77,7 @@ void lfd_add_mod(struct lfd_mod *mod)
 }
 
 /*  Initialize and allocate each module */
-int lfd_alloc_mod(struct vtun_host *host)
+static int lfd_alloc_mod(struct vtun_host *host)
 {
      struct lfd_mod *mod = lfd_mod_head;
 
@@ -91,7 +91,7 @@ int lfd_alloc_mod(struct vtun_host *host
 }
 
 /* Free all modules */
-int lfd_free_mod(void)
+static int lfd_free_mod(void)
 {
      struct lfd_mod *mod = lfd_mod_head;
 
@@ -105,7 +105,7 @@ int lfd_free_mod(void)
 }
 
  /* Run modules down (from head to tail) */
-inline int lfd_run_down(int len, char *in, char **out)
+static inline int lfd_run_down(int len, char *in, char **out)
 {
      register struct lfd_mod *mod;
      
@@ -119,7 +119,7 @@ inline int lfd_run_down(int len, char *i
 }
 
 /* Run modules up (from tail to head) */
-inline int lfd_run_up(int len, char *in, char **out)
+static inline int lfd_run_up(int len, char *in, char **out)
 {
      register struct lfd_mod *mod;
      
@@ -133,7 +133,7 @@ inline int lfd_run_up(int len, char *in,
 }
 
 /* Check if modules are accepting the data(down) */
-inline int lfd_check_down(void)
+static inline int lfd_check_down(void)
 {
      register struct lfd_mod *mod;
      int err = 1;
@@ -145,7 +145,7 @@ inline int lfd_check_down(void)
 }
 
 /* Check if modules are accepting the data(up) */
-inline int lfd_check_up(void)
+static inline int lfd_check_up(void)
 {
      register struct lfd_mod *mod;
      int err = 1;
@@ -179,7 +179,7 @@ static void sig_hup(int sig)
 static volatile sig_atomic_t ka_need_verify = 0;
 static time_t stat_timer = 0, ka_timer = 0; 
 
-void sig_alarm(int sig)
+static void sig_alarm(int sig)
 {
      static time_t tm_old, tm = 0;
      static char stm[20];
@@ -215,7 +215,7 @@ static void sig_usr1(int sig)
      lfd_host->stat.comp_in = lfd_host->stat.comp_out = 0; 
 }
 
-int lfd_linker(void)
+static int lfd_linker(void)
 {
      int fd1 = lfd_host->rmt_fd;
      int fd2 = lfd_host->loc_fd; 
diff -purN vtun-3.0.3/main.c vtun/main.c
--- vtun-3.0.3/main.c	2012-07-08 09:32:57.000000000 +0400
+++ vtun/main.c	2013-07-08 00:31:22.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: main.c,v 1.9.2.5 2012/07/08 05:32:57 mtbishop Exp $
+ * $Id: main.c,v 1.9.2.7 2013/07/07 20:31:22 mtbishop Exp $
  */ 
 
 #include "config.h"
@@ -39,13 +39,20 @@
 #include "lib.h"
 #include "compat.h"
 
+#define OPTSTRING "mif:P:L:t:npq"
+#ifdef HAVE_WORKING_FORK
+#  define SERVOPT_STRING "s"
+#else
+#  define SERVOPT_STRING ""
+#endif
+
 /* Global options for the server and client */
 struct vtun_opts vtun;
 struct vtun_host default_host;
 
-void write_pid(void);
-void reread_config(int sig);
-void usage(void);
+static void write_pid(void);
+static void reread_config(int sig);
+static void usage(void);
 
 extern int optind,opterr,optopt;
 extern char *optarg;
@@ -55,13 +62,19 @@ int is_rmt_fd_connected=1;
 
 int main(int argc, char *argv[], char *env[])
 {
-  int svr, daemon, sock, dofork, fd, opt;
+     int svr, daemon, sock, fd, opt;
+#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
+     int dofork;
+#endif
      struct vtun_host *host = NULL;
      struct sigaction sa;
      char *hst;
 
      /* Configure default settings */
-     svr = 0; daemon = 1; sock = 0; dofork = 1;
+     svr = 0; daemon = 1; sock = 0;
+#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
+     dofork = 1;
+#endif
 
      vtun.cfg_file = VTUN_CONFIG_FILE;
      vtun.persist = -1;
@@ -92,7 +105,7 @@ int main(int argc, char *argv[], char *e
      /* Start logging to syslog and stderr */
      openlog("vtund", LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_DAEMON);
 
-     while( (opt=getopt(argc,argv,"misf:P:L:t:npq")) != EOF ){
+     while( (opt=getopt(argc,argv,OPTSTRING SERVOPT_STRING)) != EOF ){
 	switch(opt){
 	    case 'm':
 	        if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0) {
@@ -102,7 +115,9 @@ int main(int argc, char *argv[], char *e
 		break;
 	    case 'i':
 		vtun.svr_type = VTUN_INETD;
+#ifdef HAVE_WORKING_FORK
 	    case 's':
+#endif
 		svr = 1;
 		break;
 	    case 'L':
@@ -173,13 +188,20 @@ int main(int argc, char *argv[], char *e
 	   break;
 	case VTUN_INETD:
 	   sock = dup(0);
+#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
 	   dofork = 0; 
+#endif
 	   break;
      }
 
      if( daemon ){
+#ifdef HAVE_WORKING_FORK
 	if( dofork && fork() )
 	   exit(0);
+#elif defined(HAVE_WORKING_VFORK)
+	if( dofork && vfork() )
+	   exit(0);
+#endif
 
         /* Direct stdin,stdout,stderr to '/dev/null' */
         fd = open("/dev/null", O_RDWR);
@@ -200,8 +222,14 @@ int main(int argc, char *argv[], char *e
 
         init_title(argc,argv,env,"vtund[s]: ");
 
-	if( vtun.svr_type == VTUN_STAND_ALONE )	
+	if( vtun.svr_type == VTUN_STAND_ALONE ){
+#ifdef HAVE_WORKING_FORK
 	   write_pid();
+#else
+	   vtun_syslog(LOG_ERR,"Standalone server is not supported. Use -i");
+	   exit(1);
+#endif
+	}
 	
 	server(sock);
      } else {	
@@ -218,7 +246,7 @@ int main(int argc, char *argv[], char *e
  * Very simple PID file creation function. Used by server.
  * Overrides existing file. 
  */
-void write_pid(void)
+static void write_pid(void)
 {
      FILE *f;
 
@@ -231,7 +259,7 @@ void write_pid(void)
      fclose(f);
 }
 
-void reread_config(int sig)
+static void reread_config(int sig)
 {
      if( !read_config(vtun.cfg_file) ){
 	vtun_syslog(LOG_ERR,"No hosts defined");
@@ -239,14 +267,18 @@ void reread_config(int sig)
      }
 }
 
-void usage(void)
+static void usage(void)
 {
      printf("VTun ver %s\n", VTUN_VER);
      printf("Usage: \n");
      printf("  Server:\n");
-     printf("\tvtund <-s> [-f file] [-P port] [-L local address]\n");
+#ifdef HAVE_WORKING_FORK
+     printf("\tvtund <-s|-i> [-f file] [-P port] [-L local address]\n");
+#else
+     printf("\tvtund <-i> [-f file] [-P port] [-L local address]\n");
+#endif
      printf("  Client:\n");
      /* I don't think these work. I'm disabling the suggestion - bish 20050601*/
      printf("\tvtund [-f file] " /* [-P port] [-L local address] */
-	    "[-p] [-m] [-t timeout] <host profile> <server address>\n");
+	    "[-q] [-p] [-m] [-t timeout] <host profile> <server address>\n");
 }
diff -purN vtun-3.0.3/Makefile.in vtun/Makefile.in
--- vtun-3.0.3/Makefile.in	2012-07-09 08:55:38.000000000 +0400
+++ vtun/Makefile.in	2013-07-08 00:36:44.000000000 +0400
@@ -15,7 +15,7 @@
 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #   GNU General Public License for more details.
 #
-#   $Id: Makefile.in,v 1.11.2.6 2012/07/09 04:55:38 mtbishop Exp $
+#   $Id: Makefile.in,v 1.11.2.7 2013/07/07 20:36:44 mtbishop Exp $
 #  
 CC = @CC@
 CFLAGS = @CFLAGS@ @CPPFLAGS@
@@ -73,7 +73,7 @@ depend:
 	makedepend -- $(CFLAGS) -- *.c
 
 clean:
-	rm -f core cfg_file.tab.* cfg_file.lex.* *.o *~ *.bak vtund
+	rm -f core cfg_file.tab.* cfg_file.lex.* *.o *~ .#* *.bak vtund
 
 distclean: clean
 	rm -f $(CONFIGURE_FILES)
diff -purN vtun-3.0.3/packages/vtun.spec vtun/packages/vtun.spec
--- vtun-3.0.3/packages/vtun.spec	2012-07-08 14:30:27.000000000 +0400
+++ vtun/packages/vtun.spec	2013-07-07 22:03:49.000000000 +0400
@@ -1,4 +1,4 @@
-# $Id: vtun.spec,v 1.24.2.9 2012/07/08 10:30:27 mtbishop Exp $
+# $Id: vtun.spec,v 1.24.2.10 2013/07/07 18:03:49 mtbishop Exp $
 
 # By default, builds without socks-support.
 # To build with socks-support, issue:
@@ -46,6 +46,8 @@ Summary: 	Virtual tunnel over TCP/IP net
 Summary(pl):	Wirtualne tunele poprzez sieci TCP/IP
 Vendor: 	Maxim Krasnyansky <max_mk@yahoo.com>
 Packager: 	Bishop Clark (LC957) <bishop@platypus.bc.ca>
+
+		# Remember this is ignored for recent distros (Backward Compatibility is dumb)
 BuildRoot: 	%{?_tmppath:%{_tmppath}}%{!?_tmppath:%{tmpdir}}/%{name}-%{version}-root-%(id -u -n)
 Obsoletes: 	vppp
 BuildRequires:  autoconf
diff -purN vtun-3.0.3/server.c vtun/server.c
--- vtun-3.0.3/server.c	2012-07-09 05:01:08.000000000 +0400
+++ vtun/server.c	2013-07-07 23:55:14.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: server.c,v 1.9.2.3 2012/07/09 01:01:08 mtbishop Exp $
+ * $Id: server.c,v 1.9.2.4 2013/07/07 19:55:14 mtbishop Exp $
  */ 
 
 #include "config.h"
@@ -58,7 +58,7 @@ static void sig_term(int sig)
      server_term = VTUN_SIG_TERM;
 }
 
-void connection(int sock)
+static void connection(int sock)
 {
      struct sockaddr_in my_addr, cl_addr;
      struct vtun_host *host;
@@ -111,7 +111,8 @@ void connection(int sock)
      exit(0);
 }
 
-void listener(void)
+#ifdef HAVE_WORKING_FORK
+static void listener(void)
 {
      struct sigaction sa;
      struct sockaddr_in my_addr, cl_addr;
@@ -172,6 +173,7 @@ void listener(void)
 	}
      }  
 }	
+#endif
 
 void server(int sock)
 {
@@ -190,7 +192,11 @@ void server(int sock)
 
      switch( vtun.svr_type ){
 	case VTUN_STAND_ALONE:
+#ifdef HAVE_WORKING_FORK
 	   listener();
+#else
+	   vtun_syslog(LOG_ERR,"Standalone server is not supported: fork() not available");
+#endif
 	   break;
         case VTUN_INETD:
 	   connection(sock);
diff -purN vtun-3.0.3/tunnel.c vtun/tunnel.c
--- vtun-3.0.3/tunnel.c	2008-01-08 01:36:03.000000000 +0300
+++ vtun/tunnel.c	2013-07-07 23:55:17.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: tunnel.c,v 1.14.2.2 2008/01/07 22:36:03 mtbishop Exp $
+ * $Id: tunnel.c,v 1.14.2.3 2013/07/07 19:55:17 mtbishop Exp $
  */ 
 
 #include "config.h"
@@ -147,6 +147,7 @@ int tunnel(struct vtun_host *host)
 	   break;
      }
 
+#ifdef HAVE_WORKING_FORK
         switch( (pid=fork()) ){
 	   case -1:
 	      vtun_syslog(LOG_ERR,"Couldn't fork()");
@@ -187,6 +188,9 @@ int tunnel(struct vtun_host *host)
 
 	   exit(0);           
 	}
+#else
+     vtun_syslog(LOG_ERR,"Couldn't run up commands: fork() not available");
+#endif
 
      switch( host->flags & VTUN_TYPE_MASK ){
         case VTUN_TTY:
@@ -222,8 +226,12 @@ int tunnel(struct vtun_host *host)
 
      opt = linkfd(host);
 
+#ifdef HAVE_WORKING_FORK
      set_title("%s running down commands", host->host);
      llist_trav(&host->down, run_cmd, &host->sopt);
+#else
+     vtun_syslog(LOG_ERR,"Couldn't run down commands: fork() not available");
+#endif
 
      if(! ( host->persist == VTUN_PERSIST_KEEPIF ) ) {
         set_title("%s closing", host->host);
diff -purN vtun-3.0.3/vtund.conf vtun/vtund.conf
--- vtun-3.0.3/vtund.conf	2012-07-08 09:31:44.000000000 +0400
+++ vtun/vtund.conf	2013-07-08 00:36:48.000000000 +0400
@@ -6,7 +6,7 @@
 #   Ted Rolle <ted@acacia.datacomm.com>
 #
 # Configuration file example
-# $Id: vtund.conf,v 1.4.2.5 2012/07/07 07:14:17 mtbishop Exp $
+# $Id: vtund.conf,v 1.4.2.6 2013/07/07 20:36:48 mtbishop Exp $
 #
 # 
 # Lines which begin with '#' are comments
@@ -227,6 +227,7 @@
 #	      %P - Local TCP or UDP port  
 #	      %a - Remote IP address
 #	      %p - Remote TCP or UDP port
+#	      %h - Host Profile Name in config
 #
 #       wait - Wait for the program termination. 
 #
diff -purN vtun-3.0.3/vtund.conf.5 vtun/vtund.conf.5
--- vtun-3.0.3/vtund.conf.5	2012-07-08 09:31:44.000000000 +0400
+++ vtun/vtund.conf.5	2013-07-08 00:36:52.000000000 +0400
@@ -1,5 +1,5 @@
 .\" Manual page for vtund.conf
-.\" $Id: vtund.conf.5,v 1.4.2.4 2012/07/07 07:14:17 mtbishop Exp $
+.\" $Id: vtund.conf.5,v 1.4.2.5 2013/07/07 20:36:52 mtbishop Exp $
 .TH VTUND.CONF 5
 
 .SH NAME
@@ -315,6 +315,8 @@ Special characters that can be used insi
 \fB%a\fR - Remote IP address
 .br
 \fB%p\fR - Remote TCP or UDP port
+.br
+\fB%h\fR - Host profile name
 .IP \fBppp\ \fIarguments\fR
 run program specified by \fBppp\fR statement in \fBoptions\fR section.
 All special character described above are valid in \fIarguments\fR here.
diff -purN vtun-3.0.3/vtun.h vtun/vtun.h
--- vtun-3.0.3/vtun.h	2012-07-09 05:01:08.000000000 +0400
+++ vtun/vtun.h	2013-07-08 00:36:56.000000000 +0400
@@ -17,7 +17,7 @@
  */
 
 /*
- * $Id: vtun.h,v 1.12.2.7 2012/07/09 01:01:08 mtbishop Exp $
+ * $Id: vtun.h,v 1.12.2.8 2013/07/07 20:36:56 mtbishop Exp $
  */ 
 
 #ifndef _VTUN_H
@@ -51,6 +51,7 @@ struct vtun_sopt {
     int  lport;
     char *raddr;
     int  rport;
+    char *host;
 };
 
 struct vtun_stat {