Index: head/editors/joe/files/patch-ad =================================================================== --- head/editors/joe/files/patch-ad (revision 54833) +++ head/editors/joe/files/patch-ad (revision 54834) @@ -1,98 +1,101 @@ ---- b.c.orig Fri Jan 20 00:38:25 1995 -+++ b.c Sun Dec 3 09:58:21 2000 +--- b.c.orig Fri Jan 20 02:38:25 1995 ++++ b.c Sun Feb 10 14:39:03 2002 @@ -21,6 +21,9 @@ #include #endif #include +#include +#include +#include #include "config.h" #include "blocks.h" @@ -201,6 +204,7 @@ if(prop) b->o=prop->o; else b->o=pdefault; mset(b->marks,0,sizeof(b->marks)); + b->filehandle = -1; /* initialize filehandle &&& ob */ b->rdonly=0; b->orphan=0; b->oldcur=0; @@ -255,6 +259,10 @@ { if(b && !--b->count) { + if (b->filehandle != -1) { + /* close filehandle, free lock &&& ob */ + close (b->filehandle); + } if(b->changed) abrerr(b->name); if(b==errbuf) errbuf=0; if(b->undo) undorm(b->undo); @@ -1671,7 +1679,8 @@ B *b; long skip,amnt; char *n; - int nowrite=0; + struct stat sb; + int nowrite=0,fh=-1; if(!s || !s[0]) { @@ -1704,6 +1713,28 @@ else fclose(fi); fi=fopen(n,"r"); if(!fi) nowrite=0; +/*printf ("nowrite open=%i\n", nowrite); */ + + /* check file mod, if no write flags set, + joe in read only mode. &&& ob */ + + if (!nowrite) { + nowrite = (!stat (n, &sb)) && (!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH))); + } +/*printf ("nowrite stat=%i\n", nowrite); */ + + /* lock the file if writable, or go into read only mode if + already locked, */ + + if ((fi) && (!nowrite)) { + fh = dup( fileno(fi) ); + nowrite = (flock (fh, LOCK_EX | LOCK_NB)); + } +/*printf ("nowrite flock=%i\n", nowrite); */ + +/*nowrite = 1; */ /* for test purpose */ +/*printf ("nowrite=%i\n", nowrite); */ + } joesep(n); @@ -1761,6 +1792,7 @@ vsrm(n); b->er=error; + if( fh != -1 ) b->filehandle = fh; return b; } -@@ -1990,7 +2022,18 @@ +@@ -1988,9 +2020,20 @@ + + void ttsig(sig) { - long tim=time(0); +- long tim=time(0); ++ time_t tim=time(0); B *b; - FILE *f=fopen("DEADJOE","a"); + FILE *f; + struct stat sb; + if ((lstat("DEADJOE", &sb) == 0) && (((sb.st_mode & S_IFLNK) && (sb.st_uid != getuid())) || (sb.st_nlink > 1))) + { + printf("*** JOE was aborted "); + if (sig) printf("by signal %d, cannot save DEADJOE due to unsafe symlink\n",sig); + else printf("because the terminal closed, cannot save DEADJOE due to unsafe symlink\n"); + if(sig) ttclsn(); + _exit(1); + } + f=fopen("DEADJOE","a"); + chmod("DEADJOE", S_IRUSR | S_IWUSR); fprintf(f,"\n*** Modified files in JOE when it aborted on %s",ctime(&tim)); if(sig) fprintf(f,"*** JOE was aborted by signal %d\n",sig); else fprintf(f,"*** JOE was aborted because the terminal closed\n"); Property changes on: head/editors/joe/files/patch-ad ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.5 \ No newline at end of property +1.6 \ No newline at end of property Index: head/editors/joe/files/patch-ag =================================================================== --- head/editors/joe/files/patch-ag (revision 54833) +++ head/editors/joe/files/patch-ag (revision 54834) @@ -1,12 +1,39 @@ ---- rc.c.orig Fri Feb 1 16:50:23 2002 -+++ rc.c Fri Feb 1 16:50:43 2002 +--- rc.c.orig Fri Jan 20 02:53:42 1995 ++++ rc.c Sun Feb 10 14:28:42 2002 +@@ -29,7 +29,7 @@ + * is created. + */ + +-KMAP *getcontext(name) ++KMAP *joegetcontext(name) + char *name; + { + struct context *c; @@ -610,7 +610,8 @@ FILE *fd; /* rc file */ int line=0; /* Line number */ int err=0; /* Set to 1 if there was a syntax error */ - ossep(zcpy(buf,name)); + strlcpy(buf,name,sizeof(buf)); + ossep(buf); #ifdef __MSDOS__ fd=fopen(buf,"rt"); #else +@@ -739,7 +740,7 @@ + for(buf[x]=c;cwhite(buf[x]);++x); + for(c=x;!cwhitef(buf[c]);++c); + buf[c]=0; +- if(c!=x) kcpy(context,getcontext(buf+x)); ++ if(c!=x) kcpy(context,joegetcontext(buf+x)); + else + { + err=1; +@@ -788,7 +789,7 @@ + err=1; + fprintf(stderr,"\n%s %d: No context selected for :delete",name,line); + } +- else context=getcontext(buf+1); ++ else context=joegetcontext(buf+1); + else + { + err=1; Property changes on: head/editors/joe/files/patch-ag ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property Index: head/editors/joe/files/patch-ah =================================================================== --- head/editors/joe/files/patch-ah (nonexistent) +++ head/editors/joe/files/patch-ah (revision 54834) @@ -0,0 +1,11 @@ +--- w.c.orig Sun Feb 10 14:28:10 2002 ++++ w.c Sun Feb 10 14:29:15 2002 +@@ -594,7 +594,7 @@ + else seth(original,original->h-height); + + /* Create new keyboard handler for window */ +- if(watom->context) new->kbd=mkkbd(getcontext(watom->context)); ++ if(watom->context) new->kbd=mkkbd(joegetcontext(watom->context)); + else new->kbd=0; + + /* Put window on the screen */ Property changes on: head/editors/joe/files/patch-ah ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/editors/joe/files/patch-ai =================================================================== --- head/editors/joe/files/patch-ai (nonexistent) +++ head/editors/joe/files/patch-ai (revision 54834) @@ -0,0 +1,11 @@ +--- bw.c.orig Sun Feb 10 14:27:49 2002 ++++ bw.c Sun Feb 10 14:28:18 2002 +@@ -734,7 +734,7 @@ + if(window==window->main) + { + rmkbd(window->kbd); +- window->kbd=mkkbd(getcontext(w->o.context)); ++ window->kbd=mkkbd(joegetcontext(w->o.context)); + } + w->top->xcol=0; w->cursor->xcol=0; + return w; Property changes on: head/editors/joe/files/patch-ai ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/editors/joe/files/patch-aj =================================================================== --- head/editors/joe/files/patch-aj (nonexistent) +++ head/editors/joe/files/patch-aj (revision 54834) @@ -0,0 +1,16 @@ +--- rc.h.orig Sun Feb 10 14:28:00 2002 ++++ rc.h Sun Feb 10 14:28:55 2002 +@@ -34,11 +34,11 @@ + extern OPTIONS pdefault; + void setopt(); + +-/* KMAP *getcontext(char *name); ++/* KMAP *joegetcontext(char *name); + * Find and return the KMAP for a given context name. If none is found, an + * empty kmap is created, bound to the context name, and returned. + */ +-KMAP *getcontext(); ++KMAP *joegetcontext(); + + /* int procrc(char *name); Process an rc file + Returns 0 for success Property changes on: head/editors/joe/files/patch-aj ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/editors/joe2/files/patch-ad =================================================================== --- head/editors/joe2/files/patch-ad (revision 54833) +++ head/editors/joe2/files/patch-ad (revision 54834) @@ -1,98 +1,101 @@ ---- b.c.orig Fri Jan 20 00:38:25 1995 -+++ b.c Sun Dec 3 09:58:21 2000 +--- b.c.orig Fri Jan 20 02:38:25 1995 ++++ b.c Sun Feb 10 14:39:03 2002 @@ -21,6 +21,9 @@ #include #endif #include +#include +#include +#include #include "config.h" #include "blocks.h" @@ -201,6 +204,7 @@ if(prop) b->o=prop->o; else b->o=pdefault; mset(b->marks,0,sizeof(b->marks)); + b->filehandle = -1; /* initialize filehandle &&& ob */ b->rdonly=0; b->orphan=0; b->oldcur=0; @@ -255,6 +259,10 @@ { if(b && !--b->count) { + if (b->filehandle != -1) { + /* close filehandle, free lock &&& ob */ + close (b->filehandle); + } if(b->changed) abrerr(b->name); if(b==errbuf) errbuf=0; if(b->undo) undorm(b->undo); @@ -1671,7 +1679,8 @@ B *b; long skip,amnt; char *n; - int nowrite=0; + struct stat sb; + int nowrite=0,fh=-1; if(!s || !s[0]) { @@ -1704,6 +1713,28 @@ else fclose(fi); fi=fopen(n,"r"); if(!fi) nowrite=0; +/*printf ("nowrite open=%i\n", nowrite); */ + + /* check file mod, if no write flags set, + joe in read only mode. &&& ob */ + + if (!nowrite) { + nowrite = (!stat (n, &sb)) && (!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH))); + } +/*printf ("nowrite stat=%i\n", nowrite); */ + + /* lock the file if writable, or go into read only mode if + already locked, */ + + if ((fi) && (!nowrite)) { + fh = dup( fileno(fi) ); + nowrite = (flock (fh, LOCK_EX | LOCK_NB)); + } +/*printf ("nowrite flock=%i\n", nowrite); */ + +/*nowrite = 1; */ /* for test purpose */ +/*printf ("nowrite=%i\n", nowrite); */ + } joesep(n); @@ -1761,6 +1792,7 @@ vsrm(n); b->er=error; + if( fh != -1 ) b->filehandle = fh; return b; } -@@ -1990,7 +2022,18 @@ +@@ -1988,9 +2020,20 @@ + + void ttsig(sig) { - long tim=time(0); +- long tim=time(0); ++ time_t tim=time(0); B *b; - FILE *f=fopen("DEADJOE","a"); + FILE *f; + struct stat sb; + if ((lstat("DEADJOE", &sb) == 0) && (((sb.st_mode & S_IFLNK) && (sb.st_uid != getuid())) || (sb.st_nlink > 1))) + { + printf("*** JOE was aborted "); + if (sig) printf("by signal %d, cannot save DEADJOE due to unsafe symlink\n",sig); + else printf("because the terminal closed, cannot save DEADJOE due to unsafe symlink\n"); + if(sig) ttclsn(); + _exit(1); + } + f=fopen("DEADJOE","a"); + chmod("DEADJOE", S_IRUSR | S_IWUSR); fprintf(f,"\n*** Modified files in JOE when it aborted on %s",ctime(&tim)); if(sig) fprintf(f,"*** JOE was aborted by signal %d\n",sig); else fprintf(f,"*** JOE was aborted because the terminal closed\n"); Property changes on: head/editors/joe2/files/patch-ad ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.5 \ No newline at end of property +1.6 \ No newline at end of property Index: head/editors/joe2/files/patch-ag =================================================================== --- head/editors/joe2/files/patch-ag (revision 54833) +++ head/editors/joe2/files/patch-ag (revision 54834) @@ -1,12 +1,39 @@ ---- rc.c.orig Fri Feb 1 16:50:23 2002 -+++ rc.c Fri Feb 1 16:50:43 2002 +--- rc.c.orig Fri Jan 20 02:53:42 1995 ++++ rc.c Sun Feb 10 14:28:42 2002 +@@ -29,7 +29,7 @@ + * is created. + */ + +-KMAP *getcontext(name) ++KMAP *joegetcontext(name) + char *name; + { + struct context *c; @@ -610,7 +610,8 @@ FILE *fd; /* rc file */ int line=0; /* Line number */ int err=0; /* Set to 1 if there was a syntax error */ - ossep(zcpy(buf,name)); + strlcpy(buf,name,sizeof(buf)); + ossep(buf); #ifdef __MSDOS__ fd=fopen(buf,"rt"); #else +@@ -739,7 +740,7 @@ + for(buf[x]=c;cwhite(buf[x]);++x); + for(c=x;!cwhitef(buf[c]);++c); + buf[c]=0; +- if(c!=x) kcpy(context,getcontext(buf+x)); ++ if(c!=x) kcpy(context,joegetcontext(buf+x)); + else + { + err=1; +@@ -788,7 +789,7 @@ + err=1; + fprintf(stderr,"\n%s %d: No context selected for :delete",name,line); + } +- else context=getcontext(buf+1); ++ else context=joegetcontext(buf+1); + else + { + err=1; Property changes on: head/editors/joe2/files/patch-ag ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property Index: head/editors/joe2/files/patch-ah =================================================================== --- head/editors/joe2/files/patch-ah (nonexistent) +++ head/editors/joe2/files/patch-ah (revision 54834) @@ -0,0 +1,11 @@ +--- w.c.orig Sun Feb 10 14:28:10 2002 ++++ w.c Sun Feb 10 14:29:15 2002 +@@ -594,7 +594,7 @@ + else seth(original,original->h-height); + + /* Create new keyboard handler for window */ +- if(watom->context) new->kbd=mkkbd(getcontext(watom->context)); ++ if(watom->context) new->kbd=mkkbd(joegetcontext(watom->context)); + else new->kbd=0; + + /* Put window on the screen */ Property changes on: head/editors/joe2/files/patch-ah ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/editors/joe2/files/patch-ai =================================================================== --- head/editors/joe2/files/patch-ai (nonexistent) +++ head/editors/joe2/files/patch-ai (revision 54834) @@ -0,0 +1,11 @@ +--- bw.c.orig Sun Feb 10 14:27:49 2002 ++++ bw.c Sun Feb 10 14:28:18 2002 +@@ -734,7 +734,7 @@ + if(window==window->main) + { + rmkbd(window->kbd); +- window->kbd=mkkbd(getcontext(w->o.context)); ++ window->kbd=mkkbd(joegetcontext(w->o.context)); + } + w->top->xcol=0; w->cursor->xcol=0; + return w; Property changes on: head/editors/joe2/files/patch-ai ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/editors/joe2/files/patch-aj =================================================================== --- head/editors/joe2/files/patch-aj (nonexistent) +++ head/editors/joe2/files/patch-aj (revision 54834) @@ -0,0 +1,16 @@ +--- rc.h.orig Sun Feb 10 14:28:00 2002 ++++ rc.h Sun Feb 10 14:28:55 2002 +@@ -34,11 +34,11 @@ + extern OPTIONS pdefault; + void setopt(); + +-/* KMAP *getcontext(char *name); ++/* KMAP *joegetcontext(char *name); + * Find and return the KMAP for a given context name. If none is found, an + * empty kmap is created, bound to the context name, and returned. + */ +-KMAP *getcontext(); ++KMAP *joegetcontext(); + + /* int procrc(char *name); Process an rc file + Returns 0 for success Property changes on: head/editors/joe2/files/patch-aj ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property