1vga_init(3)                   Svgalib User Manual                  vga_init(3)
2
3
4

NAME

6       vga_init - initialize svgalib library
7

SYNOPSIS

9       #include <vga.h>
10
11       int vga_init(void);
12
13

DESCRIPTION

15       It detects the chipset and gives up supervisor rights. This is the rec‐
16       ommended   first   line   of   any   program   that    uses    svgalib.
17       vga_setchipset(3) can be called before it to avoid detection.
18
19       Svgalib  catches  a  bunch of signals that usually kill your program to
20       restore textmode. If  you  catch  signal's  before  calling  vga_init()
21       svgalib  will  restore  textmode and prepare for shutdown and then call
22       your handler routine. If you don't want this, catch  the  signal  after
23       calling vga_init and do not daisychain to svgalib's original handler.
24
25       WARNING!  svgalib needs two signals for it's own purposes (that is man‐
26       aging console switches). To avoid problems it uses the otherwise unused
27       signals  SIGUSR1  and SIGUSR2.  However, this means that you cannot use
28       them in your program by any means. They  are  setup  by  vga_init()  as
29       everything else is.
30
31       Since  version  1.2.11 vga_init() includes code to hunt for a free vir‐
32       tual console on its own in case you are not starting the  program  from
33       one (but instead over a network or modem login, from within 'screen' or
34       an 'xterm'). Provided there is a free console, this succeeds if you are
35       root or if the svgalib calling user own the current console. This is to
36       avoid people not using the console being able to fiddle  with  it.   On
37       graceful  exit  the  program  returns  to the console from which it was
38       started.  Otherwise it remains in text mode at  the  VC  which  svgalib
39       allocated  to allow you to see any error messages. In any case, any I/O
40       the svgalib makes in text mode (after calling vga_init) will also  take
41       place at this new console.
42
43       Alas,  some games misuse their suid root privilege and run as full root
44       process. svgalib cannot detect this and allows Joe Blow User to open  a
45       new  VC  on  the  console. If this annoys you ROOT_VC_SHORTCUT in Make‐
46       file.cfg allows you to disable allocating a new  VC  for  root  (except
47       when  he  owns the current console) when compiling svgalib. This is the
48       default (disabling the allocation for root).
49
50       vga_init() returns a non-zero value in case of errors. As of this writ‐
51       ing  it will return -1 if it is unable to allocate a graphical console.
52       Otherwise, 0 is returned.
53
54

BUGS

56       Svgalib versions prior to 1.2.11 had a security hole where it would  be
57       possible  to  regain root privileges even after a vga_init() call. This
58       is not necessarily a problem, but if your program is vulnerable to buf‐
59       fer overflows and other attacks, an attacker may exploit this.
60
61       However, prior to your call, your program will need to run setuid root,
62       so you should be very careful. The ioperm library  by  Olaf  Titz  will
63       allow  svgalib  programs  to run not setuid root. However, it gives all
64       programs unlimited access to the hardware. Again,  a  malicious  person
65       can  exploit this (albeit a bit more difficult) too.  Thus, in general,
66       make your svgalib programs as secure as any setuid root program.
67
68       Some programs may (accidently) rely on the  old  behaviour  (which  was
69       probably  due  to  the author not knowing about saved uids (which might
70       actually even not have existed in Linux at that time)). A line:
71
72       security compat
73
74       in the configuration file /etc/vga/libvga.conf will reinstate  the  old
75       behaviour whereas
76
77       security revoke-all-privs
78
79       enables the (currently default) action.
80
81

SEE ALSO

83       svgalib(7),   vga_setmode(3),  mouse_init(3),  vga_claimvideomemory(3),
84       vga_ext_set(3),  vga_fillblt(3),  vga_getcurrentchipset(3),  vga_getde‐
85       faultmode(3),  vga_getgraphmem(3),  vga_runinbackground(3),  vga_runin‐
86       background_version(3),      vga_safety_fork(3),      vga_setchipset(3),
87       vga_setchipsetandfeatures(3), vgagl(7), libvga.config(5),
88
89

AUTHOR

91       This  manual  page  was  edited by Michael Weller <eowmob@exp-math.uni-
92       essen.de>. The exact source of the referenced function as  well  as  of
93       the original documentation is unknown.
94
95       It is very likely that both are at least to some extent are due to Harm
96       Hanemaayer <H.Hanemaayer@inter.nl.net>.
97
98       Occasionally this might be wrong. I hereby asked to be excused  by  the
99       original author and will happily accept any additions or corrections to
100       this first version of the svgalib manual.
101
102
103
104Svgalib (>= 1.2.11)              27 July 1997                      vga_init(3)
Impressum