Lines 35-40
Link Here
|
35 |
#include "xf86_OSlib.h" |
35 |
#include "xf86_OSlib.h" |
36 |
#include "lnx.h" |
36 |
#include "lnx.h" |
37 |
|
37 |
|
|
|
38 |
#include <sys/stat.h> |
39 |
|
38 |
#ifdef USE_DEV_FB |
40 |
#ifdef USE_DEV_FB |
39 |
extern char *getenv(const char *); |
41 |
extern char *getenv(const char *); |
40 |
#include <linux/fb.h> |
42 |
#include <linux/fb.h> |
Lines 45-57
Link Here
|
45 |
static int VTnum = -1; |
47 |
static int VTnum = -1; |
46 |
static int activeVT = -1; |
48 |
static int activeVT = -1; |
47 |
|
49 |
|
|
|
50 |
int vtPermSave[4]; |
51 |
char vtname[11]; |
52 |
|
53 |
int saveVtPerms(void) |
54 |
{ |
55 |
/* We need to use stat to get permissions */ |
56 |
struct stat svtp; |
57 |
|
58 |
/* Do them numerically ordered, hard coded tty0 first */ |
59 |
if ( stat ("/dev/tty0", &svtp) != 0 ) |
60 |
return 0; |
61 |
vtPermSave[0] = (int)svtp.st_uid; |
62 |
vtPermSave[1] = (int)svtp.st_gid; |
63 |
|
64 |
/* Now check the console we are dealing with. */ |
65 |
if ( stat (vtname, &svtp) != 0 ) |
66 |
return 0; |
67 |
vtPermSave[2] = (int)svtp.st_uid; |
68 |
vtPermSave[3] = (int)svtp.st_gid; |
69 |
|
70 |
return 1; |
71 |
} |
72 |
|
73 |
void restoreVtPerms(void) |
74 |
{ |
75 |
/* Set the terminal permissions back to before we started */ |
76 |
chown ("/dev/tty0", vtPermSave[0], vtPermSave[1]); |
77 |
chown (vtname, vtPermSave[2], vtPermSave[3]); |
78 |
|
79 |
return; |
80 |
} |
81 |
|
48 |
void |
82 |
void |
49 |
xf86OpenConsole(void) |
83 |
xf86OpenConsole(void) |
50 |
{ |
84 |
{ |
51 |
int i, fd = -1; |
85 |
int i, fd = -1; |
52 |
int result; |
86 |
int result; |
53 |
struct vt_mode VT; |
87 |
struct vt_mode VT; |
54 |
char vtname[11]; |
|
|
55 |
struct vt_stat vts; |
88 |
struct vt_stat vts; |
56 |
MessageType from = X_PROBED; |
89 |
MessageType from = X_PROBED; |
57 |
#ifdef USE_DEV_FB |
90 |
#ifdef USE_DEV_FB |
Lines 124-129
Link Here
|
124 |
xf86Info.vtno, strerror(errno)); |
157 |
xf86Info.vtno, strerror(errno)); |
125 |
} |
158 |
} |
126 |
|
159 |
|
|
|
160 |
/* |
161 |
* grab the vt ownership before we overwrite it |
162 |
* hard coded /dev/tty0 into this function aswell for below |
163 |
*/ |
164 |
if (!saveVtPerms()){ |
165 |
xf86Msg(X_WARNING, "xf86OpenConsole: Couldnt save owenership of vt"); |
166 |
} |
167 |
|
127 |
/* change ownership of the vt */ |
168 |
/* change ownership of the vt */ |
128 |
chown(vtname, getuid(), getgid()); |
169 |
chown(vtname, getuid(), getgid()); |
129 |
|
170 |
|
Lines 247-252
Link Here
|
247 |
activeVT = -1; |
289 |
activeVT = -1; |
248 |
} |
290 |
} |
249 |
close(xf86Info.consoleFd); /* make the vt-manager happy */ |
291 |
close(xf86Info.consoleFd); /* make the vt-manager happy */ |
|
|
292 |
|
293 |
restoreVtPerms(); /* restore the permissions */ |
294 |
|
250 |
return; |
295 |
return; |
251 |
} |
296 |
} |
252 |
|
297 |
|