Blame doc/white-paper.texi

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