Contents of /trunk/xorg-server/patches/xorg-server-1.0.2-setuid.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 3372 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 3372 byte(s)
-import
1 | Index: hw/xfree86/common/xf86Init.c |
2 | =================================================================== |
3 | RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Init.c,v |
4 | retrieving revision 1.33.2.2 |
5 | diff -u -u -r1.33.2.2 xf86Init.c |
6 | --- hw/xfree86/common/xf86Init.c 9 May 2006 18:04:19 -0000 1.33.2.2 |
7 | +++ hw/xfree86/common/xf86Init.c 20 Jun 2006 08:33:03 -0000 |
8 | @@ -1905,7 +1905,11 @@ |
9 | FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno)); |
10 | break; |
11 | case 0: /* child */ |
12 | - setuid(getuid()); |
13 | + if (setuid(getuid()) == -1) { |
14 | + xf86Msg(X_ERROR, "xf86RunVtInit: setuid failed (%s)\n", |
15 | + strerror(errno)); |
16 | + exit(255); |
17 | + } |
18 | /* set stdin, stdout to the consoleFd */ |
19 | for (i = 0; i < 2; i++) { |
20 | if (xf86Info.consoleFd != i) { |
21 | Index: hw/xfree86/os-support/shared/libc_wrapper.c |
22 | =================================================================== |
23 | RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/shared/libc_wrapper.c,v |
24 | retrieving revision 1.11 |
25 | diff -u -u -r1.11 libc_wrapper.c |
26 | --- hw/xfree86/os-support/shared/libc_wrapper.c 25 Mar 2006 19:52:04 -0000 1.11 |
27 | +++ hw/xfree86/os-support/shared/libc_wrapper.c 20 Jun 2006 08:33:03 -0000 |
28 | @@ -1270,7 +1270,10 @@ |
29 | #ifndef SELF_CONTAINED_WRAPPER |
30 | xf86DisableIO(); |
31 | #endif |
32 | - setuid(getuid()); |
33 | + if (setuid(getuid()) == -1) { |
34 | + ErrorF("xf86Execl: setuid() failed: %s\n", strerror(errno)); |
35 | + exit(255); |
36 | + } |
37 | #if !defined(SELF_CONTAINED_WRAPPER) |
38 | /* set stdin, stdout to the consoleFD, and leave stderr alone */ |
39 | for (i = 0; i < 2; i++) |
40 | Index: hw/xfree86/parser/write.c |
41 | =================================================================== |
42 | RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/parser/write.c,v |
43 | retrieving revision 1.3 |
44 | diff -u -u -r1.3 write.c |
45 | --- hw/xfree86/parser/write.c 3 Jul 2005 07:01:37 -0000 1.3 |
46 | +++ hw/xfree86/parser/write.c 20 Jun 2006 08:33:03 -0000 |
47 | @@ -170,7 +170,10 @@ |
48 | strerror(errno)); |
49 | return 0; |
50 | case 0: /* child */ |
51 | - setuid(getuid()); |
52 | + if (setuid(getuid() == -1) |
53 | + FatalError("xf86writeConfigFile(): " |
54 | + "setuid failed(%s)\n", |
55 | + strerror(errno)); |
56 | ret = doWriteConfigFile(filename, cptr); |
57 | exit(ret); |
58 | break; |
59 | Index: os/utils.c |
60 | =================================================================== |
61 | RCS file: /cvs/xorg/xserver/xorg/os/utils.c,v |
62 | retrieving revision 1.25 |
63 | diff -u -u -r1.25 utils.c |
64 | --- os/utils.c 25 Mar 2006 19:52:05 -0000 1.25 |
65 | +++ os/utils.c 20 Jun 2006 08:33:04 -0000 |
66 | @@ -1721,8 +1721,10 @@ |
67 | case -1: /* error */ |
68 | p = -1; |
69 | case 0: /* child */ |
70 | - setgid(getgid()); |
71 | - setuid(getuid()); |
72 | + if (setgid(getgid()) == -1) |
73 | + _exit(127); |
74 | + if (setuid(getuid()) == -1) |
75 | + _exit(127); |
76 | execl("/bin/sh", "sh", "-c", command, (char *)NULL); |
77 | _exit(127); |
78 | default: /* parent */ |
79 | @@ -1773,8 +1775,10 @@ |
80 | xfree(cur); |
81 | return NULL; |
82 | case 0: /* child */ |
83 | - setgid(getgid()); |
84 | - setuid(getuid()); |
85 | + if (setgid(getgid()) == -1) |
86 | + _exit(127); |
87 | + if (setuid(getuid()) == -1) |
88 | + _exit(127); |
89 | if (*type == 'r') { |
90 | if (pdes[1] != 1) { |
91 | /* stdout */ |
92 | @@ -1848,8 +1852,10 @@ |
93 | xfree(cur); |
94 | return NULL; |
95 | case 0: /* child */ |
96 | - setgid(getgid()); |
97 | - setuid(getuid()); |
98 | + if (setgid(getgid()) == -1) |
99 | + _exit(127); |
100 | + if (setuid(getuid()) == -1) |
101 | + _exit(127); |
102 | if (*type == 'r') { |
103 | if (pdes[1] != 1) { |
104 | /* stdout */ |