home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1621 / config.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  9.4 KB  |  272 lines

  1. /* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  2.  
  3. #ifndef PTY_CONFIG_H
  4. #define PTY_CONFIG_H
  5.  
  6. /* It is recommended that you make local changes in the Makefile, */
  7. /* except for feature control, which is best done here. */
  8.  
  9. /* Section 1: Feature control. */
  10. /* Section 2: Pseudo-terminal pathnames. */
  11. /* Section 3: Logging. */
  12. /* Section 4: Protection. */
  13. /* Section 5: Other. */
  14. /* Section 6: Sanity checks. */
  15.  
  16. /* Each section starts with the necessary defines and finishes with */
  17. /* an explanation. */
  18.  
  19.  
  20. /* Section 1: Feature control. */
  21.  
  22. /*#define MUST_UTMP  /* force utmp logging */
  23. /*#define NO_UTMP  /* prohibit utmp logging */
  24. /*#define MUST_WTMP  /* force utmp logging */
  25. /*#define NO_WTMP  /* prohibit wtmp logging */
  26. /*#define MUST_SESSION  /* force disconnectable sessions (what for?) */
  27. /*#define NO_SESSION  /* prohibit disconnectable sessions */
  28. /*#define MUST_CHOWN  /* force changing pty owner */
  29. /*#define NO_CHOWN  /* prohibit changing pty owner */
  30. /*#define NO_FDPASSING  /* prohibit file descriptor passing */
  31. /*#define NO_UNIXSOCKS  /* prohibit use of UNIX-domain sockets */
  32. #define TTY_WINDOWS  /* have winsize, WINCH, etc. in tty (4.3) */
  33. /*#define TTY_AUXCHARS  /* have systat, e.g. with ^T, in tty */
  34. #define DESPERATE_ALARMS  /* if NDELAY may not be enough */
  35. #define DONT_NDELAY  /* might as well, with DESPERATE_ALARMS */
  36. #define SIGINTERRUPT  /* if you have siginterrupt() (4.3) */
  37. #define USLEEP  /* if you have usleep() */
  38.  
  39. /* These are mostly self-explanatory. If your system doesn't support */
  40. /* some feature, you should prohibit it by defining NO_WHATEVER. */
  41.  
  42. /* Any BSD 4.2 or 4.3 system should have UNIXSOCKS and FDPASSING. Look */
  43. /* for /sys/h/un.h to see if you have UNIX-domain sockets. Look for */
  44. /* msg_accrights in the man page for recvmsg() to see if you have */
  45. /* file desriptor passing. (Sometimes fd passing is available but buggy, */
  46. /* as it's a relatively new, powerful, and rarely exploited feature. In */
  47. /* this case you should define NO_FDPASSING.) In the current version, */
  48. /* NO_UNIXSOCKS implies NO_FDPASSING and NO_SESSION; see Section 6. */
  49.  
  50. /* For TTY_WINDOWS, look for struct winsize in /usr/include/sgtty.h. */
  51. /* For TTY_AUXCHARS, look for struct auxchars in the same place. */
  52. /* All BSD 4.3 systems should have winsize; auxchars isn't so common. */
  53.  
  54. /* Opening the slave side of a pty without a master should hang the */
  55. /* process. Normally, opening with NDELAY gets around this effect; */
  56. /* opening the slave side first is necessary for some security checks. */
  57. /* On some systems, however, NDELAY doesn't do its job; you must */
  58. /* define DESPERATE_ALARMS to forcibly interrupt each open(). There */
  59. /* shouldn't be any problem in leaving this (and DONT_NDELAY) defined */
  60. /* anyway. (On a few systems, you must have DONT_NDELAY for -xn.) */
  61.  
  62. /* Define SIGINTERRUPT if you have siginterrupt() (i.e., if you're */
  63. /* running BSD 4.3). Without this call, there's no correct way to do */
  64. /* per-process nonblocking I/O, and pty may block when it shouldn't */
  65. /* (namely, when it has N bytes to write to the output, the output is */
  66. /* a blocking pipe with M bytes of space, and N > M > 0). If you define */
  67. /* SIGINTERRUPT, pty will take some extra effort to never, ever, ever */
  68. /* block when it doesn't have to. (See OUTBUFSIZE, below.) */
  69.  
  70. /* Define USLEEP if you have usleep(). */
  71.  
  72.  
  73. /* Section 2: Pathnames. */
  74.  
  75. #ifndef PTYDIR
  76. #define PTYDIR "/usr/etc/pty"
  77. #endif
  78. #ifndef DEVMTY
  79. #define DEVMTY "/dev/pty  "
  80. #endif
  81. #ifndef DEVSTY
  82. #define DEVSTY "/dev/tty  "
  83. #endif
  84. #ifndef PTY1
  85. #define PTY1 "pqrstuvwxyzabcdefghijklmno"
  86. #endif
  87. #ifndef PTY2
  88. #define PTY2 "0123456789abcdef"
  89. #endif
  90. #ifndef TTYNAMELEN
  91. #define TTYNAMELEN 30
  92. #endif
  93.  
  94. /* PTYDIR is where pty sessions store their information. You should */
  95. /* create it mode 700, owner pty, group irrelevant. You must define */
  96. /* PTYDIR as something even if you don't allow sessions. If you don't */
  97. /* set up PTYDIR at all but you do allow sessions, pty will switch */
  98. /* out of setuid after grabbing a pty, then set up session information */
  99. /* in the user's home directory. This isn't totally secure but it's */
  100. /* at least partially workable. */
  101.  
  102. /* DEVMTY and DEVSTY are the basenames of the master and slave ptys */
  103. /* respectively. They must each end with two spaces, filled in with */
  104. /* characters from PTY1 and PTY2 respectively. If your ptys aren't */
  105. /* labelled by this convention, I'm surprised you have anything working; */
  106. /* either set up a new pty bank with normal names or change the pty code */
  107. /* that allocates ptys. Note that convention allows you to only have */
  108. /* some of a pty bank, as long as one of them is there; the first letter */
  109. /* in PTY2 must indicate that one. */
  110.  
  111. /* The order of PTY1 and PTY2 is the pty searching order. pty allows */
  112. /* (and, as a break from tradition, uses by default) random searches, */
  113. /* starting from random spots in PTY1 and PTY2 rather than the beginning. */
  114. /* This has several good effects, although you may think utmp will look */
  115. /* a bit ugly. */
  116.  
  117. /* If you want to gradually convert your system to using this program, */
  118. /* PTY1 and PTY2 shouldn't reference all your ptys. Instead, pick a */
  119. /* large enough subset of your ptys to be usable, and try things out */
  120. /* with just those. If everything works and you like pty's capabilities, */
  121. /* remove your old ptys, or recompile pty to reference all of them. */
  122.  
  123. /* TTYNAMELEN should be the maximum length of a tty (not just pty!) */
  124. /* name. TTYNAMELEN shouldn't have to be there; it's used to work */
  125. /* around some fundamental failures in the current tty/pty model. */
  126.  
  127.  
  128. /* Section 3: Logging. */
  129.  
  130. #ifndef PTYUTMP_FILE
  131. #define PTYUTMP_FILE "/etc/utmp"
  132. #endif
  133. #ifndef PTYWTMP_FILE
  134. #define PTYWTMP_FILE "/usr/adm/wtmp"
  135. #endif
  136. #ifndef PTYUTMP_OFFSET
  137. #define PTYUTMP_OFFSET 5
  138. #endif
  139. #ifndef PTYWTMP_OFFSET
  140. #define PTYWTMP_OFFSET PTYUTMP_OFFSET
  141. #endif
  142. #ifndef PTYUTMP_HOST
  143. #define PTYUTMP_HOST "pty"
  144. #endif
  145. #ifndef PTYWTMP_HOST
  146. #define PTYWTMP_HOST PTYUTMP_HOST
  147. #endif
  148. #ifndef PTYUTMP_SWHOST
  149. #define PTYUTMP_SWHOST PTYUTMP_HOST
  150. #endif
  151. #ifndef PTYWTMP_SWHOST
  152. #define PTYWTMP_SWHOST "pty-sessuser"
  153. #endif
  154.  
  155. /* These are straightforward. FILE is where you want the logs. utmp and */
  156. /* wtmp are about as sensible as /etc/passwd and unfortunately just as */
  157. /* popular; typically they're in /etc/utmp and /usr/adm/wtmp, and the */
  158. /* utility programs in this package support that convention. (wtmp logs */
  159. /* all ins and outs. utmp only has one entry per line, namely the last */
  160. /* wtmp entry for it.) OFFSET is the number of chars from a pty extension */
  161. /* to remove from a log entry; usually this is 5, to make /dev/ttyxx into */
  162. /* ttyxx. Finally, HOST is the name that you want in the ``remote'' field */
  163. /* of the log; that field is rather illogical, but it's there. */
  164.  
  165. /* SWHOST is a variant of HOST, for what's logged upon a session uid */
  166. /* switch. */
  167.  
  168. /* If you're using pty under telnet/login/whatever, which do their own */
  169. /* utmp and wtmp handling, then pty will usually have -xUW, so these */
  170. /* defines aren't too important. Except for SWHOST, which is necessary */
  171. /* for sessuser's action to make sense. */
  172.  
  173.  
  174. /* Section 4: Protection. */
  175.  
  176. #ifndef USEDPTYMODE
  177. #define USEDPTYMODE 0600
  178. #endif
  179. #ifndef UNUSEDPTYMODE
  180. #define UNUSEDPTYMODE 0600
  181. #endif
  182. #ifndef PTYOWNER
  183. #define PTYOWNER euid
  184. #endif
  185. #ifndef PTYGROUP
  186. #define PTYGROUP 4
  187. #endif
  188.  
  189. /* pty -xc will change the owner of the pty back to PTYOWNER after the */
  190. /* child has exited. This should be euid, for the effective uid of the */
  191. /* pty process. If a user runs pty as himself, he won't get to change */
  192. /* the owner of the pseudo-terminal in the first place. */
  193.  
  194. /* PTYGROUP should be the ``tty'' group in /etc/group, normally 4. All */
  195. /* ptys and ttys should be in this group at all times. */
  196.  
  197. /* USEDPTYMODE is the mode of ptys while they're being used. 600 is a */
  198. /* good choice; it means messages off. If you want msgs y by default, */
  199. /* try 620. Don't use the old 622: it's exceedingly insecure. */
  200.  
  201. /* UNUSEDPTYMODE is the mode of ptys while they're unused. Traditionally */
  202. /* this would be 666, so that any process needing a pty can just grab */
  203. /* one. However, this leads to quite a few security holes. If you have */
  204. /* lots of programs like emacs that really, really, really want to use */
  205. /* ptys and don't support this interface, try 0660, and make those */
  206. /* programs setgid tty. Otherwise, stick to 0600. */
  207.  
  208.  
  209. /* Section 5: Other. */
  210.  
  211. #ifndef SIGRET_TYPE
  212. #define SIGRET_TYPE int
  213. #endif
  214.  
  215. #ifndef OUTBUFSIZE
  216. #define OUTBUFSIZE 16384
  217. #endif
  218.  
  219. #ifndef GENERIC
  220. #define GENERIC char
  221. #endif
  222.  
  223. #ifdef TTY_AUXCHARS
  224. #define USESTAT
  225. #endif
  226.  
  227. /* SIGRET_TYPE is the type returned by signal handlers. Logically, it */
  228. /* should be void, but C and signals were around before void was. */
  229.  
  230. /* OUTBUFSIZE is the size of the extra buffers provided by pty, both */
  231. /* for data coming in to the pseudo-terminal and for data going out. */
  232.  
  233. /* It should be possible to cast any pointer to a GENERIC * pointer */
  234. /* and back. Again, void makes the most sense and is the best choice */
  235. /* under ANSI, but char is correct and much more portable. */
  236.  
  237. /* Setting USESTAT is necessary for systems supporting auxchars. */
  238.  
  239.  
  240. /* Section 6: Sanity checks. */
  241.  
  242. #ifdef NO_UNIXSOCKS
  243. #define NO_FDPASSING
  244. #define NO_SESSION
  245. #endif
  246.  
  247. #ifdef NO_SESSION
  248. #ifdef MUST_SESSION
  249. #undef MUST_SESSION
  250. #endif
  251. #endif
  252.  
  253. #ifdef NO_UTMP
  254. #ifdef MUST_UTMP
  255. #undef MUST_UTMP
  256. #endif
  257. #endif
  258.  
  259. #ifdef NO_WTMP
  260. #ifdef MUST_WTMP
  261. #undef MUST_WTMP
  262. #endif
  263. #endif
  264.  
  265. #ifdef NO_CHOWN
  266. #ifdef MUST_CHOWN
  267. #undef MUST_CHOWN
  268. #endif
  269. #endif
  270.  
  271. #endif
  272.