From 1d9539d67e20ebbf6605fe2fbfce566d238b9dda Mon Sep 17 00:00:00 2001 From: b Date: Sun, 25 Sep 2022 21:54:52 +0000 Subject: [PATCH] fixed compile problems, expanded build process --- bot2.1.cpp | 90 +++--- bot3.1.cpp | 54 ++-- findpost.1.cpp | 18 +- makefile | 185 +++++++------ makefile.1.mak | 183 +++++++------ mpview.1.cpp | 63 +++-- mview.1.cpp | 65 ++--- post.1.cpp | 67 ++--- posted.1.cpp | 43 +-- settings-release.txt | 5 +- settings.txt | 53 +++- view.1.cpp | 42 +-- www/ott/end | 4 +- www/ott/np/end | 4 +- www/ott/post.htm | 5 +- www/ott/prosilver/theme/forms.css | 438 ++++++++++++++++++++++++++++++ 16 files changed, 922 insertions(+), 397 deletions(-) create mode 100644 www/ott/prosilver/theme/forms.css diff --git a/bot2.1.cpp b/bot2.1.cpp index 225179b..90dfc07 100644 --- a/bot2.1.cpp +++ b/bot2.1.cpp @@ -66,14 +66,16 @@ // ###C_AWK_UPLOAD: #define AWK_UPLOAD "/eizm/pro/ottmirror/upload.awk" // ###C_AWK_INDEX: #define AWK_INDEX "/eizm/pro/ottmirror/index.awk" +# define N_STRBUF 256 + FILE *cwfile; FILE *stopfile; bool logopen=false; -char stoppath[256]; -char nppath [256]; -char nppath1[256]; -char nppath2[256]; -char nppath3[256]; +char stoppath[N_STRBUF]; +char nppath [N_STRBUF]; +char nppath1[N_STRBUF]; +char nppath2[N_STRBUF]; +char nppath3[N_STRBUF]; pid_t sub; int r; @@ -112,15 +114,15 @@ int main(int argc, char *argv[]) unsigned long i,np,last,last2; - char argp1 [256]; - char argp2[256]; - char argp3[256]; - char argp4[256]; - char argp5[256]; - char argp6[256]; - char argp7[256]; - char temp [256]; - char URL [256]; + char argp1 [N_STRBUF]; + char argp2[N_STRBUF]; + char argp3[N_STRBUF]; + char argp4[N_STRBUF]; + char argp5[N_STRBUF]; + char argp6[N_STRBUF]; + char argp7[N_STRBUF]; + char temp [N_STRBUF]; + char URL [N_STRBUF]; time(&t); opterr=0; @@ -193,10 +195,10 @@ int main(int argc, char *argv[]) offset=1; if(!fs) { - sprintf(argp1,"%s%hu",LAST_PATH,botID); + snprintf(argp1,N_STRBUF,"%s%hu",LAST_PATH,botID); if((cwfile=fopen(argp1,"rt"))!=NULL) { - fgets(temp,255,cwfile); + fgets(temp,N_STRBUF-1,cwfile); sscanf(temp,"%lu",&start); fclose(cwfile); start=((start>offset)?(start+1-offset):1); @@ -214,7 +216,7 @@ int main(int argc, char *argv[]) avoid=0; if(!text) { - sprintf(argp1,"%s%hu",LOG_PATH,botID); + snprintf(argp1,N_STRBUF,"%s%hu",LOG_PATH,botID); if(freopen(argp1,newlog?"wt":"at",stdout)!=NULL) logopen=true; } @@ -225,11 +227,11 @@ int main(int argc, char *argv[]) printf("ID=%hu, offset=%lu, start=%lu, max=%lu, NP wait=%lus, A wait=%lus, present=%s -%lu, save_avatars=%s, save_attachments=%s, save_otherimg=%s",botID,offset,start,max,npwait,await,(recentbot?"YES":"NO"),avoid,(down?"YES":"NO"),(down2?"YES":"NO"),(down3?"YES":"NO")); - sprintf(nppath ,"%s%hu",NP_PATH ,botID); - sprintf(nppath1,"%s%hu",NP_PATH_1,botID); - sprintf(nppath2,"%s%hu",NP_PATH_2,botID); - sprintf(nppath3,"%s%hu",NP_PATH_3,botID); - sprintf(stoppath,"%s%hu",STOP_PATH,botID); + snprintf(nppath ,N_STRBUF,"%s%hu",NP_PATH ,botID); + snprintf(nppath1,N_STRBUF,"%s%hu",NP_PATH_1,botID); + snprintf(nppath2,N_STRBUF,"%s%hu",NP_PATH_2,botID); + snprintf(nppath3,N_STRBUF,"%s%hu",NP_PATH_3,botID); + snprintf(stoppath,N_STRBUF,"%s%hu",STOP_PATH,botID); stopfile=fopen(stoppath,"wt"); if (stopfile==NULL) @@ -244,7 +246,7 @@ int main(int argc, char *argv[]) sleep(npwait); printf("\n%lu: np%lu",i,np); - sprintf(URL,"%s%lu",OTT_ADDRESS,(np-1)*40); + snprintf(URL,N_STRBUF,"%s%lu",OTT_ADDRESS,(np-1)*40); // download the newpage printf(" download"); @@ -269,7 +271,7 @@ int main(int argc, char *argv[]) printf("."); // what's the last page and how many posts are there? - sprintf(argp1,"outfile=%s",nppath3); + snprintf(argp1,N_STRBUF,"outfile=%s",nppath3); sub=fork(); if(!sub) { @@ -299,7 +301,7 @@ int main(int argc, char *argv[]) // List of posts // Yes, this could be done in the next script (It ewen was) but it has to be done BEFORE it. - sprintf(argp1,"outfile=%s%lu",LIST_PATH,np); + snprintf(argp1,N_STRBUF,"outfile=%s%lu",LIST_PATH,np); sub=fork(); if(!sub) { @@ -312,13 +314,13 @@ int main(int argc, char *argv[]) printf("."); // relink, convert, download things - sprintf(argp1,"outfile=%s",nppath1); - sprintf(argp2,"tempfile=%s",nppath2); - sprintf(argp5,"imagepath=%s",IMG_PATH); - sprintf(argp3,"avatarpath=%s",AV_PATH); - sprintf(argp4,"attachmentpath=%s",ATT_PATH); - sprintf(argp6,"wait=%lu",await); - sprintf(argp7,"tempfile2=%s",nppath3); + snprintf(argp1,N_STRBUF,"outfile=%s",nppath1); + snprintf(argp2,N_STRBUF,"tempfile=%s",nppath2); + snprintf(argp5,N_STRBUF,"imagepath=%s",IMG_PATH); + snprintf(argp3,N_STRBUF,"avatarpath=%s",AV_PATH); + snprintf(argp4,N_STRBUF,"attachmentpath=%s",ATT_PATH); + snprintf(argp6,N_STRBUF,"wait=%lu",await); + snprintf(argp7,N_STRBUF,"tempfile2=%s",nppath3); sub=fork(); if(!sub) { @@ -331,9 +333,9 @@ int main(int argc, char *argv[]) printf(".OK, upload"); // upload the newpage - sprintf(argp1 ,"outfile=%s%lu",UP_PATH,np); - sprintf(argp2,"sig=%s",SIG_PATH); - sprintf(argp3,"otterinf=%s",INF_PATH); + snprintf(argp1,N_STRBUF,"outfile=%s%lu",UP_PATH,np); + snprintf(argp2,N_STRBUF,"sig=%s",SIG_PATH); + snprintf(argp3,N_STRBUF,"otterinf=%s",INF_PATH); sub=fork(); if(!sub) @@ -349,7 +351,7 @@ int main(int argc, char *argv[]) if((np==last2)&&(!recentbot)) np=0L; - sprintf(argp1,"%s%hu",LAST_PATH,botID); + snprintf(argp1,N_STRBUF,"%s%hu",LAST_PATH,botID); if((cwfile=fopen(argp1,"wt"))!=NULL) { fprintf(cwfile,"%lu\n",np); @@ -380,7 +382,7 @@ int main(int argc, char *argv[]) printf(" OK, prepare"); // cut out only what's needed - sprintf(argp1,"outfile=%s",nppath3); + snprintf(argp1,N_STRBUF,"outfile=%s",nppath3); sub=fork(); if(!sub) { @@ -393,13 +395,13 @@ int main(int argc, char *argv[]) printf("."); // relink - sprintf(argp1,"outfile=%s",IND_PATH); - sprintf(argp2,"tempfile=%s",nppath2); - sprintf(argp3,"avatarpath=%s",AV_PATH); - sprintf(argp5,"imagepath=%s",IMG_PATH); - sprintf(argp4,"attachmentpath=%s",ATT_PATH); - sprintf(argp6,"wait=%lu",await); - sprintf(argp7,"tempfile2=%s",nppath1); + snprintf(argp1,N_STRBUF,"outfile=%s",IND_PATH); + snprintf(argp2,N_STRBUF,"tempfile=%s",nppath2); + snprintf(argp3,N_STRBUF,"avatarpath=%s",AV_PATH); + snprintf(argp5,N_STRBUF,"imagepath=%s",IMG_PATH); + snprintf(argp4,N_STRBUF,"attachmentpath=%s",ATT_PATH); + snprintf(argp6,N_STRBUF,"wait=%lu",await); + snprintf(argp7,N_STRBUF,"tempfile2=%s",nppath1); sub=fork(); if(!sub) { diff --git a/bot3.1.cpp b/bot3.1.cpp index f6f406d..d3f8527 100644 --- a/bot3.1.cpp +++ b/bot3.1.cpp @@ -55,6 +55,8 @@ // ###C_AWK_POST: #define AWK_POST "/eizm/pro/ottmirror/post.awk" // ###C_AWK_PM: #define AWK_PM "/eizm/pro/ottmirror/pm.awk" +#define N_STRBUF 256 + FILE *cwfile; FILE *stopfile; FILE *listfile; @@ -85,16 +87,16 @@ int main(int argc, char *argv[]) unsigned long np, lastnp, firstnp, i; unsigned short p, lastp, firstp; - char name[256]; - char pass[256]; - char listpath[256]; - char postpath[256]; - char postname[256]; - char argp1 [256]; - char argp2[256]; - char argp3[256]; - char argp4[256]; - char argp5[256]; + char name[N_STRBUF]; + char pass[N_STRBUF]; + char listpath[N_STRBUF]; + char postpath[N_STRBUF]; + char postname[N_STRBUF]; + char argp1 [N_STRBUF]; + char argp2[N_STRBUF]; + char argp3[N_STRBUF]; + char argp4[N_STRBUF]; + char argp5[N_STRBUF]; time(&t); opterr=0; @@ -156,11 +158,11 @@ int main(int argc, char *argv[]) cwfile=fopen(NAME_PATH,"rt"); if(cwfile==NULL) end(NAME_MSTD); - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) sscanf(argp1,"%s",name); else end(NAME_MSTD); - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) sscanf(argp1,"%s",pass); else end(NAME_MSTD); @@ -169,11 +171,11 @@ int main(int argc, char *argv[]) cwfile=fopen(LAST_PATH,"rt"); if(cwfile==NULL) end(NOPOSTS); - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) sscanf(argp1,"%lu",&lastnp); else end(NOPOSTS); - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) sscanf(argp1,"%hu",&lastp); else end(NOPOSTS); @@ -189,10 +191,10 @@ int main(int argc, char *argv[]) } else { - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) { sscanf(argp1,"%lu",&firstnp); - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) sscanf(argp1,"%hu",&firstp); else firstp=0; @@ -211,7 +213,7 @@ int main(int argc, char *argv[]) p=0; printf("\nnp%lu:",np); - sprintf(listpath,"%s%lu",LIST_PATH,np); + snprintf(listpath,N_STRBUF,"%s%lu",LIST_PATH,np); listfile=fopen(listpath,"rt"); if(listfile==NULL) { @@ -220,7 +222,7 @@ int main(int argc, char *argv[]) } listopen=true; - for(p=1;fgets(argp1,255,listfile)!=NULL;++p) + for(p=1;fgets(argp1,N_STRBUF-1,listfile)!=NULL;++p) { if((np==firstnp&&p<=firstp)||(np==lastnp&&p>lastp)) continue; @@ -229,12 +231,12 @@ int main(int argc, char *argv[]) sscanf(argp1,"%s",postname); printf("\n%hu: m%s: ",p,postname); - sprintf(postpath,"%s%s",POST_PATH,postname); - sprintf(argp1 ,"postfile=%s",POSTDATA_PATH); - sprintf(argp2,"cookiefile=%s",COOKIE_PATH); - sprintf(argp3,"tempfile=%s",TEMPFILE_PATH); - sprintf(argp4,"name=%s",name); - sprintf(argp5,"pass=%s",pass); + snprintf(postpath,N_STRBUF,"%s%s",POST_PATH,postname); + snprintf(argp1,N_STRBUF,"postfile=%s",POSTDATA_PATH); + snprintf(argp2,N_STRBUF,"cookiefile=%s",COOKIE_PATH); + snprintf(argp3,N_STRBUF,"tempfile=%s",TEMPFILE_PATH); + snprintf(argp4,N_STRBUF,"name=%s",name); + snprintf(argp5,N_STRBUF,"pass=%s",pass); sub=fork(); if(!sub) @@ -342,10 +344,10 @@ int main(int argc, char *argv[]) cwfile=fopen(LAST_PATH,"rt"); if(cwfile!=NULL) { - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) { sscanf(argp1,"%lu",&np); - if(fgets(argp1,255,cwfile)!=NULL) + if(fgets(argp1,N_STRBUF-1,cwfile)!=NULL) { sscanf(argp1,"%hu",&p); fclose(cwfile); diff --git a/findpost.1.cpp b/findpost.1.cpp index 8392549..dacd5f4 100644 --- a/findpost.1.cpp +++ b/findpost.1.cpp @@ -21,6 +21,8 @@ // ###C_LIST_PATH: #define LIST_PATH "/eizm/www/time/ott/postlist/" +#define N_STRBUF 256 + #include int main(int argc, char *argv[]) @@ -29,8 +31,8 @@ int main(int argc, char *argv[]) unsigned long postnumber; unsigned long pagenumber=0; unsigned long pagenumber2; - char path[256]; - char text[256]; + char path[N_STRBUF]; + char text[N_STRBUF]; FILE *file; if (argc<2) @@ -43,11 +45,11 @@ int main(int argc, char *argv[]) for(short i=31;i>=0;--i) { pagenumber2 = pagenumber + (1L << i); - sprintf(path,"%s%lu",LIST_PATH,pagenumber2); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,pagenumber2); file=fopen(path,"rt"); if(file==NULL) continue; - fgets(text,255,file); + fgets(text,N_STRBUF-1,file); fclose(file); sscanf(text,"%lu",&postnumber); if(postnumber==to_find) @@ -63,14 +65,14 @@ int main(int argc, char *argv[]) printf("0\n"); return 0; } - sprintf(path,"%s%lu",LIST_PATH,pagenumber); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,pagenumber); file=fopen(path,"rt"); if(file==NULL) { printf("0\n"); return 0; } - while(fgets(text,255,file)!=NULL ) + while(fgets(text,N_STRBUF-1,file)!=NULL ) { sscanf(text,"%lu",&postnumber); if(postnumber==to_find) @@ -81,14 +83,14 @@ int main(int argc, char *argv[]) } } fclose(file); - sprintf(path,"%s%lu",LIST_PATH,pagenumber-1); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,pagenumber-1); file=fopen(path,"rt"); if(file==NULL) { printf("0\n"); return 0; } - while(fgets(text,255,file)!=NULL ) + while(fgets(text,N_STRBUF-1,file)!=NULL ) { sscanf(text,"%lu",&postnumber); if(postnumber==to_find) diff --git a/makefile b/makefile index 3b9dd37..b01766f 100644 --- a/makefile +++ b/makefile @@ -21,7 +21,7 @@ CC =g++ -CF =-g -Wall +CF =-g -Wall -Wno-format-truncation L_CGI=-lcgi # AI=mawk -f @@ -33,8 +33,30 @@ endif CONFIGFILE = settings-$(TARGET).txt settings.txt -PERL=/usr/bin/perl -RM =/usr/bin/rm +PERL =/usr/bin/perl +MKDIR=/usr/bin/mkdir +CP =/usr/bin/cp +RM =/usr/bin/rm +CHMOD=/usr/bin/chmod + +BIN_PATH = /botm/bin/ottmirror +LOG_PATH = /botm/log/ottmirror +MEM_PATH = /botm/data/ottmirror +MEM_LIST_PATH = /botm/data/ottmirror/mlist +MEM_POST_PATH = /botm/data/ottmirror/mpost +MEM_OK_PATH = /botm/data/ottmirror/mpost/ok +MEM_PM_PATH = /botm/data/ottmirror/mpost/pm +MEM_FAIL_PATH = /botm/data/ottmirror/mpost/fail +TMP_PATH = /botm/tmp/ottmirror +WWW_PATH = /botm/www/1190/ott +WWW_ATT_PATH = /botm/www/1190/ott/attachment +WWW_AV_PATH = /botm/www/1190/ott/avatar +WWW_IMG_PATH = /botm/www/1190/ott/image +WWW_INF_PATH = /botm/www/1190/ott/otterinf +WWW_LIST_PATH = /botm/www/1190/ott/postlist +WWW_SIG_PATH = /botm/www/1190/ott/sig +WWW_UP_PATH = /botm/www/1190/ott/np + # The configuration tool # http://bicyclesonthemoon.info/git/botm-config @@ -91,6 +113,67 @@ redirect\ update\ view +SETUID=\ +post\ +update\ +view\ +mview\ +posted\ +mpview + +BIN=\ +bb2html.awk\ +bot2\ +bot2.awk\ +bot3\ +bot3.cpp\ +findlatest.awk\ +findpost\ +image\ +index\ +index.awk\ +list.awk\ +mpview\ +mview\ +mview.awk\ +mview.cpp\ +pm.awk\ +post\ +post.awk\ +posted\ +posted.awk\ +preview.awk\ +redirect\ +update\ +upload.awk\ +verify.awk\ +view\ +view.awk + +DIR=\ +$(BIN_PATH)\ +$(LOG_PATH)\ +$(MEM_PATH)\ +$(MEM_LIST_PATH)\ +$(MEM_POST_PATH)\ +$(MEM_OK_PATH)\ +$(MEM_PM_PATH)\ +$(MEM_FAIL_PATH)\ +$(TMP_PATH)\ +$(WWW_PATH)\ +$(WWW_ATT_PATH)\ +$(WWW_AV_PATH)\ +$(WWW_IMG_PATH)\ +$(WWW_INF_PATH)\ +$(WWW_LIST_PATH)\ +$(WWW_SIG_PATH)\ +$(WWW_UP_PATH)\ + + +HIDDEN_DIR=\ +$(TMP_PATH)\ +$(MEM_POST_PATH) + all: $(TO_GENERATE) $(PROGR_NORMAL) $(PROGR_CGI) @@ -106,95 +189,27 @@ $(PROGR_NORMAL): %: %.cpp $(PROGR_CGI): %: %.cpp $(CC) $(CF) -o $@ $< $(L_CGI) -clean: - $(RM) -f $(TO_GENERATE) $(PROGR_NORMAL) $(PROGR_CGI) - -PHONY: all clean - -# all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable - -# bot2: bot2.cpp bot2.awk findlatest.awk list.awk upload.awk index.awk makefile - # $(CC) $(CF) -o bot2 bot2.cpp - -# bot3: bot3.cpp post.awk pm.awk makefile - # $(CC) $(CF) -o bot3 bot3.cpp - -# findpost: findpost.cpp makefile - # $(CC) $(CF) -o findpost findpost.cpp - -# image: image.cpp makefile - # $(CC) $(CF) -o image image.cpp - -# view: view.cpp view.awk makefile - # $(CC) $(CF) -o view view.cpp $(LF1) - -# mview: mview.cpp view.awk mview.awk makefile - # $(CC) $(CF) -o mview mview.cpp $(LF1) - -# mpview: mpview.cpp view.awk mview.awk makefile - # $(CC) $(CF) -o mpview mpview.cpp $(LF1) - -# update: update.cpp bot2 makefile - # $(CC) $(CF) -o update update.cpp $(LF1) - -# index: index.cpp makefile - # $(CC) $(CF) -o index index.cpp $(LF1) - -# post: post.cpp preview.awk view.awk bb2html.awk verify.awk makefile - # $(CC) $(CF) -o post post.cpp $(LF1) +setuid: $(SETUID) + $(CHMOD) u+s $(SETUID) -# posted: posted.cpp posted.awk makefile - # $(CC) $(CF) -o posted posted.cpp $(LF1) +mktree: + $(MKDIR) -p $(DIR) + $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) -# redirect: redirect.cpp makefile - # $(CC) $(CF) -o redirect redirect.cpp $(LF1) - -# enable: post update view mview posted mpview - # chmod u+s post update view mview posted mpview +cp_bin: $(BIN) setuid | mktree + $(CP) $(BIN) $(BIN_PATH) +cp_www: | mktree + $(CP) -r www/ott/* $(WWW_PATH) +install: cp_bin cp_www -# bot2.cpp: bot2.1.cpp re.awk makefile - # $(AI) re.awk bot2.1.cpp > bot2.cpp - -# bot3.cpp: bot3.1.cpp re.awk makefile - # $(AI) re.awk bot3.1.cpp > bot3.cpp - -# findpost.cpp: findpost.1.cpp re.awk makefile - # $(AI) re.awk findpost.1.cpp > findpost.cpp - -# index.cpp: index.1.cpp re.awk makefile - # $(AI) re.awk index.1.cpp > index.cpp - -# mview.cpp: mview.1.cpp re.awk makefile - # $(AI) re.awk mview.1.cpp > mview.cpp - -# mpview.cpp: mpview.1.cpp re.awk makefile - # $(AI) re.awk mpview.1.cpp > mpview.cpp - -# post.cpp: post.1.cpp re.awk makefile - # $(AI) re.awk post.1.cpp > post.cpp -# posted.cpp: posted.1.cpp re.awk makefile - # $(AI) re.awk posted.1.cpp > posted.cpp - -# update.cpp: update.1.cpp re.awk makefile - # $(AI) re.awk update.1.cpp > update.cpp - -# view.cpp: view.1.cpp re.awk makefile - # $(AI) re.awk view.1.cpp > view.cpp - -# bot2.awk: bot2.1.awk re.awk makefile - # $(AI) re.awk bot2.1.awk > bot2.awk +clean: + $(RM) -f $(TO_GENERATE) $(PROGR_NORMAL) $(PROGR_CGI) -# index.awk: index.1.awk re.awk makefile - # $(AI) re.awk index.1.awk > index.awk +PHONY: all clean setuid mktree cp_bin cp_www install -# pm.awk: pm.1.awk re.awk makefile - # $(AI) re.awk pm.1.awk > pm.awk +# all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable -# post.awk: post.1.awk re.awk makefile - # $(AI) re.awk post.1.awk > post.awk -# preview.awk: preview.1.awk re.awk makefile - # $(AI) re.awk preview.1.awk > preview.awk diff --git a/makefile.1.mak b/makefile.1.mak index cba95cd..b789fd5 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -33,8 +33,30 @@ endif CONFIGFILE = settings-$(TARGET).txt settings.txt -###MAKE_PERL: PERL = perl -###MAKE_RM: RM = rm +###MAKE_PERL: PERL = perl +###MAKE_MKDIR: MKDIR = mkdir +###MAKE_CP: CP = rm +###MAKE_RM: RM = rm +###MAKE_CHMOD: CHMOD = chmod + +###MAKE_BIN_PATH: BIN_PATH = /botm/bin/ottmirror +###MAKE_LOG_PATH: LOG_PATH = /botm/log/ottmirror +###MAKE_MEM_PATH: MEM_PATH = /botm/data/ottmirror +###MAKE_MEM_LIST_PATH: MEM_LIST_PATH = /botm/data/ottmirror/mlist +###MAKE_MEM_POST_PATH: MEM_POST_PATH = /botm/data/ottmirror/mpost +###MAKE_MEM_OK_PATH: MEM_OK_PATH = /botm/data/ottmirror/mpost/ok +###MAKE_MEM_PM_PATH: MEM_PM_PATH = /botm/data/ottmirror/mpost/pm +###MAKE_MEM_FAIL_PATH: MEM_FAIL_PATH = /botm/data/ottmirror/mpost/fail +###MAKE_TMP_PATH: TMP_PATH = /botm/tmp/ottmirror +###MAKE_WWW_PATH: WWW_PATH = /botm/www/1190/ott +###MAKE_WWW_ATT_PATH: WWW_ATT_PATH = /botm/www/1190/ott/attachment +###MAKE_WWW_AV_PATH: WWW_AV_PATH = /botm/www/1190/ott/avatar +###MAKE_WWW_IMG_PATH: WWW_IMG_PATH = /botm/www/1190/ott/image +###MAKE_WWW_INF_PATH: WWW_INF_PATH = /botm/www/1190/ott/otterinf +###MAKE_WWW_LIST_PATH: WWW_LIST_PATH = /botm/www/1190/ott/postlist +###MAKE_WWW_SIG_PATH: WWW_SIG_PATH = /botm/www/1190/ott/sig +###MAKE_WWW_UP_PATH: WWW_UP_PATH = /botm/www/1190/ott/np + # The configuration tool # http://bicyclesonthemoon.info/git/botm-config @@ -91,6 +113,67 @@ redirect\ update\ view +SETUID=\ +post\ +update\ +view\ +mview\ +posted\ +mpview + +BIN=\ +bb2html.awk\ +bot2\ +bot2.awk\ +bot3\ +bot3.cpp\ +findlatest.awk\ +findpost\ +image\ +index\ +index.awk\ +list.awk\ +mpview\ +mview\ +mview.awk\ +mview.cpp\ +pm.awk\ +post\ +post.awk\ +posted\ +posted.awk\ +preview.awk\ +redirect\ +update\ +upload.awk\ +verify.awk\ +view\ +view.awk + +DIR=\ +$(BIN_PATH)\ +$(LOG_PATH)\ +$(MEM_PATH)\ +$(MEM_LIST_PATH)\ +$(MEM_POST_PATH)\ +$(MEM_OK_PATH)\ +$(MEM_PM_PATH)\ +$(MEM_FAIL_PATH)\ +$(TMP_PATH)\ +$(WWW_PATH)\ +$(WWW_ATT_PATH)\ +$(WWW_AV_PATH)\ +$(WWW_IMG_PATH)\ +$(WWW_INF_PATH)\ +$(WWW_LIST_PATH)\ +$(WWW_SIG_PATH)\ +$(WWW_UP_PATH)\ + + +HIDDEN_DIR=\ +$(TMP_PATH)\ +$(MEM_POST_PATH) + all: $(TO_GENERATE) $(PROGR_NORMAL) $(PROGR_CGI) @@ -106,95 +189,27 @@ $(PROGR_NORMAL): %: %.cpp $(PROGR_CGI): %: %.cpp $(CC) $(CF) -o $@ $< $(L_CGI) -clean: - $(RM) -f $(TO_GENERATE) $(PROGR_NORMAL) $(PROGR_CGI) - -PHONY: all clean - -# all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable - -# bot2: bot2.cpp bot2.awk findlatest.awk list.awk upload.awk index.awk makefile - # $(CC) $(CF) -o bot2 bot2.cpp - -# bot3: bot3.cpp post.awk pm.awk makefile - # $(CC) $(CF) -o bot3 bot3.cpp - -# findpost: findpost.cpp makefile - # $(CC) $(CF) -o findpost findpost.cpp - -# image: image.cpp makefile - # $(CC) $(CF) -o image image.cpp - -# view: view.cpp view.awk makefile - # $(CC) $(CF) -o view view.cpp $(LF1) - -# mview: mview.cpp view.awk mview.awk makefile - # $(CC) $(CF) -o mview mview.cpp $(LF1) - -# mpview: mpview.cpp view.awk mview.awk makefile - # $(CC) $(CF) -o mpview mpview.cpp $(LF1) - -# update: update.cpp bot2 makefile - # $(CC) $(CF) -o update update.cpp $(LF1) - -# index: index.cpp makefile - # $(CC) $(CF) -o index index.cpp $(LF1) - -# post: post.cpp preview.awk view.awk bb2html.awk verify.awk makefile - # $(CC) $(CF) -o post post.cpp $(LF1) +setuid: $(SETUID) + $(CHMOD) u+s $(SETUID) -# posted: posted.cpp posted.awk makefile - # $(CC) $(CF) -o posted posted.cpp $(LF1) +mktree: + $(MKDIR) -p $(DIR) + $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) -# redirect: redirect.cpp makefile - # $(CC) $(CF) -o redirect redirect.cpp $(LF1) - -# enable: post update view mview posted mpview - # chmod u+s post update view mview posted mpview +cp_bin: $(BIN) setuid | mktree + $(CP) $(BIN) $(BIN_PATH) +cp_www: | mktree + $(CP) -r www/ott/* $(WWW_PATH) +install: cp_bin cp_www -# bot2.cpp: bot2.1.cpp re.awk makefile - # $(AI) re.awk bot2.1.cpp > bot2.cpp - -# bot3.cpp: bot3.1.cpp re.awk makefile - # $(AI) re.awk bot3.1.cpp > bot3.cpp - -# findpost.cpp: findpost.1.cpp re.awk makefile - # $(AI) re.awk findpost.1.cpp > findpost.cpp - -# index.cpp: index.1.cpp re.awk makefile - # $(AI) re.awk index.1.cpp > index.cpp - -# mview.cpp: mview.1.cpp re.awk makefile - # $(AI) re.awk mview.1.cpp > mview.cpp - -# mpview.cpp: mpview.1.cpp re.awk makefile - # $(AI) re.awk mpview.1.cpp > mpview.cpp - -# post.cpp: post.1.cpp re.awk makefile - # $(AI) re.awk post.1.cpp > post.cpp -# posted.cpp: posted.1.cpp re.awk makefile - # $(AI) re.awk posted.1.cpp > posted.cpp - -# update.cpp: update.1.cpp re.awk makefile - # $(AI) re.awk update.1.cpp > update.cpp - -# view.cpp: view.1.cpp re.awk makefile - # $(AI) re.awk view.1.cpp > view.cpp - -# bot2.awk: bot2.1.awk re.awk makefile - # $(AI) re.awk bot2.1.awk > bot2.awk +clean: + $(RM) -f $(TO_GENERATE) $(PROGR_NORMAL) $(PROGR_CGI) -# index.awk: index.1.awk re.awk makefile - # $(AI) re.awk index.1.awk > index.awk +PHONY: all clean setuid mktree cp_bin cp_www install -# pm.awk: pm.1.awk re.awk makefile - # $(AI) re.awk pm.1.awk > pm.awk +# all: bot2 bot3 findpost image view mview mpview index update post posted redirect enable -# post.awk: post.1.awk re.awk makefile - # $(AI) re.awk post.1.awk > post.awk -# preview.awk: preview.1.awk re.awk makefile - # $(AI) re.awk preview.1.awk > preview.awk diff --git a/mpview.1.cpp b/mpview.1.cpp index ebc69a1..26378b1 100644 --- a/mpview.1.cpp +++ b/mpview.1.cpp @@ -39,9 +39,12 @@ // ###POSTLIST_PATH3 // ###LAST_PATH3 -// ###C_AWK_VIEW: #define AWK_VIEW "/eizm/pro/ottmirror/view.awk" -// ###C_AWK_MVIEW: #define AWK_MVIEW "/eizm/pro/ottmirror/mview.awk" -// ###TEMP_PATHm +// ###C_AWK_VIEW: #define AWK_VIEW "/eizm/pro/ottmirror/view.awk" +// ###C_AWK_MVIEW: #define AWK_MVIEW "/eizm/pro/ottmirror/mview.awk" +// ###C_TEMP_PATH_MPVIEW: #define TEMP_PATH "/eizm/tmp/ottmirror/mpview." + +#define N_STRBUF 256 +#define N_STRBUF_SH 32 int main() { @@ -49,62 +52,62 @@ int main() pid_t sub; int r; - char line[32]; - char filename[32]; - char postpath[256]; + char line[N_STRBUF_SH]; + char filename[N_STRBUF_SH]; + char postpath[N_STRBUF]; char cat[8]; char *arg; - char path2[256]; - char left[256]; - char right[256]; - char links[256]; + char path2[N_STRBUF]; + char left[N_STRBUF]; + char right[N_STRBUF]; + char links[N_STRBUF]; cgi=cgiInit(); printf("Content-type: text/html\n\n"); arg=cgiGetValue(cgi,"v"); - sprintf(line,"%s",arg?arg:"???"); + snprintf(line,N_STRBUF_SH,"%s",arg?arg:"???"); if(line[0]=='m') { - sprintf(filename,"%s",line+1); - sprintf(cat,"t=%s","m"); - sprintf(postpath,"%s%s",POST_PATH,filename); + snprintf(filename,N_STRBUF_SH,"%s",line+1); + snprintf(cat,8,"t=%s","m"); + snprintf(postpath,N_STRBUF,"%s%s",POST_PATH,filename); } else if(line[0]=='o' && line[1]=='k') { - sprintf(filename,"%s",line+2); - sprintf(cat,"cat=%s","ok"); - sprintf(postpath,"%s%s",OK_PATH,filename); + snprintf(filename,N_STRBUF_SH,"%s",line+2); + snprintf(cat,8,"cat=%s","ok"); + snprintf(postpath,N_STRBUF,"%s%s",OK_PATH,filename); } else if(line[0]=='p' && line[1]=='m') { - sprintf(filename,"%s",line+2); - sprintf(cat,"cat=%s","pm"); - sprintf(postpath,"%s%s",PM_PATH,filename); + snprintf(filename,N_STRBUF_SH,"%s",line+2); + snprintf(cat,8,"cat=%s","pm"); + snprintf(postpath,N_STRBUF,"%s%s",PM_PATH,filename); } else if(line[0]=='f' && line[1]=='l') { - sprintf(filename,"%s",line+2); - sprintf(cat,"cat=%s","fl"); - sprintf(postpath,"%s%s",FAIL_PATH,filename); + snprintf(filename,N_STRBUF_SH,"%s",line+2); + snprintf(cat,8,"cat=%s","fl"); + snprintf(postpath,N_STRBUF,"%s%s",FAIL_PATH,filename); } else { - sprintf(filename,"%s","???"); - sprintf(postpath,"%s","???"); - sprintf(cat,"cat=%s","???"); + snprintf(filename,N_STRBUF_SH,"%s","???"); + snprintf(postpath,N_STRBUF_SH,"%s","???"); + snprintf(cat,8,"cat=%s","???"); } - sprintf(right,"%s","right="); + snprintf(right,N_STRBUF,"%s","right="); - sprintf(left,"%s","left="); + snprintf(left,N_STRBUF,"%s","left="); - sprintf(path2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - sprintf(links,"%s","links="); + snprintf(path2,N_STRBUF,"%s%lu",TEMP_PATH,(unsigned long)getpid()); + snprintf(links,N_STRBUF,"%s","links="); fflush(stdout); sub=fork(); diff --git a/mview.1.cpp b/mview.1.cpp index 71c9270..66ddcba 100644 --- a/mview.1.cpp +++ b/mview.1.cpp @@ -36,15 +36,18 @@ // ###C_LIST_PATH_3: #define LIST_PATH "/eizm/mem/ottmirror/mlist/" // ###C_LAST_PATH_3: #define LAST_PATH "/eizm/mem/ottmirror/mlist/last" -// ###C_AWK_VIEW: AWK_VIEW "/eizm/pro/ottmirror/view.awk" -// ###C_AWK_MVIEW: AWK_MVIEW "/eizm/pro/ottmirror/mview.awk" -// ###TEMP_PATH3v +// ###C_AWK_VIEW: #define AWK_VIEW "/eizm/pro/ottmirror/view.awk" +// ###C_AWK_MVIEW: #define AWK_MVIEW "/eizm/pro/ottmirror/mview.awk" +// ###C_TEMP_PATH_MVIEW: #define TEMP_PATH "/eizm/tmp/ottmirror/mview." + +#define N_STRBUF 256 +#define N_STRBUF_SHH 16 unsigned long p2np(unsigned long p) { FILE *file; - char path[256]; - char text[256]; + char path[N_STRBUF]; + char text[N_STRBUF]; unsigned long np=0; unsigned long np2; unsigned long pp; @@ -52,11 +55,11 @@ unsigned long p2np(unsigned long p) for(short i=31;i>=0;--i) { np2 = np + (1L << i); - sprintf(path,"%s%lu",LIST_PATH,np2); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,np2); file=fopen(path,"rt"); if(file==NULL) continue; - fgets(text,255,file); + fgets(text,N_STRBUF-1,file); fclose(file); sscanf(text,"%lu",&pp); if(pp==p) @@ -66,11 +69,11 @@ unsigned long p2np(unsigned long p) } if(np==0) return 1L; - sprintf(path,"%s%lu",LIST_PATH,np); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,np); file=fopen(path,"rt"); if(file==NULL) return 1L; - while(fgets(text,255,file)!=NULL) + while(fgets(text,N_STRBUF-1,file)!=NULL) { sscanf(text,"%lu",&pp); if(pp==p) @@ -78,11 +81,11 @@ unsigned long p2np(unsigned long p) } fclose(file); --np; - sprintf(path,"%s%lu",LIST_PATH,np); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,np); file=fopen(path,"rt"); if(file==NULL) return 1L; - while(fgets(text,255,file)!=NULL) + while(fgets(text,N_STRBUF-1,file)!=NULL) { sscanf(text,"%lu",&pp); if(pp==p) @@ -97,13 +100,13 @@ int main() int r; char *arg; - char path[256]; - char bg[16]; - char page[16]; - char path2[256]; - char left[256]; - char right[256]; - char links[256]; + char path[N_STRBUF]; + char bg[N_STRBUF_SHH]; + char page[N_STRBUF_SHH]; + char path2[N_STRBUF]; + char left[N_STRBUF]; + char right[N_STRBUF]; + char links[N_STRBUF]; FILE *file; unsigned long np=1L; unsigned long start=0L; @@ -124,7 +127,7 @@ int main() else { printf("Content-type: text/html\nStatus: 404 Not Found\n\n"); - sprintf(path,"info=

There are no posts in this Otherthread.

Return to the ЯOЯЯIM TTO

"); + snprintf(path,N_STRBUF,"info=

There are no posts in this Otherthread.

Return to the ЯOЯЯIM TTO

"); fflush(stdout); sub=fork(); @@ -167,16 +170,16 @@ int main() if(np>last) np=last; if(npNext",np+1); + snprintf(right,N_STRBUF,"right=Next",np+1); else - sprintf(right,"%s","right="); + snprintf(right,N_STRBUF,"%s","right="); if(np>1) - sprintf(left,"left=Previous",np-1); + snprintf(left,N_STRBUF,"left=Previous",np-1); else - sprintf(left,"%s","left="); + snprintf(left,N_STRBUF,"%s","left="); - sprintf(path2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - sprintf(links,"links=%s",path2); + snprintf(path2,N_STRBUF,"%s%lu",TEMP_PATH,(unsigned long)getpid()); + snprintf(links,N_STRBUF,"links=%s",path2); file=fopen(path2,"wt"); if(file!=NULL) { @@ -214,16 +217,16 @@ int main() if(r) printf("

Ch*rpin* M*stard

"); - sprintf(path2,"%s%lu",LIST_PATH,np); + snprintf(path2,N_STRBUF,"%s%lu",LIST_PATH,np); file=fopen(path2,"rt"); if(file!=NULL) { - for(unsigned short i=0;fgets(path,255,file)!=NULL;++i) + for(unsigned short i=0;fgets(path,N_STRBUF-1,file)!=NULL;++i) { sscanf(path,"%s",path2); - sprintf(path,"%s%s",POST_PATH,path2); - sprintf(bg,"bg=%hu",2-(i&1)); - sprintf(page,"np=%lu",np); + snprintf(path,N_STRBUF,"%s%s",POST_PATH,path2); + snprintf(bg,N_STRBUF_SHH,"bg=%hu",2-(i&1)); + snprintf(page,N_STRBUF_SHH,"np=%lu",np); fflush(stdout); sub=fork(); @@ -263,7 +266,7 @@ int main() if(r) printf("

Ch*rpin* M*stard

"); - sprintf(path2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); + snprintf(path2,N_STRBUF,"%s%lu",TEMP_PATH,(unsigned long)getpid()); fflush(stdout); sub=fork(); if(sub==0) diff --git a/post.1.cpp b/post.1.cpp index fd6aa8f..185e547 100644 --- a/post.1.cpp +++ b/post.1.cpp @@ -39,15 +39,18 @@ // ###C_MLAST_PATH: #define MLAST_PATH "/eizm/mem/ottmirror/mlist/last" // ###C_MFRONT_PATH: #define MFRONT_PATH "/eizm/www/time/ott/mfront" -// ###C_AWK_PREVIEW: AWK_PREVIEW "/eizm/pro/ottmirror/preview.awk" -// ###C_AWK_VIEW: AWK_VIEW "/eizm/pro/ottmirror/view.awk" -// ###TEMP_PATHp -// ###C_AWK_B2H: AWK_B2H "/eizm/pro/ottmirror/bb2html.awk" -// ###C_AWK_VERIFY: AWK_VERIFY "/eizm/pro/ottmirror/verify.awk" +// ###C_AWK_PREVIEW: #define AWK_PREVIEW "/eizm/pro/ottmirror/preview.awk" +// ###C_AWK_VIEW: #define AWK_VIEW "/eizm/pro/ottmirror/view.awk" +// ###C_TEMP_PATH_PREVIEW: #define TEMP_PATH "/eizm/tmp/ottmirror/preview." +// ###C_AWK_B2H: #define AWK_B2H "/eizm/pro/ottmirror/bb2html.awk" +// ###C_AWK_VERIFY: #define AWK_VERIFY "/eizm/pro/ottmirror/verify.awk" // ###C_BOT3NAME_ENCODED: #define BOT3NAME_ENCODED "bothasar_p" // ###C_BOT3_URL: #define BOT3_URL "http://1190.bicyclesonthemoon.info/bothasar_p/" +#define N_STRBUF 256 +#define N_STRBUF_SH 32 + s_cgi *cgi; pid_t sub; int r; @@ -55,8 +58,8 @@ FILE *tempfile; FILE *postfile; bool tf=false; bool pf=false; -char temppath[256]=""; -char postpath[256]=""; +char temppath[N_STRBUF]=""; +char postpath[N_STRBUF]=""; char zero='\0'; char *username = &zero; @@ -74,7 +77,7 @@ char *post =&zero; char *addquote =&zero; char *edit =&zero; char *forceID =&zero; -char wrong[256]; +char wrong[N_STRBUF]; void submit(); void preview (const char *text); @@ -218,27 +221,27 @@ void writeArgH(FILE *file,const char *value) void submit() { time_t posttime; - char timetext[32]; - char timenumber[32]; - char botinfo[256]; - char arg1[256]; - char arg2[256]; + char timetext[N_STRBUF_SH]; + char timenumber[N_STRBUF_SH]; + char botinfo[N_STRBUF]; + char arg1[N_STRBUF]; + char arg2[N_STRBUF]; unsigned long lastpage; unsigned short postslast; - char listpath[256]; + char listpath[N_STRBUF]; posttime=time(NULL); if(forceID[0]!='\0') - sprintf(timenumber,"%s",forceID); + snprintf(timenumber,N_STRBUF_SH,"%s",forceID); else - sprintf(timenumber,"%llu",(unsigned long long)posttime); - strftime(timetext,31,"%a %b %d, %Y %I:%M %p %Z",gmtime(&posttime)); + snprintf(timenumber,N_STRBUF_SH,"%llu",(unsigned long long)posttime); + strftime(timetext,N_STRBUF-1,"%a %b %d, %Y %I:%M %p %Z",gmtime(&posttime)); if(*disable_bbcode=='\0') - sprintf(botinfo,"[Posted from the Mirror at %s%s]\r\n",timetext,(forceID[0]!='\0')?", edited":""); + snprintf(botinfo,N_STRBUF,"[Posted from the Mirror at %s%s]\r\n",timetext,(forceID[0]!='\0')?", edited":""); else - sprintf(botinfo,"[size=80][Posted from the Mirror at %s%s][/size]\r\n",timetext,(forceID[0]!='\0')?", edited":""); - sprintf(postpath,"%s%s",MPOST_PATH,timenumber); + snprintf(botinfo,N_STRBUF,"[size=80][Posted from the Mirror at %s%s][/size]\r\n",timetext,(forceID[0]!='\0')?", edited":""); + snprintf(postpath,N_STRBUF,"%s%s",MPOST_PATH,timenumber); tempfile=fopen(temppath,"wt"); if(tempfile==NULL) @@ -268,7 +271,7 @@ void submit() fclose(tempfile); tf=false; - sprintf(arg1,"outfile=%s",temppath); + snprintf(arg1,N_STRBUF,"outfile=%s",temppath); fflush(stdout); sub=fork(); if(sub==0) @@ -280,8 +283,8 @@ void submit() } waitpid(sub,&r,0); - sprintf(arg1,"name=%s",username); - sprintf(arg2,"pass=%s",password); + snprintf(arg1,N_STRBUF,"name=%s",username); + snprintf(arg2,N_STRBUF,"pass=%s",password); sub=fork(); if(sub==0) { @@ -313,9 +316,9 @@ void submit() else { tf=true; - if(fgets(listpath,255,tempfile)) + if(fgets(listpath,N_STRBUF-1,tempfile)) sscanf(listpath,"%lu",&lastpage); - if(fgets(listpath,255,tempfile)) + if(fgets(listpath,N_STRBUF-1,tempfile)) sscanf(listpath,"%hu",&postslast); if(postslast>=40) { @@ -336,7 +339,7 @@ void submit() fprintf(tempfile,"%lu\n%hu\n%s\n",lastpage,postslast,timenumber); fclose(tempfile); - sprintf(listpath,"%s%lu",MLIST_PATH,lastpage); + snprintf(listpath,N_STRBUF,"%s%lu",MLIST_PATH,lastpage); tempfile=fopen(listpath,"at"); if(tempfile==NULL) { @@ -368,11 +371,11 @@ void submit() fprintf(tempfile,"\n\n\n"); } fclose(tempfile); - sprintf(arg1,"info=

This message has been posted successfully.

View your submitted message

Return to the ЯOЯЯIM TTO

",lastpage,timenumber,timenumber); + snprintf(arg1,N_STRBUF,"info=

This message has been posted successfully.

View your submitted message

Return to the ЯOЯЯIM TTO

",lastpage,timenumber,timenumber); } else - sprintf(arg1,"info=

This message has been posted successfully.

View your submitted message

Return to the ЯOЯЯIM TTO

",timenumber,timenumber); + snprintf(arg1,N_STRBUF,"info=

This message has been posted successfully.

View your submitted message

Return to the ЯOЯЯIM TTO

",timenumber,timenumber); printf("Content-type: text/html\n\n"); fflush(stdout); @@ -389,7 +392,7 @@ void submit() } void preview (const char *text) { - char arg1[256]; + char arg1[N_STRBUF]; tempfile=fopen(temppath,"wt"); if(tempfile==NULL) end(1); @@ -418,7 +421,7 @@ void preview (const char *text) printf("Content-type: text/html\n\n"); - sprintf(arg1,"outfile=%s",temppath); + snprintf(arg1,N_STRBUF,"outfile=%s",temppath); fflush(stdout); sub=fork(); if(sub==0) @@ -431,7 +434,7 @@ void preview (const char *text) waitpid(sub,&r,0); // printf("Content-type: text/html\n\n"); - sprintf(arg1,"argfile=%s",temppath); + snprintf(arg1,N_STRBUF,"argfile=%s",temppath); fflush(stdout); sub=fork(); if(sub==0) @@ -454,7 +457,7 @@ int main() cgi=cgiInit(); - sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid()); + snprintf(temppath,N_STRBUF,"%s%lu",TEMP_PATH,(unsigned long)getpid()); arg=cgiGetValue(cgi,"password"); if(arg!=NULL) diff --git a/posted.1.cpp b/posted.1.cpp index d531b16..384c212 100644 --- a/posted.1.cpp +++ b/posted.1.cpp @@ -26,16 +26,19 @@ // #include #include -// ###TEMP_PATHr -// ###C_OK_PATH_3: #define OK_PATH "/eizm/mem/ottmirror/mpost/ok/" -// ###C_PM_PATH_3: #define PM_PATH "/eizm/mem/ottmirror/mpost/pm/" -// ###C_FAIL_PATH_3: #define FAIL_PATH "/eizm/mem/ottmirror/mpost/fail/" -// ###C_LS_PATH: #define LS_PATH "/bin/ls" -// ###C_RM_PATH: #define RM_PATH "/bin/rm" -// ###C_MAWK_PATH: #define MAWK_PATH "/usr/bin/mawk" -// ###C_AWK_POSTED: #define AWK_POSTED "/eizm/pro/ottmirror/posted.awk" +// ###C_TEMP_PATH_POSTED: #define TEMP_PATH "/eizm/tmp/ottmirror/posted." +// ###C_OK_PATH_3: #define OK_PATH "/eizm/mem/ottmirror/mpost/ok/" +// ###C_PM_PATH_3: #define PM_PATH "/eizm/mem/ottmirror/mpost/pm/" +// ###C_FAIL_PATH_3: #define FAIL_PATH "/eizm/mem/ottmirror/mpost/fail/" +// ###C_LS_PATH: #define LS_PATH "/bin/ls" +// ###C_RM_PATH: #define RM_PATH "/bin/rm" +// ###C_MAWK_PATH: #define MAWK_PATH "/usr/bin/mawk" +// ###C_AWK_POSTED: #define AWK_POSTED "/eizm/pro/ottmirror/posted.awk" -// ###C_OWN_DOMAIN_ENCODED: #define  "1190.bicyclesonthemoon.info" +// ###C_OWN_DOMAIN_ENCODED: #define "1190.bicyclesonthemoon.info" + +#define N_STRBUF 256 +#define N_STRBUF_SH 256 s_cgi *cgi; pid_t sub; @@ -44,10 +47,10 @@ int r; int main(int argc, char **argv) { - char temppath[256]=""; - char line[32]; - char filename[32]; - char postpath[256]; + char temppath[N_STRBUF]=""; + char line[N_STRBUF_SH]; + char filename[N_STRBUF_SH]; + char postpath[N_STRBUF]; FILE *tempfile; FILE *postfile; @@ -55,7 +58,7 @@ int main(int argc, char **argv) // dup2(fileno(stdout),fileno(stderr)); cgi=cgiInit(); - sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid()); + snprintf(temppath,N_STRBUF,"%s%lu",TEMP_PATH,(unsigned long)getpid()); printf("Content-type: text/html\n\n"); printf("\n"); @@ -87,10 +90,10 @@ int main(int argc, char **argv) tempfile=fopen(temppath,"rt"); if(tempfile!=NULL) { - for(unsigned char i=0; fgets(line,31,tempfile)!=NULL; ++i) + for(unsigned char i=0; fgets(line,N_STRBUF_SH-1,tempfile)!=NULL; ++i) { sscanf(line,"%s",filename); - sprintf(postpath,"%s%s",FAIL_PATH,filename); + snprintf(postpath,N_STRBUF,"%s%s",FAIL_PATH,filename); fflush(stdout); sub=fork(); @@ -128,10 +131,10 @@ int main(int argc, char **argv) tempfile=fopen(temppath,"rt"); if(tempfile!=NULL) { - for(unsigned char i=0; fgets(line,31,tempfile)!=NULL; ++i) + for(unsigned char i=0; fgets(line,N_STRBUF_SH-1,tempfile)!=NULL; ++i) { sscanf(line,"%s",filename); - sprintf(postpath,"%s%s",PM_PATH,filename); + snprintf(postpath,N_STRBUF,"%s%s",PM_PATH,filename); fflush(stdout); sub=fork(); @@ -169,10 +172,10 @@ int main(int argc, char **argv) tempfile=fopen(temppath,"rt"); if(tempfile!=NULL) { - for(unsigned char i=0; fgets(line,31,tempfile)!=NULL; ++i) + for(unsigned char i=0; fgets(line,N_STRBUF_SH-1,tempfile)!=NULL; ++i) { sscanf(line,"%s",filename); - sprintf(postpath,"%s%s",OK_PATH,filename); + snprintf(postpath,N_STRBUF,"%s%s",OK_PATH,filename); fflush(stdout); sub=fork(); diff --git a/settings-release.txt b/settings-release.txt index f2dac32..01cb0ab 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -38,7 +38,10 @@ rm: /usr/bin/rm ls: /usr/bin/ls wget: /usr/bin/wget awk: /usr/bin/mawk +chmod: /usr/bin/chmod +mkdir: /usr/bin/mkdir +cp: /usr/bin/cp CC: g++ -CF: -g -Wall +CF: -g -Wall -Wno-format-truncation L_CGI: -lcgi diff --git a/settings.txt b/settings.txt index c6dea82..0b95db5 100644 --- a/settings.txt +++ b/settings.txt @@ -48,10 +48,14 @@ _tmp_bot3cook_path = @_PATH($tmp_path, bot3cook) _tmp_bot3post_path = @_PATH($tmp_path, bot3post) _tmp_bot3stop_path = @_PATH($tmp_path, bot3stop) _tmp_bot3temp_path = @_PATH($tmp_path, bot3temp) +_tmp_mpview_path = @_PATH($tmp_path, mpview.) +_tmp_mview_path = @_PATH($tmp_path, mview.) _tmp_np_path_0 = @_PATH($tmp_path, np.p0.) _tmp_np_path_1 = @_PATH($tmp_path, np.p1.) _tmp_np_path_2 = @_PATH($tmp_path, np.p2.) _tmp_np_path_3 = @_PATH($tmp_path, np.p3.) +_tmp_preview_path = @_PATH($tmp_path, preview.) +_tmp_posted_path = @_PATH($tmp_path, posted.) _tmp_stop_path = @_PATH($tmp_path, fullstop.) _tmp_view_path = @_PATH($tmp_path, view.) @@ -85,13 +89,34 @@ _www_up_path_ = @_PATH($_www_up_path, ) MAKE_CONFIGURE = CONFIGURE =$configure MAKE_TARGET = TARGET =$target -MAKE_PERL = PERL=$perl -MAKE_RM = RM =$rm +MAKE_CHMOD = CHMOD=$chmod +MAKE_CP = CP =$cp +MAKE_MKDIR = MKDIR=$mkdir +MAKE_PERL = PERL =$perl +MAKE_RM = RM =$rm MAKE_CC = CC =$CC MAKE_CF = CF =$CF MAKE_L_CGI = L_CGI=$L_CGI +MAKE_BIN_PATH = BIN_PATH = $bin_path +MAKE_LOG_PATH = LOG_PATH = $log_path +MAKE_MEM_PATH = MEM_PATH = $mem_path +MAKE_MEM_FAIL_PATH = MEM_FAIL_PATH = $_mem_fail_path +MAKE_MEM_LIST_PATH = MEM_LIST_PATH = $_mem_list_path +MAKE_MEM_OK_PATH = MEM_OK_PATH = $_mem_ok_path +MAKE_MEM_PM_PATH = MEM_PM_PATH = $_mem_pm_path +MAKE_MEM_POST_PATH = MEM_POST_PATH = $_mem_post_path +MAKE_TMP_PATH = TMP_PATH = $tmp_path +MAKE_WWW_PATH = WWW_PATH = $www_path +MAKE_WWW_ATT_PATH = WWW_ATT_PATH = $_www_att_path +MAKE_WWW_AV_PATH = WWW_AV_PATH = $_www_av_path +MAKE_WWW_IMG_PATH = WWW_IMG_PATH = $_www_img_path +MAKE_WWW_INF_PATH = WWW_INF_PATH = $_www_inf_path +MAKE_WWW_LIST_PATH = WWW_LIST_PATH = $_www_list_path +MAKE_WWW_SIG_PATH = WWW_SIG_PATH = $_www_sig_path +MAKE_WWW_UP_PATH = WWW_UP_PATH = $_www_up_path + AWK_default_subject_encoded= \t@_AWK_DEFINE_STR(default_subject_encoded,$_default_subject_encoded) AWK_failpath = \t@_AWK_DEFINE_STR(failpath, $_mem_fail_path_) AWK_findpost_path = \t@_AWK_DEFINE_STR(findpost_path, $_bin_findpost_path) @@ -150,16 +175,20 @@ C_PM_PATH_3 = @_C_DEFINE_STR(PM_PATH, $_mem_pm_path_) C_POST_PATH_3 = @_C_DEFINE_STR(POST_PATH, $_mem_post_path_) # dir-tmp -C_COOKIE_PATH_3 = @_C_DEFINE_STR(COOKIE_PATH, $_tmp_bot3cook_path) -C_NP_PATH_0 = @_C_DEFINE_STR(NP_PATH, $_tmp_np_path_0) -C_NP_PATH_1 = @_C_DEFINE_STR(NP_PATH_1, $_tmp_np_path_1) -C_NP_PATH_2 = @_C_DEFINE_STR(NP_PATH_2, $_tmp_np_path_2) -C_NP_PATH_3 = @_C_DEFINE_STR(NP_PATH_3, $_tmp_np_path_3) -C_POSTDATA_PATH_3 = @_C_DEFINE_STR(POSTDATA_PATH,$_tmp_bot3post_path) -C_STOP_PATH = @_C_DEFINE_STR(STOP_PATH, $_tmp_stop_path) -C_STOP_PATH_3 = @_C_DEFINE_STR(STOP_PATH, $_tmp_bot3stop_path) -C_TEMP_PATH_VIEW = @_C_DEFINE_STR(TEMP_PATH, $_tmp_view_path) -C_TEMPFILE_PATH_3 = @_C_DEFINE_STR(TEMPFILE_PATH,$_tmp_bot3temp_path) +C_COOKIE_PATH_3 = @_C_DEFINE_STR(COOKIE_PATH, $_tmp_bot3cook_path) +C_NP_PATH_0 = @_C_DEFINE_STR(NP_PATH, $_tmp_np_path_0) +C_NP_PATH_1 = @_C_DEFINE_STR(NP_PATH_1, $_tmp_np_path_1) +C_NP_PATH_2 = @_C_DEFINE_STR(NP_PATH_2, $_tmp_np_path_2) +C_NP_PATH_3 = @_C_DEFINE_STR(NP_PATH_3, $_tmp_np_path_3) +C_POSTDATA_PATH_3 = @_C_DEFINE_STR(POSTDATA_PATH,$_tmp_bot3post_path) +C_STOP_PATH = @_C_DEFINE_STR(STOP_PATH, $_tmp_stop_path) +C_STOP_PATH_3 = @_C_DEFINE_STR(STOP_PATH, $_tmp_bot3stop_path) +C_TEMP_PATH_MPVIEW = @_C_DEFINE_STR(TEMP_PATH, $_tmp_mpview_path) +C_TEMP_PATH_MVIEW = @_C_DEFINE_STR(TEMP_PATH, $_tmp_mview_path) +C_TEMP_PATH_POSTED = @_C_DEFINE_STR(TEMP_PATH, $_tmp_posted_path) +C_TEMP_PATH_PREVIEW= @_C_DEFINE_STR(TEMP_PATH, $_tmp_preview_path) +C_TEMP_PATH_VIEW = @_C_DEFINE_STR(TEMP_PATH, $_tmp_view_path) +C_TEMPFILE_PATH_3 = @_C_DEFINE_STR(TEMPFILE_PATH,$_tmp_bot3temp_path) # dir-www C_ATT_PATH = @_C_DEFINE_STR(ATT_PATH, $_www_att_path_) diff --git a/view.1.cpp b/view.1.cpp index 12a4f7d..492d4bc 100644 --- a/view.1.cpp +++ b/view.1.cpp @@ -41,11 +41,13 @@ // ###C_AWK_VIEW: #define AWK_VIEW "/eizm/pro/ottmirror/view.awk" // ###C_TEMP_PATH_VIEW: #define TEMP_PATH "/eizm/tmp/ottmirror/view." +#define N_STRBUF 256 + unsigned long p2np(unsigned long p) { FILE *file; - char path[256]; - char text[256]; + char path[N_STRBUF]; + char text[N_STRBUF]; unsigned long np=0; unsigned long np2; unsigned long pp; @@ -53,11 +55,11 @@ unsigned long p2np(unsigned long p) for(short i=31;i>=0;--i) { np2 = np + (1L << i); - sprintf(path,"%s%lu",LIST_PATH,np2); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,np2); file=fopen(path,"rt"); if(file==NULL) continue; - fgets(text,255,file); + fgets(text,N_STRBUF-1,file); fclose(file); sscanf(text,"%lu",&pp); if(pp==p) @@ -67,11 +69,11 @@ unsigned long p2np(unsigned long p) } if(np==0) return 1L; - sprintf(path,"%s%lu",LIST_PATH,np); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,np); file=fopen(path,"rt"); if(file==NULL) return 1L; - while(fgets(text,255,file)!=NULL) + while(fgets(text,N_STRBUF-1,file)!=NULL) { sscanf(text,"%lu",&pp); if(pp==p) @@ -79,11 +81,11 @@ unsigned long p2np(unsigned long p) } fclose(file); --np; - sprintf(path,"%s%lu",LIST_PATH,np); + snprintf(path,N_STRBUF,"%s%lu",LIST_PATH,np); file=fopen(path,"rt"); if(file==NULL) return 1L; - while(fgets(text,255,file)!=NULL) + while(fgets(text,N_STRBUF-1,file)!=NULL) { sscanf(text,"%lu",&pp); if(pp==p) @@ -98,11 +100,11 @@ int main() int r; char *arg; - char path[256]; - char path2[256]; - char left[256]; - char right[256]; - char links[256]; + char path[N_STRBUF]; + char path2[N_STRBUF]; + char left[N_STRBUF]; + char right[N_STRBUF]; + char links[N_STRBUF]; FILE *file; unsigned long np=1L; unsigned long start=0L; @@ -156,16 +158,16 @@ int main() if(np>last) np=last; if(npNext",np+1); + snprintf(right,N_STRBUF,"right=Next",np+1); else - sprintf(right,"%s",mustard?"right=Mustardtime Otherthread":"right="); + snprintf(right,N_STRBUF,"%s",mustard?"right=Mustardtime Otherthread":"right="); if(np>1) - sprintf(left,"left=Previous",np-1); + snprintf(left,N_STRBUF,"left=Previous",np-1); else - sprintf(left,"%s","left="); + snprintf(left,N_STRBUF,"%s","left="); - sprintf(path2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - sprintf(links,"links=%s",path2); + snprintf(path2,N_STRBUF,"%s%lu",TEMP_PATH,(unsigned long)getpid()); + snprintf(links,N_STRBUF,"links=%s",path2); file=fopen(path2,"wt"); if(file!=NULL) { @@ -207,7 +209,7 @@ int main() if(r) printf("

Ch*rpin* M*stard

"); - sprintf(path,"%s%lu",UP_PATH,np); + snprintf(path,N_STRBUF,"%s%lu",UP_PATH,np); fflush(stdout); sub=fork(); if(sub==0) diff --git a/www/ott/end b/www/ott/end index 72a4713..9ec7c32 100644 --- a/www/ott/end +++ b/www/ott/end @@ -73,7 +73,9 @@ - + + + diff --git a/www/ott/np/end b/www/ott/np/end index 07d6c5d..b31f683 100644 --- a/www/ott/np/end +++ b/www/ott/np/end @@ -69,7 +69,9 @@ go to newpage: - + + + diff --git a/www/ott/post.htm b/www/ott/post.htm index 061f33b..913fc88 100644 --- a/www/ott/post.htm +++ b/www/ott/post.htm @@ -164,7 +164,7 @@
-
+
@@ -177,8 +177,9 @@
-
The mirror can't verify your username or password.
Use your xkcd forum username and password.
+
The mirror can't verify your username or password.
+
So please make sure that you have typed them correctly.