home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / terminals / xterm.escapes / misc.c.patch next >
Encoding:
Text File  |  1994-01-18  |  1.4 KB  |  58 lines

  1. *** /tmp/,RCSt1024171    Sun Dec 30 01:19:03 1990
  2. --- mit/clients/xterm/misc.c    Sat Dec 29 23:42:03 1990
  3. ***************
  4. *** 32,37 ****
  5. --- 32,38 ----
  6.   
  7.   #include <stdio.h>
  8.   #include <X11/Xos.h>
  9. + #include <sys/param.h>
  10.   #include <setjmp.h>
  11.   #include <ctype.h>
  12.   #include <pwd.h>
  13. ***************
  14. *** 596,601 ****
  15. --- 597,638 ----
  16.        * One could write code to send back the display and host names,
  17.        * but that could potentially open a fairly nasty security hole.
  18.        */
  19. +     case 51:    /* echo DISPLAY variable to file 'buf' */
  20. +         {
  21. +             int fd;
  22. +             if ( !buf || !*buf )    /* no file given */
  23. +                 fd = screen->respond;
  24. +             else
  25. +                 fd = open( buf, O_WRONLY|O_CREAT, 0666 );
  26. +             if ( fd >= 0 ) {
  27. +                 char *p = DisplayString( screen->display );
  28. +                 if ( ! p )
  29. +                     p = "";
  30. +                 write( fd, p, strlen( p ) );
  31. +                 write( fd, "\n", 1 );
  32. +                 if ( fd != screen->respond )
  33. +                     (void) close( fd );
  34. +             }
  35. +         }
  36. +         break;
  37. +     case 52:    /* echo hostname to file 'buf' */
  38. +         {
  39. +             int fd;
  40. +             if ( !buf || !*buf )    /* no file given */
  41. +                 fd = screen->respond;
  42. +             else
  43. +                 fd = open( buf, O_WRONLY|O_CREAT, 0666 );
  44. +             if ( fd >= 0 ) {
  45. +                 char hname[MAXHOSTNAMELEN+1];
  46. +                 if ( gethostname( hname, sizeof(hname) ) != 0 )
  47. +                         strcpy( hname, "unknown" );
  48. +                 write( fd, hname, strlen( hname ) );
  49. +                 write( fd, "\n", 1 );
  50. +                 if ( fd != screen->respond )
  51. +                     (void) close( fd );
  52. +             }
  53. +         }
  54. +         break;
  55.       }
  56.   }
  57.   
  58.