1 | NAME |
1 | NAME |
2 | libptytty - OS independent and secure pty/tty and utmp/wtmp/lastlog |
2 | libptytty - OS independent and secure pty/tty and utmp/wtmp/lastlog |
3 | handling |
3 | handling |
4 | |
4 | |
5 | SYNOPSIS |
5 | SYNOPSIS |
6 | -lptytty |
6 | cc ... -lptytty |
|
|
7 | |
|
|
8 | #include <libptytty.h> |
|
|
9 | |
|
|
10 | // C++ |
|
|
11 | ptytty *pty = ptytty::create (); |
|
|
12 | |
|
|
13 | if (!pty->get ()) |
|
|
14 | // error allocating pty |
|
|
15 | |
|
|
16 | if (we want utmp) |
|
|
17 | pty->login (process_pid, 0, "remote.host"); |
|
|
18 | else if (we want utmp AND wtmp/lastlog) |
|
|
19 | pty->login (process_pid, 1, "remote.host"); |
|
|
20 | |
|
|
21 | // we are done with it |
|
|
22 | delete pty; |
|
|
23 | |
|
|
24 | // C |
|
|
25 | PTYTTY pty = ptytty_create (); |
|
|
26 | |
|
|
27 | if (!ptytty_get (pty)) |
|
|
28 | // error allocating pty |
|
|
29 | |
|
|
30 | if (we want utmp) |
|
|
31 | ptytty_login (pty, process_pid, 0, "remote.host"); |
|
|
32 | else if (we want utmp AND wtmp/lastlog) |
|
|
33 | ptytty_login (pty, process_pid, 1, "remote.host"); |
|
|
34 | |
|
|
35 | // we are done with it |
|
|
36 | ptytty_delete (pty); |
7 | |
37 | |
8 | DESCRIPTION |
38 | DESCRIPTION |
9 | TODO |
39 | Libptytty is a small library that offers pseudo-tty management in an |
|
|
40 | OS-independent way. It was created out of frustration over the many |
|
|
41 | differences of pty/tty handling in different operating systems for the |
|
|
42 | use inside "rxvt-unicode". |
|
|
43 | |
|
|
44 | In addition to offering mere pty/tty management, it also offers session |
|
|
45 | database support (utmp and optional wtmp/lastlog updates for login |
|
|
46 | shells). |
|
|
47 | |
|
|
48 | It also supports fork'ing after startup and dropping privileges in the |
|
|
49 | calling process, so in case the calling process gets compromised by the |
|
|
50 | user starting the program there is less to gain, as only the helper |
|
|
51 | process runs with privileges (e.g. setuid/setgid), which reduces the |
|
|
52 | area of attack immensely. |
|
|
53 | |
|
|
54 | Libptytty is written in C++, but it also offers a C-only API. |
10 | |
55 | |
11 | SECURITY CONSIDERATIONS |
56 | SECURITY CONSIDERATIONS |
12 | *It is of paramount importance that you at least read the following |
57 | *It is of paramount importance that you at least read the following |
13 | paragraph!* |
58 | paragraph!* |
14 | |
59 | |