6.31. Installing Ed-0.2

Estimated build time:           1 minute
Estimated required disk space:  2 MB

6.31.1. Installation of Ed

Ed isn't something you would personally use. It's installed here because it can be used by the patch program if you encounter an ed-based patch file. This happens rarely because diff-based patches are preferred these days.

Install Ed by running the following commands:

cp buf.c buf.c.backup &&
sed 's/int u/int u, sfd/' buf.c.backup | \
   sed '/.*\*mktemp.*/d' | \
   sed 's/.*if (mktemp.*/  sfd = mkstemp(sfn);\
   if ((sfd == -1) || (sfp = fopen (sfn, "w+")) == NULL)/' > buf.c &&
./configure --prefix=/usr &&
make &&
make install &&
mv /usr/bin/ed /usr/bin/red /bin

6.31.2. Command explanations

The sed commands fix a symlink vulnerability in ed. The ed executable creates files in /tmp with predictable names. By using various symlink attacks, it is possible to have ed write to files it should not, change the permissions of various files, etc.

6.31.3. Contents of ed-0.2

6.31.4. Dependencies

Ed-0.2 needs the following to be installed:


bash: sh
binutils: ar, as, ld, ranlib
diffutils: cmp
fileutils: chmod, cp, install, ln, mv, rm, touch
gcc: cc1, collect2, cpp0, gcc
grep: egrep, grep
make: make
sed: sed
sh-utils: hostname
textutils: cat, tr