libptytty

Miscellaneous tools
Post Reply
Message
Author
scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

libptytty

#1 Post by scsijon »

Rxvt-unicode is a unicode improved version for rxvt that we use today.

Libptytty is a small library that offers pseudo-tty management in an OS-independent way. It was created out of frustration over the many differences of pty/tty handling in different operating systems for the use inside "rxvt-unicode".

In addition to offering mere pty/tty management, it also offers session database support (utmp and optional wtmp/lastlog updates for login shells).

It also supports fork'ing after startup and dropping privileges in the calling process, so in case the calling process gets compromised by the user starting the program there is less to gain, as only the helper process runs with privileges (e.g. setuid/setgid), which reduces the area of attack immensely.

Libptytty is written in C++, but it also offers a C-only API.

Source for this library is at http://dist.schmorp.de/libptytty/

I know it's not a 2019 package, but it just seems to work!

Current version is still 1.8.

No, i'm not offering a pet as it needs to be built before rxvt-unicode is and included it it's building.

It was created by Emanuele Giaquinta <e.giaquinta@glauco.it>, Marc Alexander Lehmann <rxvt-unicode@schmorp.de> so it's not rubbish.

SECURITY CONSIDERATIONS / WARNING

*It is of paramount importance that you at least read the following paragraph if your thinking of using it (or any of the alternatives out there)!*

If you write a typical terminal-like program that just wants one or more ptys, you should call the "ptytty::init ()" method (C: "ptytty_init ()" function) as the very first thing in your program:

int main (int argc, char *argv[])
{
// do nothing here
ptytty::init ();
// in C: ptytty_init ();

// initialise, parse arguments, etc.
}

This checks whether the program runs setuid or setgid. If yes then it will fork a helper process and drop privileges.

Some programs need finer control over if and when this helper process is started, and if and how to drop privileges. For those programs, the methods "ptytty::use_helper" and "ptytty::drop_privileges" (and possibly "ptytty::sanitise_stdfd") are more useful.

Post Reply