Blame doc/white-paper.texi

Packit Service 407539
@node White Paper, Reference Manual, About, Top
Packit Service 407539
@chapter LibGTop White Paper
Packit Service 407539
Packit Service 407539
@menu
Packit Service 407539
* Introduction::                Introduction
Packit Service 407539
* Overview::                    Overview
Packit Service 407539
@end menu
Packit Service 407539
Packit Service 407539
@node Introduction, Overview, White Paper, White Paper
Packit Service 407539
@section Introduction
Packit Service 407539
Packit Service 407539
Many modern UNIX systems like Solaris, BSD or Digitial Unix only allow
Packit Service 407539
priviledged processes to read information like CPU and Memory Usage or
Packit Service 407539
information about running processes.
Packit Service 407539
Packit Service 407539
@itemize @bullet
Packit Service 407539
@item
Packit Service 407539
BSD, for instance, doesn't have any other way to get those data than reading
Packit Service 407539
directly from @file{/dev/kmem} and you need to be in the @code{kmem} group to
Packit Service 407539
be able to read this.
Packit Service 407539
Packit Service 407539
@item
Packit Service 407539
Other systems, like Digital Unix, allow all users to get things like CPU and
Packit Service 407539
Memory statistics, but only root may read information about any process other
Packit Service 407539
than the current one (you may not even get information about your own processes
Packit Service 407539
if you're not root).
Packit Service 407539
Packit Service 407539
@item
Packit Service 407539
Linux has a very nice @file{/proc} filesystem, but reading and parsing
Packit Service 407539
@file{/proc} is very slow and inefficient.
Packit Service 407539
Packit Service 407539
@item
Packit Service 407539
Solaris is a bit better, but you still need to be in the @code{sys} group or
Packit Service 407539
even root to get some data.
Packit Service 407539
@end itemize
Packit Service 407539
Packit Service 407539
Because of this system utilities like @code{ps}, @code{uptime} or @code{top}
Packit Service 407539
often are setgid kmem or setuid root. Usually, they're also very specific to
Packit Service 407539
the system they're written for and not easily portable to other systems without
Packit Service 407539
a lot of work.
Packit Service 407539
Packit Service 407539
This, of cause, becomes a problem for graphical tools like @code{gtop} - making
Packit Service 407539
a GTK+ program setgid or even setuid would be a security hole as big as you can
Packit Service 407539
drive the entire X11 source code through. For the GNOME project, we also needed
Packit Service 407539
some kind of library which provides all the required information in a portable
Packit Service 407539
since there's more than just one single program that wants to use them - for
Packit Service 407539
instance @code{gtop} and the @code{multiload}, @code{cpumemusage} and
Packit Service 407539
@code{netload} panel applets.
Packit Service 407539
Packit Service 407539
@node Overview,  , Introduction, White Paper
Packit Service 407539
@section Overview
Packit Service 407539
Packit Service 407539
This section should give you a short overview on how LibGTop was developed, which
Packit Service 407539
things needed to be considered and how it works.
Packit Service 407539
Packit Service 407539
@menu
Packit Service 407539
* Interface Design::            Things that need to be considered
Packit Service 407539
* Server Implementation::       The LibGTop "server"
Packit Service 407539
@end menu
Packit Service 407539
Packit Service 407539
@node Interface Design, Server Implementation, Overview, Overview
Packit Service 407539
@subsection Interface Design
Packit Service 407539
Packit Service 407539
At the very beginning, it was necessary to collect all the data the library part
Packit Service 407539
should provide and put them into some C structures. This was not that easiy as it
Packit Service 407539
might sound since LibGTop should be portable to any modern UNIX system with a common
Packit Service 407539
library part on all those systems, but the data that should be returned vary from
Packit Service 407539
system to system. For instance some systems support shared memory, but some others
Packit Service 407539
may not.
Packit Service 407539
Packit Service 407539
The header files where we define these C structures (which are system-independent) are
Packit Service 407539
shared between client and server. This way we can call the system dependent code
Packit Service 407539
directly where we do not need any special privileges to do so.
Packit Service 407539
Packit Service 407539
All of those structures contain a @code{flags} member which is interpreted as a bit
Packit Service 407539
mask and tells the caller of the library functions which of the fields in the returned
Packit Service 407539
structure are valid and which are not.
Packit Service 407539
Packit Service 407539
@node Server Implementation,  , Interface Design, Overview
Packit Service 407539
@subsection Server Implementation
Packit Service 407539
Packit Service 407539
The LibGTop @dfn{server} is a setgid/setuid binary which contains all the system
Packit Service 407539
dependent code which needs special privileges. It is only build if it's required
Packit Service 407539
on the current system (for instance, the Linux kernel provides all the required
Packit Service 407539
data via its @file{/proc} filesystem so we do not need the server at all) and it
Packit Service 407539
only contains the @dfn{features} which need privileges.
Packit Service 407539
Packit Service 407539
Whenever we do not need any privileges to get all the data for some of the requested
Packit Service 407539
structures (here called @dfn{features}) the library calls the sysdeps code directly
Packit Service 407539
rather than using the server.