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
|
--- b.c
+++ b.c 2000/03/02 13:15:55
@@ -15,8 +15,15 @@
You should have received a copy of the GNU General Public License along with
JOE; see the file COPYING. If not, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */
+/*
+DEADJOE tmp race condition security fix by thomas@suse.de
+at 1999-07-23
+*/
#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#ifndef __MSDOS__
#include <pwd.h>
#endif
@@ -1990,7 +1997,30 @@
{
long tim=time(0);
B *b;
- FILE *f=fopen("DEADJOE","a");
+ FILE *f;
+ int tmpfd;
+ struct stat sbuf;
+
+ if((tmpfd = open("DEADJOE", O_RDWR|O_EXCL|O_CREAT, 0600)) < 0) {
+ if(lstat("DEADJOE", &sbuf) < 0)
+ _exit(-1);
+ if(!S_ISREG(sbuf.st_mode) || sbuf.st_uid != geteuid())
+ _exit(-1);
+ /*
+ A race condition still exists between the lstat() and the open()
+ systemcall, which leads to a possible denial-of-service attack
+ by setting the file access mode to 600 for every file the
+ user executing joe has permissions to.
+ This can't be fixed w/o breacking the behavior of the orig. joe!
+ */
+ if((tmpfd = open("DEADJOE", O_RDWR|O_APPEND)) < 0)
+ _exit(-1);
+ if(fchmod(tmpfd, S_IRUSR|S_IWUSR) < 0)
+ _exit(-1);
+ }
+ if((f = fdopen(tmpfd, "a")) == NULL)
+ _exit(-1);
+
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");
--- conf.c
+++ conf.c 2000/03/02 13:15:55
@@ -204,8 +204,10 @@
fprintf(f,"\n");
fprintf(f,"char *getenv();\n");
+ fprintf(f,"#ifndef __alpha__\n");
if(sizeof(long)==8) fprintf(f,"int time();\n");
else fprintf(f,"long time();\n");
+ fprintf(f,"#endif\n");
fprintf(f,"void *malloc();\n");
fprintf(f,"void free();\n");
fprintf(f,"void *calloc();\n");
--- jmacsrc
+++ jmacsrc 2000/03/02 13:15:55
@@ -376,6 +376,8 @@
bof ^[ < Goto beginning of file
bol .kh Goto beginning of line
bol ^A
+bol ^[ [ H
+bol ^[ [ 1 ~
bop ^[ p (uemacs)
bufed ^X b
bknd ^[ ' Shell window
@@ -394,6 +396,8 @@
eof ^[ > Go to end of file
eol .kH Go to end of line
eol ^E
+eol ^[ [ F
+eol ^[ [ 4 ~
eop ^[ n (uemacs)
execmd ^[ x
insc ^C (uemacs)
--- joerc
+++ joerc 2000/03/02 13:15:55
@@ -25,7 +25,7 @@
-marking Text between ^KB and cursor is highlighted (use with -lightoff)
- -asis Characters 128 - 255 shown as-is
+-asis Characters 128 - 255 shown as-is
-force Force final newline when files are saved
@@ -456,6 +456,8 @@
bof ^K u
bol .kh Goto beginning of line
bol ^A
+bol ^[ [ H
+bol ^[ [ 1 ~
center ^K A Center line
center ^K ^A
center ^K a
@@ -478,6 +480,8 @@
eof ^K v
eol .kH Go to end of line
eol ^E
+eol ^[ [ F
+eol ^[ [ 4 ~
exsave ^K X Save and exit
exsave ^K ^X
exsave ^K x
--- jpicorc
+++ jpicorc 2000/03/02 13:15:55
@@ -351,6 +351,8 @@
bof ^[ y
bol .kh Goto beginning of line
bol ^A
+bol ^[ [ H
+bol ^[ [ 1 ~
center ^[ ^C Center line
center ^[ c
delch .kD Delete character
@@ -373,6 +375,8 @@
eof ^[ v
eol .kH Go to end of line
eol ^E
+eol ^[ [ F
+eol ^[ [ 4 ~
execmd ^[ X Prompt for command to execute
execmd ^[ ^X Prompt for command to execute
execmd ^[ x Prompt for command to execute
--- jstarrc
+++ jstarrc 2000/03/02 13:15:55
@@ -371,6 +371,8 @@
bof ^Q ^R
bof ^Q r
bol .kh Goto beginning of line
+bol ^[ [ H
+bol ^[ [ 1 ~
bol ^Q S
bol ^Q ^S
bol ^Q s
@@ -403,6 +405,8 @@
eof ^Q ^C
eof ^Q c
eol .kH Go to end of line
+eol ^[ [ F
+eol ^[ [ 4 ~
eol ^Q D
eol ^Q ^D
eol ^Q d
--- Makefile
+++ Makefile 2000/03/02 13:15:55
@@ -9,15 +9,15 @@
# to go and where you want the man page
# to go:
-WHEREJOE = /usr/local/bin
-WHERERC = /usr/local/lib
-WHEREMAN = /usr/man/man1
+WHEREJOE = /usr/bin
+WHERERC = /usr/lib
+WHEREMAN = /usr/man/man1
# If you want to use TERMINFO, you have to set
# the following variable to 1. Also you have to
# include some additional libraries- see below.
-TERMINFO = 0
+TERMINFO = 1
# You may also have to add some additional
# defines to get the include files to work
@@ -27,11 +27,11 @@
# C compiler options: make's built-in rules use this variable
-CFLAGS = -O
+CFLAGS = -O2 -fsigned-char -fomit-frame-pointer -pipe
# C compiler to use: make's built-in rules use this variable
-CC = cc
+CC = gcc
# You may have to include some extra libraries
# for some systems
@@ -45,7 +45,7 @@
# add '-ltinfo', '-lcurses' or '-ltermlib',
# depending on the system.
-EXTRALIBS =
+EXTRALIBS = -lncurses
# Object files
@@ -85,44 +85,36 @@
# Install proceedure
install: joe termidx
- strip joe
- strip termidx
if [ ! -d $(WHEREJOE) ]; then mkdir $(WHEREJOE); chmod a+rx $(WHEREJOE); fi
rm -f $(WHEREJOE)/joe $(WHEREJOE)/jmacs $(WHEREJOE)/jstar $(WHEREJOE)/jpico $(WHEREJOE)/rjoe $(WHEREJOE)/termidx
- mv joe $(WHEREJOE)
- ln $(WHEREJOE)/joe $(WHEREJOE)/jmacs
- ln $(WHEREJOE)/joe $(WHEREJOE)/jstar
- ln $(WHEREJOE)/joe $(WHEREJOE)/rjoe
- ln $(WHEREJOE)/joe $(WHEREJOE)/jpico
- mv termidx $(WHEREJOE)
+ install -s joe $(WHEREJOE)
+ ln -s $(WHEREJOE)/joe $(WHEREJOE)/jmacs
+ ln -s $(WHEREJOE)/joe $(WHEREJOE)/jstar
+ ln -s $(WHEREJOE)/joe $(WHEREJOE)/rjoe
+ ln -s $(WHEREJOE)/joe $(WHEREJOE)/jpico
+ install -s termidx $(WHEREJOE)
if [ ! -d $(WHERERC) ]; then mkdir $(WHERERC); chmod a+rx $(WHERERC); fi
rm -f $(WHERERC)/joerc $(WHERERC)/jmacsrc $(WHERERC)/jstarrc $(WHERERC)/jpicorc $(WHERERC)/rjoerc $(WHEREMAN)/joe.1
- cp joerc $(WHERERC)
- cp jmacsrc $(WHERERC)
- cp jstarrc $(WHERERC)
- cp rjoerc $(WHERERC)
- cp jpicorc $(WHERERC)
- cp joe.1 $(WHEREMAN)
- chmod a+x $(WHEREJOE)/joe
- chmod a+x $(WHEREJOE)/jmacs
- chmod a+x $(WHEREJOE)/jstar
- chmod a+x $(WHEREJOE)/rjoe
- chmod a+x $(WHEREJOE)/jpico
- chmod a+r $(WHERERC)/joerc
- chmod a+r $(WHERERC)/jmacsrc
- chmod a+r $(WHERERC)/jstarrc
- chmod a+r $(WHERERC)/rjoerc
- chmod a+r $(WHERERC)/jpicorc
- chmod a+r $(WHEREMAN)/joe.1
- chmod a+x $(WHEREJOE)/termidx
- rm -f $(WHERERC)/termcap
- cp termcap $(WHERERC)/termcap
- chmod a+r $(WHERERC)/termcap
- rm -f $(WHERERC)/terminfo
- cp terminfo $(WHERERC)/terminfo
- chmod a+r $(WHERERC)/terminfo
+ install -m 644 joerc $(WHERERC)
+ install -m 644 jmacsrc $(WHERERC)
+ install -m 644 jstarrc $(WHERERC)
+ install -m 644 rjoerc $(WHERERC)
+ install -m 644 jpicorc $(WHERERC)
+ install -m 644 joe.1 $(WHEREMAN)
+ #rm -f $(WHERERC)/termcap
+ #cp termcap $(WHERERC)/termcap
+ #chmod a+r $(WHERERC)/termcap
+ #rm -f $(WHERERC)/terminfo
+ #cp terminfo $(WHERERC)/terminfo
+ #chmod a+r $(WHERERC)/terminfo
# Cleanup proceedure
clean:
rm -f $(OBJS) termidx.o conf conf.o config.h
+
+
+
+
+
+
--- rjoerc
+++ rjoerc 2000/03/02 13:15:55
@@ -436,6 +436,8 @@
bof ^K u
bol .kh Goto beginning of line
bol ^A
+bol ^[ [ H
+bol ^[ [ 1 ~
center ^K A Center line
center ^K ^A
center ^K a
@@ -458,6 +460,8 @@
eof ^K v
eol .kH Go to end of line
eol ^E
+eol ^[ [ F
+eol ^[ [ 4 ~
exsave ^K X Save and exit
exsave ^K ^X
exsave ^K x
|