]>
Commit | Line | Data |
---|---|---|
5545a732 JR |
1 | |
2 | When you view a file with the more command and run a shell, the file descriptor | |
3 | for reading the file is leaked to that process. | |
4 | ||
5 | To test, more any file. Then do !/bin/sh. At the prompt do "ls -l /proc/$$/fd" | |
6 | and you'll see the leaked fd. | |
7 | ||
8 | From: Steve Grubb <sgrubb@redhat.com> | |
9 | ||
10 | --- util-linux-2.13-pre7/text-utils/more.c.cloexec 2006-12-14 14:05:31.000000000 +0100 | |
11 | +++ util-linux-2.13-pre7/text-utils/more.c 2006-12-14 14:04:57.000000000 +0100 | |
12 | @@ -478,6 +478,7 @@ | |
13 | } | |
14 | if (magic(f, fs)) | |
15 | return((FILE *)NULL); | |
16 | + fcntl(fileno(f), F_SETFD, FD_CLOEXEC ); | |
17 | c = Getc(f); | |
18 | *clearfirst = (c == '\f'); | |
19 | Ungetc (c, f); |