• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..27-Dec-2011-

Makefile.inH A D20-Jul-2009889 3324

READMEH A D04-Dec-20015.2 KiB10987

cleanup.cH A D05-Nov-20093 KiB11174

depsH A D18-Nov-20091.8 KiB3938

dump-utmp.cH A D05-Nov-20096 KiB284241

err.cH A D05-Nov-20091.8 KiB5024

getpty.cH A D03-May-20224.3 KiB161115

init.cH A D05-Nov-20091 KiB315

init_slave.cH A D05-Nov-20092.6 KiB9956

libpty.hH A D05-Nov-20092.3 KiB7537

logwtmp.cH A D03-May-20223.3 KiB11982

open_ctty.cH A D05-Nov-20092.4 KiB6618

open_slave.cH A D05-Nov-20092.9 KiB10050

pty-int.hH A D05-Nov-20092.6 KiB13391

pty_paranoia.cH A D05-Nov-200918.9 KiB649418

sane_hostname.cH A D11-Jul-20113.4 KiB11981

update_utmp.cH A D05-Nov-200924.9 KiB726274

update_wtmp.cH A D03-May-20223.8 KiB149102

vhangup.cH A D05-Nov-20091.5 KiB4922

void_assoc.cH A D05-Nov-20091.5 KiB4817

README

1	This file is to serve as documentation and usage notes on
2libpty until
3more formal docs are written.  By that point, it will probably
4describe how pty can be broken out of the Kerberos distribution.
5
6void pty_init(void);
7
8	 Initialize error tables.
9
10
11long pty_getpty ( int *fd, char *slave, int slavelength);
12	Find and initialize a clean master pty.  This should open the
13pty as fd, and return the name of the slave.  It should return 0 or an
14error code.  The slavelength parameter should include the maximum
15length allocated for a slave name.  The slave may not be initialized, although any
16
17operating-system specific initialization (for example, unlockpt and
18grantpt) may be performed.
19
20long pty_open_slave (/*in */ char * slave, /* out*/ int *fd)
21
22	Initialize the slave side by dissociating the current terminal
23and by setting process groups, etc.  In addition, it will initialize
24the terminal flags (termios or old BSD) appropriately; the application
25may have to do additional customization, but this should sanitize
26things.  In addition, the pty will be opened securely, and will become
27the controlling terminal.  This procedure will fail unless the process
28is running as root.  Ideally, pty_open_slave will be called in a child
29process of the process that called pty_getpty.  If an operating system
30implements setsid() per the POSIX spec, but does not implement
31TIOCNOTTY, this procedure will not be able to insure that the
32controlling terminal is established if it is called in the parent
33process.  Unfortunately, the parent process must not write to the pty
34until the slave side is opened.  Also, the parent process should not
35open the slave side through other means unless it is prepared to have
36that file descriptor subjected to a vhangup() or revoke() when
37pty_open_slave is called in the child.  So, ideally, the parent calls
38pty_getpty, forks, waits for the slave to call pty_open_slave, then
39continues.  Since this synchronization may be difficult to build in to
40existing programs, pty_open_slave makes an effort to function if
41called in the parent under operating systems where this is possible.
42Currently, I haven't found any operating systems where this isn't
43possible.  Also note that pty_open_slave will succeed only once per process.
44
45long pty_open_ctty(int *fd, char *line)
46
47	Attempt to disassociate the current process from its controlling terminal and open line as a new controlling terminal.  No assumption about line being the slave side of a pty is made.
48
49long pty_initialize_slave (int fd)
50
51	Perform the non-security related initializations on the slave
52side of a pty.  For example, push the appropriate streams, set termios
53structures, etc.  This is included in pty_open_slave.  I am interested
54in any suggestions on how to pass information on the state to which
55the application wants the terminal initialized.  For example, rlogind
56wants a transparent channel, while other programs likely want cooked
57mode.  I can't take a termios structure because I may be on a
58non-termios system.  Currently, I push the streams, do a bit of
59cleanup, but don't really modify the terminal that much. Another
60possible goal for this function would be to do enough initialization
61that the slave side of the pty can be treated simply as a tty instead
62of a pty after this call.
63
64
65long pty_update_utmp ( int process_type, int pid, char *user, char
66*line, char *host, int flags)
67
68	Update the utmp information or return an error.The
69process_type is one of the magic types defined in libpty.h.  The flags
70are logical combinations of one of the following:
71
72    		PTY_TTYSLOT_USABLE: The tty pointed to by the line
73		  parameter is the first tty that would be found by
74		  searching stdin then stdout.  In other words,
75		  ttyslot() would return the right slot in utmp on
76		  systems where ttyslot() is cannonically used.  Note
77		  that for inserting utmp entries for new logins, it
78		  is not always possible to find the right place if
79		  this flag is not given. Thus, for programs like
80		  telnetd that set up utmp entries, it is important to
81		  be able to set this flag on the initial utmp update.
82		  It is expected that this flag may be cleared on
83		  update_utmp calls to remove utmp entries.
84
85		PTY_UTMP_USERNAME_VALID: the username field in the
86		  utmp entry associated with this line contains the
87		  user who (is/was) associated with the line.
88		  Regardless of this flag, the utmp file will contain
89		  the username specified after this call.  However, if
90		  a username is needed by the system for wtmp logout
91		  (Solaris 2.1 for example), then the system can fetch
92		  the user from the utmp record before doing the wtmp
93		  update.  This will only be attempted if the username
94		  is a null pointer.
95
96long pty_cleanup(char *slave, pid_t pid, int update_wtmp)
97
98	Clean up after the slave application has exited.  Close down
99the pty, HUPing processes associated with it.  (pid is the pid of the
100slave process that may have died, slave is the name of the slave
101terminal.)  PID is allowed to be zero if unknown; this may disable
102some cleanup operations.  This routine may fork on some systems.  As
103such, SIGCHLD may be generated and blocked for some time during the
104routine.  In addition, on systems without waitpid() or wait4(), wait()
105may be called.
106
107
108
109