ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/proxy.C
(Generate patch)

Comparing rxvt-unicode/src/proxy.C (file contents):
Revision 1.6 by root, Sat Jan 20 00:55:01 2007 UTC vs.
Revision 1.7 by root, Mon Feb 12 17:34:58 2007 UTC

31 31
32#include <sys/types.h> 32#include <sys/types.h>
33#include <sys/socket.h> 33#include <sys/socket.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <errno.h>
36 37
37// helper/proxy support 38// helper/proxy support
38 39
39#if PTYTTY_HELPER 40#if PTYTTY_HELPER
40 41
295#endif 296#endif
296 return new ptytty_unix; 297 return new ptytty_unix;
297} 298}
298 299
299void 300void
301ptytty::sanitise_stdfd ()
302{
303 // sanitise stdin/stdout/stderr to point to *something*.
304 for (int fd = 0; fd <= 2; ++fd)
305 if (fcntl (fd, F_GETFL) < 0 && errno == EBADF)
306 {
307 int fd2 = open ("/dev/tty", fd ? O_WRONLY : O_RDONLY);
308
309 if (fd2 < 0)
310 fd2 = open ("/dev/null", fd ? O_WRONLY : O_RDONLY);
311
312 if (fd2 != fd)
313 abort ();
314 }
315}
316
317void
300ptytty::init () 318ptytty::init ()
301{ 319{
320 sanitise_stdfd ();
321
302 uid_t uid = getuid (); 322 uid_t uid = getuid ();
303 gid_t gid = getgid (); 323 gid_t gid = getgid ();
304 324
305 // before doing anything else, check for setuid/setgid operation, 325 // before doing anything else, check for setuid/setgid operation,
306 // start the helper process and drop privileges 326 // start the helper process and drop privileges

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines