ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libptytty/doc/libptytty.3.man
Revision: 1.2
Committed: Mon Jan 23 12:27:47 2006 UTC (20 years, 8 months ago) by root
Content type: application/x-troff-man
Branch: MAIN
Changes since 1.1: +160 -6 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
2     .\"
3     .\" Standard preamble:
4     .\" ========================================================================
5     .de Sh \" Subsection heading
6     .br
7     .if t .Sp
8     .ne 5
9     .PP
10     \fB\\$1\fR
11     .PP
12     ..
13     .de Sp \" Vertical space (when we can't use .PP)
14     .if t .sp .5v
15     .if n .sp
16     ..
17     .de Vb \" Begin verbatim text
18     .ft CW
19     .nf
20     .ne \\$1
21     ..
22     .de Ve \" End verbatim text
23     .ft R
24     .fi
25     ..
26     .\" Set up some character translations and predefined strings. \*(-- will
27     .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28     .\" double quote, and \*(R" will give a right double quote. | will give a
29     .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30     .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31     .\" expand to `' in nroff, nothing in troff, for use with C<>.
32     .tr \(*W-|\(bv\*(Tr
33     .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34     .ie n \{\
35     . ds -- \(*W-
36     . ds PI pi
37     . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38     . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39     . ds L" ""
40     . ds R" ""
41     . ds C` ""
42     . ds C' ""
43     'br\}
44     .el\{\
45     . ds -- \|\(em\|
46     . ds PI \(*p
47     . ds L" ``
48     . ds R" ''
49     'br\}
50     .\"
51     .\" If the F register is turned on, we'll generate index entries on stderr for
52     .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53     .\" entries marked with X<> in POD. Of course, you'll have to process the
54     .\" output yourself in some meaningful fashion.
55     .if \nF \{\
56     . de IX
57     . tm Index:\\$1\t\\n%\t"\\$2"
58     ..
59     . nr % 0
60     . rr F
61     .\}
62     .\"
63     .\" For nroff, turn off justification. Always turn off hyphenation; it makes
64     .\" way too many mistakes in technical documents.
65     .hy 0
66     .if n .na
67     .\"
68     .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69     .\" Fear. Run. Save yourself. No user-serviceable parts.
70     . \" fudge factors for nroff and troff
71     .if n \{\
72     . ds #H 0
73     . ds #V .8m
74     . ds #F .3m
75     . ds #[ \f1
76     . ds #] \fP
77     .\}
78     .if t \{\
79     . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80     . ds #V .6m
81     . ds #F 0
82     . ds #[ \&
83     . ds #] \&
84     .\}
85     . \" simple accents for nroff and troff
86     .if n \{\
87     . ds ' \&
88     . ds ` \&
89     . ds ^ \&
90     . ds , \&
91     . ds ~ ~
92     . ds /
93     .\}
94     .if t \{\
95     . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96     . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97     . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98     . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99     . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100     . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101     .\}
102     . \" troff and (daisy-wheel) nroff accents
103     .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104     .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105     .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106     .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107     .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108     .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109     .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110     .ds ae a\h'-(\w'a'u*4/10)'e
111     .ds Ae A\h'-(\w'A'u*4/10)'E
112     . \" corrections for vroff
113     .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114     .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115     . \" for low resolution devices (crt and lpr)
116     .if \n(.H>23 .if \n(.V>19 \
117     \{\
118     . ds : e
119     . ds 8 ss
120     . ds o a
121     . ds d- d\h'-1'\(ga
122     . ds D- D\h'-1'\(hy
123     . ds th \o'bp'
124     . ds Th \o'LP'
125     . ds ae ae
126     . ds Ae AE
127     .\}
128     .rm #[ #] #H #V #F C
129     .\" ========================================================================
130     .\"
131     .IX Title "libptytty 3"
132 root 1.2 .TH libptytty 3 "2006-01-23" "" "LIBPTYTTY"
133 root 1.1 .SH "NAME"
134     libptytty \- OS independent and secure pty/tty and utmp/wtmp/lastlog handling
135     .SH "SYNOPSIS"
136     .IX Header "SYNOPSIS"
137     .Vb 1
138     \& -lptytty
139     .Ve
140     .SH "DESCRIPTION"
141     .IX Header "DESCRIPTION"
142 root 1.2 \&\s-1TODO\s0
143     .SH "SECURITY CONSIDERATIONS"
144     .IX Header "SECURITY CONSIDERATIONS"
145     \&\fI\f(BIIt is of paramount importance that you at least read the following
146     paragraph!\fI\fR
147     .PP
148     If you are a typical terminal-like program that just wants one or more
149     ptys, you should call the \f(CW\*(C`ptytty::init ()\*(C'\fR method (C: \f(CW\*(C`ptytty_init ()\*(C'\fR
150     function) as the very first thing in your program:
151     .PP
152     .Vb 5
153     \& int main (int argc, char *argv[])
154     \& {
155     \& // do nothing here
156     \& ptytty::init ();
157     \& // in C: ptytty_init ();
158     .Ve
159     .PP
160     .Vb 2
161     \& // initialise, parse arguments, etc.
162     \& }
163     .Ve
164     .PP
165     This checks wether the program runs setuid or setgid. If yes then it will
166     fork a helper process and drop privileges.
167     .PP
168     Some programs need finer control over if and when this helper process
169     is started, and if and how to drop privileges. For those programs, the
170     methods \f(CW\*(C`ptytty::use_helper\*(C'\fR and \f(CW\*(C`ptytty::drop_privileges\*(C'\fR are more
171     useful.
172     .SH "\*(C+ INTERFACE: THE ptytty CLASS"
173     .IX Header " INTERFACE: THE ptytty CLASS"
174     .Sh "\s-1STATIC\s0 \s-1METHODS\s0"
175     .IX Subsection "STATIC METHODS"
176     .IP "ptytty::init ()" 4
177     .IX Item "ptytty::init ()"
178     The default way to initialise libptytty. Must be called imemdiately as
179     the first thing in the \f(CW\*(C`main\*(C'\fR function, or earlier e.g. during static
180     construction time. The earlier, the better.
181     .Sp
182     This method checks wether the program runs with setuid/setgid permissions
183     and, if yes, spawns a helper process for pty/tty management. \s-1IT\s0 then
184     drops the privileges completely, so the actual program runs without
185     setuid/setgid privileges.
186     .IP "ptytty::use_helper ()" 4
187     .IX Item "ptytty::use_helper ()"
188     Tries to start a helper process that retains privileges even when the
189     calling process does not. This is usually called from \f(CW\*(C`ptytty::init\*(C'\fR when
190     it detects that the program is running setuid or setgid, but can be called
191     manually if it is inconvinient to drop privileges at startup, or when
192     you are not running setuid/setgid but want to drop privileges (e.g. when
193     running as a root-started daemon).
194     .Sp
195     This method will try not to start more than one helper process. The same
196     helper process cna usually be used form the process starting it an all its
197     fork'ed (not exec'ed) children
198     .IP "ptytty::drop_privileges ()" 4
199     .IX Item "ptytty::drop_privileges ()"
200     Drops privileges completely, i.e. sets real, effective and saved user id
201     to the real user id. Also aborts if this cnanot be achieved. Useful to
202     make sure that the process doesn't run with special privileges.
203     .IP "bool success = ptytty::send_fd (int socket, int fd)" 4
204     .IX Item "bool success = ptytty::send_fd (int socket, int fd)"
205     Utility method to send a file descriptor over a unix domain
206     socket. Returns true if successful, false otherwise. This method is only
207     exposed for your convinience and is not required for normal operation.
208     .IP "int fd = ptytty::recv_fd (int socket)" 4
209     .IX Item "int fd = ptytty::recv_fd (int socket)"
210     Utility method to receive a file descriptor over a unix domain
211     socket. Returns the fd if sucecssful and \f(CW\*(C`\-1\*(C'\fR otherwise. This method
212     is only exposed for your convinience and is not required for normal
213     operation.
214     .IP "ptytty *pty = ptytty::create ()" 4
215     .IX Item "ptytty *pty = ptytty::create ()"
216     Creates new ptytty object. Creation does not yet do anything besides
217     allocating the structure.
218     .Sp
219     A static method is used because the actual ptytty implementation can
220     differ at runtime, so you need a dynamic object creation facility.
221     .Sh "\s-1DYNAMIC/SESSION\-RELATED\s0 \s-1DATA\s0 \s-1MEMBERS\s0 \s-1AND\s0 \s-1METHODS\s0"
222     .IX Subsection "DYNAMIC/SESSION-RELATED DATA MEMBERS AND METHODS"
223     .IP "int pty_fd = pty\->pty" 4
224     .IX Item "int pty_fd = pty->pty"
225     .PD 0
226     .IP "int tty_fd = pty\->tty" 4
227     .IX Item "int tty_fd = pty->tty"
228     .PD
229     These members contain the pty and tty file descriptors, respectively. They
230     initially contain \f(CW\*(C`\-1\*(C'\fR until a successful to \f(CW\*(C`ptytty::get\*(C'\fR.
231     .IP "bool success = pty\->get ()" 4
232     .IX Item "bool success = pty->get ()"
233     Tries to find, allocate and initialise a new pty/tty pair. Returns \f(CW\*(C`true\*(C'\fR
234     when successful.
235     .IP "pty\->login (int cmd_pid, bool login_shell, const char *hostname)" 4
236     .IX Item "pty->login (int cmd_pid, bool login_shell, const char *hostname)"
237     Creates an entry in the systems session database(s) (utmp, wtmp, lastlog).
238     \&\f(CW\*(C`cmd_pid\*(C'\fR must be the pid of the process representing the session
239     (such as the login shell), \f(CW\*(C`login_shell\*(C'\fR defines wether the session is
240     associated with a login, which influences wether wtmp and lastlog entries
241     are created, and \f(CW\*(C`hostname\*(C'\fR should identify the \*(L"hostname\*(R" the user logs
242     in from, which often is the value of the \f(CW\*(C`DISPLAY\*(C'\fR variable or tty line
243     in case of local logins.
244     .Sp
245     Calling this method is optional. A session starts at the time of the login
246     call and extends until the ptytty object is destroyed.
247     .IP "pty\->close_tty ()" 4
248     .IX Item "pty->close_tty ()"
249     Closes the tty. Useful after forking in the parent/pty process.
250     .IP "bool success = pty\->make_controlling_tty ()" 4
251     .IX Item "bool success = pty->make_controlling_tty ()"
252     Tries to make the pty/tty pair the controlling terminal of the current
253     process. Useful after forking in the child/tty process.
254     .IP "pty\->set_utf8_mode (bool on)" 4
255     .IX Item "pty->set_utf8_mode (bool on)"
256     On systems supporting special \s-1UTF\-8\s0 line disciplines (e.g. Linux), tries
257     to enable it for the given pty. Can be called at any time to change the
258     mode.
259     .SH "C INTERFACE: THE ptytty FAMILY OF FUNCTIONS"
260     .IX Header "C INTERFACE: THE ptytty FAMILY OF FUNCTIONS"
261     .IP "ptytty_init ()" 4
262     .IX Item "ptytty_init ()"
263     See \f(CW\*(C`ptytty::init ()\*(C'\fR.
264     .IP "\s-1PTYTTY\s0 ptytty_create ()" 4
265     .IX Item "PTYTTY ptytty_create ()"
266     Creates a new opaque \s-1PTYTTY\s0 object and returns it. Do not try to access it
267     in any way excecp by testing it for truthness (e.g. \f(CW\*(C`if (pty) ....\*(C'\fR). See
268     \&\f(CW\*(C`ptytty::create ()\*(C'\fR.
269     .IP "int ptytty_pty (\s-1PTYTTY\s0 ptytty)" 4
270     .IX Item "int ptytty_pty (PTYTTY ptytty)"
271     Return the pty file descriptor. See \f(CW\*(C`pty\->pty\*(C'\fR.
272     .IP "int ptytty_tty (\s-1PTYTTY\s0 ptytty)" 4
273     .IX Item "int ptytty_tty (PTYTTY ptytty)"
274     Return the tty file descriptor. See \f(CW\*(C`pty\->tty\*(C'\fR.
275     .IP "void ptytty_delete (\s-1PTYTTY\s0 ptytty)" 4
276     .IX Item "void ptytty_delete (PTYTTY ptytty)"
277     Destroys the \s-1PTYTTY\s0 object, freeing the pty/tty pair and cleaning up the
278     utmp/wtmp/lastlog databases, if initialised/used. Same as \f(CW\*(C`delete pty\*(C'\fR in
279     \&\*(C+.
280     .IP "int ptytty_get (\s-1PTYTTY\s0 ptytty)" 4
281     .IX Item "int ptytty_get (PTYTTY ptytty)"
282     See \f(CW\*(C`pty\->get\*(C'\fR, returns 0 in case of an error, non-zero otherwise.
283     .IP "void ptytty_login (\s-1PTYTTY\s0 ptytty, int cmd_pid, bool login_shell, const char *hostname)" 4
284     .IX Item "void ptytty_login (PTYTTY ptytty, int cmd_pid, bool login_shell, const char *hostname)"
285     See \f(CW\*(C`pty\->login\*(C'\fR.
286     .IP "void ptytty_close_tty (\s-1PTYTTY\s0 ptytty)" 4
287     .IX Item "void ptytty_close_tty (PTYTTY ptytty)"
288     See \f(CW\*(C`pty\->close_tty\*(C'\fR.
289     .IP "int ptytty_make_controlling_tty (\s-1PTYTTY\s0 ptytty)" 4
290     .IX Item "int ptytty_make_controlling_tty (PTYTTY ptytty)"
291     See \f(CW\*(C`pty\->make_controlling_tty\*(C'\fR.
292     .IP "void ptytty_set_utf8_mode (\s-1PTYTTY\s0 ptytty, int on)" 4
293     .IX Item "void ptytty_set_utf8_mode (PTYTTY ptytty, int on)"
294     See \f(CW\*(C`pty\->set_utf8_mode\*(C'\fR.
295     .IP "void ptytty_drop_privileges ()" 4
296     .IX Item "void ptytty_drop_privileges ()"
297     See \f(CW\*(C`ptytty::drop_privileges\*(C'\fR.
298     .IP "void ptytty_use_helper ()" 4
299     .IX Item "void ptytty_use_helper ()"
300     See \f(CW\*(C`ptytty::use_helper\*(C'\fR.
301 root 1.1 .SH "BUGS"
302     .IX Header "BUGS"
303     You kiddin'?
304     .SH "AUTHORS"
305     .IX Header "AUTHORS"
306     Emanuele Giaquinta <e.giaquinta@glauco.it>, Marc Alexander Lehmann
307     <rxvt\-unicode@schmorp.de>.