-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.test.c
2287 lines (1703 loc) · 49.6 KB
/
update.test.c
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
/*
*
* update program for
*
* updates from pre vshop version 1.6.1
*
*/
/* -------------------------------------------------- */
/*
*
* defines
*
*/
#define PROVIDER
#define VERSION "161"
#define CHMAP (S_IRWXU | S_IRUSR | S_IWUSR | S_IXUSR | S_IRWXG | S_IRGRP | S_IWGRP | S_IXGRP | S_IRWXO | S_IROTH | S_IWOTH | S_IXOTH)
#define COMMENT 1
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define OLD 1
#define NEW 2
#ifndef S_IFMT
#define S_IFMT 00170000
#endif
#ifndef S_IFLNK
#define S_IFLNK 0120000
#endif
/* -------------------------------------------------- */
/*
*
* includes
*
*/
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
/*#include <statbuf.h>*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* #include <asm/errno.h> */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
/* -------------------------------------------------- */
/*
*
* structures
*
*/
typedef struct tableStruct
{
char DBROOT[256];
char DBUSER[256];
char DBPASSWORD[256];
char TEMPLATEROOT[256];
char BASEREF[256];
char PROFILING[2];
char TIMEOUTURL[512];
char DBERRORURL[512];
char MAILSERVER[100];
char MAILFROM[256];
char EURODM[24];
char EUROUSD[24];
char RTF[256];
char ADMINREAD[256];
struct stat *AdminRights;
struct stat *DokRights;
} tstrT;
typedef struct vsStruct
{
char *SHOPNAME;
struct vsStruct *next;
} vsstrT;
typedef struct fList
{
char *name;
ino_t inode;
struct fList *next;
} flistT;
typedef struct inoList
{
ino_t inode;
struct inoList *next;
} inostrT;
/* -------------------------------------------------- */
/*
*
* global variables
*
*/
int count = 0;
int stage = 0;
int vshopfd = 0;
char tableNam[7];
vsstrT *gvsBufferPtr = NULL;
char *findPath[3] = {"/etc", "/sbin", "/var"};
/* -------------------------------------------------- */
/*
*
* prototypes
*
*/
int AdabasRun (tstrT *);
int Addstr (char *, char *, int, char *, int);
int RecChmod (char *, struct stat *);
int RecRem (char *);
int Libc ();
int Variables (char *, int, char *, tstrT *);
int VariSearch (char *, int, char *, int, int, char *, char *);
int VsadFile (vsstrT *);
char *GetNextFile (flistT *);
char *VsadNext ();
struct stat *AdminRights (char *);
struct stat *DokRights (char *);
flistT *FindFile (char *, char *, flistT *, inostrT *);
int UpSystem (char *);
int ShSystem (char *);
void UpExit (int);
/* -------------------------------------------------- */
int
main (int argc, char **argv)
{
extern char **environ;
int adabasState;
int bufLen;
int forkRes;
int i;
int oldNewDoc;
int readres;
int unreadlast;
int unread;
char actwd[256];
char cgiPath[256];
char instDir[256];
char startwd[256];
char systemStr[1024];
char table[64];
char testBuf[512];
char *buffer;
char *testPtr;
char *s1Ptr;
char *vsPtr;
off_t foffset;
uid_t iam;
struct stat fstat;
struct stat fstat0;
struct dirent *testdirent;
struct passwd *pwstr;
tstrT tableVar;
vsstrT *vsBuffer;
if (argc > 1)
Help ();
adabasState = FALSE;
stage = 0;
memset (&tableNam[0], '\0', sizeof (tableNam));
sprintf (&tableNam[0], "vshop");
/* ***** test if we are superuser ***** */
printf ("\n\n\t Es wird ueberprueft ob das Programm ueber \"root\" Rechte verfuegt ...\n");
if ((pwstr = (struct passwd *) getpwnam ("root")) == NULL)
{
printf ("\n\n(001) error: can't get passwd file entry for \"root\",\n exiting update program !\n");
UpExit (-1);
}
iam = getuid ();
if (pwstr->pw_uid != iam)
{
printf ("\n\n(002) error: become \"root\" before you start the update program,\n exiting update program !\n");
UpExit (-1);
}
/* ***** get the directory where update is installed ***** */
memset (&testBuf[0], '\0', sizeof (testBuf));
if (argv[0][0] != '/')
{
if (getcwd(&testBuf[0], sizeof (testBuf)) == NULL)
{
printf ("\n\n(003) error: internal error testBuf to small to hold path for actual working directory,\n exiting update program !\n");
UpExit (-1);
}
strcat (&testBuf[0], "/");
}
strcat (&testBuf[0], argv[0]);
s1Ptr = (char *) strrchr (&testBuf[0], '/');
*(s1Ptr + 1) = '\0';
if (chdir ((const char *) &testBuf[0]) != 0)
{
printf ("\n\n(004) error: internal error path %s not found,\n exiting update program !\n", &testBuf[0]);
UpExit (-1);
}
memset (&instDir[0], '\0', sizeof (instDir));
if (getcwd (&instDir[0], sizeof (instDir)) != &instDir[0])
{
printf ("\n\n(005) error: could not get actuell working directory,\n exiting update program !\n");
UpExit (-1);
}
/* ***** open the file "/etc/vshop.conf" and read out variose usefull variables ***** */
printf ("\n\n\t Es werden nun verschiedene Variablen aus der Datei \n \"/etc/vshop.conf\" ausgelesen ...\n");
if ((vshopfd = open("/etc/vshop.conf", O_RDWR | O_APPEND | O_SYNC)) == -1)
{
printf ("\n\n(006) error: can't open \"/etc/vshop.conf\" file does not exist or no permision,\n exiting update program !\n");
UpExit (-1);
}
if ((foffset = lseek (vshopfd, 0, SEEK_END)) <= 0)
{
printf ("\n\n(007) error: can't read from \"/etc/vshop.conf\" or file corrupted,\n exiting update program !\n");
UpExit (-1);
}
bufLen = foffset + 1;
if ((buffer = (char *) calloc (1, bufLen)) == NULL)
{
printf ("\n\n(008) error: can't allocat buffer memory,\n exiting update program !\n");
UpExit (-1);
}
if (lseek (vshopfd, 0, SEEK_SET) == -1)
{
printf ("\n\n(009) error: can't read from \"/etc/vshop.conf\" or file corrupted,\n exiting update program !\n");
UpExit (-1);
}
unreadlast = 0;
unread = foffset;
readres = 0;
while (readres < foffset)
{
unread = (int ) read (vshopfd, (void *) buffer, (size_t ) unread);
if (unreadlast > unread)
{
printf ("\n\n(010) error: in reading \"/etc/vshop.conf\" file,\n exiting update program !\n");
UpExit (-1);
}
readres += unread;
unreadlast = unread;
}
#ifndef PROVIDER
memset (&tableNam[0], '\0', sizeof (tableNam));
sprintf (&tableNam[0], "vshop");
#endif
#ifdef PROVIDER
if (VsadFile (vsBuffer) != 0)
{
printf ("\n\n(011) error: in reading \"/opt/vshop/vsadmin.conf\" file,\n exiting update program !\n");
UpExit (-1);
}
while ((vsPtr = VsadNext ()) != NULL)
{
memset (&tableNam[0], '\0', sizeof (tableNam));
strcpy (&tableNam[0], vsPtr);
#endif
memset (&tableVar, '\0', sizeof (tableVar));
if (Variables (buffer, bufLen, &tableNam[0], &tableVar) == -1)
{
printf ("\n\n(012) error: in reading \"/etc/vshop.conf\" file,\n exiting update program !\n");
UpExit (-1);
}
/* ***** test if the adabas database is running ***** */
if (adabasState == FALSE)
{
printf ("\n\n\t Fuer das Update ist es notwendig, dass die Datenbank \n vshop gestartet ist,sollte dies noch nicht geschehen sein \n wird versucht das Start Script \"vshopdb\" auszufuehren ...\n");
adabasState = TRUE;
}
if (AdabasRun(&tableVar) != 1)
{
printf ("\n\n(013) error: it is nececarry that database \"vshop\" is running,\n \
please start the database, \n \
the programm was not able to atomaticly detect the startup script.\n exiting update program !\n");
UpExit (-1);
}
/* ***** first get the actual working directory "startwd" ***** */
if ((testPtr = getcwd (&startwd[0], 255)) != &startwd[0])
{
printf ("\n\n(014) error: can't get actual working directory,\n exiting update program !\n");
UpExit (-1);
}
#ifdef PROVIDER
/* ***** test if directory '/opt' is present ***** */
memset (&fstat, '\0', sizeof (struct stat));
if (stat ("/opt", &fstat) != 0)
{
printf ("\n\n(015) error: directory \"/opt\" doase not exist, don't know where to find the admin region\n ,\n exiting update program !\n");
UpExit (-1);
}
memset (&fstat, '\0', sizeof (struct stat));
if (stat ("/opt/vshop", &fstat) != 0)
{
printf ("\n\n(016) error: directory \"/opt\" doase not exist, don't know where to find the admin region\n ,\n exiting update program !\n");
UpExit (-1);
}
#endif
/* ***** determin the rights, set on files in the admin zone ***** */
if ((tableVar.AdminRights = AdminRights(&tableVar.TEMPLATEROOT[0])) == 0)
{
printf ("\n\n(017) error: directory \"%s/admin\" does not exist or access denied,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
if ((tableVar.DokRights = DokRights(&tableVar.TEMPLATEROOT[0])) == 0)
{
printf ("\n\n(018) error: directory \"%s/dok\" does not exist or access denied,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
/* ***** create a backup of admin region ***** */
/* ***** create backup statement ***** */
printf ("\n\n\tErstellen eines Backups des alten Administrationsbereichs \n unter %s ...\n", &tableVar.TEMPLATEROOT[0]);
if (chdir (&tableVar.TEMPLATEROOT[0]) != 0)
{
printf ("\n\n(019) error: could not change working directory to \"%s\" ,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
oldNewDoc = OLD;
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "./update-backup.%s.tar.gz", VERSION);
if (stat (&systemStr[0], &fstat0) == -1)
{
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "tar zcf ./update-backup.%s.tar.gz ./admin ./dok", VERSION);
if (UpSystem (&systemStr[0]) != 0)
{
printf ("\n\n(020) error: could not backup your old admin and dok directorys\n under %s ,\n try to tar vshop_documentation directory!\n", &tableVar.TEMPLATEROOT[0]);
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "tar zcf ./update-backup.%s.tar.gz ./admin ./vshop_documentation", VERSION);
if (UpSystem (&systemStr[0]) != 0)
{
printf ("\n\n(021) error: could not backup your vshop_documentation directory,\n exiting update program !\n");
UpExit (-1);
}
else
oldNewDoc = NEW;
}
}
/* ***** wipe out the old admin region ***** */
/* ***** remove old admin region statement ***** */
printf ("\n\n\tLoeschen des alten Administrations- und Dokumentationsbereiches...\n");
memset (&systemStr[0], '\0', sizeof (systemStr));
if (oldNewDoc = OLD)
sprintf (&systemStr[0], "rm -fr %s/admin %s/dok", &tableVar.TEMPLATEROOT[0], &tableVar.TEMPLATEROOT[0]);
else
sprintf (&systemStr[0], "rm -fr %s/admin %s/vshop_documentation", &tableVar.TEMPLATEROOT[0], &tableVar.TEMPLATEROOT[0]);
if (ShSystem (&systemStr[0]) != 0)
{
printf ("\n\n(022) error: could not remove your old admin and dok directorys under %s ,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
/* ***** for recovery reasons we reached stage 1 ***** */
stage = 1;
if (chdir ((const char *) &tableVar.TEMPLATEROOT[0]) != 0)
{
printf ("\n\n(023) error: could not change working directory to %s ,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
/* ***** extract the new admin region ***** */
/* ***** extrtact statement ***** */
printf ("\n\n\t Entpacken des neuen Administrations Bereiches ...\n");
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "tar zxvf %s/vshtml%supdate.tgz", &instDir[0], VERSION);
if (ShSystem (&systemStr[0]) != 0)
{
printf ("\n\n(024) error: error in tar command,\n exiting update program !\n");
UpExit (-1);
}
if (setenv ("DBROOT", &tableVar.DBROOT[0], 1) != 0)
{
printf ("\n\n(025) error: could not set environment variable \"DBROOT\",\n exiting update program !\n");
UpExit (-1);
}
if (chdir ((const char *) &tableVar.DBROOT[0]) != 0)
{
printf ("\n\n(026) error: could not change directory to %s,\n exiting update program !\n", &tableVar.DBROOT[0]);
UpExit (-1);
}
/* ***** set access rights for admin region ***** */
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/admin", &tableVar.TEMPLATEROOT[0]);
if (RecChmod (&systemStr[0], tableVar.AdminRights) != 0)
{
printf ("\n\n(027) error: could not set access rights under %s/admin,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/vshop_documentation", &tableVar.TEMPLATEROOT[0]);
if (RecChmod (&systemStr[0], tableVar.DokRights) != 0)
{
printf ("\n\n(028) error: could not set access rights under %s/vshop_documentation,\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
/* ***** get the database working ***** */
/* ***** database startup statement ***** */
printf ("\n\n\t Anpassen der Datenbank ...\n");
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/bin/xload -d vshop -u %s,%s -S ADABAS -b %s/vsdb%supdate", &tableVar.DBROOT[0], \
&tableVar.DBUSER[0], &tableVar.DBPASSWORD[0], &instDir[0], VERSION);
system (&systemStr[0]);
/*
if (system (&systemStr[0]) != 0)
{
printf ("\n\n(029) error: error in execution of xload,\n exiting update program !\n");
UpExit (-1);
}
*/
/* ***** update the database ***** */
printf ("\n\n________________________________________\n\n \
\t UPDATE des vshops \"%s\"\n\n", &tableNam[0]);
while (TRUE)
{
printf ("\t Bitte geben sie den Pfad des CGI-Verzeichnisses\n \
\t fuer den shop \"%s\" an:\n\n\t>", &tableNam[0], &tableNam[0]);
memset (&cgiPath[0], '\0', sizeof (cgiPath));
fgets (&cgiPath[0], sizeof (cgiPath), (FILE *) stdin);
printf ("\n\n________________________________________\n\n");
while ((cgiPath[strlen (&cgiPath[0]) - 1] == '\n') ||
(cgiPath[strlen (&cgiPath[0]) - 1] == '\t') ||
(cgiPath[strlen (&cgiPath[0]) - 1] == ' '))
cgiPath[strlen (&cgiPath[0]) - 1] = '\0';
memset (&fstat, '\0', sizeof (struct stat));
memset (&fstat0, '\0', sizeof (struct stat));
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/%s", &cgiPath[0], &tableNam[0]);
if ((stat ((const char *) &cgiPath[0], &fstat) != 0) ||
(stat ((const char *) &systemStr[0], &fstat0) != 0))
printf ("\n\n\t Das Verzeichniss \"%s\" existiert nicht,\n\t \
oder ist nicht das korrekte CGI-Verzeichniss \n\t \
fuer \"%s\"\n\n", &cgiPath[0], &tableNam[0]);
else
break;
}
/* ***** copy the right vshop engine in place ***** */
/* ***** vshop 'engine' statement ***** */
printf ("\n\n\t Kopieren der Vshop \"engine\"\n");
memset (&testBuf[0], '\0', sizeof (testBuf));
sprintf (&testBuf[0], "libc.so.6");
if (Libc (&testBuf[0]) == 0)
{
if (chdir (&tableVar.TEMPLATEROOT[0]) != 0)
{
printf ("\n\n(030) error: error could not change working directory to \"%s\",\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/engine/libc6/vshop %s/%s", &instDir[0], &cgiPath[0], &tableNam[0]);
if (UpSystem (&systemStr[0]) != 0)
{
printf ("\n\n(031) error: error in execution of cp command,\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/%s", &cgiPath[0], &tableNam[0]);
setreuid (getuid(), getuid ());
setregid (getgid(), getgid ());
chown (&systemStr[0], (tableVar.AdminRights)->st_uid, (tableVar.AdminRights)->st_gid);
setreuid (getuid(), (tableVar.AdminRights)->st_uid);
setregid (getgid(), (tableVar.AdminRights)->st_gid);
chmod (&systemStr[0], (tableVar.AdminRights)->st_mode & CHMAP);
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/engine/libc6/vsl-compile %s/vsl-compile", &instDir[0], &cgiPath[0]);
if (ShSystem (&systemStr[0]) != 0)
{
printf ("\n\n(032) error: error in execution of cp command,\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/vsl-compile", &cgiPath[0]);
setreuid (getuid(), getuid ());
setregid (getgid(), getgid ());
chown (&systemStr[0], (tableVar.AdminRights)->st_uid, (tableVar.AdminRights)->st_gid);
setreuid (getuid(), (tableVar.AdminRights)->st_uid);
setregid (getgid(), (tableVar.AdminRights)->st_gid);
chmod (&systemStr[0], (tableVar.AdminRights)->st_mode & CHMAP);
}
else
{
memset (&testBuf[0], '\0', sizeof (testBuf));
sprintf (&testBuf[0], "libc.so.5");
if (Libc (&testBuf[0]) == 0)
{
if (chdir (&tableVar.TEMPLATEROOT[0]) != 0)
{
printf ("\n\n(033) error: error could not change working directory to \"%s\",\n exiting update program !\n", &tableVar.TEMPLATEROOT[0]);
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/engine/libc5/vshop %s/%s", &instDir[0], &cgiPath[0], &tableNam[0]);
if (UpSystem (&systemStr[0]) != 0)
{
printf ("\n\n(034) error: error in execution of command cp,\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/%s", &cgiPath[0], &tableNam[0]);
setreuid (getuid(), (tableVar.AdminRights)->st_uid);
setregid (getgid(), (tableVar.AdminRights)->st_gid);
chmod (&systemStr[0], (tableVar.AdminRights)->st_mode & CHMAP);
setreuid (getuid(), getuid ());
setregid (getgid(), getgid ());
chown (&systemStr[0], (tableVar.AdminRights)->st_uid, (tableVar.AdminRights)->st_gid);
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/engine/libc5/vsl-compile %s/vsl-compile", &instDir[0], &cgiPath[0]);
if (UpSystem (&systemStr[0]) != 0)
{
printf ("\n\n(035) error: error in execution of command cp,\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s/vsl-compile", &cgiPath[0]);
setreuid (getuid(), (tableVar.AdminRights)->st_uid);
setregid (getgid(), (tableVar.AdminRights)->st_gid);
chmod (&systemStr[0], (tableVar.AdminRights)->st_mode & CHMAP);
setreuid (getuid(), getuid ());
setregid (getgid(), getgid ());
chown (&systemStr[0], (tableVar.AdminRights)->st_uid, (tableVar.AdminRights)->st_gid);
}
else
{
printf ("\n\n(036) error: can't determin your libc version,\n exiting update program !\n");
UpExit (-1);
}
}
/* ***** removing all user '.p' files ***** */
/* ***** remove statement ***** */
printf ("\n\n\tLoeschen aller \"user\" .p Dateien unter %s ...\n", &tableVar.TEMPLATEROOT[0]);
if (RecRem (&tableVar.TEMPLATEROOT[0]) != 0)
{
printf ("\n\n(037) error: can't remove all user \".p\" files,\n exiting update program !\n");
UpExit (-1);
}
/* ***** for recovery reasons we reached stage 2 ***** */
stage = 2;
/* ***** search for 'productlink' in TEMPLATEROOT ***** */
/* ***** search statement ***** */
printf ("\n\n\tSuchen nach \"productlink\" in allen Textdateien\n unter %s ...\n", &tableVar.TEMPLATEROOT[0]);
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "grep --line-number -2 productlink `find %s/ -regex .*\\.[htm,html,HTM,HTML]$` > %s/productlink.log 2> /dev/null", &tableVar.TEMPLATEROOT[0], &tableVar.TEMPLATEROOT[0]);
ShSystem (&systemStr[0]);
/* --- O D
if (system (&systemStr[0]) != 0)
{
printf ("\n\n(038) error: error in execution of command string,\n exiting update program !\n");
UpExit (-1);
}
O D --- */
#ifdef PROVIDER
/* ***** add additional configuration statments to '/etc/vshop.conf' ***** */
/* ***** configuration statement ***** */
printf ("\n\n\tErgaenzen von /etc/vshop.conf ...\n");
i = 0;
while (i < strlen (tableNam))
{
table[i] = toupper (*(tableNam + i));
i++;
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_PROFILING", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "1", vshopfd, "_PROFILING ", 0) != 0)
{
printf ("\n\n(039) error: could not add PROFILING string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_TIMEOUTURL", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "http://your.server.name/...", vshopfd, "_TIMEOUTURL ", COMMENT) != 0)
{
printf ("\n\n(040) error: could not add TIMEOUTURL string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_DBERRORURL", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "http://your.server.name/...", vshopfd, "_DBERRORURL ", COMMENT) != 0)
{
printf ("\n\n(041) error: could not add DBERRORURL string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0],"%s_MAILSERVER", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "your.mail.server", vshopfd, "_MAILSERVER ", COMMENT) != 0)
{
printf ("\n\n(042) error: could not add MAILSERVER string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_MAILFROM", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "shop@your.server.name", vshopfd, "_MAILFROM ", COMMENT) != 0)
{
printf ("\n\n(043) error: could not add MAILFROM string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_MAILTO", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "orders@your.server.name", vshopfd, "_MAILTO ", COMMENT) != 0)
{
printf ("\n\n(044) error: could not add MAILTO string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_EURODM", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "0.5112918811962", vshopfd, "_EURODM ", 0) != 0)
{
printf ("\n\n(045) error: could not add EURODM string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_EUROUSD", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "0.8637816360024", vshopfd, "_EUROUSD ", 0) != 0)
{
printf ("\n\n(046) error: could not add EUROUSD string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_RTF", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "application/rtf", vshopfd, "_RTF ", 0) != 0)
{
printf ("\n\n(047) error: could not add RTF string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "%s_ADMINIP", &table[0]);
if (strstr (buffer, &systemStr[0]) == NULL)
if (Addstr (&tableNam[0], "*", vshopfd, "_ADMINIP ", 0) != 0)
{
printf ("\n\n(047) error: could not add ADMINIP string to \"/etc/vshop.conf\",\n exiting update program !\n");
UpExit (-1);
}
/* ***** for recovery reasons we reached stage 3 ***** */
stage = 3;
}
#endif
/* ***** new vsadmin region will be copied to '/opt/vshop/..' ***** */
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/vshtmlp%s.tgz /opt/vshop/vshtml.tgz", &instDir[0], VERSION);
if (ShSystem (&systemStr[0]) != 0)
{
printf ("\n\n(048) error: error in cp command,\n exiting update program !\n");
UpExit (-1);
}
/* ***** for recovery reasons we reached stage 4 ***** */
stage = 4;
/* ***** 'vsadmin'statement ***** */
printf ("\n\n\t Kopieren von \"vsadmin\"\n");
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/engine/vsadmin /opt/vshop/vsadmin", &instDir[0]);
if (ShSystem (&systemStr[0]) != 0)
{
printf ("\n\n(049) error: error in cp command,\n exiting update program !\n");
UpExit (-1);
}
/* ***** for recovery reasons we reached stage 5 ***** */
stage = 5;
memset (&systemStr[0], '\0', sizeof (systemStr));
sprintf (&systemStr[0], "cp -f %s/createtabs%s /opt/vshop/createtabs", &instDir[0], VERSION);
if (ShSystem (&systemStr[0]) != 0)
{
printf ("\n\n(050) error: error in cp command,\n exiting update program !\n");
UpExit (-1);
}
/* ***** for recovery reasons we reached stage 6 ***** */
stage = 6;
/* ***** end statment of update program ***** */
printf ("\n\n\tDas Update auf VShop %s wurde durchgefuehrt.\n \
\t Bitte ueberpruefen Sie die Zugriffsrechte der neu\n \
\t installierten Dateien, da es sonst zu Problemen\n \
\t kommen kann.\n\n",VERSION);
}
/* -------------------------------------------------- */
/*
*
* Variables function
*
*/
int
Variables (char *buffer, int bufLen, char *tableNam, tstrT *tableVar)
{
int i;
char searchStr[255];
char table[64];
char *s1Ptr;
char *s2Ptr;
struct stat fstat;
i = 0;
memset (&table[0], '\0', sizeof (table));
while (i <= strlen (tableNam))
{
table[i] = toupper(*(tableNam + i));
i++;
}
if ((s1Ptr = (char *) strstr ((const char *) buffer, "DBROOT")) == NULL)
return (-1);
s2Ptr = s1Ptr + strlen ("DBROOT");
while (((*s2Ptr == ' ') ||
(*s2Ptr == '\t')) &&
(s2Ptr <= buffer + bufLen))
s2Ptr++;
if ((*s2Ptr == '\n') ||
(*s2Ptr == EOF))
return (-1);
if (*s2Ptr == '"')
{
i = 0;
while ((*s2Ptr != '"') &&
(*(s2Ptr - 1) != '\\') &&
(s2Ptr <= buffer + bufLen) &&
(i <= 255))
{
if (*s2Ptr == '\n')
return (-1);
tableVar->DBROOT[i] = *s2Ptr;
i++;
s2Ptr++;
}
*s2Ptr = '"';
}
else
{
i = 0;
while ((*s2Ptr != '\n') &&
(*s2Ptr != ' ') &&
(*s2Ptr != '\t') &&
(s2Ptr <= buffer + bufLen) &&
(i <= 255))
{
tableVar->DBROOT[i] = *s2Ptr;
i++;
s2Ptr++;
}
}